[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/plasma/applets/weather
From:       Shawn Starr <shawn.starr () rogers ! com>
Date:       2007-11-24 21:13:03
Message-ID: 1195938783.169160.10816.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 741115 by spstarr:

Configurations now written correctly. We can now work on actually displaying data in \
the applet!

 M  +24 -13    weatherapplet.cpp  
 M  +2 -1      weatherapplet.h  


--- trunk/playground/base/plasma/applets/weather/weatherapplet.cpp #741114:741115
@@ -246,9 +246,8 @@
 
     ui.weatherUpdateSpin->setValue(m_weatherUpdateTime);
     if (ui.pluginComboList->count() == 0) {
-        Plasma::DataEngine::Data data;
-        data = weatherEngine->query("ions");
-        foreach (QVariant item, data) {
+        m_ionPlugins = weatherEngine->query("ions");
+        foreach (QVariant item, m_ionPlugins) {
            QStringList pluginInfo = item.toString().split(":");
            ui.pluginComboList->addItem(pluginInfo[0], pluginInfo[1]);
         }
@@ -314,12 +313,11 @@
 
 
 
-void WeatherApplet::getWeather(const QString &source)
+void WeatherApplet::getWeather(const QString& pluginName, const QStringList& places)
 {
-    Q_UNUSED(source)
-    //kDebug() << "Do Get Weather: " << source;
-    // Iterate though a list of sources + plugin and build a connectSource string...
-    //weatherEngine->connectSource( source, this);
+    foreach (QString place, places) {
+       weatherEngine->connectSource(QString("%1:weather:%2").arg(pluginName).arg(place), \
this); +    }
 }
 
 void WeatherApplet::dataUpdated(const QString &source, const \
Plasma::DataEngine::Data &data) @@ -334,7 +332,7 @@
     }
 
     if (!data.value("validate").toBool()) {
-        weatherEngine->disconnectSource(m_activeValidation, this);
+        //weatherEngine->disconnectSource(m_activeValidation, this);
         // XXX: Get the basic weather info for now, for 1.0. We'll change this later \
                on for KDE 4.1.
         kDebug() << "Weather Information: Country: " << data["Country"].toString();
         kDebug() << "Weather Information: Place: " << data["Place"].toString();
@@ -357,6 +355,7 @@
         kDebug() << "Weather Information: Wind Speed Unit: " << data["Wind Speed \
                Unit"].toString();
         kDebug() << "Weather Information: Wind Gust: " << data["Wind \
                Gust"].toString();
         kDebug() << "Weather Information: Wind Gust Unit: " << data["Wind Gust \
Unit"].toString(); +	kDebug() << "Weather Information: Credits: " << \
data["Credit"].toString();  }
 
 update();
@@ -375,12 +374,21 @@
     QString placeName;
     QMap<QString, QStringList> items;
     KConfigGroup generalConfig = config();
+
+    foreach (QVariant item, m_ionPlugins) {
+        QStringList pluginInfo = item.toString().split(":");
+        generalConfig.deleteEntry(pluginInfo[1]);
+    }
+   
+    generalConfig.config()->sync();
+
     // Write out a KConfig containing all the places the user wants to get weather \
for.  // get the TreeView items
       ui.weathersourceTree->selectAll();
+      items.clear();
 
       for (int row = 0; row < m_cmodel->rowCount(); row++) {
-           for (int column = m_cmodel->columnCount()-1; column >= 1; column--) {
+         for (int column = m_cmodel->columnCount()-1; column >= 1; column--) {
              QModelIndex index = m_cmodel->index(row, column);
              QVariant item = m_cmodel->data(index, Qt::DisplayRole);
              if (column % 2) {
@@ -391,10 +399,13 @@
     
          }
          items[pluginName].append(placeName);
-         //generalConfig.group(pluginName).writeEntry("place", items[pluginName]);
-         generalConfig.writeEntry(pluginName, items[pluginName]);
       }
- 
+
+    foreach (QString plugin, items.keys()) {
+       generalConfig.writeEntry(plugin, items[plugin]);
+       getWeather(plugin, items[plugin]);
+    }
+
     // Write out config options
     m_weatherWindFormat = ui.windFormatToggle->checkState() == Qt::Checked;
     m_weatherUpdateTime = ui.weatherUpdateSpin->value();
--- trunk/playground/base/plasma/applets/weather/weatherapplet.h #741114:741115
@@ -49,7 +49,7 @@
         //QSizeF contentSize() const;
         void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem \
*option, const QRect &contentsRect);  void showData(Plasma::DataEngine::Data& data);
-	void getWeather(const QString& source);
+	void getWeather(const QString& pluginName, const QStringList& places);
 	void validate(const QString& source, const QVariant& data);
 
     public slots:
@@ -81,6 +81,7 @@
         QString m_activeValidation;
 	bool m_weatherWindFormat;
 	int m_weatherUpdateTime;
+	Plasma::DataEngine::Data m_ionPlugins;
 };
 
 K_EXPORT_PLASMA_APPLET(weather, WeatherApplet)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic