2 #include <QApplication> 3 #include <QCoreApplication> 22 m_enabled(
true), m_label(
""), m_helptext(
""), m_visible(
true),
31 QList<StandardSetting *>::const_iterator i;
36 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
39 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
49 item->
SetData(qVariantFromValue(
this));
110 std::initializer_list<StandardSetting *> settings)
112 m_targets[value].reserve(settings.size());
159 return subSettings && subSettings->size() > 0;
169 setValue(QString::number(newValue));
192 LOG(VB_GENERAL, LOG_DEBUG,
193 QString(
"Setting %1 changed to %2").arg(
getLabel())
203 QList<StandardSetting *>::const_iterator i;
205 for (i = children->constBegin(); !
haveChanged && i != children->constEnd();
224 QList<StandardSetting *>::const_iterator i;
228 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
231 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
245 for (
auto i = children->constBegin(); i != children->constEnd(); ++i)
279 moveToThread(thread);
281 QList<StandardSetting *>::const_iterator i;
283 (*i)->MoveToThread(thread);
285 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
288 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
289 (*i)->MoveToThread(thread);
303 QCoreApplication::postEvent(screen, dce);
331 QString querystr =
"INSERT INTO " +
m_table +
336 if (!query.
exec(querystr))
354 querystr =
"SELECT MAX(" +
m_column +
") FROM " +
356 if (query.
exec(querystr) && query.
next())
358 int lii = query.
value(0).toInt();
363 LOG(VB_GENERAL, LOG_EMERG,
364 "Can't determine the Id of the last insert " 365 "QSqlQuery.lastInsertId() failed, the workaround " 374 m_table(_table), m_column(_column)
404 if (settingdialog->
Create())
410 delete settingdialog;
434 m_typeFilter = (QDir::AllDirs | QDir::Drives | QDir::Files |
435 QDir::Readable | QDir::Writable | QDir::Executable);
452 if (settingdialog->
Create())
458 delete settingdialog;
499 if (value >= 0 && value <
m_values.size())
514 return (index >= 0) ?
m_labels.at(index) : QString(
"");
520 value = value.isEmpty() ? label : value;
573 menuPopup->
AddButton(QObject::tr(
"New entry"),
609 if (settingdialog->
Create())
611 connect(settingdialog, SIGNAL(haveResult(QString)),
616 delete settingdialog;
625 QFileInfoList il = dir.entryInfoList();
627 for (QFileInfoList::Iterator it = il.begin();
649 int step,
int pageMultiple,
650 const QString &special_value_text)
655 m_pageMultiple(pageMultiple),
656 m_special_value_text(special_value_text)
710 if (settingdialog->
Create())
720 delete settingdialog;
776 QCoreApplication::postEvent(screen, dce);
792 m_buttonList(nullptr),
794 m_groupHelp(nullptr),
795 m_selectedSettingHelp(nullptr),
796 m_menuPopup(nullptr),
797 m_settingsTree(groupSettings),
798 m_currentGroupSetting(nullptr),
823 LOG(VB_GENERAL, LOG_ERR,
"Theme elements missing.");
863 QString resultid = dce->
GetId();
865 if (resultid ==
"leveldown")
870 else if (resultid ==
"editsetting")
880 else if (resultid ==
"exit")
890 else if (buttonnum == 1)
948 QList<StandardSetting *> *settings =
953 QList<StandardSetting *>::const_iterator i;
955 for (i = settings->constBegin(); i != settings->constEnd(); ++i)
957 if ((*i)->isVisible())
959 if (selectedSetting == (*i))
1003 QString label = tr(
"Exit ?");
1017 menuPopup->
AddButton(tr(
"Save then Exit"));
1018 menuPopup->
AddButton(tr(
"Exit without saving changes"));
1029 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,
"SELECT"));
1031 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,
"DELETE"));
1035 QStringList actions;
1054 for (
int i = 0; i < actions.size() && !handled; i++)
1056 QString
action = actions[i];
1067 else if (
action ==
"RIGHT")
1069 else if (
action ==
"EDIT")
1073 else if (
action ==
"DELETE")
1131 QString message = tr(
"Do you want to delete the '%1' entry?")
MythUITextEditSetting(Storage *_storage=nullptr)
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static QKeyEvent deleteEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"DELETE"))
void setParent(StandardSetting *parent)
MythUIFileBrowserSetting(Storage *_storage)
QString getValueLabel(void) const
virtual bool canDelete(void)
void AddSelection(QString label, int value)
virtual bool keyPressEvent(QKeyEvent *)
virtual ~StandardSettingDialog()
void edit(MythScreenType *screen) override
VERBOSE_PREAMBLE Most true
virtual void clearSettings()
void SetPasswordEcho(bool b)
bool TranslateKeyPress(const QString &context, QKeyEvent *e, QStringList &actions, bool allowJumps=true)
Get a list of actions for a keypress in the given context.
void edit(MythScreenType *screen) override
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
void MoveToThread(QThread *thread)
static void error(const char *str,...)
StandardSetting * getParent() const
void settingsChanged(StandardSetting *selectedSetting=nullptr)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
virtual void setName(const QString &str)
Basic menu dialog, message and a list of options.
void addSelection(const QString &label, QString value=QString(), bool select=false)
void SetReturnEvent(QObject *retobject, const QString &resultid)
QVector< QString > m_labels
void edit(MythScreenType *screen) override
virtual bool haveSubSettings()
QVector< QString > m_values
virtual void SetText(const QString &text)
bool Create(void) override
QString getLabel(void) const
StandardSetting(Storage *_storage=nullptr)
void setChanged(bool changed)
MythScreenStack * GetStack(const QString &stackname)
MythUIText * m_selectedSettingHelp
int getValueIndex(const QString &value) const
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
void clearTargetedSettings(const QString &value)
void settingSelected(MythUIButtonListItem *item)
static MythThemedMenu * menu
void customEvent(QEvent *event) override
StandardSettingDialog(MythScreenStack *parent, const char *name, GroupSetting *groupSettings=nullptr)
void BuildFocusList(void)
virtual void updateButton(MythUIButtonListItem *item)
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
MythUIComboBoxSetting(Storage *_storage=nullptr, bool rw=false)
Create a Setting Widget to select the value from a list.
void settingClicked(MythUIButtonListItem *item)
void resultEdit(DialogCompletionEvent *dce) override
virtual QString getValue(void) const
void resultEdit(DialogCompletionEvent *dce) override
void SetNameFilter(QStringList filter)
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
QVariant value(int i) const
void AddButton(const QString &title, QVariant data=0, bool newMenu=false, bool setCurrent=false)
void edit(MythScreenType *screen) override
bool Create(void) override
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
QVariant lastInsertId()
Return the id of the last inserted row.
void ShouldRedraw(StandardSetting *)
void setValue(int value) override
QString m_special_value_text
virtual int size(void) const
virtual void setLabel(QString str)
StandardSetting * m_currentGroupSetting
bool keyPressEvent(QKeyEvent *) override
Key event handler.
void SetReturnEvent(QObject *retobject, const QString &resultid)
virtual void edit(MythScreenType *screen)=0
bool haveChanged()
Return true if the setting have changed or any of its children.
void SetTypeFilter(QDir::Filters filter)
MythUIButtonList * m_buttonList
virtual void applyChange()
void resultEdit(DialogCompletionEvent *dce) override
virtual void setEnabled(bool enabled)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
void fillSelectionsFromDir(const QDir &dir, bool absPath=true)
QDir::Filters m_typeFilter
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
virtual void Save(void)=0
StandardSetting * m_parent
virtual void Load(void)=0
QList< StandardSetting * > m_children
virtual QList< StandardSetting * > * getSubSettings()
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
virtual void addChild(StandardSetting *child)
MythMainWindow * GetMythMainWindow(void)
MythUIButtonListItem * createButton(MythUIButtonList *list)
void deleteEntryConfirmed(bool ok)
void resultEdit(DialogCompletionEvent *dce) override
virtual void resultEdit(DialogCompletionEvent *dce)=0
Dialog prompting the user to enter a text string.
void setVisible(bool visible)
MythUISpinBoxSetting(Storage *_storage, int min, int max, int step, int pageMultiple=8, const QString &special_value_text=QString())
bool keyPressEvent(QKeyEvent *) override
Key event handler.
#define LOG(_MASK_, _LEVEL_, _STRING_)
bool Create(void) override
void deleteSelected(void)
void addTargetedChildren(const QString &value, std::initializer_list< StandardSetting * > settings)
void updateSettings(StandardSetting *selectedSetting=nullptr)
void SetReturnEvent(QObject *retobject, const QString &resultid)
void edit(MythScreenType *screen) override
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
GroupSetting * m_settingsTree
GroupSetting * GetGroupSettings(void) const
void removeTargetedChild(const QString &value, StandardSetting *child)
void setValue(const QString &) override
void edit(MythScreenType *screen) override
Dialog prompting the user to enter a number using a spin box.
void ShowMenu(void) override
QMap< QString, QList< StandardSetting * > > m_targets
void SetValue(const QString &value)
Can be called only after MythSpinBoxDialog::Create() return successfully The range need to be set bef...
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
MythUICheckBoxSetting(Storage *_storage=nullptr)
static void DBError(const QString &where, const MSqlQuery &query)
void resultEdit(DialogCompletionEvent *dce) override
Screen in which all other widgets are contained and rendered.
virtual void deleteEntry(void)
void Close(void) override
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
static QKeyEvent selectEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"SELECT"))
void addTargetedChild(const QString &value, StandardSetting *setting)
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
virtual void setValue(const QString &newValue)
virtual ~StandardSetting()
bool Create(void) override
void setCurrentGroupSetting(StandardSetting *groupSettings, StandardSetting *selectedSetting=nullptr)
void SetReturnEvent(QObject *retobject, const QString &resultid)
QString getHelpText(void) const
StandardSetting * byName(const QString &name)
virtual void removeChild(StandardSetting *child)
void updateButton(MythUIButtonListItem *item) override
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
void LoadInBackground(QString message="")
bool Create(void) override
AutoIncrementSetting(QString _table, QString _column)
void valueChanged(const QString &)