fix bug introduced by lazy subscription

Sources in custom dataengine updated only if user subscribe on specified
source. I've implemented drop returing value so if no requested value
found it will return force update event.
This commit is contained in:
Evgenii Alekseev 2016-03-04 15:06:12 +03:00
parent 071d7fdb78
commit 5af4b0c40c
5 changed files with 21 additions and 14 deletions

View File

@ -44,9 +44,10 @@ QVariant BatterySource::data(QString source)
{ {
qCDebug(LOG_ESM) << "Source" << source; qCDebug(LOG_ESM) << "Source" << source;
if (source == QString("battery/ac")) if (!values.contains(source))
run(); run();
return values[source]; QVariant value = values.take(source);
return value;
} }

View File

@ -52,9 +52,10 @@ QVariant PlayerSource::data(QString source)
{ {
qCDebug(LOG_ESM) << "Source" << source; qCDebug(LOG_ESM) << "Source" << source;
if (source == QString("player/title")) if (!values.contains(source))
run(); run();
return values[source]; QVariant value = values.take(source);
return value;
} }

View File

@ -41,9 +41,10 @@ QVariant ProcessesSource::data(QString source)
{ {
qCDebug(LOG_ESM) << "Source" << source; qCDebug(LOG_ESM) << "Source" << source;
if (source == QString("ps/running/count")) if (!values.contains(source))
run(); run();
return values[source]; QVariant value = values.take(source);
return value;
} }

View File

@ -45,13 +45,15 @@ QVariant QuotesSource::data(QString source)
{ {
qCDebug(LOG_ESM) << "Source" << source; qCDebug(LOG_ESM) << "Source" << source;
if (source.startsWith(QString("quotes/percpricechg"))) { int ind = index(source);
QVariantHash data = extQuotes->itemByTagNumber(index(source))->run(); source.remove(QString("quotes/"));
if (!values.contains(source)) {
QVariantHash data = extQuotes->itemByTagNumber(ind)->run();
for (auto key : data.keys()) for (auto key : data.keys())
values[key] = data[key]; values[key] = data[key];
} }
QString key = QString(source).remove(QString("quotes/")); QVariant value = values.take(source);
return values[key]; return value;
} }

View File

@ -45,13 +45,15 @@ QVariant WeatherSource::data(QString source)
{ {
qCDebug(LOG_ESM) << "Source" << source; qCDebug(LOG_ESM) << "Source" << source;
if (source.startsWith(QString("weather/weatherId"))) { int ind = index(source);
QVariantHash data = extWeather->itemByTagNumber(index(source))->run(); source.remove(QString("weather/"));
if (!values.contains(source)) {
QVariantHash data = extWeather->itemByTagNumber(ind)->run();
for (auto key : data.keys()) for (auto key : data.keys())
values[key] = data[key]; values[key] = data[key];
} }
QString key = QString(source).remove(QString("weather/")); QVariant value = values.take(source);
return values[key]; return value;
} }