From befdf0519f7b4f40685bc65dd3524ffef01dd100 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Wed, 30 Sep 2015 00:16:57 +0300 Subject: [PATCH] add loadsource for testing needs --- .../plugin/awkeysaggregator.cpp | 6 ++ sources/extsysmon/extsysmonaggregator.cpp | 8 ++ sources/extsysmon/sources/loadsource.cpp | 75 +++++++++++++++++++ sources/extsysmon/sources/loadsource.h | 38 ++++++++++ 4 files changed, 127 insertions(+) create mode 100644 sources/extsysmon/sources/loadsource.cpp create mode 100644 sources/extsysmon/sources/loadsource.h diff --git a/sources/awesome-widget/plugin/awkeysaggregator.cpp b/sources/awesome-widget/plugin/awkeysaggregator.cpp index b1b0279..fd85276 100644 --- a/sources/awesome-widget/plugin/awkeysaggregator.cpp +++ b/sources/awesome-widget/plugin/awkeysaggregator.cpp @@ -500,6 +500,12 @@ QStringList AWKeysAggregator::registerSource(const QString source, const QString key.remove(QString("weather/")); m_map[source] = key; m_formater[key] = NoFormat; + } else if (source.startsWith(QString("load/load"))) { + // load source + QString key = source; + key.remove(QString("load/")); + m_map[source] = key; + m_formater[key] = Temperature; } return keysFromSource(source); diff --git a/sources/extsysmon/extsysmonaggregator.cpp b/sources/extsysmon/extsysmonaggregator.cpp index 50a6c7d..e8f017c 100644 --- a/sources/extsysmon/extsysmonaggregator.cpp +++ b/sources/extsysmon/extsysmonaggregator.cpp @@ -18,12 +18,14 @@ #include "extsysmonaggregator.h" #include "awdebug.h" +#include "version.h" #include "sources/batterysource.h" #include "sources/customsource.h" #include "sources/desktopsource.h" #include "sources/gpuloadsource.h" #include "sources/gputempsource.h" #include "sources/hddtempsource.h" +#include "sources/loadsource.h" #include "sources/networksource.h" #include "sources/playersource.h" #include "sources/processessource.h" @@ -152,4 +154,10 @@ void ExtSysMonAggregator::init(const QHash config) AbstractExtSysMonSource *weatherItem = new WeatherSource(this, QStringList()); foreach(QString source, weatherItem->sources()) m_map[source] = weatherItem; +#ifdef BUILD_TEST + // additional load source + AbstractExtSysMonSource *loadItem = new LoadSource(this, QStringList()); + foreach(QString source, loadItem->sources()) + m_map[source] = loadItem; +#endif /* BUILD_TEST */ } diff --git a/sources/extsysmon/sources/loadsource.cpp b/sources/extsysmon/sources/loadsource.cpp new file mode 100644 index 0000000..3b211f1 --- /dev/null +++ b/sources/extsysmon/sources/loadsource.cpp @@ -0,0 +1,75 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#include "loadsource.h" + +#include "awdebug.h" + + +LoadSource::LoadSource(QObject *parent, const QStringList args) + : AbstractExtSysMonSource(parent, args) +{ + Q_ASSERT(args.count() == 0); + qCDebug(LOG_ESM); +} + + +LoadSource::~LoadSource() +{ + qCDebug(LOG_ESM); +} + + +QVariant LoadSource::data(QString source) +{ + qCDebug(LOG_ESM); + qCDebug(LOG_ESM) << "Source" << source; + + source.remove(QString("load/load")); + return source.toInt(); +} + + +QVariantMap LoadSource::initialData(QString source) const +{ + qCDebug(LOG_ESM); + qCDebug(LOG_ESM) << "Source" << source; + + QVariantMap data; + if (source.startsWith(QString("load/load"))) { + data[QString("min")] = 0; + data[QString("max")] = 0; + data[QString("name")] = QString("Simple sources for load tests"); + data[QString("type")] = QString("int"); + data[QString("units")] = QString(""); + } + + return data; +} + + +QStringList LoadSource::sources() const +{ + qCDebug(LOG_ESM); + + QStringList sources; + for (int i=0; i<1000; i++) + sources.append(QString("load/load%1").arg(i)); + + return sources; +} diff --git a/sources/extsysmon/sources/loadsource.h b/sources/extsysmon/sources/loadsource.h new file mode 100644 index 0000000..8ef7ab7 --- /dev/null +++ b/sources/extsysmon/sources/loadsource.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets is free software: you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#ifndef LOADSOURCE_H +#define LOADSOURCE_H + +#include + +#include "abstractextsysmonsource.h" + + +class LoadSource : public AbstractExtSysMonSource +{ +public: + explicit LoadSource(QObject *parent, const QStringList args); + virtual ~LoadSource(); + QVariant data(QString source); + QVariantMap initialData(QString source) const; + void run() {}; + QStringList sources() const; +}; + + +#endif /* LOADSOURCE_H */