Commit cbfe6276 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Add an object that aggregates all network device data sensors

Similar to the old aggregate sensors but now in a different place.
parent 8fcc71af
/*
* SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "AllDevicesObject.h"
#include <KLocalizedString>
#include <AggregateSensor.h>
#include "NetworkDevice.h"
AllDevicesObject::AllDevicesObject(SensorContainer *parent)
: SensorObject(QStringLiteral("all"), i18nc("@title", "All Network Devices"), parent)
{
m_downloadSensor = new AggregateSensor(this, QStringLiteral("download"), i18nc("@title", "Download Rate"));
m_downloadSensor->setShortName(i18nc("@title Short for Download Rate", "Download"));
m_downloadSensor->setUnit(KSysGuard::utils::UnitByteRate);
m_downloadSensor->setMatchSensors(QRegularExpression{"^(?!all).*$"}, QStringLiteral("download"));
m_uploadSensor = new AggregateSensor(this, QStringLiteral("upload"), i18nc("@title", "Upload Rate"));
m_uploadSensor->setShortName(i18nc("@title Short for Upload Rate", "Upload"));
m_uploadSensor->setUnit(KSysGuard::utils::UnitByteRate);
m_uploadSensor->setMatchSensors(QRegularExpression{"^(?!all).*$"}, QStringLiteral("upload"));
m_totalDownloadSensor = new AggregateSensor(this, QStringLiteral("totalDownload"), i18nc("@title", "Total Downloaded"));
m_totalDownloadSensor->setShortName(i18nc("@title Short for Total Downloaded", "Downloaded"));
m_totalDownloadSensor->setUnit(KSysGuard::utils::UnitByte);
m_totalDownloadSensor->setMatchSensors(QRegularExpression{"^(?!all).*$"}, QStringLiteral("totalDownload"));
m_totalUploadSensor = new AggregateSensor(this, QStringLiteral("totalUpload"), i18nc("@title", "Total Uploaded"));
m_totalUploadSensor->setShortName(i18nc("@title Short for Total Uploaded", "Uploaded"));
m_totalUploadSensor->setUnit(KSysGuard::utils::UnitByte);
m_totalUploadSensor->setMatchSensors(QRegularExpression{"^(?!all).*$"}, QStringLiteral("upload"));
}
/*
* SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
*
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include <SensorObject.h>
class NetworkDevice;
class AggregateSensor;
/**
* This object aggregates the network usage of all devices.
*/
class AllDevicesObject : public SensorObject
{
Q_OBJECT
public:
AllDevicesObject(SensorContainer* parent);
private:
AggregateSensor *m_downloadSensor = nullptr;
AggregateSensor *m_uploadSensor = nullptr;
AggregateSensor *m_totalDownloadSensor = nullptr;
AggregateSensor *m_totalUploadSensor = nullptr;
};
......@@ -3,6 +3,7 @@ set(KSYSGUARD_NETWORK_PLUGIN_SOURCES
NetworkDevice.cpp
NetworkBackend.cpp
NetworkManagerBackend.cpp
AllDevicesObject.cpp
)
add_library(ksysguard_globalplugin_network MODULE ${KSYSGUARD_NETWORK_PLUGIN_SOURCES})
......
......@@ -28,12 +28,15 @@
#include "NetworkDevice.h"
#include "NetworkManagerBackend.h"
#include "AllDevicesObject.h"
class NetworkPrivate
{
public:
SensorContainer *container = nullptr;
AllDevicesObject *allDevices = nullptr;
NetworkBackend *backend = nullptr;
QVector<NetworkDevice *> devices;
......@@ -45,6 +48,7 @@ NetworkPlugin::NetworkPlugin(QObject *parent, const QVariantList &args)
{
d->container = new SensorContainer(QStringLiteral("network"), i18nc("@title", "Network Devices"), this);
d->allDevices = new AllDevicesObject(d->container);
d->backend = new NetworkManagerBackend(this);
if (!d->backend->isSupported()) {
......
Markdown is supported
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