kontact

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 Qt, and distribute the resulting executable,
00021     without including the source code for Qt 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     K_DCOP
00091   public:
00092     SummaryWidget( TQWidget *parent, const char *name = 0 );
00093 
00094     TQStringList configModules() const;
00095 
00096     void updateSummary( bool force = false );
00097 
00098   k_dcop:
00099     virtual void refresh( TQString );
00100     virtual void stationRemoved( TQString );
00101 
00102   protected:
00103     virtual bool eventFilter( TQObject *obj, TQEvent *e );
00104 
00105   private slots:
00106     void updateView();
00107     void timeout();
00108     void showReport( const TQString& );
00109     void reportFinished( KProcess* );
00110 
00111   private:
00112     TQStringList mStations;
00113     TQMap<TQString, WeatherData> mWeatherMap;
00114     TQTimer mTimer;
00115 
00116     TQPtrList<TQLabel> mLabels;
00117     TQPtrList<TQGridLayout> mLayouts;
00118     TQVBoxLayout *mLayout;
00119 
00120     KProcess* mProc;
00121 };
00122 
00123 #endif