summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Weimer <bernd.weimer@pelagicore.com>2017-01-23 17:25:14 +0100
committerRobert Griebl <robert.griebl@pelagicore.com>2017-01-25 12:21:55 +0000
commitf4b69af2954f60f820b535414f30a205df2b9c19 (patch)
treea8c01e940e2886c8dd949c0993b8afe137c97a34
parent779a4dd5f2c3577163a5017c9af243417c1cf3e1 (diff)
downloadqtapplicationmanager-f4b69af2954f60f820b535414f30a205df2b9c19.tar.gz
Improve SystemMonitor
- Added changed signals to properties - Updated idle value before its changed signal is emitted - Finally removed deprecated idleLoadAverage property Change-Id: Ibc7c2c265329362649dd66f9808f7e572266e252 Reviewed-by: Nedim Hadzic <nedim.hadzic@pelagicore.com>
-rw-r--r--src/manager-lib/systemmonitor.cpp8
-rw-r--r--src/manager-lib/systemmonitor.h10
2 files changed, 12 insertions, 6 deletions
diff --git a/src/manager-lib/systemmonitor.cpp b/src/manager-lib/systemmonitor.cpp
index ce9bb74f..204a29ac 100644
--- a/src/manager-lib/systemmonitor.cpp
+++ b/src/manager-lib/systemmonitor.cpp
@@ -523,9 +523,10 @@ public:
} else if (te && te->timerId() == idleTimerId) {
qreal idleVal = idleCpu->readLoadValue();
bool nowIdle = (idleVal <= idleThreshold);
- if (nowIdle != isIdle)
+ if (nowIdle != isIdle) {
+ isIdle = nowIdle;
emit q->idleChanged(nowIdle);
- isIdle = nowIdle;
+ }
}
}
@@ -773,6 +774,7 @@ void SystemMonitor::setIdleLoadThreshold(qreal loadThreshold)
if (loadThreshold != d->idleThreshold) {
d->idleThreshold = loadThreshold;
+ emit idleLoadThresholdChanged(loadThreshold);
}
}
@@ -905,6 +907,7 @@ void SystemMonitor::setReportingInterval(int intervalInMSec)
it.value()->readLoadValue(); // for initialization only
d->setupTimer(intervalInMSec);
d->updateModel();
+ emit reportingIntervalChanged(intervalInMSec);
}
}
@@ -922,6 +925,7 @@ void SystemMonitor::setReportingRange(int rangeInMSec)
if (d->reportingRange != rangeInMSec && rangeInMSec > 0) {
d->reportingRange = rangeInMSec;
d->updateModel();
+ emit reportingRangeChanged(rangeInMSec);
}
}
diff --git a/src/manager-lib/systemmonitor.h b/src/manager-lib/systemmonitor.h
index 49a0dde0..a4fe28af 100644
--- a/src/manager-lib/systemmonitor.h
+++ b/src/manager-lib/systemmonitor.h
@@ -56,10 +56,9 @@ class SystemMonitor : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_PROPERTY(int reportingInterval READ reportingInterval WRITE setReportingInterval)
- Q_PROPERTY(int reportingRange READ reportingRange WRITE setReportingRange)
- Q_PROPERTY(qreal idleLoadThreshold READ idleLoadThreshold WRITE setIdleLoadThreshold)
- Q_PROPERTY(qreal idleLoadAverage READ idleLoadThreshold WRITE setIdleLoadThreshold) // deprecated
+ Q_PROPERTY(int reportingInterval READ reportingInterval WRITE setReportingInterval NOTIFY reportingIntervalChanged)
+ Q_PROPERTY(int reportingRange READ reportingRange WRITE setReportingRange NOTIFY reportingRangeChanged)
+ Q_PROPERTY(qreal idleLoadThreshold READ idleLoadThreshold WRITE setIdleLoadThreshold NOTIFY idleLoadThresholdChanged)
Q_PROPERTY(quint64 totalMemory READ totalMemory CONSTANT)
Q_PROPERTY(int cpuCores READ cpuCores CONSTANT)
Q_PROPERTY(bool memoryReportingEnabled READ isMemoryReportingEnabled WRITE setMemoryReportingEnabled NOTIFY memoryReportingEnabledChanged)
@@ -120,6 +119,9 @@ public:
signals:
void countChanged();
void idleChanged(bool idle);
+ void reportingIntervalChanged(int reportingInterval);
+ void reportingRangeChanged(int reportingRange);
+ void idleLoadThresholdChanged(qreal idleLoadThreshold);
void memoryReportingChanged(quint64 total, quint64 used);
void cpuLoadReportingChanged(qreal load);