<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>124754</bug_id>
          
          <creation_ts>2006-04-02 14:23:22 +0000</creation_ts>
          <short_desc>Arrange the weather stations alphabetically</short_desc>
          <delta_ts>2006-12-24 22:05:48 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>10</classification_id>
          <classification>Unmaintained</classification>
          <product>kweather-kde3</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>Debian testing</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>wishlist</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Torquil Macdonald Sørensen">torquil</reporter>
          <assigned_to>geiseri</assigned_to>
          
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>426942</commentid>
    <comment_count>0</comment_count>
    <who name="Torquil Macdonald Sørensen">torquil</who>
    <bug_when>2006-04-02 14:23:23 +0000</bug_when>
    <thetext>Version:            (using KDE KDE 3.5.2)
Installed from:    Debian testing/unstable Packages

In &quot;Configure&quot; -&gt; &quot;Display&quot; -&gt; &quot;Weather Station Options&quot; -&gt; &quot;Location&quot;, please order the weather stations alphabetically

Best regards,
TMS</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>495878</commentid>
    <comment_count>1</comment_count>
    <who name="Martin Koller">martin</who>
    <bug_when>2006-12-24 22:05:48 +0000</bug_when>
    <thetext>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 &amp;locationCode)
 {
-	m_locationCode = locationCode;
+    m_locationCode = locationCode;
+    showWeather();
 }
 
 void dockwidget::setViewMode(int _mode)
@@ -82,7 +83,7 @@
     QString wind     = &quot;?&quot;;
     QString pressure = &quot;?&quot;;
 
-    if ( m_weatherService-&gt;stationNeedsMaintenance( m_locationCode ) )
+    if ( !m_locationCode.isEmpty() &amp;&amp; m_weatherService-&gt;stationNeedsMaintenance( m_locationCode ) )
     {
         tip = i18n(&quot;Station reports that it needs maintenance\n&quot;
                    &quot;Please try again later&quot;);
@@ -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-&gt;icon( m_locationCode );
 
+    if ( ! m_locationCode.isEmpty() )
+        tip = m_weatherService-&gt;stationName( m_locationCode ) + &quot;\n&quot; + 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-&gt;m_reportLocation-&gt;currentText();
+
+  mWidget-&gt;m_reportLocation-&gt;clear();
+
   QStringList stationList = mWeatherService-&gt;listStations();
   QStringList::Iterator idx = stationList.begin();
+
+  // get station name from station id for sorting afterwards
   for(; idx != stationList.end(); ++idx)
-    mWidget-&gt;m_reportLocation-&gt;insertItem(mWeatherService-&gt;stationName(*idx));
+    *idx = mWeatherService-&gt;stationName(*idx);
+
+  stationList.sort();
+
+  idx = stationList.begin();
+  for(; idx != stationList.end(); ++idx)
+    mWidget-&gt;m_reportLocation-&gt;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-&gt;m_reportLocation-&gt;insertItem(&quot;&quot;);
+    mWidget-&gt;m_reportLocation-&gt;setCurrentText(&quot;&quot;);
+  }
+  else
+  {
+    for (int i = 0; i &lt; mWidget-&gt;m_reportLocation-&gt;count(); i++)
+      if (  mWidget-&gt;m_reportLocation-&gt;text(i) == current )
+      {
+        mWidget-&gt;m_reportLocation-&gt;setCurrentItem(i);
+        break;
+      }
+  }
+
+  if ( current != mWidget-&gt;m_reportLocation-&gt;currentText() )
+    reportLocationChanged();
 }
 
 void KCMWeather::changeViewMode( int mode )
@@ -102,11 +136,6 @@
   emit changed( true );
 }
 
-void KCMWeather::processURL( const QString &amp;url )
-{
-  kapp-&gt;invokeBrowser( url );
-}
-
 void KCMWeather::enableLogWidgets( bool value )
 {
   mWidget-&gt;m_logFile-&gt;setEnabled( value );
@@ -135,7 +164,10 @@
   QString loc =  config.readEntry( &quot;report_location&quot; );
 
   mWidget-&gt;m_logFile-&gt;setURL( config.readPathEntry( &quot;log_file_name&quot; ) );
-  mWidget-&gt;m_reportLocation-&gt;setCurrentText( mWeatherService-&gt;stationName( loc ) );
+
+  if ( ! loc.isEmpty() )
+    mWidget-&gt;m_reportLocation-&gt;setCurrentText( mWeatherService-&gt;stationName( loc ) );
+
   mWidget-&gt;m_viewMode-&gt;setButton( config.readNumEntry( &quot;smallview_mode&quot;, dockwidget::ShowAll ) );
   changeViewMode( config.readNumEntry( &quot;smallview_mode&quot;, dockwidget::ShowAll ) );
   emit changed( false );
@@ -149,8 +181,13 @@
   config.setGroup( &quot;General Options&quot; );
   config.writeEntry( &quot;logging&quot;, mWidget-&gt;m_enableLog-&gt;isChecked() );
   config.writeEntry( &quot;log_file_name&quot;, mWidget-&gt;m_logFile-&gt;url() );
-  // Station idx to local idx
-  config.writeEntry( &quot;report_location&quot;, mWeatherService-&gt;stationCode( mWidget-&gt;m_reportLocation-&gt;currentText() ) );
+
+  // Station idx to local idx; if nothing selected yet, keep it empty
+  QString loc;
+  if ( ! mWidget-&gt;m_reportLocation-&gt;currentText().isEmpty() )
+    loc = mWeatherService-&gt;stationCode( mWidget-&gt;m_reportLocation-&gt;currentText() );
+  config.writeEntry( &quot;report_location&quot;, loc);
+
   config.writeEntry( &quot;smallview_mode&quot;, 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&amp; );
     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-&gt;addWidget( mWidget );
   KAboutData *about = new KAboutData( &quot;kcmweatherservice&quot;,
                                       I18N_NOOP( &quot;KWeather Configure Dialog&quot; ),
--- 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) &lt;&lt; &quot;Constructor &quot; &lt;&lt; endl;
 	setObjId(&quot;weatherIface&quot;);
@@ -146,32 +146,41 @@
 }
 
 /** prefs */
-void kweather::preferences(){
+void kweather::preferences()
+{
     kdDebug(12004) &lt;&lt; &quot;prefs&quot; &lt;&lt; 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&amp;) ), SLOT( slotPrefsAccepted() ) );
-
-      dlg-&gt;addModule( &quot;kcmweather.desktop&quot; );
-      dlg-&gt;addModule( &quot;kcmweatherservice.desktop&quot; );
+      settingsDialog-&gt;addModule( &quot;kcmweather.desktop&quot; );
+      settingsDialog-&gt;addModule( &quot;kcmweatherservice.desktop&quot; );
     }
 
-    dlg-&gt;show();
-    dlg-&gt;raise();
+    settingsDialog-&gt;show();
+    settingsDialog-&gt;raise();
 }
 
 /** The help handler */
-void kweather::help(){
+void kweather::help()
+{
     kapp-&gt;invokeHelp(QString::null, QString::fromLatin1(&quot;kweather&quot;));
 }
 
 /** Display the current weather report. */
-void kweather::doReport(){
+void kweather::doReport()
+{
+    if ( reportLocation.isEmpty() )
+    {
+        // no station to display defined -&gt; open settings dialog
+        preferences();
+        return;
+    }
+
 	kdDebug(12004) &lt;&lt; &quot;Showing out the report&quot; &lt;&lt; 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 @@
             &lt;height&gt;0&lt;/height&gt;
         &lt;/size&gt;
     &lt;/property&gt;
-    &lt;property name=&quot;maximumSize&quot;&gt;
-        &lt;size&gt;
-            &lt;width&gt;640&lt;/width&gt;
-            &lt;height&gt;480&lt;/height&gt;
-        &lt;/size&gt;
-    &lt;/property&gt;
     &lt;property name=&quot;focusPolicy&quot;&gt;
         &lt;enum&gt;TabFocus&lt;/enum&gt;
     &lt;/property&gt;
@@ -83,6 +77,20 @@
                     &lt;property name=&quot;name&quot;&gt;
                         &lt;cstring&gt;m_reportLocation&lt;/cstring&gt;
                     &lt;/property&gt;
+                    &lt;property name=&quot;sizePolicy&quot;&gt;
+                        &lt;sizepolicy&gt;
+                            &lt;hsizetype&gt;3&lt;/hsizetype&gt;
+                            &lt;vsizetype&gt;0&lt;/vsizetype&gt;
+                            &lt;horstretch&gt;0&lt;/horstretch&gt;
+                            &lt;verstretch&gt;0&lt;/verstretch&gt;
+                        &lt;/sizepolicy&gt;
+                    &lt;/property&gt;
+                    &lt;property name=&quot;minimumSize&quot;&gt;
+                        &lt;size&gt;
+                            &lt;width&gt;0&lt;/width&gt;
+                            &lt;height&gt;0&lt;/height&gt;
+                        &lt;/size&gt;
+                    &lt;/property&gt;
                 &lt;/widget&gt;
                 &lt;spacer&gt;
                     &lt;property name=&quot;name&quot;&gt;
@@ -284,4 +292,10 @@
 &lt;/includes&gt;
 &lt;layoutdefaults spacing=&quot;3&quot; margin=&quot;6&quot;/&gt;
 &lt;layoutfunctions spacing=&quot;KDialog::spacingHint&quot; margin=&quot;KDialog::marginHint&quot;/&gt;
+&lt;includehints&gt;
+    &lt;includehint&gt;kcombobox.h&lt;/includehint&gt;
+    &lt;includehint&gt;kurlrequester.h&lt;/includehint&gt;
+    &lt;includehint&gt;klineedit.h&lt;/includehint&gt;
+    &lt;includehint&gt;kpushbutton.h&lt;/includehint&gt;
+&lt;/includehints&gt;
 &lt;/UI&gt;
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>