mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-19 00:29:57 +00:00
refactor: simplify sources processing
Also fix desktop source
This commit is contained in:
@ -15,26 +15,15 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "loadsource.h"
|
||||
|
||||
#include <ksysguard/formatter/Unit.h>
|
||||
#include <ksysguard/systemstats/SensorInfo.h>
|
||||
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include "awdebug.h"
|
||||
|
||||
|
||||
LoadSource::LoadSource(QObject *_parent, const QStringList &_args)
|
||||
: AbstractExtSysMonSource(_parent, _args)
|
||||
{
|
||||
Q_ASSERT(_args.count() == 0);
|
||||
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
|
||||
}
|
||||
|
||||
|
||||
LoadSource::~LoadSource()
|
||||
LoadSource::LoadSource(QObject *_parent)
|
||||
: AbstractExtSysMonSource(_parent)
|
||||
{
|
||||
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
|
||||
}
|
||||
@ -48,28 +37,12 @@ QVariant LoadSource::data(const QString &_source)
|
||||
}
|
||||
|
||||
|
||||
KSysGuard::SensorInfo *LoadSource::initialData(const QString &_source) const
|
||||
QHash<QString, KSysGuard::SensorInfo *> LoadSource::sources() const
|
||||
{
|
||||
qCDebug(LOG_ESS) << "Source" << _source;
|
||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||
|
||||
auto data = new KSysGuard::SensorInfo();
|
||||
if (_source.startsWith("load")) {
|
||||
data->min = 0;
|
||||
data->max = 0;
|
||||
data->name = "Simple sources for load tests";
|
||||
data->variantType = QVariant::Int;
|
||||
data->unit = KSysGuard::UnitNone;
|
||||
}
|
||||
for (auto i = 0; i < 1000; i++)
|
||||
result.insert(QString("load%1").arg(i), makeSensorInfo("Simple sources for load tests", QVariant::Int));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
QStringList LoadSource::sources() const
|
||||
{
|
||||
QStringList sources;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
sources.append(QString("load%1").arg(i));
|
||||
|
||||
return sources;
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user