00001 #ifndef PROFILEGROUP_H
00002 #define PROFILEGROUP_H
00003
00004 #include "libmyth/settings.h"
00005 #include "libmyth/mythwidgets.h"
00006
00007 class ProfileGroup;
00008
00009
00010 class ProfileGroupStorage : public SimpleDBStorage
00011 {
00012 protected:
00013 ProfileGroupStorage(Setting *_setting,
00014 const ProfileGroup &_parentProfile,
00015 QString _name) :
00016 SimpleDBStorage(_setting, "profilegroups", _name),
00017 parent(_parentProfile)
00018 {
00019 _setting->setName(_name);
00020 }
00021
00022 virtual QString setClause(MSqlBindings& bindings);
00023 virtual QString whereClause(MSqlBindings& bindings);
00024 const ProfileGroup& parent;
00025 };
00026
00027 class ProfileGroup : public ConfigurationWizard
00028 {
00029 friend class ProfileGroupEditor;
00030 protected:
00031 class ID : public AutoIncrementDBSetting
00032 {
00033 public:
00034 ID() : AutoIncrementDBSetting("profilegroups", "id")
00035 {
00036 setVisible(false);
00037 }
00038 };
00039
00040 class Is_default : public IntegerSetting, public ProfileGroupStorage
00041 {
00042 public:
00043 Is_default(const ProfileGroup &parent) :
00044 IntegerSetting(this),
00045 ProfileGroupStorage(this, parent, "is_default")
00046 {
00047 setVisible(false);
00048 }
00049 };
00050
00051 class Name : public LineEditSetting, public ProfileGroupStorage
00052 {
00053 public:
00054 Name(const ProfileGroup &parent) :
00055 LineEditSetting(this),
00056 ProfileGroupStorage(this, parent, "name")
00057 {
00058 setLabel(QObject::tr("Profile Group Name"));
00059 }
00060 };
00061
00062 class HostName : public ComboBoxSetting, public ProfileGroupStorage
00063 {
00064 public:
00065 HostName(const ProfileGroup &parent) :
00066 ComboBoxSetting(this),
00067 ProfileGroupStorage(this, parent, "hostname")
00068 {
00069 setLabel(QObject::tr("Hostname"));
00070 }
00071 void fillSelections();
00072 };
00073
00074 class CardInfo : public ComboBoxSetting, public ProfileGroupStorage
00075 {
00076 public:
00077 CardInfo(const ProfileGroup &parent) :
00078 ComboBoxSetting(this),
00079 ProfileGroupStorage(this, parent, "cardtype")
00080 {
00081 setLabel(QObject::tr("Card-Type"));
00082 }
00083 };
00084
00085 public:
00086 ProfileGroup();
00087
00088 virtual void loadByID(int id);
00089
00090 static void fillSelections(SelectSetting* setting);
00091 static void getHostNames(QStringList* hostnames);
00092 int getProfileNum(void) const {
00093 return id->intValue();
00094 };
00095
00096 int isDefault(void) const {
00097 return is_default->intValue();
00098 };
00099
00100 QString getName(void) const { return name->getValue(); };
00101 static QString getName(int group);
00102 void setName(QString newName) { name->setValue(newName); };
00103 bool allowedGroupName(void);
00104
00105 private:
00106 ID* id;
00107 Name* name;
00108 HostName* host;
00109 Is_default* is_default;
00110 };
00111
00112 class MPUBLIC ProfileGroupEditor :
00113 public QObject, public ConfigurationDialog
00114 {
00115 Q_OBJECT
00116
00117 public:
00118 ProfileGroupEditor() :
00119 listbox(new ListBoxSetting(this)), dialog(NULL), redraw(true)
00120 { addChild(listbox); }
00121
00122 virtual DialogCode exec(void);
00123 virtual void load();
00124 virtual void save() {};
00125
00126 protected slots:
00127 void open(int id);
00128 void callDelete(void);
00129
00130 protected:
00131 ListBoxSetting *listbox;
00132 MythDialog *dialog;
00133 bool redraw;
00134 };
00135
00136 #endif
00137