drop own workaround for update functions

use qtimer instead
This commit is contained in:
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;