[Marble-devel] KDE/kdeedu/marble/src/plugins/render

Thibaut Gridel tgridel at free.fr
Sun Nov 1 15:16:49 CET 2009


SVN commit 1043428 by tgridel:

Revert "Marble Plugins "wikipedia" and "weather" don't initialize the config dialog in constructor anymore."

This reverts commit 1037683 because of crash:
#5 Marble::WikipediaModel::showThumbnail (this=0x0)
#6 Marble::WikipediaPlugin::configDialog (this=0xe9aeb0)
#7 Marble::RenderPlugin::item (this=0xe9aeb0)

CCMAIL: bastianholst at gmx.de
CCMAIL: marble-devel at kde.org

 M  +30 -42    weather/WeatherPlugin.cpp  
 M  +0 -2      weather/WeatherPlugin.h  
 M  +0 -5      wikipedia/WikipediaModel.cpp  
 M  +0 -1      wikipedia/WikipediaModel.h  
 M  +14 -23    wikipedia/WikipediaPlugin.cpp  
 M  +1 -3      wikipedia/WikipediaPlugin.h  


--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/WeatherPlugin.cpp #1043427:1043428
@@ -45,6 +45,7 @@
     // Plugin is not visible by default
     setVisible( false );
 
+    configDialog();
     readSettings();    
 }
 
@@ -116,16 +117,15 @@
         // Initializing configuration dialog
         m_configDialog = new QDialog();
         ui_configWidget.setupUi( m_configDialog );
-        updateConfigDialog();
-        connect( ui_configWidget.m_buttonBox, SIGNAL( accepted() ),
-                                              SLOT( writeSettings() ) );
+            connect( ui_configWidget.m_buttonBox, SIGNAL( accepted() ),
+                                            SLOT( writeSettings() ) );
         connect( ui_configWidget.m_buttonBox, SIGNAL( rejected() ),
-                                              SLOT( readSettings() ) );
+                                            SLOT( readSettings() ) );
         QPushButton *applyButton = ui_configWidget.m_buttonBox->button( QDialogButtonBox::Apply );
         connect( applyButton, SIGNAL( clicked() ),
-                 this,        SLOT( writeSettings() ) );
+                this,        SLOT( writeSettings() ) );
         connect( this, SIGNAL( settingsChanged( QString ) ),
-                 this, SLOT( updateItemSettings() ) );
+                this, SLOT( updateItemSettings() ) );
     }
     return m_configDialog;
 }
@@ -143,6 +143,27 @@
 
 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;
@@ -159,6 +180,7 @@
         }
         m_settings.insert( "temperatureUnit", temperatureUnit );
     }
+    ui_configWidget.m_temperatureComboBox->setCurrentIndex( temperatureUnit );
 
     int windSpeedUnit;
     if ( m_settings.contains( "windSpeedUnit" ) ) {
@@ -173,6 +195,7 @@
         }
         m_settings.insert( "windSpeedUnit", temperatureUnit );
     }
+    ui_configWidget.m_windSpeedComboBox->setCurrentIndex( windSpeedUnit );
 
     int pressureUnit;
     if ( m_settings.contains( "pressureUnit" ) ) {
@@ -187,10 +210,7 @@
         }
         m_settings.insert( "pressureUnit", pressureUnit );
     }
-    
-    if ( m_configDialog ) {
-        updateConfigDialog();
-    }
+    ui_configWidget.m_pressureComboBox->setCurrentIndex( pressureUnit );
 
     updateItemSettings();
 }
@@ -223,38 +243,6 @@
     }
 }
 
-void WeatherPlugin::updateConfigDialog() const
-{
-    // 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
-    ui_configWidget.m_temperatureComboBox
-            ->setCurrentIndex( m_settings.value( "temperatureUnit" ).toInt() );
-    ui_configWidget.m_windSpeedComboBox
-            ->setCurrentIndex( m_settings.value( "windSpeedUnit" ).toInt() );
-    ui_configWidget.m_pressureComboBox
-            ->setCurrentIndex( m_settings.value( "pressureUnit" ).toInt() );    
-}
-
 Q_EXPORT_PLUGIN2(WeatherPlugin, Marble::WeatherPlugin)
 
 #include "WeatherPlugin.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/WeatherPlugin.h #1043427:1043428
@@ -64,8 +64,6 @@
     void changedSettings();
 
  private:
-    void updateConfigDialog() const;
-    
     bool m_isInitialized;
 
     mutable QIcon m_icon;
--- trunk/KDE/kdeedu/marble/src/plugins/render/wikipedia/WikipediaModel.cpp #1043427:1043428
@@ -52,11 +52,6 @@
     m_showThumbnail = show;
 }
 
-bool WikipediaModel::showThumbnail() const
-{
-    return m_showThumbnail;
-}
-
 void WikipediaModel::getAdditionalItems( const GeoDataLatLonAltBox& box,
                                          MarbleDataFacade *facade,
                                          qint32 number )
--- trunk/KDE/kdeedu/marble/src/plugins/render/wikipedia/WikipediaModel.h #1043427:1043428
@@ -32,7 +32,6 @@
     ~WikipediaModel();
 
     void setShowThumbnail( bool show );
-    bool showThumbnail() const;
  
  protected:
     /**
--- trunk/KDE/kdeedu/marble/src/plugins/render/wikipedia/WikipediaPlugin.cpp #1043427:1043428
@@ -39,8 +39,7 @@
     // Plugin is not visible by default
     setVisible( false );
     
-    connect( this, SIGNAL( changedNumberOfItems( quint32 ) ),
-             this, SLOT( checkNumberOfItems( quint32 ) ) );
+    configDialog();
     readSettings();
 }
 
@@ -114,9 +113,6 @@
         m_configDialog = new QDialog();
         ui_configWidget.setupUi( m_configDialog );
         ui_configWidget.m_itemNumberSpinBox->setRange( 0, maximumNumberOfItems );
-        ui_configWidget.m_itemNumberSpinBox->setValue( numberOfItems() );
-        WikipediaModel *wikipediaModel = qobject_cast<WikipediaModel*>( model() );
-        updateDialogShowThumbnails( wikipediaModel->showThumbnail() );
         connect( ui_configWidget.m_buttonBox, SIGNAL( accepted() ),
                                             SLOT( writeSettings() ) );
         connect( ui_configWidget.m_buttonBox, SIGNAL( rejected() ),
@@ -124,6 +120,8 @@
         QPushButton *applyButton = ui_configWidget.m_buttonBox->button( QDialogButtonBox::Apply );
         connect( applyButton, SIGNAL( clicked() ),
                 this,        SLOT( writeSettings() ) );
+        connect( this, SIGNAL( changedNumberOfItems( quint32 ) ),
+                this, SLOT( setDialogNumberOfItems( quint32 ) ) );
         connect( this, SIGNAL( settingsChanged( QString ) ),
                 this, SLOT( updateItemSettings() ) );
     }
@@ -143,9 +141,12 @@
 
 void WikipediaPlugin::setShowThumbnails( bool shown )
 {
-    if ( m_configDialog ) {
-        updateDialogShowThumbnails( shown );
+    if ( shown ) {
+        ui_configWidget.m_showThumbnailCheckBox->setCheckState( Qt::Checked );
     }
+    else {
+        ui_configWidget.m_showThumbnailCheckBox->setCheckState( Qt::Unchecked );
+    }
 
     WikipediaModel *wikipediaModel = qobject_cast<WikipediaModel*>( model() );
 
@@ -158,6 +159,7 @@
 void WikipediaPlugin::readSettings()
 {
     setNumberOfItems( m_settings.value( "numberOfItems", 15 ).toUInt() );
+    setDialogNumberOfItems( numberOfItems() );
     if ( !m_settings.contains( "showThumbnails" ) ) {
         m_settings.insert( "showThumbnails", true );
     }
@@ -181,16 +183,15 @@
     emit settingsChanged( nameId() );
 }
 
-void WikipediaPlugin::checkNumberOfItems( quint32 number )
+void WikipediaPlugin::setDialogNumberOfItems( quint32 number )
 {
-    if ( number > maximumNumberOfItems ) {
+    if ( number <= maximumNumberOfItems ) {
+        ui_configWidget.m_itemNumberSpinBox->setValue( (int) number );
+    }
+    else {
         // Force a the number of items being lower or equal maximumNumberOfItems
         setNumberOfItems( maximumNumberOfItems );
     }
-    
-    if ( m_configDialog ) {
-        ui_configWidget.m_itemNumberSpinBox->setValue( (int) number );
-    }
 }
 
 void WikipediaPlugin::updateItemSettings()
@@ -201,16 +202,6 @@
     }
 }
 
-void WikipediaPlugin::updateDialogShowThumbnails( bool shown ) const
-{
-    if ( shown ) {
-        ui_configWidget.m_showThumbnailCheckBox->setCheckState( Qt::Checked );
-    }
-    else {
-        ui_configWidget.m_showThumbnailCheckBox->setCheckState( Qt::Unchecked );
-    }
-}
-
 Q_EXPORT_PLUGIN2(WikipediaPlugin, Marble::WikipediaPlugin)
 
 #include "WikipediaPlugin.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/render/wikipedia/WikipediaPlugin.h #1043427:1043428
@@ -66,13 +66,11 @@
     void readSettings();
     void writeSettings();
 
-    void checkNumberOfItems( quint32 number );
+    void setDialogNumberOfItems( quint32 number );
 
     void updateItemSettings();
 
  private:
-    void updateDialogShowThumbnails( bool shown ) const;
-     
     bool m_isInitialized;
 
     mutable QIcon m_icon;


More information about the Marble-devel mailing list