Changeset View
Changeset View
Standalone View
Standalone View
dataengines/geolocation/geolocation.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
47 | } | 47 | } | ||
48 | 48 | | |||
49 | void Geolocation::init() | 49 | void Geolocation::init() | ||
50 | { | 50 | { | ||
51 | //TODO: should this be delayed even further, e.g. when the source is requested? | 51 | //TODO: should this be delayed even further, e.g. when the source is requested? | ||
52 | const KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/GeolocationProvider")); | 52 | const KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/GeolocationProvider")); | ||
53 | QVariantList args; | 53 | QVariantList args; | ||
54 | 54 | | |||
55 | Q_FOREACH (const KService::Ptr &service, offers) { | 55 | for (const KService::Ptr &service : offers) { | ||
56 | QString error; | 56 | QString error; | ||
57 | GeolocationProvider *plugin = service->createInstance<GeolocationProvider>(nullptr, args, &error); | 57 | GeolocationProvider *plugin = service->createInstance<GeolocationProvider>(nullptr, args, &error); | ||
58 | if (plugin) { | 58 | if (plugin) { | ||
59 | m_plugins << plugin; | 59 | m_plugins << plugin; | ||
60 | plugin->init(&m_data, &m_accuracy); | 60 | plugin->init(&m_data, &m_accuracy); | ||
61 | connect(plugin, &GeolocationProvider::updated, this, &Geolocation::pluginUpdated); | 61 | connect(plugin, &GeolocationProvider::updated, this, &Geolocation::pluginUpdated); | ||
62 | connect(plugin, &GeolocationProvider::availabilityChanged, | 62 | connect(plugin, &GeolocationProvider::availabilityChanged, | ||
63 | this, &Geolocation::pluginAvailabilityChanged); | 63 | this, &Geolocation::pluginAvailabilityChanged); | ||
Show All 22 Lines | 81 | { | |||
86 | 86 | | |||
87 | return false; | 87 | return false; | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | bool Geolocation::updatePlugins(GeolocationProvider::UpdateTriggers triggers) | 90 | bool Geolocation::updatePlugins(GeolocationProvider::UpdateTriggers triggers) | ||
91 | { | 91 | { | ||
92 | bool changed = false; | 92 | bool changed = false; | ||
93 | 93 | | |||
94 | Q_FOREACH (GeolocationProvider *plugin, m_plugins) { | 94 | for (GeolocationProvider *plugin : qAsConst(m_plugins)) { | ||
95 | changed = plugin->requestUpdate(triggers) || changed; | 95 | changed = plugin->requestUpdate(triggers) || changed; | ||
96 | } | 96 | } | ||
97 | 97 | | |||
98 | if (changed) { | 98 | if (changed) { | ||
99 | m_updateTimer.start(); | 99 | m_updateTimer.start(); | ||
100 | } | 100 | } | ||
101 | 101 | | |||
102 | return changed; | 102 | return changed; | ||
Show All 22 Lines | |||||
125 | void Geolocation::pluginAvailabilityChanged(GeolocationProvider *provider) | 125 | void Geolocation::pluginAvailabilityChanged(GeolocationProvider *provider) | ||
126 | { | 126 | { | ||
127 | m_data.clear(); | 127 | m_data.clear(); | ||
128 | m_accuracy.clear(); | 128 | m_accuracy.clear(); | ||
129 | 129 | | |||
130 | provider->requestUpdate(GeolocationProvider::ForcedUpdate); | 130 | provider->requestUpdate(GeolocationProvider::ForcedUpdate); | ||
131 | 131 | | |||
132 | bool changed = false; | 132 | bool changed = false; | ||
133 | Q_FOREACH (GeolocationProvider *plugin, m_plugins) { | 133 | for (GeolocationProvider *plugin : qAsConst(m_plugins)) { | ||
134 | changed = plugin->populateSharedData() || changed; | 134 | changed = plugin->populateSharedData() || changed; | ||
135 | } | 135 | } | ||
136 | 136 | | |||
137 | if (changed) { | 137 | if (changed) { | ||
138 | m_updateTimer.start(); | 138 | m_updateTimer.start(); | ||
139 | } | 139 | } | ||
140 | } | 140 | } | ||
141 | 141 | | |||
Show All 13 Lines |