MythTV  master
mythuispinbox.h
Go to the documentation of this file.
1 #ifndef MYTHUISPINBOX_H_
2 #define MYTHUISPINBOX_H_
3 
4 #include "mythuibuttonlist.h"
5 
17 {
18  Q_OBJECT
19  public:
20  MythUISpinBox(MythUIType *parent, const QString &name)
21  : MythUIButtonList(parent, name) {}
22  ~MythUISpinBox() override = default;
23 
24  void SetRange(int low, int high, int step, uint pageMultiple = 5);
25 
26  void SetValue(int val) override // MythUIButtonList
27  { SetValueByData(val); }
28  void SetValue(const QString &val) override // MythUIButtonList
29  { SetValueByData(val.toInt()); }
30  void AddSelection (int value, const QString &label = "");
31  QString GetValue(void) const override // MythUIButtonList
32  { return GetDataValue().toString(); }
33  int GetIntValue(void) const override // MythUIButtonList
34  { return GetDataValue().toInt(); }
35  bool keyPressEvent(QKeyEvent *event) override; // MythUIButtonList
36 
37  template <typename T>
38  typename std::enable_if<std::chrono::__is_duration<T>::value, T>::type
40  { return T(GetDataValue().toInt()); }
41  template <typename T>
42  typename std::enable_if<std::chrono::__is_duration<T>::value, void>::type
43  SetDuration(T val)
44  { return SetValueByData(static_cast<int>(val.count())); }
45 
46  protected:
47  bool ParseElement(const QString &filename, QDomElement &element,
48  bool showWarnings) override; // MythUIButtonList
49  void CopyFrom(MythUIType *base) override; // MythUIButtonList
50  void CreateCopy(MythUIType *parent) override; // MythUIButtonList
51 
52  bool MoveDown(MovementUnit unit = MoveItem, uint amount = 0) override; // MythUIButtonList
53  bool MoveUp(MovementUnit unit = MoveItem, uint amount = 0) override; // MythUIButtonList
54  void ShowEntryDialog(QString initialEntry);
55 
56  bool m_hasTemplate {false};
58  QString m_zeroTemplate;
60 
61  uint m_moveAmount {0};
62  int m_low {0};
63  int m_high {0};
64  int m_step {0};
65 };
66 
67 // Convenience Dialog to allow entry of a Spinbox value
68 
70 {
71  Q_OBJECT
72  public:
73  SpinBoxEntryDialog(MythScreenStack *parent, const char *name,
74  MythUIButtonList *parentList, QString searchText,
75  int low, int high, int step);
76  ~SpinBoxEntryDialog(void) override = default;
77 
78  bool Create(void) override; // MythScreenType
79 
80  protected slots:
81  void entryChanged(void);
82  void okClicked(void);
83 
84  protected:
86  QString m_searchText;
93  int m_low;
94  int m_high;
95  int m_step;
96 
97 
98 };
99 
100 #endif
SpinBoxEntryDialog::m_entryEdit
MythUITextEdit * m_entryEdit
Definition: mythuispinbox.h:87
MythUISpinBox::m_positiveTemplate
QString m_positiveTemplate
Definition: mythuispinbox.h:59
MythUIButtonList::SetValueByData
void SetValueByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1542
MythUISpinBox::GetValue
QString GetValue(void) const override
Definition: mythuispinbox.h:31
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
SpinBoxEntryDialog::m_high
int m_high
Definition: mythuispinbox.h:94
SpinBoxEntryDialog::m_parentList
MythUIButtonList * m_parentList
Definition: mythuispinbox.h:85
MythUIButtonList::MoveDown
virtual bool MoveDown(MovementUnit unit=MoveItem, uint amount=0)
Definition: mythuibuttonlist.cpp:2163
SpinBoxEntryDialog::m_searchText
QString m_searchText
Definition: mythuispinbox.h:86
MythScreenStack
Definition: mythscreenstack.h:16
MythScreenType::Create
virtual bool Create(void)
Definition: mythscreentype.cpp:265
SpinBoxEntryDialog::m_okButton
MythUIButton * m_okButton
Definition: mythuispinbox.h:89
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:32
MythUISpinBox::m_zeroTemplate
QString m_zeroTemplate
Definition: mythuispinbox.h:58
SpinBoxEntryDialog::m_selection
int m_selection
Definition: mythuispinbox.h:91
SpinBoxEntryDialog
Definition: mythuispinbox.h:69
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:44
MythUIButtonList::ParseElement
bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings) override
Parse the xml definition of this widget setting the state of the object accordingly.
Definition: mythuibuttonlist.cpp:2838
mythuibuttonlist.h
SpinBoxEntryDialog::m_step
int m_step
Definition: mythuispinbox.h:95
MythUISpinBox::m_negativeTemplate
QString m_negativeTemplate
Definition: mythuispinbox.h:57
MythUISpinBox::SetValue
void SetValue(int val) override
Definition: mythuispinbox.h:26
SpinBoxEntryDialog::m_okClicked
bool m_okClicked
Definition: mythuispinbox.h:92
MythUISpinBox::MythUISpinBox
MythUISpinBox(MythUIType *parent, const QString &name)
Definition: mythuispinbox.h:20
MythUIButtonList::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythuibuttonlist.cpp:2490
MythUISpinBox::GetDuration
std::enable_if< std::chrono::__is_duration< T >::value, T >::type GetDuration()
Definition: mythuispinbox.h:39
MythUISpinBox::GetIntValue
int GetIntValue(void) const override
Definition: mythuispinbox.h:33
MythUISpinBox::SetValue
void SetValue(const QString &val) override
Definition: mythuispinbox.h:28
SpinBoxEntryDialog::m_low
int m_low
Definition: mythuispinbox.h:93
SpinBoxEntryDialog::m_cancelButton
MythUIButton * m_cancelButton
Definition: mythuispinbox.h:88
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
MythUIButtonList::GetDataValue
QVariant GetDataValue() const
Definition: mythuibuttonlist.cpp:1619
MythUIButtonList::MoveUp
virtual bool MoveUp(MovementUnit unit=MoveItem, uint amount=0)
Definition: mythuibuttonlist.cpp:1945
uint
unsigned int uint
Definition: compat.h:144
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:84
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:30
MythUISpinBox
A widget for offering a range of numerical values where only the the bounding values and interval are...
Definition: mythuispinbox.h:16
MythUIButtonList::CreateCopy
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
Definition: mythuibuttonlist.cpp:2967
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:177
build_compdb.filename
filename
Definition: build_compdb.py:21
MythUISpinBox::SetDuration
std::enable_if< std::chrono::__is_duration< T >::value, void >::type SetDuration(T val)
Definition: mythuispinbox.h:43
SpinBoxEntryDialog::m_rulesText
MythUIText * m_rulesText
Definition: mythuispinbox.h:90
MythUIButtonList::CopyFrom
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
Definition: mythuibuttonlist.cpp:2976