Bug 103887 - KWeather impossible to select weather station.
Summary: KWeather impossible to select weather station.
Status: RESOLVED FIXED
Alias: None
Product: kweather-kde3
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: geiseri
URL:
Keywords:
: 94970 96951 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-04-14 15:36 UTC by Ali Akcaagac
Modified: 2006-12-24 22:05 UTC (History)
5 users (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 Ali Akcaagac 2005-04-14 15:36:34 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 3.4.3 
OS:                Linux

Added KWeather CVS HEAD to Kicker, jumped into Configuration, selected Bremen as Weather Service unfortunately nothing shows up. Jumping into Configuration again and I saw that Weather Station Options shows Unknown Weather station.
Comment 1 Ali Akcaagac 2005-10-10 13:35:54 UTC
KWeather still doesn't work for me. I can select a weather station but nothing much happens, no update, nothing gets shown and worst the applet usually crashes after some mins and takes Kicker with it.
Comment 2 Dale Crummie 2005-12-17 02:58:12 UTC
The same thing has happened to me, I added Kweather to the kicker and when I tried to configure it 1) it wouldn't let me enter the station code and 2) when I did select the station from the list I got the message of Unknown Station
Comment 3 Christopher Martin 2006-01-17 17:54:26 UTC
Based on personal testing, and the reports of Debian users, I can confirm that KWeather, in KDE 3.5.0, is broken. It appears to be impossible to select a real weather station, as whatever stations you add to the list are not available to be selected; you only get "Unknown Weather station". And KWeather does seem to be able to crash kicker quite easily, though I can't reproduce the crashes at will.

Fixes for KDE 3.5.1 (or .2) would be great.

Thanks,
Christopher Martin
Comment 4 gerard 2006-02-24 00:35:53 UTC
KWeather is not completely broken.

If you right click on the applet and choose Refresh, then you will be able to choose the good towns in the drop down list in the config pane.

But it is clear this applet is very buggy :
-the error messages are wrong
-the tooltips don't work on the applet
-the doc is wrong and weak
Comment 5 tink 2006-04-28 09:15:35 UTC
Ummm ... not quite that easy.  It's impossible for me to select Wellington,
be it in the list or not.  I can see Zurich, I can see Auckland, but Wellington
*won't* work.

And that's in 3.5.2 in kubuntu 5.10 and 3.5.1 in Slack 10.2
Comment 6 eddie 2006-06-08 12:05:55 UTC
Regardless of what I select in the configuration setting, the weather station remains on Unknown weather station.  My work around is to edit the config file directly and then remove and reinstall the applet.  A bit of a pain as I have to search the web to find the code I need but at least it works. (Had similar problems in earlier versions of KDE & SUSE too, only that now I find it more irritating and more difficult to resolve).

SUSE 10.1, KDE 3.5.3 level "a", kernel 2.6.16.13-4-default
Comment 7 Pupeno 2006-07-06 11:42:46 UTC
Removing the applet and re-adding it did wonders for me *sigh*.
Comment 8 Scott 2006-10-04 22:04:28 UTC
I've done everything described previously in this bug. Sometimes they work. Sometimes they don't.  At the time of this writng, none were working.

This bug has been in (whatever the current stable version of) KDE (is)  since at least late 2004.

I'm presently running KDE 3.5.4 (Ubuntu 6.10 packages).
Comment 9 ben miller 2006-11-04 16:46:32 UTC
I've been having the same problems with KWeather. I've also tried several of the correction methods mentioned in other posts but to no avail. The only change I see during different removals and readds of the applet is that sometimes the station menu isn't clickable at all, other times it only provides an 'unknown station' choice. 

According to the help file, there should be a 'lookup station' button, but it's not visible for me.
Comment 10 Michael Cummings 2006-11-19 02:08:13 UTC
Looks like the crux of the problem (at least over here, kde 3.5.5, gentoo) is that weather_panelappletrc isn't being updated with the selection written to KWeatherServicerc.
Comment 11 Martin Koller 2006-12-24 01:39:43 UTC
*** Bug 96951 has been marked as a duplicate of this bug. ***
Comment 12 Martin Koller 2006-12-24 21:01:29 UTC
*** Bug 94970 has been marked as a duplicate of this bug. ***
Comment 13 Martin Koller 2006-12-24 22:05:48 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>