MythTV  master
weatherScreen.h
Go to the documentation of this file.
1 #ifndef _WEATHERSCREEN_H_
2 #define _WEATHERSCREEN_H_
3 
4 // QT headers
5 #include <QStringList>
6 #include <QMap>
7 
8 // MythTV headers
9 #include <mythscreentype.h>
10 #include <mythuitext.h>
11 #include <mythuiimage.h>
12 
13 // MythWeather headers
14 #include "weatherUtils.h"
15 
16 class Weather;
17 
18 enum DaysOfWeek {
21 };
22 
27 {
28  Q_OBJECT
29 
30  public:
31  WeatherScreen(MythScreenStack *parent, ScreenListInfo *screenDefn, int id);
32  ~WeatherScreen() = default;
33 
34  bool Create(void) override; // MythScreenType
35  bool keyPressEvent(QKeyEvent *) override; // MythScreenType
36 
38  ScreenListInfo *screenDefn, int id);
39 
40  void setValue(const QString &key, const QString &value);
41  QString getValue(const QString &key) { return m_dataValueMap[key]; }
42  bool containsKey(const QString &key) { return m_dataValueMap.contains(key); }
43  virtual bool canShowScreen();
44  void setUnits(units_t units) { m_units = units; }
45  units_t getUnits() { return m_units; }
46  virtual bool usingKeys() { return false; }
47  bool inUse() { return m_inuse; }
48  void setInUse(bool inuse) { m_inuse = inuse; }
49  int getId() { return m_id; }
50 
51  signals:
52  void screenReady(WeatherScreen *);
53 
54  public slots:
55  virtual void newData(const QString& /*loc*/, units_t /*units*/, DataMap data);
56 
57  protected:
60  QString m_name;
61 
62  protected:
63  virtual QString prepareDataItem(const QString &key, const QString &value);
64  virtual void prepareWidget(MythUIType *widget);
65  virtual bool prepareScreen(bool checkOnly = false);
66  virtual QString getTemperatureUnit();
67  QString formatDataItem(const QString &key, const QString &value);
68 
69  private:
70  QMap<QString, QString> m_dataValueMap;
71 
72  bool m_inuse {false};
73  bool m_prepared {false};
74  int m_id;
75 };
76 
77 #endif
virtual QString getTemperatureUnit()
unsigned int slots[4]
Definition: element.c:38
void setUnits(units_t units)
Definition: weatherScreen.h:44
QMap< QString, QString > m_dataValueMap
Definition: weatherScreen.h:70
virtual QString prepareDataItem(const QString &key, const QString &value)
void setValue(const QString &key, const QString &value)
static WeatherScreen * loadScreen(MythScreenStack *parent, ScreenListInfo *screenDefn, int id)
units_t m_units
Definition: weatherScreen.h:58
QString formatDataItem(const QString &key, const QString &value)
The base class on which all widgets and screens are based.
Definition: mythuitype.h:63
virtual bool prepareScreen(bool checkOnly=false)
virtual void newData(const QString &, units_t, DataMap data)
virtual bool usingKeys()
Definition: weatherScreen.h:46
bool containsKey(const QString &key)
Definition: weatherScreen.h:42
DaysOfWeek
Definition: weatherScreen.h:18
void screenReady(WeatherScreen *)
bool Create(void) override
void setInUse(bool inuse)
Definition: weatherScreen.h:48
virtual bool canShowScreen()
virtual void prepareWidget(MythUIType *widget)
ScreenListInfo * m_screenDefn
Definition: weatherScreen.h:59
unsigned char units_t
Definition: weatherUtils.h:22
QMap< QString, QString > DataMap
Definition: weatherUtils.h:23
WeatherScreen(MythScreenStack *parent, ScreenListInfo *screenDefn, int id)
~WeatherScreen()=default
Screen in which all other widgets are contained and rendered.
Weather screen.
Definition: weatherScreen.h:26
QString m_name
Definition: weatherScreen.h:60
#define SI_UNITS
Definition: weatherUtils.h:15
units_t getUnits()
Definition: weatherScreen.h:45
bool keyPressEvent(QKeyEvent *) override
Key event handler.
QString getValue(const QString &key)
Definition: weatherScreen.h:41