Summary: | applet does not show a weather station | ||
---|---|---|---|
Product: | [Unmaintained] kweather-kde3 | Reporter: | karl sebastian liebich <karl.sebastian.liebich> |
Component: | general | Assignee: | geiseri |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
karl sebastian liebich
2006-11-02 05:43:54 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> |