summarywidget.h
00001 /* 00002 This file is part of Kontact. 00003 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of TQt, and distribute the resulting executable, 00021 without including the source code for TQt in the source distribution. 00022 */ 00023 00024 #ifndef SUMMARYWIDGET_H 00025 #define SUMMARYWIDGET_H 00026 00027 #include "summary.h" 00028 00029 #include <dcopobject.h> 00030 00031 #include <tqmap.h> 00032 #include <tqpixmap.h> 00033 #include <tqptrlist.h> 00034 #include <tqstringlist.h> 00035 #include <tqtimer.h> 00036 #include <tqwidget.h> 00037 00038 class KProcess; 00039 00040 class TQGridLayout; 00041 class TQLabel; 00042 class TQVBoxLayout; 00043 00044 class WeatherData 00045 { 00046 public: 00047 void setIcon( const TQPixmap &icon ) { mIcon = icon; } 00048 TQPixmap icon() const { return mIcon; } 00049 00050 void setName( const TQString &name ) { mName = name; } 00051 TQString name() const { return mName; } 00052 00053 void setCover( const TQStringList& cover ) { mCover = cover; } 00054 TQStringList cover() const { return mCover; } 00055 00056 void setDate( const TQString &date ) { mDate = date; } 00057 TQString date() const { return mDate; } 00058 00059 void setTemperature( const TQString &temperature ) { mTemperature = temperature; } 00060 TQString temperature() const { return mTemperature; } 00061 00062 void setWindSpeed( const TQString &windSpeed ) { mWindSpeed = windSpeed; } 00063 TQString windSpeed() const { return mWindSpeed; } 00064 00065 void setRelativeHumidity( const TQString &relativeHumidity ) { mRelativeHumidity = relativeHumidity; } 00066 TQString relativeHumidity() const { return mRelativeHumidity; } 00067 00068 void setStationID( const TQString &station ) { mStationID = station;} 00069 TQString stationID() { return mStationID; } 00070 00071 bool operator< ( const WeatherData &data ) 00072 { 00073 return ( TQString::localeAwareCompare( mName, data.mName ) < 0 ); 00074 } 00075 00076 private: 00077 TQPixmap mIcon; 00078 TQString mName; 00079 TQStringList mCover; 00080 TQString mDate; 00081 TQString mTemperature; 00082 TQString mWindSpeed; 00083 TQString mRelativeHumidity; 00084 TQString mStationID; 00085 }; 00086 00087 class SummaryWidget : public Kontact::Summary, public DCOPObject 00088 { 00089 Q_OBJECT 00090 // TQ_OBJECT 00091 K_DCOP 00092 public: 00093 SummaryWidget( TQWidget *parent, const char *name = 0 ); 00094 00095 TQStringList configModules() const; 00096 00097 void updateSummary( bool force = false ); 00098 00099 k_dcop: 00100 virtual void refresh( TQString ); 00101 virtual void stationRemoved( TQString ); 00102 00103 protected: 00104 virtual bool eventFilter( TQObject *obj, TQEvent *e ); 00105 00106 private slots: 00107 void updateView(); 00108 void timeout(); 00109 void showReport( const TQString& ); 00110 void reportFinished( KProcess* ); 00111 00112 private: 00113 TQStringList mStations; 00114 TQMap<TQString, WeatherData> mWeatherMap; 00115 TQTimer mTimer; 00116 00117 TQPtrList<TQLabel> mLabels; 00118 TQPtrList<TQGridLayout> mLayouts; 00119 TQVBoxLayout *mLayout; 00120 00121 KProcess* mProc; 00122 }; 00123 00124 #endif