possible again to access to sources without the model
svn path=/trunk/KDE/kdebase/runtime/; revision=1194365
This commit is contained in:
parent
befceb8dee
commit
0797009207
@ -37,8 +37,6 @@ DataSource::DataSource(QObject* parent)
|
||||
{
|
||||
setObjectName("DataSource");
|
||||
|
||||
// m_data = new QDeclarativePropertyMap(this);
|
||||
|
||||
connect(this, SIGNAL(engineChanged()),
|
||||
this, SLOT(setupData()));
|
||||
connect(this, SIGNAL(connectedSourcesChanged()),
|
||||
@ -78,6 +76,16 @@ void DataSource::setEngine(const QString &e)
|
||||
emit engineChanged();
|
||||
}
|
||||
|
||||
void DataSource::setInterval(const int interval)
|
||||
{
|
||||
if (interval == m_interval) {
|
||||
return;
|
||||
}
|
||||
m_interval = interval;
|
||||
m_changes |= DataEngineChanged;
|
||||
emit intervalChanged();
|
||||
}
|
||||
|
||||
void DataSource::setupData()
|
||||
{
|
||||
|
||||
@ -103,7 +111,7 @@ void DataSource::setupData()
|
||||
|
||||
if (!(m_changes & SourcesChanged)) {
|
||||
foreach (const QString &source, m_connectedSources) {
|
||||
m_dataEngine->connectSource(source, this);
|
||||
m_dataEngine->connectSource(source, this, m_interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,7 +122,7 @@ void DataSource::setupData()
|
||||
m_dataEngine->disconnectSource(source, this);
|
||||
}
|
||||
foreach (const QString &source, m_newSources) {
|
||||
m_dataEngine->connectSource(source, this);
|
||||
m_dataEngine->connectSource(source, this, m_interval);
|
||||
}
|
||||
m_oldSources.clear();
|
||||
m_newSources.clear();
|
||||
@ -125,8 +133,6 @@ void DataSource::setupData()
|
||||
|
||||
void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
||||
{
|
||||
QStringList newKeys;
|
||||
|
||||
m_data.insert(sourceName.toLatin1(), data);
|
||||
|
||||
emit dataChanged();
|
||||
@ -155,7 +161,7 @@ QStringList DataSource::keysForSource(const QString &source) const
|
||||
if (!m_data.contains(source)) {
|
||||
return QStringList();
|
||||
}
|
||||
return m_data.value(source).keys();
|
||||
return m_data.value(source).value<Data>().keys();
|
||||
}
|
||||
|
||||
Plasma::Service *DataSource::serviceForSource(const QString &source)
|
||||
|
@ -49,8 +49,9 @@ public:
|
||||
SourcesChanged = 2
|
||||
};
|
||||
Q_DECLARE_FLAGS(Changes, Change)
|
||||
|
||||
typedef QHash<QString, QVariant> Data;
|
||||
typedef QMap<QString, Data> DataMap;
|
||||
|
||||
DataSource(QObject* parent=0);
|
||||
|
||||
Q_PROPERTY(bool valid READ valid)
|
||||
@ -58,7 +59,7 @@ public:
|
||||
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
|
||||
int interval() const {return m_interval;}
|
||||
void setInterval(int i) {if(i==m_interval) return; m_interval=i; emit intervalChanged();}
|
||||
void setInterval(const int interval);
|
||||
|
||||
Q_PROPERTY(QString engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||
QString engine() const {return m_engine;}
|
||||
@ -71,8 +72,8 @@ public:
|
||||
Q_PROPERTY(QStringList sources READ sources NOTIFY sourcesChanged)
|
||||
QStringList sources() const {if (m_dataEngine) return m_dataEngine->sources(); else return QStringList();}
|
||||
|
||||
Q_PROPERTY(DataMap data READ data NOTIFY dataChanged);
|
||||
DataMap data() const {return m_data;}
|
||||
Q_PROPERTY(QVariantMap data READ data NOTIFY dataChanged);
|
||||
QVariantMap data() const {return m_data;}
|
||||
|
||||
Q_INVOKABLE QStringList keysForSource(const QString &source) const;
|
||||
Q_INVOKABLE Plasma::Service *serviceForSource(const QString &source);
|
||||
@ -101,7 +102,7 @@ private:
|
||||
QString m_id;
|
||||
int m_interval;
|
||||
QString m_engine;
|
||||
DataMap m_data;
|
||||
QVariantMap m_data;
|
||||
Plasma::DataEngine* m_dataEngine;
|
||||
QStringList m_connectedSources;
|
||||
QStringList m_oldSources;
|
||||
|
Loading…
Reference in New Issue
Block a user