Changeset View
Changeset View
Standalone View
Standalone View
src/declarativeimports/core/datasource.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | { | 44 | { | ||
45 | m_ready = true; | 45 | m_ready = true; | ||
46 | setupData(); | 46 | setupData(); | ||
47 | } | 47 | } | ||
48 | 48 | | |||
49 | void DataSource::setConnectedSources(const QStringList &sources) | 49 | void DataSource::setConnectedSources(const QStringList &sources) | ||
50 | { | 50 | { | ||
51 | bool sourcesChanged = false; | 51 | bool sourcesChanged = false; | ||
52 | foreach (const QString &source, sources) { | 52 | for (const QString &source : sources) { | ||
53 | if (!m_connectedSources.contains(source)) { | 53 | if (!m_connectedSources.contains(source)) { | ||
54 | sourcesChanged = true; | 54 | sourcesChanged = true; | ||
55 | if (m_dataEngine) { | 55 | if (m_dataEngine) { | ||
56 | m_connectedSources.append(source); | 56 | m_connectedSources.append(source); | ||
57 | m_dataEngine->connectSource(source, this, m_interval, m_intervalAlignment); | 57 | m_dataEngine->connectSource(source, this, m_interval, m_intervalAlignment); | ||
58 | emit sourceConnected(source); | 58 | emit sourceConnected(source); | ||
59 | } | 59 | } | ||
60 | } | 60 | } | ||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | foreach (const QString &source, m_connectedSources) { | 63 | for (const QString &source : qAsConst(m_connectedSources)) { | ||
64 | if (!sources.contains(source)) { | 64 | if (!sources.contains(source)) { | ||
65 | m_data->clear(source); | 65 | m_data->clear(source); | ||
66 | sourcesChanged = true; | 66 | sourcesChanged = true; | ||
67 | if (m_dataEngine) { | 67 | if (m_dataEngine) { | ||
68 | m_dataEngine->disconnectSource(source, this); | 68 | m_dataEngine->disconnectSource(source, this); | ||
69 | emit sourceDisconnected(source); | 69 | emit sourceDisconnected(source); | ||
70 | } | 70 | } | ||
71 | } | 71 | } | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 155 | if (!m_ready) { | |||
156 | return; | 156 | return; | ||
157 | } | 157 | } | ||
158 | 158 | | |||
159 | // qDebug() << " loading engine " << m_engine; | 159 | // qDebug() << " loading engine " << m_engine; | ||
160 | //FIXME: should all services be deleted just because we're changing the interval, etc? | 160 | //FIXME: should all services be deleted just because we're changing the interval, etc? | ||
161 | qDeleteAll(m_services); | 161 | qDeleteAll(m_services); | ||
162 | m_services.clear(); | 162 | m_services.clear(); | ||
163 | 163 | | |||
164 | foreach (const QString &source, m_connectedSources) { | 164 | for (const QString &source : qAsConst(m_connectedSources)) { | ||
165 | m_dataEngine->connectSource(source, this, m_interval, m_intervalAlignment); | 165 | m_dataEngine->connectSource(source, this, m_interval, m_intervalAlignment); | ||
166 | emit sourceConnected(source); | 166 | emit sourceConnected(source); | ||
167 | } | 167 | } | ||
168 | } | 168 | } | ||
169 | 169 | | |||
170 | void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data) | 170 | void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data) | ||
171 | { | 171 | { | ||
172 | //it can arrive also data we don't explicitly connected a source | 172 | //it can arrive also data we don't explicitly connected a source | ||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |