MythTV  master
profilegroup.h
Go to the documentation of this file.
1 #ifndef PROFILEGROUP_H
2 #define PROFILEGROUP_H
3 
4 #include <QString>
5 #include <QCoreApplication>
6 
7 #include "mythtvexp.h"
8 #include "standardsettings.h"
9 
10 class ProfileGroup;
11 
12 // A parameter associated with the profile itself
14 {
15  public:
17  const ProfileGroup &_parentProfile,
18  const QString& _name) :
19  SimpleDBStorage(_user, "profilegroups", _name),
20  m_parent(_parentProfile)
21  {
22  }
23 
24  QString GetSetClause(MSqlBindings &bindings) const override; // SimpleDBStorage
25  QString GetWhereClause(MSqlBindings &bindings) const override; // SimpleDBStorage
27 };
28 
29 class ProfileGroup : public GroupSetting
30 {
31  Q_DECLARE_TR_FUNCTIONS(ProfileGroup)
32 
33  friend class ProfileGroupEditor;
34  protected:
35  class ID : public AutoIncrementSetting
36  {
37  public:
38  ID() : AutoIncrementSetting("profilegroups", "id")
39  {
40  setVisible(false);
41  }
42  };
43 
44  class Is_default : public StandardSetting
45  {
46  public:
47  explicit Is_default(const ProfileGroup &parent) :
48  StandardSetting(new ProfileGroupStorage(this, parent, "is_default"))
49  {
50  setVisible(false);
51  }
52 
53  void edit(MythScreenType * /*screen*/) override { } // StandardSetting
54  void resultEdit(DialogCompletionEvent * /*dce*/) override { } // StandardSetting
55  };
56 
57  class Name : public MythUITextEditSetting
58  {
59  public:
60  explicit Name(const ProfileGroup &parent) :
61  MythUITextEditSetting(new ProfileGroupStorage(this, parent, "name"))
62  {
63  setLabel(QObject::tr("Profile Group Name"));
64  }
65  };
66 
68  {
69  public:
70  explicit HostName(const ProfileGroup &parent) :
72  "hostname"))
73  {
74  setLabel(QObject::tr("Hostname"));
75  }
76  void fillSelections();
77  };
78 
80  {
81  public:
82  explicit CardInfo(const ProfileGroup &parent) :
84  "cardtype"))
85  {
86  setLabel(QObject::tr("Card-Type"));
87  }
88  };
89 
90 public:
91  ProfileGroup();
92 
93  virtual void loadByID(int id);
94 
95  static bool addMissingDynamicProfiles(void);
96  static void fillSelections(GroupSetting* setting);
97  static void getHostNames(QStringList* hostnames);
98  int getProfileNum(void) const {
99  return m_id->getValue().toInt();
100  };
101 
102  int isDefault(void) const {
103  return m_is_default->getValue().toInt();
104  };
105 
106  QString getName(void) const { return m_name->getValue(); };
107  static QString getName(int group);
108  void setName(const QString& newName) override // StandardSetting
109  { m_name->setValue(newName); };
110  bool allowedGroupName(void);
111 
112 private:
113 
114  ID *m_id {nullptr};
115  Name *m_name {nullptr};
116  HostName *m_host {nullptr};
118 };
119 
121  public GroupSetting
122 {
123  Q_OBJECT
124 
125  public:
126  ProfileGroupEditor() { setLabel(tr("Profile Group")); }
127 
128  void Load(void) override; // StandardSetting
129 };
130 
131 #endif
static void getHostNames(QStringList *hostnames)
HostName * m_host
Definition: profilegroup.h:116
ProfileGroupStorage(StorageUser *_user, const ProfileGroup &_parentProfile, const QString &_name)
Definition: profilegroup.h:16
void resultEdit(DialogCompletionEvent *) override
Definition: profilegroup.h:54
void setName(const QString &newName) override
Definition: profilegroup.h:108
virtual void Load(void)
QString getName(void) const
Definition: profilegroup.h:106
virtual void loadByID(int id)
bool allowedGroupName(void)
HostName(const ProfileGroup &parent)
Definition: profilegroup.h:70
QString GetSetClause(MSqlBindings &bindings) const override
QString GetWhereClause(MSqlBindings &bindings) const override
Definition: profilegroup.cpp:8
virtual QString getValue(void) const
const ProfileGroup & m_parent
Definition: profilegroup.h:26
static bool addMissingDynamicProfiles(void)
CardInfo(const ProfileGroup &parent)
Definition: profilegroup.h:82
static void fillSelections(GroupSetting *setting)
#define MTV_PUBLIC
Definition: mythtvexp.h:15
virtual void setLabel(QString str)
Is_default(const ProfileGroup &parent)
Definition: profilegroup.h:47
int getProfileNum(void) const
Definition: profilegroup.h:98
Name(const ProfileGroup &parent)
Definition: profilegroup.h:60
void edit(MythScreenType *) override
Definition: profilegroup.h:53
void setVisible(bool visible)
int isDefault(void) const
Definition: profilegroup.h:102
QMap< QString, QVariant > MSqlBindings
typedef for a map of string -> string bindings for generic queries.
Definition: mythdbcon.h:98
Screen in which all other widgets are contained and rendered.
Is_default * m_is_default
Definition: profilegroup.h:117
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:37
virtual void setValue(const QString &newValue)