drop own workaround for update functions

use qtimer instead
This commit is contained in:
Evgenii Alekseev 2016-04-28 18:18:13 +03:00
parent 77388deab6
commit 097b63415e
5 changed files with 15 additions and 121 deletions

View File

@ -21,6 +21,7 @@
#include <QJSEngine>
#include <QRegExp>
#include <QThread>
#include <QTimer>
#include "awdataaggregator.h"
#include "awdataengineaggregator.h"
@ -49,13 +50,16 @@ AWKeys::AWKeys(QObject *parent)
dataEngineAggregator = new AWDataEngineAggregator(this);
keyOperator = new AWKeyOperations(this);
m_timer = new QTimer(this);
m_timer->setSingleShot(false);
// update key data if required
connect(keyOperator, SIGNAL(updateKeys(QStringList)), this,
SLOT(reinitKeys(QStringList)));
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateTextData()));
// transfer signal from AWDataAggregator object to QML ui
connect(dataAggregator, SIGNAL(toolTipPainted(const QString)), this,
SIGNAL(needToolTipToBeUpdated(const QString)));
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(updateTextData()));
connect(this, SIGNAL(dropSourceFromDataengine(QString)),
dataEngineAggregator, SLOT(dropSource(QString)));
// transfer signal from dataengine to update source list
@ -68,6 +72,9 @@ AWKeys::~AWKeys()
{
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
m_timer->stop();
delete m_timer;
// core
delete dataEngineAggregator;
delete m_threadPool;
@ -103,7 +110,11 @@ void AWKeys::initKeys(const QString currentPattern, const int interval,
keyOperator->updateCache();
dataEngineAggregator->clear();
return dataEngineAggregator->initDataEngines(interval);
dataEngineAggregator->initDataEngines(interval);
// timer
m_timer->setInterval(interval);
m_timer->start();
}
@ -183,12 +194,6 @@ void AWKeys::editItem(const QString type)
void AWKeys::dataUpdated(const QString &sourceName,
const Plasma::DataEngine::Data &data)
{
// do not log these parameters
if (sourceName == QString("update")) {
qCInfo(LOG_AW) << "Update data";
return emit(needToBeUpdated());
}
// run concurrent data update
QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, sourceName,
data);

View File

@ -30,6 +30,7 @@ class AWDataEngineAggregator;
class AWKeyOperations;
class AWKeysAggregator;
class QThreadPool;
class QTimer;
class AWKeys : public QObject
{
@ -67,7 +68,6 @@ signals:
void dropSourceFromDataengine(const QString source);
void needTextToBeUpdated(const QString newText) const;
void needToolTipToBeUpdated(const QString newText) const;
void needToBeUpdated();
private slots:
void reinitKeys(const QStringList currentKeys);
@ -83,6 +83,7 @@ private:
AWDataEngineAggregator *dataEngineAggregator = nullptr;
AWKeysAggregator *aggregator = nullptr;
AWKeyOperations *keyOperator = nullptr;
QTimer *m_timer = nullptr;
// variables
QVariantMap m_tooltipParams;
QStringList m_foundBars, m_foundKeys, m_foundLambdas, m_requiredKeys;

View File

@ -29,7 +29,6 @@
#include "sources/playersource.h"
#include "sources/processessource.h"
#include "sources/quotessource.h"
#include "sources/updatesource.h"
#include "sources/upgradesource.h"
#include "sources/weathersource.h"
#include "version.h"
@ -140,10 +139,6 @@ void ExtSysMonAggregator::init(const QHash<QString, QString> config)
AbstractExtSysMonSource *quotesItem = new QuotesSource(this, QStringList());
for (auto source : quotesItem->sources())
m_map[source] = quotesItem;
// update
AbstractExtSysMonSource *updateItem = new UpdateSource(this, QStringList());
for (auto source : updateItem->sources())
m_map[source] = updateItem;
// upgrade
AbstractExtSysMonSource *upgradeItem
= new UpgradeSource(this, QStringList());

View File

@ -1,69 +0,0 @@
/***************************************************************************
* 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 "updatesource.h"
#include "awdebug.h"
UpdateSource::UpdateSource(QObject *parent, const QStringList args)
: AbstractExtSysMonSource(parent, args)
{
Q_ASSERT(args.count() == 0);
qCDebug(LOG_ESM) << __PRETTY_FUNCTION__;
}
UpdateSource::~UpdateSource()
{
qCDebug(LOG_ESM) << __PRETTY_FUNCTION__;
}
QVariant UpdateSource::data(QString source)
{
qCDebug(LOG_ESM) << "Source" << source;
return true;
}
QVariantMap UpdateSource::initialData(QString source) const
{
qCDebug(LOG_ESM) << "Source" << source;
QVariantMap data;
if (source == QString("update")) {
data[QString("min")] = true;
data[QString("max")] = true;
data[QString("name")] = QString("Simple value which is always true");
data[QString("type")] = QString("bool");
data[QString("units")] = QString("");
}
return data;
}
QStringList UpdateSource::sources() const
{
QStringList sources;
sources.append(QString("update"));
return sources;
}

View File

@ -1,38 +0,0 @@
/***************************************************************************
* 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 UPDATESOURCE_H
#define UPDATESOURCE_H
#include <QObject>
#include "abstractextsysmonsource.h"
class UpdateSource : public AbstractExtSysMonSource
{
public:
explicit UpdateSource(QObject *parent, const QStringList args);
virtual ~UpdateSource();
QVariant data(QString source);
QVariantMap initialData(QString source) const;
void run(){};
QStringList sources() const;
};
#endif /* UPDATESOURCE_H */