Bug 116375 - menubar kweather applet refuses to accept my location, defaults to 0000
Summary: menubar kweather applet refuses to accept my location, defaults to 0000
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:
Depends on:
Blocks:
 
Reported: 2005-11-14 21:28 UTC by Andrew Kohlsmith
Modified: 2006-12-24 22:05 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Kohlsmith 2005-11-14 21:28:54 UTC
Version:            (using KDE KDE 3.4.92)
Installed from:    Compiled From Sources

I have had kweather working inside of kontact as long as I can remember.  Today, however, I changed my desktop to have a menubar (osx-style) at the top, and added a half dozen applets to that menubar, among them kweatherapplet.

It refuses to use my Toronto, Ontario, Canada weather station (the one I've been using with Kontact forever) and instead "sticks" on station ID 0000, which is always sunny and 0 degrees Celcius.  I can delete that station (Toronto, ON is still there) and Apply/Ok...  but it doesn't change, and if I go back in the configuration, 0000 is there again.
Comment 1 Andrew Kohlsmith 2005-11-14 21:29:45 UTC
It should be noted that while the menubar kweather applet is misbehaving, the one inside of Kontact is working perfectly, although it does show station 0000 in addition to Toronto, ON.  :-)
Comment 2 Andrew Kohlsmith 2005-11-14 22:15:57 UTC
Just an update.

I pulled up kdcop and restarted kicker with its restart instance.  the "top of screen" kweather applet now lets me choose Toronto correctly, and I have removed the oddball "0000" station ID.  It seems to be working so far.  When I stop and restart KDE tonight I'll find out for sure.  :-)
Comment 3 chuck gelm 2005-11-22 14:00:17 UTC
Fresh install of Slackware v10.2 (<24 hours).
Kweather keeps displaying weather for station "0000".
I keep removing station "000" and inserting "Dayton, OH" as default.
Display returns to station "0000" (sunny and zero degrees Celcius).
Comment 4 Rick Harris 2005-12-01 05:16:06 UTC
Had the same issue as Chuck Gelm here upgrading from kde-3.4.3 to kde-3.5.0.
Using a clean ~/.kde/ directory, it seems the new kweather (using kdetoys-3.5.0) does not successfully create the config files ~/.kde/share/config/KWeatherServicerc
~/.kde/share/config/weather_panelappletrc

Manually creating/editing the files as below has kweather working well now (also fixes Bug# 107733 with Kicker crashing):

~/.kde/share/config/KWeatherServicerc
[WEATHERSTATIONS]
stations=YPAD

~/.kde/share/config/weather_panelappletrc
[General Options]
log_file_name=
logging=false
report_location=YPAD
reportview_size=743,577
smallview_mode=2


Full list of station codes for location can be found in the source tarball, kdetoys-3.5.0/kweather/stations.dat
Comment 5 Patrick Steiner 2005-12-08 20:53:23 UTC
had the same bug with version 2.1.0 (kde 3.4.3)

had to edit KWeatherServicerc and weather_panelappletrc manually.

after this all works fine.

i also had to add Location Aigen im Ennstal (LOXA) to

/usr/share/apps/kweatherservice/weather_stations.desktop.

in /usr/share/apps/kweatherservice/stations.dat there is already an entry for LOXA
Comment 6 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>