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 <qmap.h>
00032 #include <qpixmap.h>
00033 #include <qptrlist.h>
00034 #include <qstringlist.h>
00035 #include <qtimer.h>
00036 #include <qwidget.h>
00037 
00038 class KProcess;
00039 
00040 class QGridLayout;
00041 class QLabel;
00042 class QVBoxLayout;
00043 
00044 class WeatherData
00045 {
00046   public:
00047     void setIcon( const QPixmap &icon ) { mIcon = icon; }
00048     QPixmap icon() const { return mIcon; }
00049 
00050     void setName( const QString &name ) { mName = name; }
00051     QString name() const { return mName; }
00052 
00053     void setCover( const QStringList& cover ) { mCover = cover; }
00054     QStringList cover() const { return mCover; }
00055 
00056     void setDate( const QString &date ) { mDate = date; }
00057     QString date() const { return mDate; }
00058 
00059     void setTemperature( const QString &temperature ) { mTemperature = temperature; }
00060     QString temperature() const { return mTemperature; }
00061 
00062     void setWindSpeed( const QString &windSpeed ) { mWindSpeed = windSpeed; }
00063     QString windSpeed() const { return mWindSpeed; }
00064 
00065     void setRelativeHumidity( const QString &relativeHumidity ) { mRelativeHumidity = relativeHumidity; }
00066     QString relativeHumidity() const { return mRelativeHumidity; }
00067 
00068     void setStationID( const QString &station ) { mStationID = station;}
00069     QString stationID() { return mStationID; }
00070 
00071     bool operator< ( const WeatherData &data )
00072     {
00073       return ( QString::localeAwareCompare( mName, data.mName ) < 0 );
00074     }
00075 
00076   private:
00077     QPixmap mIcon;
00078     QString mName;
00079     QStringList mCover;
00080     QString mDate;
00081     QString mTemperature;
00082     QString mWindSpeed;
00083     QString mRelativeHumidity;
00084     QString mStationID;
00085 };
00086 
00087 class SummaryWidget : public Kontact::Summary, public DCOPObject
00088 {
00089     Q_OBJECT
00090     K_DCOP
00091   public:
00092     SummaryWidget( QWidget *parent, const char *name = 0 );
00093 
00094     QStringList configModules() const;
00095 
00096     void updateSummary( bool force = false );
00097 
00098   k_dcop:
00099     virtual void refresh( QString );
00100     virtual void stationRemoved( QString );
00101 
00102   protected:
00103     virtual bool eventFilter( QObject *obj, QEvent *e );
00104 
00105   private slots:
00106     void updateView();
00107     void timeout();
00108     void showReport( const QString& );
00109     void reportFinished( KProcess* );
00110 
00111   private:
00112     QStringList mStations;
00113     QMap<QString, WeatherData> mWeatherMap;
00114     QTimer mTimer;
00115 
00116     QPtrList<QLabel> mLabels;
00117     QPtrList<QGridLayout> mLayouts;
00118     QVBoxLayout *mLayout;
00119 
00120     KProcess* mProc;
00121 };
00122 
00123 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys