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