00001 #ifndef _WEATHERUTILS_H_
00002 #define _WEATHERUTILS_H_
00003
00004
00005 #include <QMap>
00006 #include <QMultiHash>
00007 #include <QString>
00008 #include <QDomElement>
00009 #include <QFile>
00010 #include <QMetaType>
00011
00012
00013 #include <mythcontext.h>
00014
00015 #define SI_UNITS 0
00016 #define ENG_UNITS 1
00017 #define DEFAULT_UPDATE_TIMEOUT (5*60*1000)
00018 #define DEFAULT_SCRIPT_TIMEOUT (60)
00019
00020 typedef unsigned char units_t;
00021 typedef QMap<QString, QString> DataMap;
00022
00023 class TypeListInfo
00024 {
00025 public:
00026
00027 TypeListInfo(const TypeListInfo& info)
00028 : name(info.name), location(info.location), src(info.src)
00029 {
00030 name.detach();
00031 location.detach();
00032 }
00033
00034 TypeListInfo(const QString &_name)
00035 : name(_name), location(QString::null), src(NULL)
00036 {
00037 name.detach();
00038 }
00039 TypeListInfo(const QString &_name, const QString &_location)
00040 : name(_name), location(_location), src(NULL)
00041 {
00042 name.detach();
00043 location.detach();
00044 }
00045 TypeListInfo(const QString &_name, const QString &_location,
00046 struct ScriptInfo *_src)
00047 : name(_name), location(_location), src(_src)
00048 {
00049 name.detach();
00050 location.detach();
00051 }
00052
00053 public:
00054 QString name;
00055 QString location;
00056 struct ScriptInfo *src;
00057 };
00058 typedef QMultiHash<QString, TypeListInfo> TypeListMap;
00059
00060 class ScreenListInfo
00061 {
00062 public:
00063 ScreenListInfo() :
00064 units(SI_UNITS),
00065 hasUnits(false),
00066 multiLoc(false)
00067 {
00068 updating = false;
00069 }
00070
00071 ScreenListInfo(const ScreenListInfo& info) :
00072 name(info.name),
00073 title(info.title),
00074 types(info.types),
00075 dataTypes(info.dataTypes),
00076 helptxt(info.helptxt),
00077 sources(info.sources),
00078 units(info.units),
00079 hasUnits(info.hasUnits),
00080 multiLoc(info.multiLoc),
00081 updating(info.updating)
00082 {
00083 types.detach();
00084 }
00085
00086 TypeListInfo GetCurrentTypeList(void) const;
00087
00088 public:
00089 QString name;
00090 QString title;
00091 TypeListMap types;
00092 QStringList dataTypes;
00093 QString helptxt;
00094 QStringList sources;
00095 units_t units;
00096 bool hasUnits;
00097 bool multiLoc;
00098 bool updating;
00099 };
00100
00101 Q_DECLARE_METATYPE(ScreenListInfo *);
00102
00103 typedef QMap<QString, ScreenListInfo> ScreenListMap;
00104
00105 ScreenListMap loadScreens();
00106 QStringList loadScreen(QDomElement ScreenListInfo);
00107 bool doLoadScreens(const QString &filename, ScreenListMap &screens);
00108
00109 #endif