Commit 419f5a55 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Use a single copy of SensorInfo.h for both sensors and systemstats libs

The system stats lib needs it as public API but the sensors lib does
not, so use the header from systemstats for sensors.
parent 5ba60c0a
......@@ -28,7 +28,7 @@ ecm_qt_declare_logging_category(sensors_LIB_SRCS
DESCRIPTION "libksysguard (sensors)" EXPORT LIBKSYSGUARD
)
set_source_files_properties(org.kde.KSysGuardDaemon.xml PROPERTIES INCLUDE SensorInfo_p.h)
set_source_files_properties(org.kde.KSysGuardDaemon.xml PROPERTIES INCLUDE ../systemstats/SensorInfo.h)
qt5_add_dbus_interface(sensors_LIB_SRCS org.kde.KSysGuardDaemon.xml ksysguarddaemon)
add_library(Sensors ${sensors_LIB_SRCS})
......
......@@ -22,10 +22,11 @@
#include "Sensor.h"
#include "SensorDaemonInterface_p.h"
#include "SensorInfo_p.h"
#include "formatter/Formatter.h"
#include "SensorQuery.h"
#include "../systemstats/SensorInfo.h"
using namespace KSysGuard;
class Q_DECL_HIDDEN Sensor::Private
......
......@@ -102,7 +102,7 @@ void SensorDaemonInterface::requestValue(const QString &sensorId)
const auto allData = reply.value();
for (auto data : allData) {
Q_EMIT valueChanged(data.attribute, data.payload);
Q_EMIT valueChanged(data.sensorProperty, data.payload);
}
});
}
......@@ -149,6 +149,6 @@ void SensorDaemonInterface::onMetaDataChanged(const QHash<QString, SensorInfo> &
void SensorDaemonInterface::onValueChanged(const SensorDataList &values)
{
for (auto entry : values) {
Q_EMIT valueChanged(entry.attribute, entry.payload);
Q_EMIT valueChanged(entry.sensorProperty, entry.payload);
}
}
......@@ -19,9 +19,10 @@
#pragma once
#include "SensorInfo_p.h"
#include <QObject>
#include <memory>
#include <QObject>
#include "../systemstats/SensorInfo.h"
class QDBusPendingCallWatcher;
......
......@@ -26,9 +26,10 @@
#include "Formatter.h"
#include "SensorDaemonInterface_p.h"
#include "SensorInfo_p.h"
#include "sensors_logging.h"
#include "../systemstats/SensorInfo.h"
using namespace KSysGuard;
class Q_DECL_HIDDEN SensorDataModel::Private
......
......@@ -30,10 +30,11 @@
#include "Sensor.h"
#include "SensorDaemonInterface_p.h"
#include "SensorInfo_p.h"
#include "SensorQuery.h"
#include "SensorGroup_p.h"
#include "../systemstats/SensorInfo.h"
using namespace KSysGuard;
struct Q_DECL_HIDDEN SensorTreeItem
......
......@@ -10,6 +10,14 @@ set(systemstats_SRCS
)
set(systemstats_HDRS
AggregateSensor.h
SensorObject.h
SensorContainer.h
SensorPlugin.h
SensorProperty.h
SysFsSensor.h
SysctlSensor.h
SensorInfo.h
)
add_library(SystemStats ${systemstats_SRCS})
......
......@@ -16,32 +16,36 @@
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#pragma once
#include <QDBusArgument>
#include <QDateTime>
#include <QDebug>
#include <QObject>
#include <QVariant>
#include <QDBusArgument>
#include "formatter/Unit.h"
namespace KSysGuard
{
#include <ksysguard/formatter/Unit.h>
constexpr uint BackendUpdateInterval = 500;
//Data that is static for the lifespan of the sensor
class SensorInfo
// Data that is static for the lifespan of the sensor
class Q_DECL_EXPORT SensorInfo
{
public:
SensorInfo() = default;
QString name; //translated?
QString shortName;
QString description; // translated
QString name; // Translated name of the sensor.
QString shortName; // Shorter translated name of the sensor, to use when space is constrained.
QString description; // Translated description of the sensor.
QVariant::Type variantType = QVariant::Invalid;
KSysGuard::Unit unit = KSysGuard::UnitInvalid; //Both a format hint and implies data type (i.e double/string)
KSysGuard::Unit unit = KSysGuard::UnitInvalid; // Both a format hint and implies data type (i.e double/string)
qreal min = 0;
qreal max = 0;
};
Q_DECLARE_METATYPE(SensorInfo);
// this stuff could come from .desktop files (for the DBus case) or hardcoded (eg. for example nvidia-smi case) or come from current "ksysgrd monitors"
class Q_DECL_EXPORT SensorData
{
......@@ -55,13 +59,10 @@ public:
QString sensorProperty;
QVariant payload;
};
Q_DECLARE_METATYPE(SensorData);
typedef QHash<QString, SensorInfo> SensorInfoMap;
typedef QVector<SensorData> SensorDataList;
Q_DECLARE_METATYPE(SensorDataList);
inline QDBusArgument &operator<<(QDBusArgument &argument, const SensorInfo &s)
{
argument.beginStructure();
......@@ -110,3 +111,9 @@ inline const QDBusArgument &operator>>(const QDBusArgument &argument, SensorData
argument.endStructure();
return argument;
}
} // namespace KSysGuard
Q_DECLARE_METATYPE(KSysGuard::SensorInfo);
Q_DECLARE_METATYPE(KSysGuard::SensorData);
Q_DECLARE_METATYPE(KSysGuard::SensorDataList);
......@@ -19,9 +19,9 @@
#pragma once
#include "types.h"
#include <QObject>
#include "SensorInfo.h"
#include "systemstats_export.h"
namespace KSysGuard
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment