7#include "geolocationprovider.h"
9GeolocationProvider::GeolocationProvider(
QObject *parent)
11 , m_sharedData(nullptr)
12 , m_sharedAccuracies(nullptr)
14 , m_updateTriggers(SourceEvent)
18 m_updateTimer.setSingleShot(
true);
19 m_updateTimer.setInterval(0);
20 qRegisterMetaType<Plasma5Support::DataEngine::Data>(
"Plasma5Support::DataEngine::Data");
27 m_sharedAccuracies = accuracies;
31int GeolocationProvider::accuracy()
const
36bool GeolocationProvider::isAvailable()
const
43 if (m_available && !m_updating && (triggers == ForcedUpdate || triggers & m_updateTriggers)) {
54 return m_updateTriggers;
57bool GeolocationProvider::populateSharedData()
63 if (!m_sharedData->
contains(it.key()) || m_sharedAccuracies->
value(it.key()) < m_accuracy) {
64 m_sharedData->
insert(it.key(), it.value());
65 m_sharedAccuracies->
insert(it.key(), m_accuracy);
75void GeolocationProvider::setAccuracy(
int accuracy)
77 m_accuracy = accuracy;
80void GeolocationProvider::setIsAvailable(
bool available)
82 if (m_available == available) {
86 m_available = available;
87 Q_EMIT availabilityChanged(
this);
94 if (populateSharedData()) {
95 m_updateTimer.
start();
99void GeolocationProvider::setData(
const QString &key,
const QVariant &value)
102 m_data.
insert(key, value);
104 if (!m_sharedData->
contains(key) || m_sharedAccuracies->
value(QStringLiteral(
"key")) < m_accuracy) {
105 m_sharedData->
insert(key, value);
106 m_sharedAccuracies->
insert(key, accuracy());
107 m_updateTimer.
start();
111void GeolocationProvider::setUpdateTriggers(UpdateTriggers triggers)
113 m_updateTriggers = triggers;
116void GeolocationProvider::init()
120void GeolocationProvider::update()
iterator insert(const Key &key, const T &value)
T value(const Key &key) const const
const_iterator constBegin() const const
const_iterator constEnd() const const
bool contains(const Key &key) const const
iterator insert(const Key &key, const T &value)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)