Changeset View
Changeset View
Standalone View
Standalone View
dataengines/systemmonitor/systemmonitor.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | |||||
50 | 50 | | |||
51 | QStringList SystemMonitorEngine::sources() const | 51 | QStringList SystemMonitorEngine::sources() const | ||
52 | { | 52 | { | ||
53 | return m_sensors; | 53 | return m_sensors; | ||
54 | } | 54 | } | ||
55 | 55 | | |||
56 | bool SystemMonitorEngine::sourceRequestEvent(const QString &name) | 56 | bool SystemMonitorEngine::sourceRequestEvent(const QString &name) | ||
57 | { | 57 | { | ||
58 | // NB: do not follow this example in your own data engines! | | |||
59 | // This is kept for backwards compatilibility. | | |||
60 | // Visualizations should instead listen to sourceAdded() | | |||
61 | if (m_sensors.isEmpty()) { | | |||
62 | // we don't have our first data yet, so let's trust the requester, at least fo rnow | | |||
63 | // when we get our list of sensors later, then we'll know for sure and remove | | |||
64 | // this source if they were wrong | | |||
65 | setData(name, DataEngine::Data()); | 58 | setData(name, DataEngine::Data()); | ||
66 | return true; | 59 | return true; | ||
67 | } | 60 | } | ||
68 | 61 | | |||
69 | return false; | | |||
70 | } | | |||
71 | | ||||
72 | bool SystemMonitorEngine::updateSourceEvent(const QString &sensorName) | 62 | bool SystemMonitorEngine::updateSourceEvent(const QString &sensorName) | ||
73 | { | 63 | { | ||
74 | const int index = m_sensors.indexOf(sensorName); | 64 | const int index = m_sensors.indexOf(sensorName); | ||
75 | 65 | | |||
76 | if (index != -1) { | 66 | if (index != -1) { | ||
77 | KSGRD::SensorMgr->sendRequest(QStringLiteral("localhost"), sensorName, (KSGRD::SensorClient*)this, index); | 67 | KSGRD::SensorMgr->sendRequest(QStringLiteral("localhost"), sensorName, (KSGRD::SensorClient*)this, index); | ||
78 | KSGRD::SensorMgr->sendRequest(QStringLiteral("localhost"), QStringLiteral("%1?").arg(sensorName), (KSGRD::SensorClient*)this, -(index + 2)); | 68 | KSGRD::SensorMgr->sendRequest(QStringLiteral("localhost"), QStringLiteral("%1?").arg(sensorName), (KSGRD::SensorClient*)this, -(index + 2)); | ||
79 | } | 69 | } | ||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |