00001 #ifndef _WEATHER_SETUP_H_
00002 #define _WEATHER_SETUP_H_
00003
00004 #include <mythtv/mythcontext.h>
00005 #include <mythtv/xmlparse.h>
00006
00007 #include "defs.h"
00008
00009 class SourceManager;
00010 class UIListBtnTypeItem;
00011
00012 struct TypeListInfo
00013 {
00014 QString name;
00015 QString location;
00016 struct ScriptInfo *src;
00017 };
00018
00019 struct ScreenListInfo
00020 {
00021
00022
00023
00024
00025 QDict<TypeListInfo> types;
00026 QString helptxt;
00027 QStringList sources;
00028 units_t units;
00029 bool hasUnits;
00030 bool multiLoc;
00031 };
00032
00033 struct SourceListInfo
00034 {
00035 QString name;
00036 QString author;
00037 QString email;
00038 QString version;
00039 uint update_timeout;
00040 uint retrieve_timeout;
00041 uint id;
00042 };
00043
00044 class WeatherSpinBox : public MythSpinBox
00045 {
00046 Q_OBJECT
00047 public:
00048 WeatherSpinBox(MythThemedDialog *parent = NULL, const char *name = 0,
00049 bool allow_single_step = false) :
00050 MythSpinBox(parent, name, allow_single_step)
00051 {
00052 m_parent = parent;
00053 m_context = -1;
00054 }
00055
00056 protected slots:
00057 virtual bool eventFilter(QObject *o, QEvent *e)
00058 {
00059 bool handled = false;
00060 if (e->type() == QEvent::KeyPress)
00061 {
00062 QStringList actions;
00063 if (gContext->GetMainWindow()->
00064 TranslateKeyPress("qt", (QKeyEvent *)e, actions))
00065 {
00066 for (uint i = 0; i < actions.size(); ++i)
00067 {
00068 QString action = actions[i];
00069 handled = true;
00070 if (action == "DOWN")
00071 {
00072 m_parent->nextPrevWidgetFocus(true);
00073 }
00074 else if (action == "UP")
00075 {
00076 m_parent->nextPrevWidgetFocus(false);
00077 }
00078 else handled = false;
00079 }
00080 }
00081
00082 if (!handled)
00083 ((QKeyEvent *)e)->ignore();
00084 }
00085
00086
00087
00088
00089
00090
00091
00092
00093 MythSpinBox::eventFilter(o, e);
00094 return handled;
00095 }
00096
00097 private:
00098 MythThemedDialog *m_parent;
00099 int m_context;
00100 };
00101
00102 class GlobalSetup : public MythThemedDialog
00103 {
00104 Q_OBJECT
00105
00106 public:
00107 GlobalSetup(MythMainWindow *parent);
00108 ~GlobalSetup();
00109
00110 protected slots:
00111 void keyPressEvent(QKeyEvent *e);
00112 void saveData();
00113
00114 private:
00115 void loadData();
00116 void wireUI();
00117
00118 private:
00119 UICheckBoxType *m_background_check;
00120 UICheckBoxType *m_skip_check;
00121 WeatherSpinBox *m_timeout_spinbox;
00122 WeatherSpinBox *m_hold_spinbox;
00123 int m_timeout;
00124 int m_hold_timeout;
00125 UITextButtonType *m_finish_btn;
00126 };
00127
00128 class ScreenSetup : public MythThemedDialog
00129 {
00130 Q_OBJECT
00131
00132 public:
00133 ScreenSetup(MythMainWindow *parent, SourceManager *srcman);
00134
00135 protected slots:
00136 void keyPressEvent(QKeyEvent *e);
00137 void activeListItemSelected(UIListBtnTypeItem *itm = 0);
00138 void updateHelpText();
00139 void saveData();
00140
00141 private:
00142 void loadData();
00143 void wireUI();
00144
00145 void doListSelect(UIListBtnType *list, UIListBtnTypeItem *selected);
00146 bool showUnitsPopup(const QString &name, ScreenListInfo *si);
00147 bool doLocationDialog(ScreenListInfo *si, bool alltypes);
00148 bool showLocationPopup(QStringList types, QString &loc,
00149 ScriptInfo *&src);
00150
00151 void cursorUp(UIType *curr);
00152 void cursorDown(UIType *curr);
00153 void cursorRight(UIType *curr);
00154 void cursorLeft(UIType *curr);
00155 void cursorSelect(UIType *curr);
00156
00157 void deleteScreen(UIListBtnType *list);
00158
00159 private:
00160 SourceManager *m_src_man;
00161 XMLParse m_weather_screens;
00162 UITextType *m_help_txt;
00163 UIListBtnType *m_active_list;
00164 UIListBtnType *m_inactive_list;
00165
00166 UITextButtonType *m_finish_btn;
00167 };
00168
00169 class SourceSetup : public MythThemedDialog
00170 {
00171 Q_OBJECT
00172
00173 public:
00174 SourceSetup(MythMainWindow *parent);
00175 ~SourceSetup();
00176
00177 bool loadData();
00178
00179 protected slots:
00180 void keyPressEvent(QKeyEvent *e);
00181 void sourceListItemSelected(UIListBtnTypeItem *itm = 0);
00182 void updateSpinboxUpdate();
00183 void retrieveSpinboxUpdate();
00184 void saveData();
00185
00186 private:
00187 void wireUI();
00188
00189 WeatherSpinBox *m_update_spinbox;
00190 WeatherSpinBox *m_retrieve_spinbox;
00191 UIListBtnType *m_src_list;
00192 UITextButtonType *m_finish_btn;
00193 };
00194
00195 struct ResultListInfo
00196 {
00197 QString idstr;
00198 ScriptInfo *src;
00199 };
00200
00201 class LocationDialog : public MythThemedDialog
00202 {
00203 Q_OBJECT
00204
00205 public:
00206 LocationDialog(MythMainWindow *parent, QStringList types,
00207 SourceManager *srcman);
00208 QString getLocation();
00209 ScriptInfo *getSource();
00210
00211 protected slots:
00212 void keyPressEvent(QKeyEvent *e);
00213 void doSearch();
00214 void itemSelected(UIListBtnTypeItem *itm);
00215
00216 private:
00217 void wireUI();
00218
00219 private:
00220 QDict<QValueList<ScriptInfo *> > m_cache;
00221 QStringList m_types;
00222 SourceManager *m_src_man;
00223 UIListBtnType *m_list;
00224 UIRemoteEditType *m_edit;
00225 UITextButtonType *m_btn;
00226 };
00227
00228 #endif