weather/summarywidget.h
1 /*
2  This file is part of Kontact.
3  Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 
19  As a special exception, permission is given to link this program
20  with any edition of TQt, and distribute the resulting executable,
21  without including the source code for TQt in the source distribution.
22 */
23 
24 #ifndef SUMMARYWIDGET_H
25 #define SUMMARYWIDGET_H
26 
27 #include "summary.h"
28 
29 #include <dcopobject.h>
30 
31 #include <tqmap.h>
32 #include <tqpixmap.h>
33 #include <tqptrlist.h>
34 #include <tqstringlist.h>
35 #include <tqtimer.h>
36 #include <tqwidget.h>
37 
38 class TDEProcess;
39 
40 class TQGridLayout;
41 class TQLabel;
42 class TQVBoxLayout;
43 
44 class WeatherData
45 {
46  public:
47  void setIcon( const TQPixmap &icon ) { mIcon = icon; }
48  TQPixmap icon() const { return mIcon; }
49 
50  void setName( const TQString &name ) { mName = name; }
51  TQString name() const { return mName; }
52 
53  void setCover( const TQStringList& cover ) { mCover = cover; }
54  TQStringList cover() const { return mCover; }
55 
56  void setDate( const TQString &date ) { mDate = date; }
57  TQString date() const { return mDate; }
58 
59  void setTemperature( const TQString &temperature ) { mTemperature = temperature; }
60  TQString temperature() const { return mTemperature; }
61 
62  void setWindSpeed( const TQString &windSpeed ) { mWindSpeed = windSpeed; }
63  TQString windSpeed() const { return mWindSpeed; }
64 
65  void setRelativeHumidity( const TQString &relativeHumidity ) { mRelativeHumidity = relativeHumidity; }
66  TQString relativeHumidity() const { return mRelativeHumidity; }
67 
68  void setStationID( const TQString &station ) { mStationID = station;}
69  TQString stationID() { return mStationID; }
70 
71  bool operator< ( const WeatherData &data )
72  {
73  return ( TQString::localeAwareCompare( mName, data.mName ) < 0 );
74  }
75 
76  private:
77  TQPixmap mIcon;
78  TQString mName;
79  TQStringList mCover;
80  TQString mDate;
81  TQString mTemperature;
82  TQString mWindSpeed;
83  TQString mRelativeHumidity;
84  TQString mStationID;
85 };
86 
87 class SummaryWidget : public Kontact::Summary, public DCOPObject
88 {
89  TQ_OBJECT
90 //
91  K_DCOP
92  public:
93  SummaryWidget( TQWidget *parent, const char *name = 0 );
94 
95  TQStringList configModules() const;
96 
97  void updateSummary( bool force = false );
98 
99  k_dcop:
100  virtual void refresh( TQString );
101  virtual void stationRemoved( TQString );
102 
103  protected:
104  virtual bool eventFilter( TQObject *obj, TQEvent *e );
105 
106  private slots:
107  void updateView();
108  void timeout();
109  void showReport( const TQString& );
110  void reportFinished( TDEProcess* );
111 
112  private:
113  TQStringList mStations;
114  TQMap<TQString, WeatherData> mWeatherMap;
115  TQTimer mTimer;
116 
117  TQPtrList<TQLabel> mLabels;
118  TQPtrList<TQGridLayout> mLayouts;
119  TQVBoxLayout *mLayout;
120 
121  TDEProcess* mProc;
122 };
123 
124 #endif
Summary widget for display in the Summary View plugin.
Definition: summary.h:37
virtual TQStringList configModules() const
Return list of strings identifying configuration modules for this summary part.
Definition: summary.h:64
virtual void updateSummary(bool force=false)
This is called if the displayed information should be updated.
Definition: summary.h:73