From b1d0b204e125214893eb84c05d25772ac3afaa28 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Fri, 24 Dec 2021 11:39:08 +0200 Subject: KWeather: Split Display module in two sumbodules Signed-off-by: Mavridis Philippe --- kweather/CMakeLists.txt | 25 ++- kweather/appletconfig.ui | 311 ++++++++++++++++++++++++++++ kweather/kcmweather.cpp | 230 --------------------- kweather/kcmweather.desktop | 15 -- kweather/kcmweather.h | 59 ------ kweather/kcmweatherapplet.cpp | 203 +++++++++++++++++++ kweather/kcmweatherapplet.desktop | 15 ++ kweather/kcmweatherapplet.h | 57 ++++++ kweather/kcmweatherservice.cpp | 140 +++++++++---- kweather/kcmweatherservice.desktop | 10 +- kweather/kcmweatherservice.h | 60 +++--- kweather/kcmweatherstations.cpp | 72 +++++++ kweather/kcmweatherstations.desktop | 16 ++ kweather/kcmweatherstations.h | 47 +++++ kweather/kweather.cpp | 5 +- kweather/prefdialogdata.ui | 393 ------------------------------------ kweather/serviceconfig.ui | 198 ++++++++++++++++++ kweather/serviceconfigdata.ui | 259 ------------------------ kweather/serviceconfigwidget.cpp | 239 ---------------------- kweather/serviceconfigwidget.h | 59 ------ kweather/sidebarwidget.cpp | 1 + kweather/stationsconfig.ui | 259 ++++++++++++++++++++++++ kweather/stationsconfigwidget.cpp | 239 ++++++++++++++++++++++ kweather/stationsconfigwidget.h | 59 ++++++ 24 files changed, 1636 insertions(+), 1335 deletions(-) create mode 100644 kweather/appletconfig.ui delete mode 100644 kweather/kcmweather.cpp delete mode 100644 kweather/kcmweather.desktop delete mode 100644 kweather/kcmweather.h create mode 100644 kweather/kcmweatherapplet.cpp create mode 100644 kweather/kcmweatherapplet.desktop create mode 100644 kweather/kcmweatherapplet.h create mode 100644 kweather/kcmweatherstations.cpp create mode 100644 kweather/kcmweatherstations.desktop create mode 100644 kweather/kcmweatherstations.h delete mode 100644 kweather/prefdialogdata.ui create mode 100644 kweather/serviceconfig.ui delete mode 100644 kweather/serviceconfigdata.ui delete mode 100644 kweather/serviceconfigwidget.cpp delete mode 100644 kweather/serviceconfigwidget.h create mode 100644 kweather/stationsconfig.ui create mode 100644 kweather/stationsconfigwidget.cpp create mode 100644 kweather/stationsconfigwidget.h (limited to 'kweather') diff --git a/kweather/CMakeLists.txt b/kweather/CMakeLists.txt index b618585..a3abbcd 100644 --- a/kweather/CMakeLists.txt +++ b/kweather/CMakeLists.txt @@ -110,21 +110,29 @@ tde_add_kpart( weather_panelapplet AUTOMOC ) -##### kcm_weather (kpart) ####################### +##### kcm_weatherapplet (kpart) ################# -tde_add_kpart( kcm_weather AUTOMOC - SOURCES kcmweather.cpp prefdialogdata.ui +tde_add_kpart( kcm_weatherapplet AUTOMOC + SOURCES kcmweatherapplet.cpp appletconfig.ui weatherservice.stub LINK tdeio-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) - -##### kcm_weatherservice (kpart) ################ +##### kcm_weatherservice (kpart) ################# tde_add_kpart( kcm_weatherservice AUTOMOC - SOURCES kcmweatherservice.cpp - serviceconfigwidget.cpp serviceconfigdata.ui + SOURCES kcmweatherservice.cpp serviceconfig.ui + weatherservice.stub + LINK tdeio-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) + +##### kcm_weatherstations (kpart) ################ + +tde_add_kpart( kcm_weatherstations AUTOMOC + SOURCES kcmweatherstations.cpp + stationsconfigwidget.cpp stationsconfig.ui weatherservice.stub LINK tdeui-shared tdehtml-shared DESTINATION ${PLUGIN_INSTALL_DIR} @@ -171,8 +179,9 @@ tde_create_translated_desktop( tde_create_translated_desktop( SOURCE kweatherservice.desktop - kcmweather.desktop + kcmweatherapplet.desktop kcmweatherservice.desktop + kcmweatherstations.desktop DESTINATION ${SERVICES_INSTALL_DIR} PO_DIR kweather-desktops ) diff --git a/kweather/appletconfig.ui b/kweather/appletconfig.ui new file mode 100644 index 0000000..d29ab3d --- /dev/null +++ b/kweather/appletconfig.ui @@ -0,0 +1,311 @@ + +appletConfig +ian reinhart geiser <geiseri@kde.org> + + + appletConfig + + + + 0 + 0 + 761 + 385 + + + + + 3 + 3 + 0 + 0 + + + + + 0 + 0 + + + + appletConfig + + + TabFocus + + + + unnamed + + + 0 + + + + GroupBox2 + + + + 1 + 1 + 0 + 0 + + + + NoFrame + + + Sunken + + + Weather Station Options + + + + unnamed + + + + TextLabel1_4_2_2 + + + &Location: + + + m_reportLocation + + + + + m_reportLocation + + + + 3 + 0 + 0 + 0 + + + + + 0 + 0 + + + + + + spacer2 + + + Horizontal + + + MinimumExpanding + + + + 40 + 20 + + + + + + + + m_viewMode + + + + 1 + 1 + 0 + 0 + + + + 0 + + + Panel Display Options + + + AlignVCenter|AlignLeft + + + true + + + + m_smallView + + + + 6 + 24 + 747 + 26 + + + + + 1 + 0 + 0 + 0 + + + + &Show icon only + + + 1 + + + <qt>Click here to show only the weather icon.</qt> + + + This feature will allow you to make KWeather take up only one slot on the kicker. Normally this application will take up two slots. The small view will only show the weather icon, while the normal view will display both the icon and the current weather statistics. For the small view the weather statistics will be put on the buttons tool tip. + + + + + CheckBox10 + + + + 6 + 82 + 747 + 26 + + + + Show icon, temperature, &wind and pressure information + + + true + + + 3 + + + + + CheckBox9 + + + + 6 + 53 + 747 + 26 + + + + Show &icon and temperature + + + 2 + + + + + + groupBox3 + + + + 1 + 1 + 0 + 0 + + + + Text + + + + unnamed + + + + layout1 + + + + unnamed + + + + textLabel1 + + + Color: + + + + + m_textColor + + + + + + + + + + spacer3 + + + Horizontal + + + MinimumExpanding + + + + 624 + 20 + + + + + + + + spacer4 + + + Vertical + + + MinimumExpanding + + + + 20 + 91 + + + + + + + kcolorbutton.h + kcombobox.h + kdialog.h + klineedit.h + kpushbutton.h + kurlrequester.h + kpushbutton.h + klineedit.h + + + + diff --git a/kweather/kcmweather.cpp b/kweather/kcmweather.cpp deleted file mode 100644 index b480980..0000000 --- a/kweather/kcmweather.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - This file is part of KWeather. - Copyright (c) 2003 Tobias Koenig - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of TQt, and distribute the resulting executable, - without including the source code for TQt in the source distribution. -*/ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dockwidget.h" -#include "prefdialogdata.h" - -#include "kcmweather.h" -#include "weatherservice_stub.h" - -extern "C" -{ - KDE_EXPORT TDECModule *create_weather( TQWidget *parent, const char * ) - { - return new KCMWeather( parent, "kweather" ); - } -} - -KCMWeather::KCMWeather( TQWidget *parent, const char *name ) - : TDECModule( parent, name ) -{ - mWeatherService = new WeatherService_stub( "KWeatherService", - "WeatherService" ); - TQVBoxLayout *layout = new TQVBoxLayout( this ); - mWidget = new prefsDialogData( this ); - - mWidget->m_reportLocation->setFocus(); - layout->addWidget( mWidget ); - layout->addStretch(); - - fillStationList(); - load(); - connect( mWidget->m_enableLog, TQT_SIGNAL( toggled( bool ) ), - TQT_SLOT( enableLogWidgets( bool ) ) ); - connect( mWidget->m_viewMode, TQT_SIGNAL( released( int ) ), - TQT_SLOT( changeViewMode( int ) ) ); - connect( mWidget->m_reportLocation, TQT_SIGNAL( activated( const TQString& ) ), - TQT_SLOT( reportLocationChanged() ) ); - connect( mWidget->m_textColor, TQT_SIGNAL( changed(const TQColor &) ), - TQT_SLOT( textColorChanged(const TQColor &) ) ); - connect( mWidget->m_iconTheme, TQT_SIGNAL( released( int ) ), - TQT_SLOT( changed() ) ); - - TDEAboutData *about = new TDEAboutData( - I18N_NOOP( "kcmweather" ), - I18N_NOOP( "KWeather Configure Dialog" ), - 0, 0, TDEAboutData::License_GPL, - I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); - - about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); - setAboutData(about); -} - -KCMWeather::~KCMWeather() -{ - delete mWeatherService; -} -void KCMWeather::showEvent( TQShowEvent * ) -{ - fillStationList(); -} - -void KCMWeather::fillStationList() -{ - // store current selection - TQString current = mWidget->m_reportLocation->currentText(); - - mWidget->m_reportLocation->clear(); - - TQStringList stationList = mWeatherService->listStations(); - TQStringList::Iterator idx = stationList.begin(); - - // get station name from station id for sorting afterwards - for(; idx != stationList.end(); ++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 ) -{ - mViewMode = mode; - emit changed( true ); -} - -void KCMWeather::enableLogWidgets( bool value ) -{ - mWidget->m_logFile->setEnabled( value ); - mWidget->m_labelLogFile->setEnabled( value ); - - emit changed( true ); -} - -void KCMWeather::reportLocationChanged() -{ - kdDebug() << "New station: " << mWidget->m_reportLocation->currentText() - << " Code: " << mWeatherService->stationCode( mWidget->m_reportLocation->currentText() ) << endl; - emit changed( true ); -} - -void KCMWeather::textColorChanged(const TQColor &) -{ - emit changed( true ); -} - -void KCMWeather::load() -{ - kdDebug() << "Load" << endl; - TDEConfig config( "weather_panelappletrc" ); - - config.setGroup( "General Options" ); - bool enabled = config.readBoolEntry( "logging", false ); - mWidget->m_enableLog->setChecked( enabled ); - enableLogWidgets( enabled ); - - static TQColor black(TQt::black); - TQColor textColor = config.readColorEntry("textColor", &black); - mWidget->m_textColor->setColor(textColor); - - TQString loc = config.readEntry( "report_location" ); - - mWidget->m_logFile->setURL( config.readPathEntry( "log_file_name" ) ); - - 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 ) ); - - mWidget->m_iconTheme->setButton( config.readBoolEntry("use_icon_theme", true) ? 0 : 1 ); - - emit changed( false ); -} - -void KCMWeather::save() -{ - kdDebug() << "Save" << endl; - TDEConfig config( "weather_panelappletrc" ); - - config.setGroup( "General Options" ); - config.writeEntry( "logging", mWidget->m_enableLog->isChecked() ); - config.writeEntry( "log_file_name", mWidget->m_logFile->url() ); - config.writeEntry( "textColor", mWidget->m_textColor->color() ); - - // Station idx to local idx; if nothing selected yet, keep it empty - TQString 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.writeEntry( "use_icon_theme", mWidget->m_iconTheme->selectedId() == 0 ); - - config.sync(); - - emit changed( false ); -} - -void KCMWeather::defaults() -{ - mWidget->m_enableLog->setChecked( false ); - enableLogWidgets( false ); - - mWidget->m_logFile->setURL( "" ); - mWidget->m_reportLocation->setCurrentText( "" ); - changeViewMode( dockwidget::ShowAll ); - - emit changed( true ); -} - -#include "kcmweather.moc" diff --git a/kweather/kcmweather.desktop b/kweather/kcmweather.desktop deleted file mode 100644 index cc8f28d..0000000 --- a/kweather/kcmweather.desktop +++ /dev/null @@ -1,15 +0,0 @@ -[Desktop Entry] -Icon=configure -Type=Service -X-TDE-ServiceTypes=TDECModule - -X-TDE-ModuleType=Library -X-TDE-Library=weather -X-TDE-FactoryName=weather -X-TDE-ParentApp=weather_panelapplet -X-TDE-ParentComponents=weather_panelapplet - -Name=Display -Comment=Display Setup -Keywords=kweather; weather; configure; settings; display; -X-DocPath=kweather?anchor=configuring-kweather diff --git a/kweather/kcmweather.h b/kweather/kcmweather.h deleted file mode 100644 index fb4abcf..0000000 --- a/kweather/kcmweather.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - This file is part of KWeather. - Copyright (c) 2003 Tobias Koenig - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - As a special exception, permission is given to link this program - with any edition of TQt, and distribute the resulting executable, - without including the source code for TQt in the source distribution. -*/ - -#ifndef KCMWEATHER_H -#define KCMWEATHER_H - -#include - -class prefsDialogData; - -class KCMWeather : public TDECModule -{ - Q_OBJECT - - - public: - KCMWeather( TQWidget *parent = 0, const char *name = 0 ); - ~KCMWeather(); - - virtual void load(); - virtual void save(); - virtual void defaults(); - - protected: - void fillStationList(); - virtual void showEvent( TQShowEvent * ); - - private slots: - void enableLogWidgets( bool value ); - void changeViewMode( int mode ); - void reportLocationChanged(); - void textColorChanged(const TQColor &); - - private: - prefsDialogData *mWidget; - WeatherService_stub *mWeatherService; - int mViewMode; -}; - -#endif diff --git a/kweather/kcmweatherapplet.cpp b/kweather/kcmweatherapplet.cpp new file mode 100644 index 0000000..87decad --- /dev/null +++ b/kweather/kcmweatherapplet.cpp @@ -0,0 +1,203 @@ +/* + This file is part of KWeather. + Copyright (c) 2003 Tobias Koenig + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. +*/ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dockwidget.h" +#include "appletconfig.h" + +#include "kcmweatherapplet.h" +#include "weatherservice_stub.h" + +extern "C" +{ + KDE_EXPORT TDECModule *create_weatherapplet( TQWidget *parent, const char * ) + { + return new KCMWeatherApplet( parent, "kweather" ); + } +} + +KCMWeatherApplet::KCMWeatherApplet( TQWidget *parent, const char *name ) + : TDECModule( parent, name ) +{ + mWeatherService = new WeatherService_stub( "KWeatherService", + "WeatherService" ); + TQVBoxLayout *layout = new TQVBoxLayout( this ); + mWidget = new appletConfig( this ); + + mWidget->m_reportLocation->setFocus(); + layout->addWidget( mWidget ); + layout->addStretch(); + + fillStationList(); + load(); + connect( mWidget->m_viewMode, TQT_SIGNAL( released( int ) ), + TQT_SLOT( changeViewMode( int ) ) ); + connect( mWidget->m_reportLocation, TQT_SIGNAL( activated( const TQString& ) ), + TQT_SLOT( reportLocationChanged() ) ); + connect( mWidget->m_textColor, TQT_SIGNAL( changed(const TQColor &) ), + TQT_SLOT( textColorChanged(const TQColor &) ) ); + + TDEAboutData *about = new TDEAboutData( + I18N_NOOP( "kcmweatherapplet" ), + I18N_NOOP( "KWeather Configure Dialog" ), + 0, 0, TDEAboutData::License_GPL, + I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); + + about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + setAboutData(about); +} + +KCMWeatherApplet::~KCMWeatherApplet() +{ + delete mWeatherService; +} +void KCMWeatherApplet::showEvent( TQShowEvent * ) +{ + fillStationList(); +} + +void KCMWeatherApplet::fillStationList() +{ + // store current selection + TQString current = mWidget->m_reportLocation->currentText(); + + mWidget->m_reportLocation->clear(); + + TQStringList stationList = mWeatherService->listStations(); + TQStringList::Iterator idx = stationList.begin(); + + // get station name from station id for sorting afterwards + for(; idx != stationList.end(); ++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 KCMWeatherApplet::changeViewMode( int mode ) +{ + mViewMode = mode; + emit changed( true ); +} + +void KCMWeatherApplet::reportLocationChanged() +{ + kdDebug() << "New station: " << mWidget->m_reportLocation->currentText() + << " Code: " << mWeatherService->stationCode( mWidget->m_reportLocation->currentText() ) << endl; + emit changed( true ); +} + +void KCMWeatherApplet::textColorChanged(const TQColor &) +{ + emit changed( true ); +} + +void KCMWeatherApplet::load() +{ + kdDebug() << "Load" << endl; + TDEConfig config( "weather_panelappletrc" ); + + config.setGroup( "General Options" ); + + static TQColor black(TQt::black); + TQColor textColor = config.readColorEntry("textColor", &black); + mWidget->m_textColor->setColor(textColor); + + TQString loc = config.readEntry( "report_location" ); + + 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 ); +} + +void KCMWeatherApplet::save() +{ + kdDebug() << "Save" << endl; + TDEConfig config( "weather_panelappletrc" ); + + config.setGroup( "General Options" ); + config.writeEntry( "textColor", mWidget->m_textColor->color() ); + + // Station idx to local idx; if nothing selected yet, keep it empty + TQString 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(); + + emit changed( false ); +} + +void KCMWeatherApplet::defaults() +{ + mWidget->m_reportLocation->setCurrentText( "" ); + changeViewMode( dockwidget::ShowAll ); + + emit changed( true ); +} + +#include "kcmweatherapplet.moc" diff --git a/kweather/kcmweatherapplet.desktop b/kweather/kcmweatherapplet.desktop new file mode 100644 index 0000000..247ba19 --- /dev/null +++ b/kweather/kcmweatherapplet.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Icon=kicker +Type=Service +X-TDE-ServiceTypes=TDECModule + +X-TDE-ModuleType=Library +X-TDE-Library=weatherapplet +X-TDE-FactoryName=weatherapplet +X-TDE-ParentApp=weather_panelapplet +X-TDE-ParentComponents=weather_panelapplet + +Name=Applet +Comment=Applet Config +Keywords=kweather; weather; configure; settings; display; applet; +X-DocPath=kweather?anchor=configuring-kweather diff --git a/kweather/kcmweatherapplet.h b/kweather/kcmweatherapplet.h new file mode 100644 index 0000000..adb6f98 --- /dev/null +++ b/kweather/kcmweatherapplet.h @@ -0,0 +1,57 @@ +/* + This file is part of KWeather. + Copyright (c) 2003 Tobias Koenig + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. +*/ + +#ifndef KCMWEATHERAPPLET_H +#define KCMWEATHERAPPLET_H + +#include + +class appletConfig; + +class KCMWeatherApplet : public TDECModule +{ + Q_OBJECT + + public: + KCMWeatherApplet( TQWidget *parent = 0, const char *name = 0 ); + ~KCMWeatherApplet(); + + virtual void load(); + virtual void save(); + virtual void defaults(); + + protected: + void fillStationList(); + virtual void showEvent( TQShowEvent * ); + + private slots: + void changeViewMode( int mode ); + void reportLocationChanged(); + void textColorChanged(const TQColor &); + + private: + appletConfig *mWidget; + WeatherService_stub *mWeatherService; + int mViewMode; +}; + +#endif diff --git a/kweather/kcmweatherservice.cpp b/kweather/kcmweatherservice.cpp index 81639df..cf0828c 100644 --- a/kweather/kcmweatherservice.cpp +++ b/kweather/kcmweatherservice.cpp @@ -1,72 +1,136 @@ -/* - This file is part of KWeather. - Copyright (c) 2003 Tobias Koenig - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of TQt, and distribute the resulting executable, - without including the source code for TQt in the source distribution. -*/ +/* + This file is part of KWeather. + Copyright (c) 2003 Tobias Koenig + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. +*/ + +#include +#include +#include #include #include +#include +#include #include #include +#include +#include +#include -#include "serviceconfigwidget.h" +#include "dockwidget.h" +#include "serviceconfig.h" #include "kcmweatherservice.h" +#include "weatherservice_stub.h" extern "C" { - KDE_EXPORT TDECModule *create_weatherservice( TQWidget *parent, const char * ) { - return new KCMWeatherService( parent, "kweather" ); - } + KDE_EXPORT TDECModule *create_weatherservice( TQWidget *parent, const char * ) + { + return new KCMWeatherService( parent, "kweather" ); + } } KCMWeatherService::KCMWeatherService( TQWidget *parent, const char *name ) - : TDECModule( parent, name ) + : TDECModule( parent, name ) { - TQVBoxLayout *layout = new TQVBoxLayout( this ); - mWidget = new ServiceConfigWidget( this ); + mWeatherService = new WeatherService_stub( "KWeatherService", + "WeatherService" ); + TQVBoxLayout *layout = new TQVBoxLayout( this ); + mWidget = new serviceConfig( this ); + + layout->addWidget( mWidget ); + layout->addStretch(); + + load(); + connect( mWidget->m_enableLog, TQT_SIGNAL( toggled( bool ) ), + TQT_SLOT( enableLogWidgets( bool ) ) ); + connect( mWidget->m_iconTheme, TQT_SIGNAL( released( int ) ), + TQT_SLOT( changed() ) ); - // not needed, as a change immediately changes the service - //connect(mWidget, TQT_SIGNAL(changed(bool)), this, TQT_SIGNAL(changed(bool))); + TDEAboutData *about = new TDEAboutData( + I18N_NOOP( "kcmweatherservice" ), + I18N_NOOP( "KWeather Configure Dialog" ), + 0, 0, TDEAboutData::License_GPL, + I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); + + about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + setAboutData(about); +} + +KCMWeatherService::~KCMWeatherService() +{ + delete mWeatherService; +} - layout->addWidget( mWidget ); - TDEAboutData *about = new TDEAboutData( "kcmweatherservice", - I18N_NOOP( "KWeather Configure Dialog" ), - 0, 0, TDEAboutData::License_GPL, - I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); +void KCMWeatherService::enableLogWidgets( bool value ) +{ + mWidget->m_logFile->setEnabled( value ); + mWidget->m_labelLogFile->setEnabled( value ); - about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); - setAboutData(about); + emit changed( true ); } void KCMWeatherService::load() { + kdDebug() << "Load" << endl; + TDEConfig config( "weather_panelappletrc" ); + + config.setGroup( "General Options" ); + bool enabled = config.readBoolEntry( "logging", false ); + mWidget->m_enableLog->setChecked( enabled ); + enableLogWidgets( enabled ); + + mWidget->m_logFile->setURL( config.readPathEntry( "log_file_name" ) ); + + mWidget->m_iconTheme->setButton( config.readBoolEntry("use_icon_theme", true) ? 0 : 1 ); + + emit changed( false ); } void KCMWeatherService::save() { + kdDebug() << "Save" << endl; + TDEConfig config( "weather_panelappletrc" ); + + config.setGroup( "General Options" ); + config.writeEntry( "logging", mWidget->m_enableLog->isChecked() ); + config.writeEntry( "log_file_name", mWidget->m_logFile->url() ); + + config.writeEntry( "use_icon_theme", mWidget->m_iconTheme->selectedId() == 0 ); + + config.sync(); + + emit changed( false ); } void KCMWeatherService::defaults() { + mWidget->m_enableLog->setChecked( false ); + enableLogWidgets( false ); + mWidget->m_logFile->setURL( "" ); + + mWidget->m_iconTheme->setButton(0); + + emit changed( true ); } #include "kcmweatherservice.moc" diff --git a/kweather/kcmweatherservice.desktop b/kweather/kcmweatherservice.desktop index f04ea65..adddb83 100644 --- a/kweather/kcmweatherservice.desktop +++ b/kweather/kcmweatherservice.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Icon=kweather +Icon=gear Type=Service X-TDE-ServiceTypes=TDECModule @@ -10,7 +10,7 @@ X-TDE-ParentApp=weather_panelapplet X-TDE-ParentComponents=weather_panelapplet,kontact_weatherplugin X-TDE-CfgDlgHierarchy=KontactSummary -Name=Weather Service -Comment=Weather Service Setup -Keywords=kweather; weather service; configure; settings; -X-DocPath=kweather?anchor=weather-service +Name=Service +Comment=Weather Service Config +Keywords=kweather; weather service; configure; settings; service; +X-DocPath=kweather?anchor=configuring-kweather diff --git a/kweather/kcmweatherservice.h b/kweather/kcmweatherservice.h index f22e179..9e61e86 100644 --- a/kweather/kcmweatherservice.h +++ b/kweather/kcmweatherservice.h @@ -1,24 +1,23 @@ /* - This file is part of KWeather. - Copyright (c) 2003 Tobias Koenig + This file is part of KWeather. + Copyright (c) 2003 Tobias Koenig - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of TQt, and distribute the resulting executable, - without including the source code for TQt in the source distribution. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. */ #ifndef KCMWEATHERSERVICE_H @@ -26,22 +25,27 @@ #include -class ServiceConfigWidget; +class serviceConfig; class KCMWeatherService : public TDECModule { - Q_OBJECT - + Q_OBJECT + + public: + KCMWeatherService( TQWidget *parent = 0, const char *name = 0 ); + ~KCMWeatherService(); - public: - KCMWeatherService( TQWidget *parent = 0, const char *name = 0 ); + virtual void load(); + virtual void save(); + virtual void defaults(); - virtual void load(); - virtual void save(); - virtual void defaults(); + private slots: + void enableLogWidgets( bool value ); - private: - ServiceConfigWidget *mWidget; + private: + serviceConfig *mWidget; + WeatherService_stub *mWeatherService; + int mViewMode; }; -#endif +#endif \ No newline at end of file diff --git a/kweather/kcmweatherstations.cpp b/kweather/kcmweatherstations.cpp new file mode 100644 index 0000000..3d60f5a --- /dev/null +++ b/kweather/kcmweatherstations.cpp @@ -0,0 +1,72 @@ +/* + This file is part of KWeather. + Copyright (c) 2003 Tobias Koenig + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. +*/ + +#include + +#include +#include +#include + +#include "stationsconfigwidget.h" + +#include "kcmweatherstations.h" + +extern "C" +{ + KDE_EXPORT TDECModule *create_weatherstations( TQWidget *parent, const char * ) { + return new KCMWeatherStations( parent, "kweather" ); + } +} + +KCMWeatherStations::KCMWeatherStations( TQWidget *parent, const char *name ) + : TDECModule( parent, name ) +{ + TQVBoxLayout *layout = new TQVBoxLayout( this ); + mWidget = new StationsConfigWidget( this ); + + // not needed, as a change immediately changes the service + //connect(mWidget, TQT_SIGNAL(changed(bool)), this, TQT_SIGNAL(changed(bool))); + + layout->addWidget( mWidget ); + TDEAboutData *about = new TDEAboutData( "kcmweatherstations", + I18N_NOOP( "KWeather Configure Dialog" ), + 0, 0, TDEAboutData::License_GPL, + I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); + + about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + setAboutData(about); +} + +void KCMWeatherStations::load() +{ +} + +void KCMWeatherStations::save() +{ +} + +void KCMWeatherStations::defaults() +{ +} + +#include "kcmweatherstations.moc" diff --git a/kweather/kcmweatherstations.desktop b/kweather/kcmweatherstations.desktop new file mode 100644 index 0000000..1fd39b4 --- /dev/null +++ b/kweather/kcmweatherstations.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Icon=kweather +Type=Service +X-TDE-ServiceTypes=TDECModule + +X-TDE-ModuleType=Library +X-TDE-Library=weatherstations +X-TDE-FactoryName=weatherstations +X-TDE-ParentApp=weather_panelapplet +X-TDE-ParentComponents=weather_panelapplet,kontact_weatherplugin +X-TDE-CfgDlgHierarchy=KontactSummary + +Name=Stations +Comment=Weather Stations Config +Keywords=kweather; weather service; configure; settings; stations; +X-DocPath=kweather?anchor=weather-service diff --git a/kweather/kcmweatherstations.h b/kweather/kcmweatherstations.h new file mode 100644 index 0000000..7660457 --- /dev/null +++ b/kweather/kcmweatherstations.h @@ -0,0 +1,47 @@ +/* + This file is part of KWeather. + Copyright (c) 2003 Tobias Koenig + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. +*/ + +#ifndef KCMWEATHERSTATIONS_H +#define KCMWEATHERSTATIONS_H + +#include + +class StationsConfigWidget; + +class KCMWeatherStations : public TDECModule +{ + Q_OBJECT + + + public: + KCMWeatherStations( TQWidget *parent = 0, const char *name = 0 ); + + virtual void load(); + virtual void save(); + virtual void defaults(); + + private: + StationsConfigWidget *mWidget; +}; + +#endif diff --git a/kweather/kweather.cpp b/kweather/kweather.cpp index 62114c1..76ffb48 100644 --- a/kweather/kweather.cpp +++ b/kweather/kweather.cpp @@ -161,8 +161,9 @@ void kweather::preferences() settingsDialog = new KCMultiDialog( this ); connect( settingsDialog, TQT_SIGNAL( configCommitted() ), TQT_SLOT( slotPrefsAccepted() ) ); - settingsDialog->addModule( "kcmweather.desktop" ); - settingsDialog->addModule( "kcmweatherservice.desktop" ); + settingsDialog->addModule( "kcmweatherapplet.desktop" ); + settingsDialog->addModule( "kcmweatherstations.desktop" ); + settingsDialog->addModule( "kcmweatherservice.desktop" ); } settingsDialog->show(); diff --git a/kweather/prefdialogdata.ui b/kweather/prefdialogdata.ui deleted file mode 100644 index 6c053aa..0000000 --- a/kweather/prefdialogdata.ui +++ /dev/null @@ -1,393 +0,0 @@ - -prefsDialogData -ian reinhart geiser <geiseri@kde.org> - - - prefsDialogData - - - - 0 - 0 - 761 - 464 - - - - - 3 - 3 - 0 - 0 - - - - - 0 - 0 - - - - prefsDialogData - - - TabFocus - - - - unnamed - - - 0 - - - - GroupBox2 - - - - 1 - 1 - 0 - 0 - - - - NoFrame - - - Sunken - - - Weather Station Options - - - - unnamed - - - - TextLabel1_4_2_2 - - - &Location: - - - m_reportLocation - - - - - m_reportLocation - - - - 3 - 0 - 0 - 0 - - - - - 0 - 0 - - - - - - spacer2 - - - Horizontal - - - MinimumExpanding - - - - 40 - 20 - - - - - - - - m_viewMode - - - - 1 - 1 - 0 - 0 - - - - 0 - - - Panel Display Options - - - AlignVCenter|AlignLeft - - - true - - - - unnamed - - - - m_smallView - - - - 1 - 0 - 0 - 0 - - - - &Show icon only - - - 1 - - - <qt>Click here to show only the weather icon.</qt> - - - This feature will allow you to make KWeather take up only one slot on the kicker. Normally this application will take up two slots. The small view will only show the weather icon, while the normal view will display both the icon and the current weather statistics. For the small view the weather statistics will be put on the buttons tool tip. - - - - - CheckBox9 - - - Show &icon and temperature - - - 2 - - - - - CheckBox10 - - - Show icon, temperature, &wind and pressure information - - - true - - - 3 - - - - - - - GroupBox1 - - - - 1 - 1 - 0 - 0 - - - - Logging Options - - - - unnamed - - - - m_enableLog - - - E&nable logging - - - - - Spacer6_2 - - - Horizontal - - - Expanding - - - - 294 - 16 - - - - - - m_labelLogFile - - - false - - - Log &file: - - - m_logFile - - - - - m_logFile - - - false - - - - 252 - 0 - - - - Enter the logfile name. - - - Enter the full path and filename to enable logging in KWeather. - - - - - - - m_iconTheme - - - Weather Icons - - - - unnamed - - - - m_systemIcons - - - &Use system theme - - - true - - - - - m_kweatherIcons - - - Use classic &KWeather theme - - - - - - - groupBox3 - - - Text - - - - unnamed - - - - layout1 - - - - unnamed - - - - textLabel1 - - - Color: - - - - - m_textColor - - - - - - - - - - spacer3 - - - Horizontal - - - Expanding - - - - 637 - 20 - - - - - - - - - - m_enableLog - toggled(bool) - m_labelLogFile - setEnabled(bool) - - - m_enableLog - toggled(bool) - m_logFile - setEnabled(bool) - - - - kcolorbutton.h - kcombobox.h - kdialog.h - klineedit.h - kpushbutton.h - kurlrequester.h - kpushbutton.h - klineedit.h - - - - diff --git a/kweather/serviceconfig.ui b/kweather/serviceconfig.ui new file mode 100644 index 0000000..84ca62e --- /dev/null +++ b/kweather/serviceconfig.ui @@ -0,0 +1,198 @@ + +serviceConfig +ian reinhart geiser <geiseri@kde.org> + + + serviceConfig + + + + 0 + 0 + 491 + 194 + + + + + 3 + 3 + 0 + 0 + + + + + 0 + 0 + + + + serviceConfig + + + TabFocus + + + + unnamed + + + 0 + + + + m_iconTheme + + + Weather Icons + + + + unnamed + + + + m_systemIcons + + + &Use system theme + + + true + + + + + m_kweatherIcons + + + Use classic &KWeather theme + + + + + + + GroupBox1 + + + + 1 + 1 + 0 + 0 + + + + Logging Options + + + + unnamed + + + + m_enableLog + + + E&nable logging + + + + + Spacer6_2 + + + Horizontal + + + Expanding + + + + 294 + 16 + + + + + + m_labelLogFile + + + false + + + Log f&ile: + + + m_logFile + + + + + m_logFile + + + false + + + + 252 + 0 + + + + Enter the logfile name. + + + Enter the full path and filename to enable logging in KWeather. + + + + + + + spacer4 + + + Vertical + + + Expanding + + + + 20 + 111 + + + + + + + + m_enableLog + toggled(bool) + m_labelLogFile + setEnabled(bool) + + + m_enableLog + toggled(bool) + m_logFile + setEnabled(bool) + + + + kcolorbutton.h + kcombobox.h + kdialog.h + kurlrequester.h + kpushbutton.h + klineedit.h + + + + diff --git a/kweather/serviceconfigdata.ui b/kweather/serviceconfigdata.ui deleted file mode 100644 index 35be484..0000000 --- a/kweather/serviceconfigdata.ui +++ /dev/null @@ -1,259 +0,0 @@ - -wsPrefs -Ian Reinhart Geiser <geiseri@kde.org> - - - wsPrefs - - - - 0 - 0 - 374 - 315 - - - - - unnamed - - - 0 - - - - mAddButton - - - A&dd - - - - - textLabel2 - - - Se&lected stations: - - - mSelectedStations - - - - - textLabel1 - - - A&vailable stations: - - - mAllStations - - - - - spacer1 - - - Vertical - - - Expanding - - - - 20 - 86 - - - - - - - Selected - - - false - - - false - - - - mSelectedStations - - - - 5 - 7 - 1 - 0 - - - - LastColumn - - - false - - - false - - - false - - - - - mRemoveButton - - - &Remove - - - - - spacer2 - - - Vertical - - - Expanding - - - - 20 - 85 - - - - - - - All - - - false - - - false - - - - mAllStations - - - - 5 - 7 - 1 - 0 - - - - true - - - LastColumn - - - false - - - false - - - false - - - - - layout1 - - - - unnamed - - - - mExit - - - &Stop Weather Service - - - - - mUpdate - - - &Update All - - - - - - - - - - - mAddButton - clicked() - wsPrefs - addStation() - - - mRemoveButton - clicked() - wsPrefs - removeStation() - - - mUpdate - clicked() - wsPrefs - updateStations() - - - mExit - clicked() - wsPrefs - exitWeatherService() - - - mSelectedStations - selectionChanged(TQListViewItem*) - wsPrefs - selectionChanged(TQListViewItem*) - - - - class TQListViewItem; - - - mAllStations - mSelectedStations - mAddButton - mRemoveButton - mExit - mUpdate - - - kiconloader.h - kdialog.h - knuminput.h - kpushbutton.h - tdelistview.h - - - exitWeatherService() - removeStation() - updateStations() - addStation() - selectionChanged( TQListViewItem* ) - - - - diff --git a/kweather/serviceconfigwidget.cpp b/kweather/serviceconfigwidget.cpp deleted file mode 100644 index d6f85e2..0000000 --- a/kweather/serviceconfigwidget.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* - This file is part of KWeather. - Copyright (c) 2004 Tobias Koenig - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serviceconfigwidget.h" -#include "weatherservice_stub.h" - -class StationItem : public TQListViewItem -{ - public: - StationItem( TQListView *view, const TQString &name, const TQString &uid ) - : TQListViewItem( view, name ), mUID( uid ) - { - } - - StationItem( TQListViewItem *item, const TQString &name, const TQString &uid ) - : TQListViewItem( item, name ), mUID( uid ) - { - } - - TQString uid() const { return mUID; } - - private: - TQString mUID; -}; - -static void parseStationEntry( const TQString &line, TQString &name, TQString &uid ); - -ServiceConfigWidget::ServiceConfigWidget( TQWidget *parent, const char *name ) - : wsPrefs( parent, name ), mService(0) -{ - mService = new WeatherService_stub( "KWeatherService", "WeatherService" ); - connect( mAllStations, TQT_SIGNAL( doubleClicked ( TQListViewItem *, const TQPoint &, int ) ), TQT_SLOT( addStation() ) ); - connect( mSelectedStations, TQT_SIGNAL( doubleClicked ( TQListViewItem *, const TQPoint &, int ) ), TQT_SLOT( removeStation() ) ); - - initGUI(); - loadLocations(); - scanStations(); -} - -ServiceConfigWidget::~ServiceConfigWidget() -{ - delete mService; -} - -void ServiceConfigWidget::addStation() -{ - if ( !dcopActive() ) - return; - - StationItem *item = dynamic_cast( mAllStations->selectedItem() ); - if ( item == 0 ) - return; - - mService->addStation( item->uid() ); - scanStations(); - - modified(); -} - -void ServiceConfigWidget::removeStation() -{ - if ( !dcopActive() ) - return; - - StationItem *item = dynamic_cast( mSelectedStations->selectedItem() ); - if ( item == 0 ) - return; - - mService->removeStation( item->uid() ); - scanStations(); - - modified(); -} - -void ServiceConfigWidget::updateStations() -{ - if ( !dcopActive() ) - return; - - mService->updateAll( ); - scanStations(); -} - -void ServiceConfigWidget::exitWeatherService() -{ - if ( !dcopActive() ) - return; - - mService->exit(); - modified(); -} - -void ServiceConfigWidget::scanStations() -{ - if ( !dcopActive() ) - return; - - TQStringList list = mService->listStations( ); - - mSelectedStations->clear(); - for ( uint i = 0; i < list.count(); ++i ) { - TQPixmap pm = mService->icon( list[ i ] ); - TQImage img = pm.convertToImage(); - img = img.smoothScale( 22, 22 ); - pm.convertFromImage( img ); - - TQString uid = list[ i ]; - if (mStationMap[ uid ].isEmpty()) - { - mStationMap[ uid ] = uid; - } - StationItem *item = new StationItem( mSelectedStations, mStationMap[ uid ], uid ); - - item->setPixmap( 0, pm ); - } -} - -void ServiceConfigWidget::selectionChanged( TQListViewItem *item ) -{ - mRemoveButton->setEnabled( item != 0 ); -} - -void ServiceConfigWidget::modified() -{ - emit changed( true ); -} - -void ServiceConfigWidget::initGUI() -{ - mAllStations->header()->hide(); - mSelectedStations->header()->hide(); -} - -void ServiceConfigWidget::loadLocations() -{ - TDEConfig config( locate( "data", "kweatherservice/weather_stations.desktop" ) ); - - config.setGroup( "Main" ); - TQStringList regions = TQStringList::split( ' ', config.readEntry( "regions" ) ); - - TQStringList::ConstIterator regionIt; - for ( regionIt = regions.begin(); regionIt != regions.end(); ++regionIt ) { - config.setGroup( *regionIt ); - TQString name = config.readEntry( "name" ); - TQStringList states = config.readListEntry( "states", ' ' ); - - TQListViewItem *regionItem = new TQListViewItem( mAllStations, name ); - regionItem->setSelectable( false ); - - TQStringList::ConstIterator stateIt; - for ( stateIt = states.begin(); stateIt != states.end(); ++stateIt ) { - config.setGroup( *regionIt + "_" + *stateIt ); - TQString name = config.readEntry( "name" ); - - TQListViewItem *stateItem = new TQListViewItem( regionItem, name ); - stateItem->setSelectable( false ); - - TQMap entries = config.entryMap( *regionIt + "_" + *stateIt ); - TQMap::ConstIterator entryIt; - for ( entryIt = entries.begin(); entryIt != entries.end(); ++entryIt ) { - if ( entryIt.key() != "name" ) { - TQString station, uid; - // get station and uid from the data - parseStationEntry( entryIt.data(), station, uid ); - new StationItem( stateItem, station, uid ); - mStationMap.insert( uid, TQString( "%1, %2" ) - .arg( station ).arg( *stateIt ) ); - } - } - } - } -} - -bool ServiceConfigWidget::dcopActive() -{ - TQString error; - TQCString appID; - bool isGood = true; - DCOPClient *client = kapp->dcopClient(); - if ( !client->isApplicationRegistered( "KWeatherService" ) ) { - if ( TDEApplication::startServiceByDesktopName( "kweatherservice", TQStringList(), &error, &appID ) ) - isGood = false; - } - - return isGood; -} - -void parseStationEntry( const TQString &line, TQString &name, TQString &uid ) -{ - TQStringList list = TQStringList::split( ' ', line ); - - bool inName = true; - - for ( uint i = 0; i < list.count(); ++i ) { - if ( inName ) { - if ( list[ i ].endsWith( "\\" ) ) { - name.append( list[ i ].replace( "\\", " " ) ); - } else { - name.append( list[ i ] ); - inName = false; - } - } else { - uid = list[ i ]; - return; - } - } -} - -#include "serviceconfigwidget.moc" diff --git a/kweather/serviceconfigwidget.h b/kweather/serviceconfigwidget.h deleted file mode 100644 index 3fb7006..0000000 --- a/kweather/serviceconfigwidget.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - This file is part of KWeather. - Copyright (c) 2004 Tobias Koenig - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef SERVICECONFIGWIDGET_H -#define SERVICECONFIGWIDGET_H - -#include - -class TQListViewItem; -class WeatherService_stub; - -class ServiceConfigWidget : public wsPrefs -{ - Q_OBJECT - - - public: - ServiceConfigWidget( TQWidget *parent, const char *name = 0 ); - virtual ~ServiceConfigWidget(); - - signals: - void changed( bool ); - - public slots: - void addStation(); - void removeStation(); - void updateStations(); - void exitWeatherService(); - - void selectionChanged( TQListViewItem* ); - void modified(); - - private: - void initGUI(); - void loadLocations(); - bool dcopActive(); - void scanStations(); - - TQMap mStationMap; - WeatherService_stub *mService; -}; - -#endif diff --git a/kweather/sidebarwidget.cpp b/kweather/sidebarwidget.cpp index 792d4a4..693f525 100644 --- a/kweather/sidebarwidget.cpp +++ b/kweather/sidebarwidget.cpp @@ -85,6 +85,7 @@ void sidebarwidget::slotConfigure() settingsDialog = new KCMultiDialog(0); connect( settingsDialog, TQT_SIGNAL( configCommitted() ), this, TQT_SLOT( slotRefresh() ) ); + settingsDialog->addModule( "kcmweatherstations.desktop" ); settingsDialog->addModule( "kcmweatherservice.desktop" ); } diff --git a/kweather/stationsconfig.ui b/kweather/stationsconfig.ui new file mode 100644 index 0000000..5ad40b6 --- /dev/null +++ b/kweather/stationsconfig.ui @@ -0,0 +1,259 @@ + +stationsConfig +Ian Reinhart Geiser <geiseri@kde.org> + + + stationsConfig + + + + 0 + 0 + 374 + 315 + + + + + unnamed + + + 0 + + + + mAddButton + + + A&dd + + + + + textLabel2 + + + Se&lected stations: + + + mSelectedStations + + + + + textLabel1 + + + A&vailable stations: + + + mAllStations + + + + + spacer1 + + + Vertical + + + Expanding + + + + 20 + 86 + + + + + + + Selected + + + false + + + false + + + + mSelectedStations + + + + 5 + 7 + 1 + 0 + + + + LastColumn + + + false + + + false + + + false + + + + + mRemoveButton + + + &Remove + + + + + spacer2 + + + Vertical + + + Expanding + + + + 20 + 85 + + + + + + + All + + + false + + + false + + + + mAllStations + + + + 5 + 7 + 1 + 0 + + + + true + + + LastColumn + + + false + + + false + + + false + + + + + layout1 + + + + unnamed + + + + mExit + + + &Stop Weather Service + + + + + mUpdate + + + &Update All + + + + + + + + + + + mAddButton + clicked() + stationsConfig + addStation() + + + mRemoveButton + clicked() + stationsConfig + removeStation() + + + mUpdate + clicked() + stationsConfig + updateStations() + + + mExit + clicked() + stationsConfig + exitWeatherService() + + + mSelectedStations + selectionChanged(TQListViewItem*) + stationsConfig + selectionChanged(TQListViewItem*) + + + + class TQListViewItem; + + + mAllStations + mSelectedStations + mAddButton + mRemoveButton + mExit + mUpdate + + + kiconloader.h + kdialog.h + knuminput.h + kpushbutton.h + tdelistview.h + + + exitWeatherService() + removeStation() + updateStations() + addStation() + selectionChanged( TQListViewItem* ) + + + + diff --git a/kweather/stationsconfigwidget.cpp b/kweather/stationsconfigwidget.cpp new file mode 100644 index 0000000..b02d4be --- /dev/null +++ b/kweather/stationsconfigwidget.cpp @@ -0,0 +1,239 @@ +/* + This file is part of KWeather. + Copyright (c) 2004 Tobias Koenig + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "stationsconfigwidget.h" +#include "weatherservice_stub.h" + +class StationItem : public TQListViewItem +{ + public: + StationItem( TQListView *view, const TQString &name, const TQString &uid ) + : TQListViewItem( view, name ), mUID( uid ) + { + } + + StationItem( TQListViewItem *item, const TQString &name, const TQString &uid ) + : TQListViewItem( item, name ), mUID( uid ) + { + } + + TQString uid() const { return mUID; } + + private: + TQString mUID; +}; + +static void parseStationEntry( const TQString &line, TQString &name, TQString &uid ); + +StationsConfigWidget::StationsConfigWidget( TQWidget *parent, const char *name ) + : stationsConfig( parent, name ), mService(0) +{ + mService = new WeatherService_stub( "KWeatherService", "WeatherService" ); + connect( mAllStations, TQT_SIGNAL( doubleClicked ( TQListViewItem *, const TQPoint &, int ) ), TQT_SLOT( addStation() ) ); + connect( mSelectedStations, TQT_SIGNAL( doubleClicked ( TQListViewItem *, const TQPoint &, int ) ), TQT_SLOT( removeStation() ) ); + + initGUI(); + loadLocations(); + scanStations(); +} + +StationsConfigWidget::~StationsConfigWidget() +{ + delete mService; +} + +void StationsConfigWidget::addStation() +{ + if ( !dcopActive() ) + return; + + StationItem *item = dynamic_cast( mAllStations->selectedItem() ); + if ( item == 0 ) + return; + + mService->addStation( item->uid() ); + scanStations(); + + modified(); +} + +void StationsConfigWidget::removeStation() +{ + if ( !dcopActive() ) + return; + + StationItem *item = dynamic_cast( mSelectedStations->selectedItem() ); + if ( item == 0 ) + return; + + mService->removeStation( item->uid() ); + scanStations(); + + modified(); +} + +void StationsConfigWidget::updateStations() +{ + if ( !dcopActive() ) + return; + + mService->updateAll( ); + scanStations(); +} + +void StationsConfigWidget::exitWeatherService() +{ + if ( !dcopActive() ) + return; + + mService->exit(); + modified(); +} + +void StationsConfigWidget::scanStations() +{ + if ( !dcopActive() ) + return; + + TQStringList list = mService->listStations( ); + + mSelectedStations->clear(); + for ( uint i = 0; i < list.count(); ++i ) { + TQPixmap pm = mService->icon( list[ i ] ); + TQImage img = pm.convertToImage(); + img = img.smoothScale( 22, 22 ); + pm.convertFromImage( img ); + + TQString uid = list[ i ]; + if (mStationMap[ uid ].isEmpty()) + { + mStationMap[ uid ] = uid; + } + StationItem *item = new StationItem( mSelectedStations, mStationMap[ uid ], uid ); + + item->setPixmap( 0, pm ); + } +} + +void StationsConfigWidget::selectionChanged( TQListViewItem *item ) +{ + mRemoveButton->setEnabled( item != 0 ); +} + +void StationsConfigWidget::modified() +{ + emit changed( true ); +} + +void StationsConfigWidget::initGUI() +{ + mAllStations->header()->hide(); + mSelectedStations->header()->hide(); +} + +void StationsConfigWidget::loadLocations() +{ + TDEConfig config( locate( "data", "kweatherservice/weather_stations.desktop" ) ); + + config.setGroup( "Main" ); + TQStringList regions = TQStringList::split( ' ', config.readEntry( "regions" ) ); + + TQStringList::ConstIterator regionIt; + for ( regionIt = regions.begin(); regionIt != regions.end(); ++regionIt ) { + config.setGroup( *regionIt ); + TQString name = config.readEntry( "name" ); + TQStringList states = config.readListEntry( "states", ' ' ); + + TQListViewItem *regionItem = new TQListViewItem( mAllStations, name ); + regionItem->setSelectable( false ); + + TQStringList::ConstIterator stateIt; + for ( stateIt = states.begin(); stateIt != states.end(); ++stateIt ) { + config.setGroup( *regionIt + "_" + *stateIt ); + TQString name = config.readEntry( "name" ); + + TQListViewItem *stateItem = new TQListViewItem( regionItem, name ); + stateItem->setSelectable( false ); + + TQMap entries = config.entryMap( *regionIt + "_" + *stateIt ); + TQMap::ConstIterator entryIt; + for ( entryIt = entries.begin(); entryIt != entries.end(); ++entryIt ) { + if ( entryIt.key() != "name" ) { + TQString station, uid; + // get station and uid from the data + parseStationEntry( entryIt.data(), station, uid ); + new StationItem( stateItem, station, uid ); + mStationMap.insert( uid, TQString( "%1, %2" ) + .arg( station ).arg( *stateIt ) ); + } + } + } + } +} + +bool StationsConfigWidget::dcopActive() +{ + TQString error; + TQCString appID; + bool isGood = true; + DCOPClient *client = kapp->dcopClient(); + if ( !client->isApplicationRegistered( "KWeatherService" ) ) { + if ( TDEApplication::startServiceByDesktopName( "kweatherservice", TQStringList(), &error, &appID ) ) + isGood = false; + } + + return isGood; +} + +void parseStationEntry( const TQString &line, TQString &name, TQString &uid ) +{ + TQStringList list = TQStringList::split( ' ', line ); + + bool inName = true; + + for ( uint i = 0; i < list.count(); ++i ) { + if ( inName ) { + if ( list[ i ].endsWith( "\\" ) ) { + name.append( list[ i ].replace( "\\", " " ) ); + } else { + name.append( list[ i ] ); + inName = false; + } + } else { + uid = list[ i ]; + return; + } + } +} + +#include "stationsconfigwidget.moc" diff --git a/kweather/stationsconfigwidget.h b/kweather/stationsconfigwidget.h new file mode 100644 index 0000000..afdac56 --- /dev/null +++ b/kweather/stationsconfigwidget.h @@ -0,0 +1,59 @@ +/* + This file is part of KWeather. + Copyright (c) 2004 Tobias Koenig + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef STATIONSCONFIGWIDGET_H +#define STATIONSCONFIGWIDGET_H + +#include + +class TQListViewItem; +class WeatherService_stub; + +class StationsConfigWidget : public stationsConfig +{ + Q_OBJECT + + + public: + StationsConfigWidget( TQWidget *parent, const char *name = 0 ); + virtual ~StationsConfigWidget(); + + signals: + void changed( bool ); + + public slots: + void addStation(); + void removeStation(); + void updateStations(); + void exitWeatherService(); + + void selectionChanged( TQListViewItem* ); + void modified(); + + private: + void initGUI(); + void loadLocations(); + bool dcopActive(); + void scanStations(); + + TQMap mStationMap; + WeatherService_stub *mService; +}; + +#endif -- cgit v1.2.1