diff options
author | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-09-20 09:35:56 +0200 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-09-27 06:35:24 +0000 |
commit | cf2ec248f2c8d6fabc539f2acef4df5d3c0e8b6c (patch) | |
tree | 01c4feef45ddf310113a7f2f2d5b06e20b443fbe /tradeshow/iot-sensortag/dataproviderpool.cpp | |
parent | 55ce120e6ceccb40f19a941fbda05edefd22d64c (diff) |
iot-sensortag: Redesign of example
The updated version switches the focus from having multiple sensors
locally towards showing one sensor from a list. This list can display
local or remote sensors and switch on runtime.
Also incorporated many style fixes and cleanups.
Change-Id: If7b8acbb2a784ebba95d467176e76728721c82f7
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'tradeshow/iot-sensortag/dataproviderpool.cpp')
-rw-r--r-- | tradeshow/iot-sensortag/dataproviderpool.cpp | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/tradeshow/iot-sensortag/dataproviderpool.cpp b/tradeshow/iot-sensortag/dataproviderpool.cpp index 77c4514..66d9480 100644 --- a/tradeshow/iot-sensortag/dataproviderpool.cpp +++ b/tradeshow/iot-sensortag/dataproviderpool.cpp @@ -51,12 +51,16 @@ DataProviderPool::DataProviderPool(QObject *parent) : QObject(parent) + , m_currentProvider(nullptr) + , m_currentProviderIndex(-1) { } DataProviderPool::DataProviderPool(QString poolName, QObject *parent) : QObject(parent) , m_poolName(poolName) + , m_currentProvider(nullptr) + , m_currentProviderIndex(-1) { } @@ -70,21 +74,7 @@ void DataProviderPool::stopScanning() emit scanFinished(); } -SensorTagDataProvider *DataProviderPool::getProvider(SensorTagDataProvider::TagType type) const -{ - auto it = m_dataProviders.constBegin(); - SensorTagDataProvider* p = 0; - while (it != m_dataProviders.end()) { - if ((*it)->tagType() & type) { - p = *it; - break; - } - it++; - } - return p; -} - -void DataProviderPool::disconnectProvider(QString id) +void DataProviderPool::disconnectProvider(const QString &id) { Q_UNUSED(id) } @@ -98,3 +88,24 @@ SensorTagDataProvider *DataProviderPool::providerForCloud() const { return 0; } + +SensorTagDataProvider *DataProviderPool::currentProvider() const +{ + return m_currentProvider; +} + +int DataProviderPool::currentProviderIndex() const +{ + return m_currentProviderIndex; +} + +void DataProviderPool::setCurrentProviderIndex(int currentProviderIndex) +{ + if (m_currentProviderIndex == currentProviderIndex) + return; + + m_currentProviderIndex = currentProviderIndex; + m_currentProvider = m_dataProviders.at(m_currentProviderIndex); + emit currentProviderIndexChanged(m_currentProviderIndex); + emit currentProviderChanged(m_currentProvider); +} |