[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/dataengines/weather/ions
From: Shawn Starr <shawn.starr () rogers ! com>
Date: 2007-10-13 18:20:36
Message-ID: 1192299636.280796.9555.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 724872 by spstarr:
Revamp ion backend API, remove fetch() this became updateIonSource, added \
sourceRequested slots, merge in aseigo's async fixes for ions
M +30 -19 ion.cpp
M +23 -27 ion.h
--- trunk/KDE/kdebase/workspace/plasma/dataengines/weather/ions/ion.cpp \
#724871:724872 @@ -24,12 +24,14 @@
{
public:
Private(IonInterface *i)
- : ion(i) {}
+ : ion(i),
+ initialized(false)
+ {}
int ref;
IonInterface *ion;
bool valid;
- QVector<QString> ionSource; // Array of this ions sources
+ bool initialized;
};
IonInterface::IonInterface(QObject *parent)
@@ -62,29 +64,38 @@
return d->valid;
}
-// Set the Ions datasource name listing. Used by weather dataengine
-void IonInterface::setSource(QString key)
+bool IonInterface::sourceRequested(const QString &source)
{
- if (!d->ionSource.contains(key)) {
- d->ionSource.append(key);
+ setData(source, Plasma::DataEngine::Data());
+
+ if (d->initialized) {
+ this->updateSource(source);
}
-}
-// Return an array of sources from a Ion
-QVector<QString> IonInterface::ionSourceDict() const
-{
- return d->ionSource;
+ return true;
}
-// Deletes a datasource from the ion
-void IonInterface::removeSource(QString key)
+bool IonInterface::updateSource(const QString& source)
{
- QVector<QString>::iterator it;
- for (it = d->ionSource.begin(); it != d->ionSource.end(); ++it) {
- if (*it == key) {
- kDebug() << "Going to remove: " << *it;
- d->ionSource.erase(it);
- break;
+ kDebug() << "SOURCE IS = " << source;
+ if (d->initialized) {
+ if(this->updateIonSource(source)) {
+ return true;
+ } else {
+ return false;
}
}
+
+ return false;
}
+
+void IonInterface::setInitialized(bool initialized)
+{
+ d->initialized = initialized;
+
+ if (d->initialized) {
+ foreach (const QString &source, sources()) {
+ updateSource(source);
+ }
+ }
+}
--- trunk/KDE/kdebase/workspace/plasma/dataengines/weather/ions/ion.h #724871:724872
@@ -51,16 +51,12 @@
* For example fetching the list of available cities or weather data sources \
should be fetched here.
*/
virtual void init(void) = 0;
- /**
- * Reimplement to do the fetching of weather data.
- * This is being called just before calling updateData()
- */
- virtual void fetch(void) = 0;
/**
* Increment ion counter. This is used to watch if the ion is being used.
*/
void ref();
+
/**
* Decrement ion counter.
*/
@@ -71,42 +67,42 @@
* @return true if the ion is being used, false otherwise
*/
bool isUsed() const;
-
+
/**
* Returns whether the ion is valid. Not used for now.
* @return true if the ion is valid.
*/
bool isValid() const;
+ enum ionOptions { UNITS, TIMEFORMAT, WINDFORMAT };
/**
- * Reimplement this to set the data to the engine by using setData() calls.
- * You may have to force to call this method inside your ion everytime new data \
has been arrived from the fetching job. + * Reimplement to set the wanted options \
for the ion such as unit and time, and wind speed formats.
*/
- virtual void updateData(void) = 0;
+ virtual void option(int option, QVariant value) = 0;
- /**
- * Returns the source array.
- * @return Returns the array of source the ion has.
- */
- QVector<QString> ionSourceDict() const;
- /**
- * Set the datasource name to the array of sources
- * @param key The name of the datasource
- */
- void setSource(QString key);
+public slots:
+ bool updateSource(const QString& source);
+protected:
/**
- * Remove a datasource entry from the array
- * @param key The name of the datasource
- */
- void removeSource(QString key);
+ * Call this method to flush waiting source requests that may be pending
+ * initialization
+ *
+ * @arg initialized whether or not the ion is currently ready to fetch data
+ */
+ void setInitialized(bool initialized);
- enum ionOptions { UNITS, TIMEFORMAT, WINDFORMAT };
/**
- * Reimplement to set the wanted options for the ion such as unit and time, and \
wind speed formats.
- */
- virtual void option(int option, QVariant value) = 0;
+ * reimplemented from DataEngine
+ */
+ bool sourceRequested(const QString &name);
+ /**
+ * Reimplement to fetch the data from the ion
+ *
+ */
+ virtual bool updateIonSource(const QString &name) = 0;
+
private:
class Private;
Private* const d;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic