[Marble-commits] KDE/kdeedu/marble/src/plugins/render/weather

Bastian Holst bastianholst at gmx.de
Sat Jul 11 22:03:11 CEST 2009


SVN commit 995048 by bholst:

Marbles WeatherPlugin now configurable to show more than condition and temperature. Layout isn't bug-free, yet.


 M  +2 -0      BBCParser.cpp  
 M  +17 -11    BBCWeatherService.cpp  
 M  +2 -0      BBCWeatherService.h  
 M  +41 -4     WeatherConfigWidget.ui  
 M  +10 -7     WeatherItem.cpp  
 M  +35 -0     WeatherPlugin.cpp  
 AM            weatherGlobal.h   [License: LGPL]


--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/BBCParser.cpp #995047:995048
@@ -353,6 +353,7 @@
     dayConditions["heavy rain"] = WeatherData::Rain;
     dayConditions["heavy showers"] = WeatherData::Rain;
     dayConditions["heavy shower"] = WeatherData::Rain;
+    dayConditions["heavy rain shower"] = WeatherData::Rain;
     dayConditions["thundery shower"] = WeatherData::Thunderstorm;
     dayConditions["thunderstorm"] = WeatherData::Thunderstorm;
     dayConditions["thunder storm"] = WeatherData::Thunderstorm;
@@ -397,6 +398,7 @@
     nightConditions["heavy rain"] = WeatherData::Rain;
     nightConditions["heavy showers"] = WeatherData::Rain;
     nightConditions["heavy shower"] = WeatherData::Rain;
+    nightConditions["heavy rain shower"] = WeatherData::Rain;
     nightConditions["thundery shower"] = WeatherData::Thunderstorm;
     nightConditions["thunderstorm"] = WeatherData::Thunderstorm;
     nightConditions["thunder storm"] = WeatherData::Thunderstorm;
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/BBCWeatherService.cpp #995047:995048
@@ -33,17 +33,6 @@
 BBCWeatherService::BBCWeatherService( QObject *parent ) 
     : AbstractWeatherService( parent )
 {
-    QTime time;
-    QFile file( MarbleDirs::path( "weather/bbc-stations.xml" ) );
-    qDebug() << "Filepath: " << file.fileName();
-    
-    if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
-        return;
-    }
-    
-    StationListParser parser( this );
-    m_items = parser.read( &file );
-    qDebug() << "Parsed station list in " << time.elapsed() << " ms and found " << m_items.size() << "items";
 }
 
 BBCWeatherService::~BBCWeatherService() {
@@ -54,6 +43,10 @@
                                             qint32 number )
 {
     Q_UNUSED( facade );
+
+    if ( m_items.isEmpty() ) {
+        setupList();
+    }
     
     qint32 fetched = 0;
     QList<BBCWeatherItem *>::iterator it = m_items.begin();
@@ -68,4 +61,17 @@
     }
 }
 
+void BBCWeatherService::setupList() {
+    QTime time;
+    QFile file( MarbleDirs::path( "weather/bbc-stations.xml" ) );
+
+    if( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
+        return;
+    }
+
+    StationListParser parser( this );
+    m_items = parser.read( &file );
+    qDebug() << "Parsed station list in " << time.elapsed() << " ms and found " << m_items.size() << "items";
+}
+
 #include "BBCWeatherService.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/BBCWeatherService.h #995047:995048
@@ -30,6 +30,8 @@
                              qint32 number = 10 );
  
  private:
+    void setupList();
+
     QList<BBCWeatherItem*> m_items;
 };
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/WeatherConfigWidget.ui #995047:995048
@@ -6,15 +6,52 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>300</height>
+    <width>364</width>
+    <height>414</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Configure Weather Plugin</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
+  <layout class="QVBoxLayout" name="verticalLayout_3">
    <item>
+    <widget class="QGroupBox" name="m_informationGroupBox">
+     <property name="title">
+      <string>Information</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <item>
+       <widget class="QCheckBox" name="m_weatherConditionBox">
+        <property name="text">
+         <string>Weather condition</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="m_temperatureBox">
+        <property name="text">
+         <string>Temperature</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="m_windDirectionBox">
+        <property name="text">
+         <string>Wind direction</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QCheckBox" name="m_windSpeedBox">
+        <property name="text">
+         <string>Wind speed</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <widget class="QGroupBox" name="m_unitsGroupBox">
      <property name="title">
       <string>Units</string>
@@ -136,7 +173,7 @@
      <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
-       <height>118</height>
+       <height>80</height>
       </size>
      </property>
     </spacer>
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/WeatherItem.cpp #995047:995048
@@ -15,6 +15,7 @@
 #include "GeoPainter.h"
 #include "MarbleDirs.h"
 #include "WeatherData.h"
+#include "weatherGlobal.h"
 
 // Qt
 #include <QtCore/QDebug>
@@ -160,22 +161,22 @@
     
     bool isConditionShown() {
         return m_currentWeather.hasValidCondition()
-               && m_settings.value( "showCondition", true ).toBool();
+               && m_settings.value( "showCondition", showConditionDefault ).toBool();
     }
     
     bool isTemperatureShown() {
         return m_currentWeather.hasValidTemperature()
-               && m_settings.value( "showTemperature", true ).toBool();
+               && m_settings.value( "showTemperature", showTemperatureDefault ).toBool();
     }
     
     bool isWindDirectionShown() {
         return m_currentWeather.hasValidWindDirection()
-               && m_settings.value( "showWindDirection", false ).toBool();
+               && m_settings.value( "showWindDirection", showWindDirectionDefault ).toBool();
     }
     
     bool isWindSpeedShown() {
         return m_currentWeather.hasValidWindSpeed()
-               && m_settings.value( "showWindSpeed", false ).toBool();
+               && m_settings.value( "showWindSpeed", showWindSpeedDefault ).toBool();
     }
 
     QString temperatureString() {
@@ -244,8 +245,10 @@
  
 bool WeatherItem::initialized() {
     WeatherData current = currentWeather();
-    return current.hasValidCondition()
-           || current.hasValidTemperature();
+    return d->isConditionShown()
+           || d->isTemperatureShown()
+           || d->isWindDirectionShown()
+           || d->isWindSpeedShown();
 }
 
 void WeatherItem::paint( GeoPainter *painter, ViewportParams *viewport,
@@ -284,7 +287,7 @@
         temperatureRect.setHeight( topRow.height() );
         // If we have a two line layout or condition and temperature is alone in line 1,
         // align temperature right.
-        if ( d->isWindSpeedShown()  || d->isWindDirectionShown() ) {
+        if ( d->isWindSpeedShown() || !d->isWindDirectionShown() ) {
             temperatureRect.moveTopRight( topRow.topRight() );
             alignment = Qt::AlignVCenter | Qt::AlignRight;
             topRow.setRight( topRow.right() - d->m_temperatureSize.width() );
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/WeatherPlugin.cpp #995047:995048
@@ -18,6 +18,7 @@
 #include "MarbleDirs.h"
 #include "MarbleLocale.h"
 #include "global.h"
+#include "weatherGlobal.h"
 
 // Qt
 #include <QtCore/QDebug>
@@ -119,6 +120,29 @@
 }
 
 void WeatherPlugin::readSettings() {
+    // Information
+    if ( m_settings.value( "showCondition", showConditionDefault ).toBool() )
+        ui_configWidget.m_weatherConditionBox->setCheckState( Qt::Checked );
+    else
+        ui_configWidget.m_weatherConditionBox->setCheckState( Qt::Unchecked );
+
+    if ( m_settings.value( "showTemperature", showTemperatureDefault ).toBool() )
+        ui_configWidget.m_temperatureBox->setCheckState( Qt::Checked );
+    else
+        ui_configWidget.m_temperatureBox->setCheckState( Qt::Unchecked );
+
+    if ( m_settings.value( "showWindDirection", showWindDirectionDefault ).toBool() )
+        ui_configWidget.m_windDirectionBox->setCheckState( Qt::Checked );
+    else
+        ui_configWidget.m_windDirectionBox->setCheckState( Qt::Unchecked );
+
+    if ( m_settings.value( "showWindSpeed", showWindSpeedDefault ).toBool() )
+        ui_configWidget.m_windSpeedBox->setCheckState( Qt::Checked );
+    else
+        ui_configWidget.m_windSpeedBox->setCheckState( Qt::Unchecked );
+
+    // Units
+    // The default units depend on the global measure system.
     int temperatureUnit;
     MarbleLocale *locale = MarbleGlobal::getInstance()->locale();
     if ( m_settings.contains( "temperatureUnit" ) ) {
@@ -169,6 +193,17 @@
 }
 
 void WeatherPlugin::writeSettings() {
+    // Information
+    m_settings.insert( "showCondition",
+                       ui_configWidget.m_weatherConditionBox->checkState() == Qt::Checked );
+    m_settings.insert( "showTemperature",
+                       ui_configWidget.m_temperatureBox->checkState() == Qt::Checked );
+    m_settings.insert( "showWindDirection",
+                       ui_configWidget.m_windDirectionBox->checkState() == Qt::Checked );
+    m_settings.insert( "showWindSpeed",
+                       ui_configWidget.m_windSpeedBox->checkState() == Qt::Checked );
+
+    // Units
     m_settings.insert( "temperatureUnit", ui_configWidget.m_temperatureComboBox->currentIndex() );
     m_settings.insert( "windSpeedUnit", ui_configWidget.m_windSpeedComboBox->currentIndex() );
     m_settings.insert( "pressureUnit", ui_configWidget.m_pressureComboBox->currentIndex() );
** trunk/KDE/kdeedu/marble/src/plugins/render/weather/weatherGlobal.h #property svn:eol-style
   + native


More information about the Marble-commits mailing list