From 0378568d2b736bbc1c1a6b3678dd79c72b763453 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 1 May 2019 11:34:43 -0700 Subject: [PATCH] Add support for tuning on/off live updating --- src/FactSystem/FactGroup.cc | 19 ++++++++++++++++++- src/FactSystem/FactGroup.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/FactSystem/FactGroup.cc b/src/FactSystem/FactGroup.cc index c67c02d8f..55aedaf98 100644 --- a/src/FactSystem/FactGroup.cc +++ b/src/FactSystem/FactGroup.cc @@ -46,7 +46,8 @@ void FactGroup::_setupTimer() if (_updateRateMSecs > 0) { connect(&_updateTimer, &QTimer::timeout, this, &FactGroup::_updateAllValues); _updateTimer.setSingleShot(false); - _updateTimer.start(_updateRateMSecs); + _updateTimer.setInterval(_updateRateMSecs); + _updateTimer.start(); } } @@ -125,3 +126,19 @@ void FactGroup::_updateAllValues(void) fact->sendDeferredValueChangedSignal(); } } + +void FactGroup::setLiveUpdates(bool liveUpdates) +{ + if (_updateTimer.interval() == 0) { + return; + } + + if (liveUpdates) { + _updateTimer.stop(); + } else { + _updateTimer.start(); + } + for(Fact* fact: _nameToFactMap) { + fact->setSendValueChangedSignals(liveUpdates); + } +} diff --git a/src/FactSystem/FactGroup.h b/src/FactSystem/FactGroup.h index 78a97fcb6..9e8320fca 100644 --- a/src/FactSystem/FactGroup.h +++ b/src/FactSystem/FactGroup.h @@ -38,6 +38,9 @@ public: /// @return FactGroup for specified name, NULL if not found Q_INVOKABLE FactGroup* getFactGroup(const QString& name); + /// Turning on live updates will allow value changes to flow through as they are received. + Q_INVOKABLE void setLiveUpdates(bool liveUpdates); + QStringList factNames(void) const { return _factNames; } QStringList factGroupNames(void) const { return _nameToFactGroupMap.keys(); } -- 2.22.0