Bug 122850 - kweather configuration isn't saving, not loading selected stations
Summary: kweather configuration isn't saving, not loading selected stations
Status: RESOLVED FIXED
Alias: None
Product: kweather-kde3
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Slackware Linux
: NOR normal
Target Milestone: ---
Assignee: geiseri
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-28 18:58 UTC by Andrew Burns
Modified: 2007-04-13 14:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Burns 2006-02-28 18:58:26 UTC
Version:           2.1.0 (using KDE KDE 3.4.2)
Installed from:    Slackware Packages
OS:                Linux

I started Kweather and added a location.  The icon in the selected stations list updated.  I went to "Display" and the dropdown  menu didn't update.  Following bug reports, I restarted the applet and still no luck.  I found $HOME/.kde/share/config/weather_panelappletrc and saw station 0000 is loaded there.  It appears Kweather isn't updating it.

Updating the file myself, I managed to get it to load properly (albeit it's metric, and I'm uncultured).
Comment 1 Andrew Burns 2006-03-02 19:33:16 UTC
Restarted computer a few days later and my selected station was in the dropdown menu.  Still can't get it off metric.
Comment 2 Andrew Burns 2006-03-02 19:39:41 UTC
Fixed the metric issue by searching bug system.  Manual wasn't informative about units.  I'll leave the issue unresolved on the matter of it takes a reboot to set your stations up.  This doesn't sound right, but I'll leave it to thsoe that no better.
Comment 3 Daigoro Toyama 2006-04-06 01:04:23 UTC
I have the exact same problem with kweather with KDE 3.5.1 (FC5). I selected a station from the dropdown list, but the location combo box in "display" does not get updated. It still says "Unknown Station" and no other values are in the list.

I also manually updated the value of "report_location" to KPAE (Everett, WA), and hit "Update Now," but it did not do anything. KWeather still reports "station not found." I thought an old version of kweather accepted "KPAE" as a legitimate value. What gives?
Comment 4 John Olsson 2006-11-10 11:24:17 UTC
According to
http://www.linuxquestions.org/questions/showthread.php?t=446240
you have to manually edit
$HOME/.kde/share/config/weather_panelappletrc
and set the "report_location" attribute to your weather station of choice...

I am also unable to change the report format, i.e. "just icon", "icon with temperature", ... via the GUI. The changes are not reflexted in the weather_panelappletrc file. :(
Comment 5 Martin Koller 2006-12-24 22:05:45 UTC
SVN commit 616273 by mkoller:

BUG: 124754
BUG: 138047
BUG: 136683
BUG: 126296
BUG: 113828
BUG: 122850
BUG: 118458
BUG: 116375
BUG: 103887
BUG: 76300
BUG: 73093

Long standing bug: make selection of a station work



 M  +6 -2      dockwidget.cpp  
 M  +47 -10    kcmweather.cpp  
 M  +1 -2      kcmweather.h  
 M  +4 -0      kcmweatherservice.cpp  
 M  +22 -13    kweather.cpp  
 M  +1 -0      kweather.h  
 M  +20 -6     prefdialogdata.ui  


--- branches/KDE/3.5/kdetoys/kweather/dockwidget.cpp #616272:616273
@@ -47,7 +47,8 @@
 
 void dockwidget::setLocationCode(const QString &locationCode)
 {
-	m_locationCode = locationCode;
+    m_locationCode = locationCode;
+    showWeather();
 }
 
 void dockwidget::setViewMode(int _mode)
@@ -82,7 +83,7 @@
     QString wind     = "?";
     QString pressure = "?";
 
-    if ( m_weatherService->stationNeedsMaintenance( m_locationCode ) )
+    if ( !m_locationCode.isEmpty() && m_weatherService->stationNeedsMaintenance( m_locationCode ) )
     {
         tip = i18n("Station reports that it needs maintenance\n"
                    "Please try again later");
@@ -111,6 +112,9 @@
     // On null or empty location code, or if the station needs maintenance, this will return the dunno icon.
     QPixmap icon = m_weatherService->icon( m_locationCode );
 
+    if ( ! m_locationCode.isEmpty() )
+        tip = m_weatherService->stationName( m_locationCode ) + "\n" + tip;
+
     QToolTip::remove(m_button);
     QToolTip::add(m_button, tip);
 
--- branches/KDE/3.5/kdetoys/kweather/kcmweather.cpp #616272:616273
@@ -83,17 +83,51 @@
 {
   delete mWeatherService;
 }
-void KCMWeather::focusInEvent(QFocusEvent *)
+void KCMWeather::showEvent( QShowEvent * )
 {
   fillStationList();
 }
 
 void KCMWeather::fillStationList()
 {
+  // store current selection
+  QString current = mWidget->m_reportLocation->currentText();
+
+  mWidget->m_reportLocation->clear();
+
   QStringList stationList = mWeatherService->listStations();
   QStringList::Iterator idx = stationList.begin();
+
+  // get station name from station id for sorting afterwards
   for(; idx != stationList.end(); ++idx)
-    mWidget->m_reportLocation->insertItem(mWeatherService->stationName(*idx));
+    *idx = mWeatherService->stationName(*idx);
+
+  stationList.sort();
+
+  idx = stationList.begin();
+  for(; idx != stationList.end(); ++idx)
+    mWidget->m_reportLocation->insertItem(*idx);
+
+  // restore previous selection
+  if ( current.isEmpty() )
+  {
+    // nothing defined yet; show this situation to the user, otherwise
+    // he will see the first available setting which is not what he selected to view
+    mWidget->m_reportLocation->insertItem("");
+    mWidget->m_reportLocation->setCurrentText("");
+  }
+  else
+  {
+    for (int i = 0; i < mWidget->m_reportLocation->count(); i++)
+      if (  mWidget->m_reportLocation->text(i) == current )
+      {
+        mWidget->m_reportLocation->setCurrentItem(i);
+        break;
+      }
+  }
+
+  if ( current != mWidget->m_reportLocation->currentText() )
+    reportLocationChanged();
 }
 
 void KCMWeather::changeViewMode( int mode )
@@ -102,11 +136,6 @@
   emit changed( true );
 }
 
-void KCMWeather::processURL( const QString &url )
-{
-  kapp->invokeBrowser( url );
-}
-
 void KCMWeather::enableLogWidgets( bool value )
 {
   mWidget->m_logFile->setEnabled( value );
@@ -135,7 +164,10 @@
   QString loc =  config.readEntry( "report_location" );
 
   mWidget->m_logFile->setURL( config.readPathEntry( "log_file_name" ) );
-  mWidget->m_reportLocation->setCurrentText( mWeatherService->stationName( loc ) );
+
+  if ( ! loc.isEmpty() )
+    mWidget->m_reportLocation->setCurrentText( mWeatherService->stationName( loc ) );
+
   mWidget->m_viewMode->setButton( config.readNumEntry( "smallview_mode", dockwidget::ShowAll ) );
   changeViewMode( config.readNumEntry( "smallview_mode", dockwidget::ShowAll ) );
   emit changed( false );
@@ -149,8 +181,13 @@
   config.setGroup( "General Options" );
   config.writeEntry( "logging", mWidget->m_enableLog->isChecked() );
   config.writeEntry( "log_file_name", mWidget->m_logFile->url() );
-  // Station idx to local idx
-  config.writeEntry( "report_location", mWeatherService->stationCode( mWidget->m_reportLocation->currentText() ) );
+
+  // Station idx to local idx; if nothing selected yet, keep it empty
+  QString loc;
+  if ( ! mWidget->m_reportLocation->currentText().isEmpty() )
+    loc = mWeatherService->stationCode( mWidget->m_reportLocation->currentText() );
+  config.writeEntry( "report_location", loc);
+
   config.writeEntry( "smallview_mode", mViewMode );
   config.sync();
 
--- branches/KDE/3.5/kdetoys/kweather/kcmweather.h #616272:616273
@@ -41,10 +41,9 @@
 
   protected:
     void fillStationList();
-    void focusInEvent( QFocusEvent * );
+    virtual void showEvent( QShowEvent * );
 
   private slots:
-    void processURL( const QString& );
     void enableLogWidgets( bool value );
     void changeViewMode( int mode );
     void reportLocationChanged();
--- branches/KDE/3.5/kdetoys/kweather/kcmweatherservice.cpp #616272:616273
@@ -43,6 +43,10 @@
 {
   QVBoxLayout *layout = new QVBoxLayout( this );
   mWidget = new ServiceConfigWidget( this );
+
+  // not needed, as a change immediately changes the service
+  //connect(mWidget, SIGNAL(changed(bool)), this, SIGNAL(changed(bool)));
+
   layout->addWidget( mWidget );
   KAboutData *about = new KAboutData( "kcmweatherservice",
                                       I18N_NOOP( "KWeather Configure Dialog" ),
--- branches/KDE/3.5/kdetoys/kweather/kweather.cpp #616272:616273
@@ -52,7 +52,7 @@
         QWidget *parent, const char *name):
         KPanelApplet(configFile, t, actions, parent, name), weatherIface(),
         mFirstRun( false ), mReport( 0 ), mClient( 0 ),
-        mContextMenu( 0 ), mWeatherService( 0 )
+        mContextMenu( 0 ), mWeatherService( 0 ), settingsDialog( 0 )
 {
 	kdDebug(12004) << "Constructor " << endl;
 	setObjId("weatherIface");
@@ -146,32 +146,41 @@
 }
 
 /** prefs */
-void kweather::preferences(){
+void kweather::preferences()
+{
     kdDebug(12004) << "prefs" << endl;
 
     savePrefs();
 
-    static KCMultiDialog *dlg = 0;
+    if ( settingsDialog == 0 )
+    {
+      settingsDialog = new KCMultiDialog( this );
+      connect( settingsDialog, SIGNAL( configCommitted() ), SLOT( slotPrefsAccepted() ) );
 
-    if ( dlg == 0 ) {
-      dlg = new KCMultiDialog( );
-      connect( dlg, SIGNAL( configCommitted(const QCString&) ), SLOT( slotPrefsAccepted() ) );
-
-      dlg->addModule( "kcmweather.desktop" );
-      dlg->addModule( "kcmweatherservice.desktop" );
+      settingsDialog->addModule( "kcmweather.desktop" );
+      settingsDialog->addModule( "kcmweatherservice.desktop" );
     }
 
-    dlg->show();
-    dlg->raise();
+    settingsDialog->show();
+    settingsDialog->raise();
 }
 
 /** The help handler */
-void kweather::help(){
+void kweather::help()
+{
     kapp->invokeHelp(QString::null, QString::fromLatin1("kweather"));
 }
 
 /** Display the current weather report. */
-void kweather::doReport(){
+void kweather::doReport()
+{
+    if ( reportLocation.isEmpty() )
+    {
+        // no station to display defined -> open settings dialog
+        preferences();
+        return;
+    }
+
 	kdDebug(12004) << "Showing out the report" << endl;
 	if ( mReport == 0 )
 	{
--- branches/KDE/3.5/kdetoys/kweather/kweather.h #616272:616273
@@ -77,6 +77,7 @@
 	//DCOPRef *mWeatherService;
 	KPopupMenu *mContextMenu;
 	WeatherService_stub *mWeatherService;
+	KCMultiDialog *settingsDialog;
 };
 
 #endif
--- branches/KDE/3.5/kdetoys/kweather/prefdialogdata.ui #616272:616273
@@ -27,12 +27,6 @@
             <height>0</height>
         </size>
     </property>
-    <property name="maximumSize">
-        <size>
-            <width>640</width>
-            <height>480</height>
-        </size>
-    </property>
     <property name="focusPolicy">
         <enum>TabFocus</enum>
     </property>
@@ -83,6 +77,20 @@
                     <property name="name">
                         <cstring>m_reportLocation</cstring>
                     </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>3</hsizetype>
+                            <vsizetype>0</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="minimumSize">
+                        <size>
+                            <width>0</width>
+                            <height>0</height>
+                        </size>
+                    </property>
                 </widget>
                 <spacer>
                     <property name="name">
@@ -284,4 +292,10 @@
 </includes>
 <layoutdefaults spacing="3" margin="6"/>
 <layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+    <includehint>kcombobox.h</includehint>
+    <includehint>kurlrequester.h</includehint>
+    <includehint>klineedit.h</includehint>
+    <includehint>kpushbutton.h</includehint>
+</includehints>
 </UI>