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  std::enable_if_t<std::chrono::__is_duration<T>::value, T>
40  { return T(GetDataValue().toInt()); }
41  template <typename T>
42  std::enable_if_t<std::chrono::__is_duration<T>::value, void>
43  SetDuration(T val)
44  { 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;
87  MythUITextEdit *m_entryEdit { nullptr };
88  MythUIButton *m_cancelButton { nullptr };
89  MythUIButton *m_okButton { nullptr };
90  MythUIText *m_rulesText { nullptr };
92  bool m_okClicked { false };
93  int m_low;
94  int m_high;
95  int m_step;
96 
97 
98 };
99 
100 #endif
MythUISpinBox::m_positiveTemplate
QString m_positiveTemplate
Definition: mythuispinbox.h:59
MythUIButtonList::SetValueByData
void SetValueByData(const QVariant &data)
Definition: mythuibuttonlist.cpp:1566
MythUISpinBox::SetDuration
std::enable_if_t< std::chrono::__is_duration< T >::value, void > SetDuration(T val)
Definition: mythuispinbox.h:43
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:2193
SpinBoxEntryDialog::m_searchText
QString m_searchText
Definition: mythuispinbox.h:86
MythScreenStack
Definition: mythscreenstack.h:16
MythScreenType::Create
virtual bool Create(void)
Definition: mythscreentype.cpp:263
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:34
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:45
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:2884
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
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:2528
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
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
MythUIButtonList::GetDataValue
QVariant GetDataValue() const
Definition: mythuibuttonlist.cpp:1643
MythUIButtonList::MoveUp
virtual bool MoveUp(MovementUnit unit=MoveItem, uint amount=0)
Definition: mythuibuttonlist.cpp:1969
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:85
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
MythUISpinBox::GetDuration
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDuration()
Definition: mythuispinbox.h:39
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:3013
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:191
build_compdb.filename
filename
Definition: build_compdb.py:21
uint
unsigned int uint
Definition: freesurround.h:24
MythUIButtonList::CopyFrom
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
Definition: mythuibuttonlist.cpp:3022