MythTV  master
mythuistatetype.h
Go to the documentation of this file.
1 #ifndef MYTHUI_STATETYPE_H_
2 #define MYTHUI_STATETYPE_H_
3 
4 #include <QString>
5 #include <QMap>
6 
7 #include "mythuicomposite.h"
8 
9 class MythImage;
10 
23 {
24  public:
25  enum StateType { None = 0, Off, Half, Full }; // Can be used for tri-state checks, two state toggles, etc.
26 
27  MythUIStateType(MythUIType *parent, const QString &name);
28  ~MythUIStateType() = default;
29 
30  void SetShowEmpty(bool showempty) { m_ShowEmpty = showempty; }
31 
32  bool AddImage(const QString &name, MythImage *image);
33  bool AddImage(StateType type, MythImage *image);
34 
35  bool AddObject(const QString &name, MythUIType *object);
36  bool AddObject(StateType type, MythUIType *object);
37 
38  bool DisplayState(const QString &name);
39  bool DisplayState(StateType type);
40 
41  MythUIType* GetCurrentState() { return m_CurrentState; }
42  MythUIType* GetState(const QString &name);
43  MythUIType* GetState(StateType state);
44 
45  void Reset(void) override; // MythUIType
46  void Clear(void);
47 
48  void EnsureStateLoaded(const QString &name);
49  void EnsureStateLoaded(StateType type);
50 
51  void LoadNow(void) override; // MythUIType
52  void RecalculateArea(bool recurse = true) override; // MythUIType
53 
54  void SetTextFromMap(const InfoMap &infoMap) override; // MythUIComposite
55 
56  protected:
57  bool ParseElement(const QString &filename, QDomElement &element,
58  bool showWarnings) override; // MythUIType
59  void CopyFrom(MythUIType *base) override; // MythUIType
60  void CreateCopy(MythUIType *parent) override; // MythUIType
61  void Finalize(void) override; // MythUIType
62  virtual void AdjustDependence(void);
63 
64  QMap<QString, MythUIType *> m_ObjectsByName;
65  QMap<int, MythUIType *> m_ObjectsByState;
66 
67  MythUIType *m_CurrentState {nullptr};
69 
70  bool m_ShowEmpty {true};
71 
72  friend class MythUIButtonList;
73 };
74 
75 #endif
This widget is used for grouping other widgets for display when a particular named state is called.
The base class on which all widgets and screens are based.
Definition: mythuitype.h:63
MythRect m_ParentArea
virtual void CreateCopy(MythUIType *parent)
Copy the state of this widget to the one given, it must be of the same type.
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
#define GetState(a, b)
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:17
virtual void SetTextFromMap(const InfoMap &infoMap)
virtual void RecalculateArea(bool recurse=true)
const char * name
Definition: ParseText.cpp:328
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
virtual void LoadNow(void)
Cause images in this and child widgets to be loaded.
virtual void Reset(void)
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitype.cpp:69
#define MUI_PUBLIC
Definition: mythuiexp.h:9
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
QMap< int, MythUIType * > m_ObjectsByState
#define Clear(a)
MythUIType * GetCurrentState()
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
QMap< QString, MythUIType * > m_ObjectsByName
void SetShowEmpty(bool showempty)
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.