MythTV  master
mythsettings.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #ifndef MYTHSETTINGS_H
4 #define MYTHSETTINGS_H
5 
6 #include <utility>
7 
8 // Qt headers
9 #include <QMap>
10 #include <QStringList>
11 
13 {
14  public:
15  MythSettingBase() = default;
16  virtual ~MythSettingBase() = default;
17  virtual QString ToHTML(uint /*depth*/) const { return QString(); }
18 };
19 using MythSettingList = QList<MythSettingBase*>;
20 
22 {
23  public:
24  MythSettingGroup(QString hlabel, QString ulabel,
25  QString script = "") :
26  m_human_label(std::move(hlabel)),
27  m_unique_label(std::move(ulabel)),
28  m_ecma_script(std::move(script)) {}
29 
30  QString ToHTML(uint depth) const override; // MythSettingBase
31 
32  public:
33  QString m_human_label;
34  QString m_unique_label;
36  QString m_ecma_script;
37 };
38 
40 {
41  public:
42  enum SettingType {
47  };
48 
49  enum DataType {
65  };
66 
67  MythSetting(QString _value, const QString& _default_data,
68  SettingType _stype, QString _label,
69  QString _help_text, DataType _dtype) :
70  m_value(std::move(_value)), m_data(_default_data),
71  m_default_data(_default_data), m_stype(_stype),
72  m_label(std::move(_label)), m_help_text(std::move(_help_text)),
73  m_dtype(_dtype)
74  {
75  }
76 
77  MythSetting(QString _value, const QString& _default_data,
78  SettingType _stype, QString _label,
79  QString _help_text, DataType _dtype,
80  QStringList _data_list, QStringList _display_list) :
81  m_value(std::move(_value)), m_data(_default_data),
82  m_default_data(_default_data), m_stype(_stype),
83  m_label(std::move(_label)), m_help_text(std::move(_help_text)),
84  m_dtype(_dtype), m_data_list(std::move(_data_list)),
85  m_display_list(std::move(_display_list))
86  {
87  }
88 
89  MythSetting(QString _value, const QString& _default_data, SettingType _stype,
90  QString _label, QString _help_text, DataType _dtype,
91  long long _range_min, long long _range_max) :
92  m_value(std::move(_value)), m_data(_default_data),
93  m_default_data(_default_data), m_stype(_stype),
94  m_label(std::move(_label)), m_help_text(std::move(_help_text)),
95  m_dtype(_dtype), m_range_min(_range_min), m_range_max(_range_max)
96  {
97  }
98 
99  MythSetting(QString _value, const QString& _default_data, SettingType _stype,
100  QString _label, QString _help_text, DataType _dtype,
101  QStringList _data_list, QStringList _display_list,
102  long long _range_min, long long _range_max,
103  QString _placeholder) :
104  m_value(std::move(_value)), m_data(_default_data),
105  m_default_data(_default_data), m_stype(_stype),
106  m_label(std::move(_label)), m_help_text(std::move(_help_text)),
107  m_dtype(_dtype), m_data_list(std::move(_data_list)),
108  m_display_list(std::move(_display_list)),
109  m_range_min(_range_min), m_range_max(_range_max),
110  m_placeholder_text(std::move(_placeholder))
111  {
112  }
113 
114  QString ToHTML(uint level) const override; // MythSettingBase
115 
116  public:
117  QString m_value;
118  QString m_data;
119  QString m_default_data;
121  QString m_label;
122  QString m_help_text;
124  QStringList m_data_list;
125  QStringList m_display_list;
126  long long m_range_min {-1};
127  long long m_range_max {-1};
129 };
130 
131 bool parse_settings(MythSettingList &settings, const QString &filename,
132  const QString &group = "");
133 bool load_settings(MythSettingList &settings, const QString &hostname);
134 bool check_settings(MythSettingList &database_settings,
135  const QMap<QString,QString> &params, QString &result);
136 
137 QStringList GetSettingValueList(const QString &type);
138 QString StringMapToJSON(const QMap<QString,QString> &map);
139 QString StringListToJSON(const QString &key, const QStringList &sList);
140 QMap<QString,QString> GetSettingsMap(const MythSettingList &settings, const QString &hostname);
141 
142 #endif // MYTHSETTINGS_H
MythSetting::kFile
@ kFile
Definition: mythsettings.h:43
MythSettingBase::ToHTML
virtual QString ToHTML(uint) const
Definition: mythsettings.h:17
GetSettingsMap
QMap< QString, QString > GetSettingsMap(const MythSettingList &settings, const QString &hostname)
Definition: mythsettings.cpp:353
MythSetting::m_stype
SettingType m_stype
Definition: mythsettings.h:120
MythSetting::kCheckBox
@ kCheckBox
Definition: mythsettings.h:53
MythSetting::kInteger
@ kInteger
Definition: mythsettings.h:50
MythSetting::kSelect
@ kSelect
list where only data_list are valid
Definition: mythsettings.h:54
MythSetting::m_placeholder_text
QString m_placeholder_text
Definition: mythsettings.h:128
MythSetting::kUnsignedInteger
@ kUnsignedInteger
Definition: mythsettings.h:51
MythSetting::kHost
@ kHost
Definition: mythsettings.h:44
check_settings
bool check_settings(MythSettingList &database_settings, const QMap< QString, QString > &params, QString &result)
Definition: mythsettings.cpp:716
MythSetting::kInvalidSettingType
@ kInvalidSettingType
Definition: mythsettings.h:46
MythSetting::ToHTML
QString ToHTML(uint level) const override
Definition: mythsettings.cpp:155
MythSetting::kTVFormat
@ kTVFormat
Definition: mythsettings.h:56
MythSetting::SettingType
SettingType
Definition: mythsettings.h:42
MythSetting::MythSetting
MythSetting(QString _value, const QString &_default_data, SettingType _stype, QString _label, QString _help_text, DataType _dtype, long long _range_min, long long _range_max)
Definition: mythsettings.h:89
MythSettingGroup::m_ecma_script
QString m_ecma_script
Definition: mythsettings.h:36
parse_settings
bool parse_settings(MythSettingList &settings, const QString &filename, const QString &group="")
Definition: mythsettings.cpp:640
MythSetting::m_display_list
QStringList m_display_list
Definition: mythsettings.h:125
GetSettingValueList
QStringList GetSettingValueList(const QString &type)
Definition: mythsettings.cpp:400
MythSetting
Definition: mythsettings.h:40
MythSetting::kIPAddress
@ kIPAddress
Definition: mythsettings.h:59
MythSetting::m_value
QString m_value
Definition: mythsettings.h:117
MythSettingGroup
Definition: mythsettings.h:22
MythSetting::kInvalidDataType
@ kInvalidDataType
Definition: mythsettings.h:64
MythSetting::kTimeOfDay
@ kTimeOfDay
Definition: mythsettings.h:62
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:637
MythSettingGroup::m_unique_label
QString m_unique_label
div name for stylesheets & javascript
Definition: mythsettings.h:34
MythSettingBase::MythSettingBase
MythSettingBase()=default
MythSetting::kString
@ kString
Definition: mythsettings.h:61
MythSettingGroup::ToHTML
QString ToHTML(uint depth) const override
Definition: mythsettings.cpp:135
MythSettingGroup::m_settings
MythSettingList m_settings
Definition: mythsettings.h:35
MythSetting::kComboBox
@ kComboBox
list where user input is allowed
Definition: mythsettings.h:55
uint
unsigned int uint
Definition: compat.h:140
MythSettingGroup::MythSettingGroup
MythSettingGroup(QString hlabel, QString ulabel, QString script="")
Definition: mythsettings.h:24
MythSetting::kFloat
@ kFloat
Definition: mythsettings.h:58
MythSetting::DataType
DataType
Definition: mythsettings.h:49
load_settings
bool load_settings(MythSettingList &settings, const QString &hostname)
Definition: mythsettings.cpp:675
MythSetting::kGlobal
@ kGlobal
Definition: mythsettings.h:45
MythSettingBase
Definition: mythsettings.h:13
MythSetting::MythSetting
MythSetting(QString _value, const QString &_default_data, SettingType _stype, QString _label, QString _help_text, DataType _dtype, QStringList _data_list, QStringList _display_list, long long _range_min, long long _range_max, QString _placeholder)
Definition: mythsettings.h:99
MythSettingList
QList< MythSettingBase * > MythSettingList
Definition: mythsettings.h:19
MythSetting::kLocalIPAddress
@ kLocalIPAddress
Definition: mythsettings.h:60
MythSetting::MythSetting
MythSetting(QString _value, const QString &_default_data, SettingType _stype, QString _label, QString _help_text, DataType _dtype)
Definition: mythsettings.h:67
MythSetting::m_help_text
QString m_help_text
Definition: mythsettings.h:122
MythSettingBase::~MythSettingBase
virtual ~MythSettingBase()=default
MythSetting::m_range_min
long long m_range_min
Definition: mythsettings.h:126
MythSetting::m_default_data
QString m_default_data
Definition: mythsettings.h:119
MythSetting::m_dtype
DataType m_dtype
Definition: mythsettings.h:123
MythSetting::kFrequencyTable
@ kFrequencyTable
Definition: mythsettings.h:57
musicbrainzngs.caa.hostname
string hostname
Definition: caa.py:17
MythSettingGroup::m_human_label
QString m_human_label
Definition: mythsettings.h:33
MythSetting::m_label
QString m_label
Definition: mythsettings.h:121
StringMapToJSON
QString StringMapToJSON(const QMap< QString, QString > &map)
Definition: mythsettings.cpp:421
MythSetting::kIntegerRange
@ kIntegerRange
Definition: mythsettings.h:52
MythSetting::m_range_max
long long m_range_max
Definition: mythsettings.h:127
MythSetting::MythSetting
MythSetting(QString _value, const QString &_default_data, SettingType _stype, QString _label, QString _help_text, DataType _dtype, QStringList _data_list, QStringList _display_list)
Definition: mythsettings.h:77
MythSetting::m_data_list
QStringList m_data_list
Definition: mythsettings.h:124
MythSetting::kOther
@ kOther
Definition: mythsettings.h:63
MythSetting::m_data
QString m_data
Definition: mythsettings.h:118
StringListToJSON
QString StringListToJSON(const QString &key, const QStringList &sList)
Definition: mythsettings.cpp:445