MythTV master
standardsettings.cpp
Go to the documentation of this file.
1#include "standardsettings.h"
2#include <QApplication>
3#include <QCoreApplication>
4#include <QThread>
5#include <utility>
6
15
17{
18 setting->updateButton(this);
19}
20
22{
23 QList<StandardSetting *>::const_iterator i;
24 for (i = m_children.constBegin(); i != m_children.constEnd(); ++i)
25 delete *i;
26 m_children.clear();
27
28 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
29 for (iMap = m_targets.constBegin(); iMap != m_targets.constEnd(); ++iMap)
30 {
31 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
32 delete *i;
33 }
34 m_targets.clear();
35}
36
38{
39 auto *item = new MythUIButtonListItemSetting(list, m_label);
40 item->SetData(QVariant::fromValue(this));
41 connect(this, &StandardSetting::ShouldRedraw,
43 updateButton(item);
44 return item;
45}
46
48{
49 m_enabled = enabled;
50 emit ShouldRedraw(this);
51}
52
54{
55 m_readonly = readonly;
56 emit ShouldRedraw(this);
57}
58
60{
61 m_visible = visible;
62 emit settingsChanged(this);
63}
64
66{
67 m_parent = parent;
68}
69
71{
72 if (!child)
73 return;
74
75 m_children.append(child);
76 child->setParent(this);
77}
78
80{
81 m_children.removeAll(child);
82 emit settingsChanged(this);
83}
84
85bool StandardSetting::keyPressEvent(QKeyEvent * /*e*/)
86{
87 return false;
88}
89
96{
97 item->setVisible(m_visible);
98 item->DisplayState("standard", "widgettype");
99 item->setEnabled(isEnabled());
100 item->SetText(m_label);
101 item->SetText(m_settingValue, "value");
102 item->SetText(getHelpText(), "description");
104}
105
106void StandardSetting::addTargetedChildren(const QString &value,
107 std::initializer_list<StandardSetting *> settings)
108{
109 m_targets[value].reserve(settings.size());
110 for (auto *setting : std::as_const(settings))
111 {
112 m_targets[value].append(setting);
113 setting->setParent(this);
114 }
115}
116void StandardSetting::addTargetedChild(const QString &value,
117 StandardSetting * setting)
118{
119 m_targets[value].append(setting);
120 setting->setParent(this);
121}
122
123void StandardSetting::removeTargetedChild(const QString &value,
124 StandardSetting *child)
125{
126 if (m_targets.contains(value))
127 {
128 m_targets[value].removeAll(child);
129 delete child;
130 }
131}
132
134{
135 if (m_targets.contains(value))
136 {
137 for (auto *setting : std::as_const(m_targets[value]))
138 {
139 delete setting;
140 }
141 m_targets[value].clear();
142 }
143}
144
145QList<StandardSetting *> *StandardSetting::getSubSettings()
146{
147 if (m_targets.contains(m_settingValue) &&
148 !m_targets[m_settingValue].empty())
149 return &m_targets[m_settingValue];
150 return &m_children;
151}
152
154{
155 QList<StandardSetting *> *subSettings = getSubSettings();
156 return subSettings && !subSettings->empty();
157}
158
160{
161 m_children.clear();
162}
163
165{
166 setValue(QString::number(newValue));
167}
168
169void StandardSetting::setValue(const QString &newValue)
170{
171 if (m_settingValue != newValue)
172 {
173 m_settingValue = newValue;
174 m_haveChanged = true;
175
176 emit valueChanged(newValue);
177 emit valueChanged(this);
178 }
179 emit ShouldRedraw(this);
180}
181
186{
187 if (m_haveChanged)
188 {
189 LOG(VB_GENERAL, LOG_DEBUG,
190 QString("Setting '%1' changed to %2").arg(getLabel(), getValue()));
191 return true;
192 }
193
194 //we check only the relevant children
195 QList<StandardSetting *> *children = getSubSettings();
196 if (!children)
197 return false;
198
199 QList<StandardSetting *>::const_iterator i;
200 bool haveChanged = false;
201 for (i = children->constBegin(); !haveChanged && i != children->constEnd();
202 ++i)
203 haveChanged = (*i)->haveChanged();
204
205 return haveChanged;
206}
207
209{
210 m_haveChanged = changed;
211}
212
214{
215 if (m_storage)
216 m_storage->Load();
217
218 m_haveChanged = false;
219
220 QList<StandardSetting *>::const_iterator i;
221 for (i = m_children.constBegin(); i != m_children.constEnd(); ++i)
222 (*i)->Load();
223
224 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
225 for (iMap = m_targets.constBegin(); iMap != m_targets.constEnd(); ++iMap)
226 {
227 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
228 (*i)->Load();
229 }
230}
231
233{
234 if (m_storage)
235 m_storage->Save();
236
237 //we save only the relevant children
238 QList<StandardSetting *> *children = getSubSettings();
239 if (children)
240 {
241 for (auto i = children->constBegin(); i != children->constEnd(); ++i)
242 (*i)->Save();
243 }
244
245 if (!m_haveChanged)
246 return;
247
248 m_haveChanged = false;
249 emit ChangeSaved();
250}
251
252void StandardSetting::setName(const QString &name)
253{
254 m_name = name;
255 if (m_label.isEmpty())
256 setLabel(name);
257}
258
260{
261 if (name == m_name)
262 return this;
263
264 for (auto *setting : std::as_const(*getSubSettings()))
265 {
266 StandardSetting *s = setting->byName(name);
267 if (s)
268 return s;
269 }
270 return nullptr;
271}
272
273void StandardSetting::MoveToThread(QThread *thread)
274{
275 moveToThread(thread);
276
277 QList<StandardSetting *>::const_iterator i;
278 for (i = m_children.constBegin(); i != m_children.constEnd(); ++i)
279 (*i)->MoveToThread(thread);
280
281 QMap<QString, QList<StandardSetting *> >::const_iterator iMap;
282 for (iMap = m_targets.constBegin(); iMap != m_targets.constEnd(); ++iMap)
283 {
284 for (i = (*iMap).constBegin(); i != (*iMap).constEnd(); ++i)
285 (*i)->MoveToThread(thread);
286 }
287}
288
289/******************************************************************************
290 Group Setting
291*******************************************************************************/
293{
294 if (!isEnabled())
295 return;
296
297 if (isReadOnly())
298 return;
299
300 auto *dce = new DialogCompletionEvent("leveldown", 0, "", "");
301 QCoreApplication::postEvent(screen, dce);
302}
303
305{
306 item->DisplayState("group", "widgettype");
307 item->setEnabled(isEnabled());
308 item->SetText(m_label);
309 item->SetText(m_settingValue, "value");
310 item->SetText(getHelpText(), "description");
312}
313
315{
316 setLabel(label);
317}
318
320{
321 emit clicked();
322}
323
325{
326 if (getValue() == "0")
327 {
328 // Generate a new, unique ID
329 QString querystr = "INSERT INTO " + m_table +
330 " (" + m_column + ") VALUES (0);";
331
333
334 if (!query.exec(querystr))
335 {
336 MythDB::DBError("inserting row", query);
337 return;
338 }
339 // XXX -- HACK BEGIN:
340 // lastInsertID fails with "QSqlQuery::value: not positioned on a valid
341 // record" if we get a invalid QVariant we workaround the problem by
342 // taking advantage of mysql always incrementing the auto increment
343 // pointer this breaks if someone modifies the auto increment pointer
344 //setValue(query.lastInsertId().toInt());
345
346 QVariant var = query.lastInsertId();
347
348#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
349 auto id = static_cast<QMetaType::Type>(var.type());
350#else
351 auto id = var.typeId();
352#endif
353 if (id != QMetaType::UnknownType)
354 setValue(var.toInt());
355 else
356 {
357 querystr = "SELECT MAX(" + m_column + ") FROM " +
358 m_table + ";";
359 if (query.exec(querystr) && query.next())
360 {
361 int lii = query.value(0).toInt();
362 lii = lii ? lii : 1;
363 setValue(lii);
364 }
365 else
366 {
367 LOG(VB_GENERAL, LOG_EMERG,
368 "Can't determine the Id of the last insert "
369 "QSqlQuery.lastInsertId() failed, the workaround "
370 "failed too!");
371 }
372 }
373 // XXX -- HACK END:
374 }
375}
376
377AutoIncrementSetting::AutoIncrementSetting(QString _table, QString _column) :
378 m_table(std::move(_table)), m_column(std::move(_column))
379{
380 setValue("0");
381}
382
383/******************************************************************************
384 Text Setting
385*******************************************************************************/
386
388{
389 m_passwordEcho = b;
390}
391
393{
394 if (!isEnabled())
395 return;
396
397 if (isReadOnly())
398 return;
399
400 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
401
402 auto *settingdialog =
403 new MythTextInputDialog(popupStack, getLabel(), FilterNone,
405
406 if (settingdialog->Create())
407 {
408 settingdialog->SetReturnEvent(screen, "editsetting");
409 popupStack->AddScreen(settingdialog);
410 }
411 else
412 {
413 delete settingdialog;
414 }
415}
416
418{
419 if (m_settingValue != dce->GetResultText())
420 setValue(dce->GetResultText());
421}
422
423
425{
427 item->DisplayState("textedit", "widgettype");
428}
429
430
431/******************************************************************************
432 Directory Setting
433*******************************************************************************/
434
436{
437 if (!isEnabled())
438 return;
439
440 if (isReadOnly())
441 return;
442
443 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
444
445 auto *settingdialog = new MythUIFileBrowser(popupStack, m_settingValue);
446 settingdialog->SetTypeFilter(m_typeFilter);
447 settingdialog->SetNameFilter(m_nameFilter);
448
449 if (settingdialog->Create())
450 {
451 settingdialog->SetReturnEvent(screen, "editsetting");
452 popupStack->AddScreen(settingdialog);
453 }
454 else
455 {
456 delete settingdialog;
457 }
458}
459
461{
462 if (m_settingValue != dce->GetResultText())
463 setValue(dce->GetResultText());
464}
465
467{
469 item->DisplayState("filebrowser", "widgettype");
470}
471
472
473/******************************************************************************
474 ComboBoxSetting
475*******************************************************************************/
477{
478 m_labels.clear();
479 m_values.clear();
480}
481
483{
484 if (value >= 0 && value < m_values.size())
485 {
487 m_isSet = true;
488 }
489}
490
491int MythUIComboBoxSetting::getValueIndex(const QString &value) const
492{
493 return m_values.indexOf(value);
494}
495
497{
498 int index = getValueIndex(getValue());
499 return (index >= 0) ? m_labels.at(index) : QString("");
500}
501
502void MythUIComboBoxSetting::addSelection(const QString &label, QString value,
503 bool select)
504{
505 value = value.isEmpty() ? label : value;
506 m_labels.push_back(label);
507 m_values.push_back(value);
508
509 if (select || !m_isSet)
510 {
512 if (!m_isSet)
513 m_isSet = true;
514 }
515}
516
518{
519 m_isSet = false;
520 m_labels.clear();
521 m_values.clear();
522}
523
525{
526 item->DisplayState("combobox", "widgettype");
527 item->setEnabled(isEnabled());
528 item->SetText(m_label);
529 int indexValue = m_values.indexOf(m_settingValue);
530 if (indexValue >= 0)
531 item->SetText(m_labels.value(indexValue), "value");
532 else
533 item->SetText(m_settingValue, "value");
534 item->SetText(getHelpText(), "description");
536}
537
539{
540 if (!isEnabled())
541 return;
542
543 if (isReadOnly())
544 return;
545
546 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
547
548 auto *menuPopup = new MythDialogBox(getLabel(), popupStack, "optionmenu");
549
550 if (menuPopup->Create())
551 {
552 popupStack->AddScreen(menuPopup);
553
554 //connect(menuPopup, &MythDialogBox::haveResult,
555 //this, qOverload<const QString&>(&MythUIComboBoxSetting::setValue));
556
557 menuPopup->SetReturnEvent(screen, "editsetting");
558
559 if (m_rewrite)
560 {
561 menuPopup->AddButtonV(QObject::tr("New entry"),
562 QString("NEWENTRY"),
563 false,
564 m_settingValue == "");
565 }
566 for (int i = 0; i < m_labels.size() && !m_values.empty(); ++i)
567 {
568 QString value = m_values.at(i);
569 menuPopup->AddButtonV(m_labels.at(i),
570 value,
571 false,
572 value == m_settingValue);
573 }
574 }
575 else
576 {
577 delete menuPopup;
578 }
579}
580
581void MythUIComboBoxSetting::setValue(const QString& newValue)
582{
584 m_isSet = true;
585}
586
588{
589 if (dce->GetResult() != -1)
590 {
591 if (m_rewrite && dce->GetData().toString() == "NEWENTRY")
592 {
593 MythScreenStack *popupStack =
594 GetMythMainWindow()->GetStack("popup stack");
595
596 auto *settingdialog =
597 new MythTextInputDialog(popupStack, getLabel(), FilterNone,
598 false, m_settingValue);
599
600 if (settingdialog->Create())
601 {
602 connect(settingdialog, &MythTextInputDialog::haveResult,
603 this, qOverload<const QString&>(&MythUIComboBoxSetting::setValue));
604 popupStack->AddScreen(settingdialog);
605 }
606 else
607 {
608 delete settingdialog;
609 }
610 }
611 else if (m_settingValue != dce->GetData().toString())
612 {
613 StandardSetting::setValue(dce->GetData().toString());
614 }
615 }
616}
617
618void MythUIComboBoxSetting::fillSelectionsFromDir(const QDir &dir, bool absPath)
619{
620 QFileInfoList entries = dir.entryInfoList();
621 for (const auto& fi : std::as_const(entries))
622 {
623 if (absPath)
624 addSelection( fi.absoluteFilePath() );
625 else
626 addSelection( fi.fileName() );
627 }
628}
629
631{
632 return m_labels.size();
633}
634
635/******************************************************************************
636 SpinBox Setting
637*******************************************************************************/
639 int step, int pageMultiple,
640 QString special_value_text)
641 : StandardSetting(_storage),
642 m_min(min),
643 m_max(max),
644 m_step(step),
645 m_pageMultiple(pageMultiple),
646 m_specialValueText(std::move(special_value_text))
647{
648 // We default to 0 unless 0 is out of range.
649 if (m_min > 0 || m_max < 0)
650 m_settingValue = QString::number(m_min);
651
652 // The settings pages were coded to assume a parameter true/false
653 // meaning allow_single_step. Many pages use this but it was not
654 // implemented. It is difficult to implement using the current
655 // UI widget design. So I have changed it so you can specify
656 // the size of pageup / pagedown increments as an integer instead.
657 // For compatibility with callers still using true to indicate
658 // allowing single step, the code will set the step size as 1 and
659 // the pageup / pagedown as the requested step.
660
661 if (m_pageMultiple == 1)
662 {
663 m_pageMultiple = step;
664 m_step = 1;
665 }
666 if (m_pageMultiple == 0)
667 {
668 m_pageMultiple = 5;
669 }
670}
671
673{
674 item->DisplayState("spinbox", "widgettype");
675 item->setEnabled(isEnabled());
676 item->SetText(m_label);
677 if (m_settingValue.toInt() == m_min && !m_specialValueText.isEmpty())
678 item->SetText(m_specialValueText, "value");
679 else
680 item->SetText(m_settingValue, "value");
681 item->SetText(getHelpText(), "description");
683}
684
686{
687 return m_settingValue.toInt();
688}
689
691{
692 if (!isEnabled())
693 return;
694
695 if (isReadOnly())
696 return;
697
698 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
699
700 auto *settingdialog = new MythSpinBoxDialog(popupStack, getLabel());
701
702 if (settingdialog->Create())
703 {
704 settingdialog->SetRange(m_min, m_max, m_step, m_pageMultiple);
705 if (!m_specialValueText.isEmpty())
706 settingdialog->AddSelection(m_specialValueText, m_min);
707 settingdialog->SetValue(m_settingValue);
708 settingdialog->SetReturnEvent(screen, "editsetting");
709 popupStack->AddScreen(settingdialog);
710 }
711 else
712 {
713 delete settingdialog;
714 }
715}
716
718{
719 if (m_settingValue != dce->GetResultText())
720 setValue(dce->GetResultText());
721}
722
723/******************************************************************************
724 MythUICheckBoxSetting
725*******************************************************************************/
726
728 StandardSetting(_storage)
729{
730}
731
732void MythUICheckBoxSetting::setValue(const QString &value)
733{
735 if (haveChanged())
736 emit valueChanged(value == "1");
737}
738
740{
741 StandardSetting::setValue(value ? "1" : "0");
742 if (haveChanged())
743 emit valueChanged(value);
744}
745
747{
749 item->DisplayState("checkbox", "widgettype");
750 item->setCheckable(true);
751 item->SetText("", "value");
752 if (m_settingValue == "1")
754 else
756}
757
759{
760 if (!isEnabled())
761 return;
762
763 if (isReadOnly())
764 return;
765
766 auto *dce = new DialogCompletionEvent("editsetting", 0, "", "");
767 QCoreApplication::postEvent(screen, dce);
768}
769
771{
773}
774
775/******************************************************************************
776 Standard setting dialog
777*******************************************************************************/
778
780{
781 if (m_settingsTree)
782 m_settingsTree->deleteLater();
783}
784
786{
787 if (!LoadWindowFromXML("standardsetting-ui.xml", "settingssetup", this))
788 return false;
789
790 bool error = false;
791 UIUtilE::Assign(this, m_title, "title", &error);
792 UIUtilW::Assign(this, m_groupHelp, "grouphelp", &error);
793 UIUtilE::Assign(this, m_buttonList, "settingslist", &error);
794
795 UIUtilW::Assign(this, m_selectedSettingHelp, "selectedsettinghelp");
796
797 if (error)
798 {
799 LOG(VB_GENERAL, LOG_ERR, "Theme elements missing.");
800 return false;
801 }
802
807
809
811
812 return true;
813}
814
816{
817 if (!item)
818 return;
819
820 auto *setting = item->GetData().value<StandardSetting*>();
821 if (setting && m_selectedSettingHelp)
822 {
823 disconnect(m_selectedSettingHelp);
824 m_selectedSettingHelp->SetText(setting->getHelpText());
826 }
827}
828
830{
831 auto* setting = item->GetData().value<StandardSetting*>();
832 if (setting)
833 setting->edit(this);
834}
835
837{
838 if (event->type() == DialogCompletionEvent::kEventType)
839 {
840 auto *dce = dynamic_cast<DialogCompletionEvent*>(event);
841 if (dce == nullptr)
842 return;
843 QString resultid = dce->GetId();
844
845 if (resultid == "leveldown")
846 {
847 //a GroupSetting have been clicked
848 LevelDown();
849 }
850 else if (resultid == "editsetting")
851 {
853 if (item)
854 {
855 auto *ss = item->GetData().value<StandardSetting*>();
856 if (ss)
857 ss->resultEdit(dce);
858 }
859 }
860 else if (resultid == "exit")
861 {
862 int buttonnum = dce->GetResult();
863 if (buttonnum == 0)
864 {
865 Save();
867 if (m_settingsTree)
869 }
870 else if (buttonnum == 1)
871 {
873 }
874 }
875 }
876}
877
879{
880 if (m_settingsTree)
881 {
883 m_settingsTree->MoveToThread(QApplication::instance()->thread());
884 }
885}
886
888{
890}
891
893{
894 return m_settingsTree;
895}
896
898 StandardSetting *groupSettings, StandardSetting *selectedSetting)
899{
900 if (!groupSettings)
901 return;
902
904 {
905 disconnect(m_currentGroupSetting,
906 &StandardSetting::settingsChanged, nullptr, nullptr);
908 }
909
910 m_currentGroupSetting = groupSettings;
912
914 if (m_groupHelp)
915 {
917 }
918 updateSettings(selectedSetting);
919 connect(m_currentGroupSetting,
922}
923
925{
928 return;
929
930 QList<StandardSetting *> *settings =
932 if (!settings)
933 return;
934
935 QList<StandardSetting *>::const_iterator i;
936 MythUIButtonListItem *selectedItem = nullptr;
937 for (i = settings->constBegin(); i != settings->constEnd(); ++i)
938 {
939 if ((*i)->isVisible())
940 {
941 if (selectedSetting == (*i))
942 selectedItem = (*i)->createButton(m_buttonList);
943 else
944 (*i)->createButton(m_buttonList);
945 }
946 }
947 if (selectedItem)
948 m_buttonList->SetItemCurrent(selectedItem);
950}
951
953{
954 if (m_settingsTree)
956}
957
959{
961 return;
962
964 {
967 }
968}
969
971{
973 if (item)
974 {
975 auto *ss = item->GetData().value<StandardSetting*>();
976 if (ss && ss->haveSubSettings() && ss->isEnabled())
978 }
979}
980
982{
984 {
985 QString label = tr("Exit ?");
986
987 MythScreenStack *popupStack =
988 GetMythMainWindow()->GetStack("popup stack");
989
990 auto * menuPopup = new MythDialogBox(label, popupStack, "exitmenu");
991
992 if (menuPopup->Create())
993 {
994 popupStack->AddScreen(menuPopup);
995
996 menuPopup->SetReturnEvent(this, "exit");
997
998 menuPopup->AddButton(tr("Save then Exit"));
999 menuPopup->AddButton(tr("Exit without saving changes"));
1000 menuPopup->AddButton(tr("Cancel"));
1001 }
1002 else
1003 {
1004 delete menuPopup;
1005 }
1006 }
1007 else
1008 {
1010 }
1011}
1012
1013static QKeyEvent selectEvent
1014 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,"SELECT"));
1015static QKeyEvent deleteEvent
1016 (QKeyEvent(QEvent::KeyPress,0,Qt::NoModifier,"DELETE"));
1017
1019{
1020 QStringList actions;
1021
1022 bool handled = m_buttonList->keyPressEvent(e);
1023 if (handled)
1024 return true;
1025
1026 handled = GetMythMainWindow()->TranslateKeyPress("Global", e, actions);
1027
1028 //send the key to the selected Item first
1030 if (item)
1031 {
1032 auto *ss = item->GetData().value<StandardSetting*>();
1033 if (ss)
1034 handled = ss->keyPressEvent(e);
1035 }
1036 if (handled)
1037 return true;
1038
1039 for (int i = 0; i < actions.size() && !handled; i++)
1040 {
1041 const QString& action = actions[i];
1042 handled = true;
1043
1044 if (action == "LEFT")
1045 {
1048 Close();
1049 else
1050 LevelUp();
1051 }
1052 else if (action == "RIGHT")
1053 {
1054 LevelDown();
1055 }
1056 else if (action == "EDIT")
1057 {
1059 }
1060 else if (action == "DELETE")
1061 {
1062 deleteEntry();
1063 }
1064 else
1065 {
1066 handled = MythScreenType::keyPressEvent(e);
1067 }
1068 }
1069
1070 return handled;
1071}
1072
1074{
1076 if (!item)
1077 return;
1078
1079 auto *source = item->GetData().value<GroupSetting*>();
1080 if (!source)
1081 return;
1082 // m_title->GetText() for screen title
1083 auto *menu = new MythMenu(source->getLabel(), this, "mainmenu");
1084 menu->AddItem(tr("Edit"), &StandardSettingDialog::editEntry);
1085 if (source->canDelete())
1086 menu->AddItem(tr("Delete"), &StandardSettingDialog::deleteSelected);
1087
1088 MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
1089
1090 auto *menuPopup = new MythDialogBox(menu, popupStack, "menudialog");
1091 menuPopup->SetReturnEvent(this, "mainmenu");
1092
1093 if (menuPopup->Create())
1094 popupStack->AddScreen(menuPopup);
1095 else
1096 delete menuPopup;
1097}
1098
1100{
1102}
1103
1105{
1107}
1108
1110{
1112 if (!item)
1113 return;
1114
1115 auto *source = item->GetData().value<GroupSetting*>();
1116 if (!source)
1117 return;
1118
1119 if (source->canDelete())
1120 {
1121 QString message = tr("Do you want to delete the '%1' entry?")
1122 .arg(source->getLabel());
1124 }
1125}
1126
1128{
1129 if (ok)
1130 {
1132 if (!item)
1133 return;
1134 auto *source = item->GetData().value<GroupSetting*>();
1135 if (!source)
1136 return;
1137 source->deleteEntry();
1138// m_settingsTree->removeChild(source);
1139 source->getParent()->removeChild(source);
1140 m_buttonList->RemoveItem(item);
1141 }
1142
1143}
AutoIncrementSetting(QString _table, QString _column)
void Save(void) override
void edit(MythScreenType *screen) override
ButtonStandardSetting(const QString &label)
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
Definition: mythdialogbox.h:41
static const Type kEventType
Definition: mythdialogbox.h:56
virtual void applyChange()
virtual void deleteEntry(void)
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 ...
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:128
QVariant value(int i) const
Definition: mythdbcon.h:204
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:618
QVariant lastInsertId()
Return the id of the last inserted row.
Definition: mythdbcon.cpp:935
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:812
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:550
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:226
Basic menu dialog, message and a list of options.
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythScreenStack * GetStack(const QString &Stackname)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Screen in which all other widgets are contained and rendered.
void LoadInBackground(const QString &message="")
void BuildFocusList(void)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
virtual void Close()
Dialog prompting the user to enter a number using a spin box.
Dialog prompting the user to enter a text string.
void haveResult(QString)
void ShouldUpdate(StandardSetting *setting)
void setVisible(bool flag)
void setEnabled(bool flag)
void setCheckable(bool flag)
void DisplayState(const QString &state, const QString &name)
void setDrawArrow(bool flag)
void setChecked(CheckState state)
void SetText(const QString &text, const QString &name="", const QString &state="")
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
MythUIButtonListItem * GetItemCurrent() const
void SetItemCurrent(MythUIButtonListItem *item)
void RemoveItem(MythUIButtonListItem *item)
void Reset() override
Reset the widget to it's original state, should not reset changes made by the theme.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void itemClicked(MythUIButtonListItem *item)
void itemSelected(MythUIButtonListItem *item)
void setValue(const QString &newValue) override
void resultEdit(DialogCompletionEvent *dce) 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 ...
MythUICheckBoxSetting(Storage *_storage=nullptr)
void edit(MythScreenType *screen) override
virtual int size(void) const
QVector< QString > m_labels
void addSelection(const QString &label, QString value=QString(), bool select=false)
QString getValueLabel(void) const
void edit(MythScreenType *screen) override
void fillSelectionsFromDir(const QDir &dir, bool absPath=true)
QVector< QString > m_values
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 setValue(int value) override
int getValueIndex(const QString &value) const
void resultEdit(DialogCompletionEvent *dce) 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 ...
void edit(MythScreenType *screen) override
void resultEdit(DialogCompletionEvent *dce) override
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 ...
void resultEdit(DialogCompletionEvent *dce) override
MythUISpinBoxSetting(Storage *_storage, int min, int max, int step, int pageMultiple=8, QString special_value_text=QString())
void resultEdit(DialogCompletionEvent *dce) 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 ...
void edit(MythScreenType *screen) override
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:115
StandardSetting * m_currentGroupSetting
bool Create(void) override
void settingClicked(MythUIButtonListItem *item)
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
void deleteEntryConfirmed(bool ok)
void settingSelected(MythUIButtonListItem *item)
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
void Close(void) override
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void updateSettings(StandardSetting *selectedSetting=nullptr)
MythUIButtonList * m_buttonList
void customEvent(QEvent *event) override
GroupSetting * m_settingsTree
MythUIText * m_selectedSettingHelp
void setCurrentGroupSetting(StandardSetting *groupSettings, StandardSetting *selectedSetting=nullptr)
GroupSetting * GetGroupSettings(void) const
void ShowMenu(void) override
virtual void addChild(StandardSetting *child)
virtual void Save(void)
StandardSetting * m_parent
void helpTextChanged(const QString &newValue)
QString getHelpText(void) const
virtual void Load(void)
virtual void setName(const QString &name)
void MoveToThread(QThread *thread)
virtual void Open(void)
bool isEnabled() const
virtual void setReadOnly(bool readonly)
void addTargetedChild(const QString &value, StandardSetting *setting)
virtual bool haveSubSettings()
virtual void clearSettings()
void settingsChanged(StandardSetting *selectedSetting=nullptr)
virtual void updateButton(MythUIButtonListItem *item)
This method is called whenever the UI need to reflect a change Reimplement this If you widget need a ...
QString getLabel(void) const
StandardSetting * getParent() const
virtual void Close(void)
void addTargetedChildren(const QString &value, std::initializer_list< StandardSetting * > settings)
virtual void removeChild(StandardSetting *child)
virtual void edit(MythScreenType *screen)=0
void ShouldRedraw(StandardSetting *setting)
void setVisible(bool visible)
StandardSetting * byName(const QString &name)
virtual QList< StandardSetting * > * getSubSettings()
bool haveChanged()
Return true if the setting have changed or any of its children.
QMap< QString, QList< StandardSetting * > > m_targets
virtual void resultEdit(DialogCompletionEvent *dce)=0
virtual void setValue(const QString &newValue)
MythUIButtonListItem * createButton(MythUIButtonList *list)
void removeTargetedChild(const QString &value, StandardSetting *child)
~StandardSetting() override
virtual bool keyPressEvent(QKeyEvent *event)
QList< StandardSetting * > m_children
bool isReadOnly() const
void clearTargetedSettings(const QString &value)
void valueChanged(const QString &newValue)
virtual QString getValue(void) const
virtual void setEnabled(bool enabled)
void setParent(StandardSetting *parent)
virtual void setLabel(QString str)
void setChanged(bool changed)
virtual void Load(void)=0
virtual void Save(void)=0
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMainWindow * GetMythMainWindow(void)
static MythThemedMenu * menu
@ FilterNone
def error(message)
Definition: smolt.py:409
STL namespace.
static QKeyEvent deleteEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"DELETE"))
static QKeyEvent selectEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"SELECT"))
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27