MythTV master
proginfolist.cpp
Go to the documentation of this file.
1
2 // MythTV
4
5// MythFrontend
6#include "proginfolist.h"
7
13bool ProgInfoList::Create(bool focusable)
14{
15 bool err = false;
16 UIUtilE::Assign(&m_screen, m_btnList, "infolist", &err);
17 if (err)
18 return false;
19
20 m_btnList->SetVisible(true);
21
22 m_btnList->SetCanTakeFocus(focusable);
23 return true;
24}
25
31{
32 // Only focusable lists have an extra 'full' state as they can
33 // be scrolled to view it all
35 {
36 // Start showing basic info then toggle between basic/full
38 }
39 else if (m_infoVisible == kLevel1) // Toggle between off/basic
40 {
42 m_btnList->SetVisible(false);
43 return;
44 }
45 else
46 {
48 }
49
50 Clear();
51
52 m_btnList->SetVisible(true);
53}
54
55
61{
62 // Only handle event if info currently displayed
63 bool handled = (m_btnList && m_infoVisible != kNone);
65
66 if (m_btnList)
67 m_btnList->SetVisible(false);
68
69 return handled;
70}
71
72
78void ProgInfoList::CreateButton(const QString& name, const QString& value)
79{
80 if (value.isEmpty())
81 return;
82
83 auto *item = new MythUIButtonListItem(m_btnList, "");
84
85 InfoMap infoMap;
86 infoMap.insert("name", name);
87 infoMap.insert("value", value);
88
89 item->SetTextFromMap(infoMap);
90}
91
92
98{
99 Clear();
100
101 // Create buttons for each data pair
102 for (const auto & pi : std::as_const(data))
103 {
104 if (m_infoVisible != kNone && std::get<2>(pi) <= m_infoVisible)
105 CreateButton(std::get<0>(pi), std::get<1>(pi));
106 }
107
108 // Only give list focus if requested
109 if (m_btnList->CanTakeFocus())
111}
bool SetFocusWidget(MythUIType *widget=nullptr)
void SetCanTakeFocus(bool set=true)
Set whether this widget can take focus.
Definition: mythuitype.cpp:362
bool CanTakeFocus(void) const
Return if this widget can accept input focus.
Definition: mythuitype.cpp:354
virtual void SetVisible(bool visible)
void CreateButton(const QString &name, const QString &value)
Populate a buttonlist item with name & value.
VisibleLevel m_infoVisible
Info list state.
Definition: proginfolist.h:44
MythUIButtonList * m_btnList
Overlay buttonlist.
Definition: proginfolist.h:43
bool Create(bool focusable)
Initialise buttonlist from XML.
QList< DataItem > DataList
Definition: proginfolist.h:21
void Display(const DataList &data)
Build list of key:value buttons.
bool Hide(void)
Remove infolist from display.
MythScreenType & m_screen
Parent screen.
Definition: proginfolist.h:42
void Toggle(void)
Toggle infolist state. Focusable widgets toggle between Basic & Full info. Non-focusable widgets togg...
void Clear()
Definition: proginfolist.h:37
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
The info/details overlay.
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27