51 Type SettingType, Roles SettingRoles,
const QVariant &Default)
54 TorcSetting::staticMetaObject, QStringLiteral(
"SetActive,SetTrue,SetFalse")),
63 defaultValue(Default),
73 setObjectName(DBName);
75 qRegisterMetaType<QString>(
"QString&");
82 if (vtype == QVariant::Int && type ==
Integer)
86 else if (vtype == QVariant::Bool && type ==
Bool)
90 else if (vtype == QVariant::String)
94 else if (vtype == QVariant::StringList)
99 value = QVariant(svalue.split(
','));
108 if (vtype != QVariant::Invalid)
109 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Unsupported setting data type for %1 (%2)").arg(m_dbName).arg(vtype));
132 Children.insert(QStringLiteral(
"name"), m_dbName);
133 Children.insert(QStringLiteral(
"uiname"),
uiName);
134 Children.insert(QStringLiteral(
"type"), TorcCoreUtils::EnumToLowerString<TorcSetting::Type>(type));
135 QVariantMap children;
140 children.insert(name, childd);
142 Children.insert(QStringLiteral(
"children"), children);
163 m_children.append(Child);
173 for (
int i = 0; i < m_children.size(); ++i)
175 if (m_children.at(i) == Child)
177 m_children.removeAt(i);
201 if (setting->objectName() == Child)
219 QSet<TorcSetting*> result;
284 m_active += Value ? 1 : -1;
285 isActive = m_active >= m_activeThreshold;
286 bool changed = wasactive !=
isActive;
298 m_activeThreshold = Threshold;
299 isActive = m_active >= m_activeThreshold;
300 bool changed = wasactive !=
isActive;
315 if (vtype == QVariant::Int)
317 int ivalue = Value.toInt();
321 valid =
selections.contains(QString::number(ivalue));
323 else if (ivalue >= m_begin && ivalue <= m_end)
338 else if (vtype == QVariant::Bool)
340 bool bvalue = Value.toBool();
348 else if (vtype == QVariant::String)
350 QString svalue = Value.toString();
361 else if (vtype == QVariant::StringList)
363 QStringList svalue = Value.toStringList();
380 if (Begin >= End || Step < 1)
382 LOG(VB_GENERAL, LOG_ERR, QStringLiteral(
"Invalid setting range: begin %1 end %2 step %3")
383 .arg(Begin).arg(End).arg(Step));
407 case Group:
return QVariant();
QVariant GetDefaultValue(void)
TorcSettingGroup(TorcSetting *Parent, const QString &UIName)
QVariantMap GetSelections(void)
QString GetSettingType(void)
void SetHelpText(const QString &HelpText)
TorcLocalContext * gLocalContext
#define TORC_SETTINGS_DIR
QString GetHelpText(void)
void SubscriberDeleted(QObject *Subscriber)
A wrapper around a database setting.
void RemoveChild(TorcSetting *Child)
TorcSetting * FindChild(const QString &Child, bool Recursive=false)
virtual bool DownRef(void)
void SetSetting(const QString &Name, const QString &Value)
TorcSetting(TorcSetting *Parent, const QString &DBName, const QString &UIName, Type SettingType, Roles SettingRoles, const QVariant &Default)
QSet< TorcSetting * > GetChildren(void)
void AddChild(TorcSetting *Child)
void HandleSubscriberDeleted(QObject *Subscriber)
QString GetSetting(const QString &Name, const QString &DefaultValue)
QReadWriteLock m_httpServiceLock
bool SetValue(const QVariant &Value)
#define LOG(_MASK_, _LEVEL_, _STRING_)
void ActiveChanged(bool Active)
void SetActiveThreshold(int Threshold)
void SetRange(int Begin, int End, int Step)
void SetSelections(QVariantMap &Selections)
void ValueChanged(int Value)
QString EnumToLowerString(T Value)
QVariantMap GetChildList(void)
void SetActive(bool Value)