00001 #ifndef _WEATHERSCREEN_H_
00002 #define _WEATHERSCREEN_H_
00003
00004 #include <qobject.h>
00005 #include <qstringlist.h>
00006 #include <qstring.h>
00007 #include <qmap.h>
00008
00009 #include <mythtv/uitypes.h>
00010
00011 #include "defs.h"
00012
00013 class Weather;
00014
00015 class WeatherScreen : public QObject
00016 {
00017 Q_OBJECT
00018
00019 public:
00020 static WeatherScreen *loadScreen(Weather *parent, LayerSet *container,
00021 int id = -1);
00022 static QStringList getAllDynamicTypes(LayerSet *container);
00023
00024 WeatherScreen(Weather *parent, LayerSet *container, int id);
00025 ~WeatherScreen();
00026
00027 void setValue(const QString &key, const QString &value);
00028 QString getValue(const QString &key) { return map[key]; }
00029 bool containsKey(const QString &key) { return map.contains(key); }
00030 virtual bool canShowScreen();
00031 void pause_animation();
00032 void unpause_animation();
00033 virtual void hiding();
00034 virtual void showing();
00035 void addDataItem(const QString &item, bool required = false);
00036 void setUnits(units_t units) { m_units = units; }
00037 units_t getUnits() { return m_units; }
00038 LayerSet *getContainer() { return m_container; }
00039 void draw(QPainter *p);
00040 virtual void toggle_pause(bool paused);
00041 virtual bool usingKeys() { return false; }
00042 bool inUse() { return m_inuse; }
00043 void setInUse(bool inuse) { m_inuse = inuse; }
00044 int getId() { return m_id; }
00045
00046 signals:
00047 void screenReady(WeatherScreen *);
00048
00049 public slots:
00050 virtual void clock_tick();
00051 virtual void newData(QString loc, units_t units, DataMap data);
00052 virtual bool handleKey(QKeyEvent *e) { (void) e; return false; }
00053
00054 protected:
00055 units_t m_units;
00056 LayerSet *m_container;
00057 Weather *m_parent;
00058 QString m_name;
00059
00060 protected:
00061 virtual QString prepareDataItem(const QString &key, const QString &value);
00062 virtual void prepareWidget(UIType *widget);
00063 virtual void prepareScreen();
00064 UIType *getType(const QString &key);
00065
00066 private:
00067 QRect fullRect;
00068 QMap<QString, QString> map;
00069 UIAnimatedImageType *m_ai;
00070 bool m_inuse;
00071 bool m_prepared;
00072 int m_id;
00073 };
00074
00075 class CurrCondScreen : public WeatherScreen
00076 {
00077 Q_OBJECT
00078
00079 public:
00080 CurrCondScreen(Weather *parent, LayerSet *container, int id);
00081
00082 protected:
00083 virtual QString prepareDataItem(const QString &key, const QString &value);
00084 };
00085
00086 class ThreeDayForecastScreen : public WeatherScreen
00087 {
00088 Q_OBJECT
00089
00090 public:
00091 ThreeDayForecastScreen(Weather *parent, LayerSet *container, int id);
00092
00093 protected:
00094 virtual QString prepareDataItem(const QString &key, const QString &value);
00095
00096 };
00097
00098 class SixDayForecastScreen : public WeatherScreen
00099 {
00100 Q_OBJECT
00101
00102 public:
00103 SixDayForecastScreen(Weather *parent, LayerSet *container, int id);
00104
00105 protected:
00106 virtual QString prepareDataItem(const QString &key, const QString &value);
00107
00108 };
00109
00110 class SevereWeatherScreen : public WeatherScreen
00111 {
00112 Q_OBJECT
00113
00114 public:
00115 SevereWeatherScreen(Weather *parent, LayerSet *container, int id);
00116 bool usingKeys() { return true; }
00117
00118 public slots:
00119 bool handleKey(QKeyEvent *e);
00120
00121 private:
00122 UIRichTextType *m_text;
00123 };
00124
00125 class StaticImageScreen : public WeatherScreen
00126 {
00127 Q_OBJECT
00128
00129 public:
00130 StaticImageScreen(Weather *parent, LayerSet *container, int id);
00131
00132 protected:
00133 QString prepareDataItem(const QString &key, const QString &value);
00134 void prepareWidget(UIType *widget);
00135
00136 private:
00137 QSize imgsize;
00138 };
00139
00140 class AnimatedImageScreen : public WeatherScreen
00141 {
00142 Q_OBJECT
00143
00144 public:
00145 AnimatedImageScreen(Weather *parent, LayerSet *container, int id);
00146
00147 protected:
00148 QString prepareDataItem(const QString &key, const QString &value);
00149 void prepareWidget(UIType *widget);
00150
00151 private:
00152 int m_count;
00153 QSize imgsize;
00154 };
00155
00156 #endif