MythTV  master
proginfolist.cpp
Go to the documentation of this file.
1 
2 #include "mythcoreutil.h"
3 #include "mythdate.h"
4 #include "proginfolist.h"
5 
11 bool ProgInfoList::Create(bool focusable)
12 {
13  bool err = false;
14  UIUtilE::Assign(&m_screen, m_btnList, "infolist", &err);
15  if (err)
16  return false;
17 
18  m_btnList->SetVisible(true);
19 
20  m_btnList->SetCanTakeFocus(focusable);
21  return true;
22 }
23 
29 {
30  // Only focusable lists have an extra 'full' state as they can
31  // be scrolled to view it all
32  if (m_btnList->CanTakeFocus())
33  {
34  // Start showing basic info then toggle between basic/full
36  }
37  else if (m_infoVisible == kLevel1) // Toggle between off/basic
38  {
40  m_btnList->SetVisible(false);
41  return;
42  }
43  else
45 
46  Clear();
47 
48  m_btnList->SetVisible(true);
49 }
50 
51 
57 {
58  // Only handle event if info currently displayed
59  bool handled = (m_btnList && m_infoVisible != kNone);
61 
62  if (m_btnList)
63  m_btnList->SetVisible(false);
64 
65  return handled;
66 }
67 
68 
74 void ProgInfoList::CreateButton(const QString& name, const QString& value)
75 {
76  if (value.isEmpty())
77  return;
78 
79  auto *item = new MythUIButtonListItem(m_btnList, "");
80 
81  InfoMap infoMap;
82  infoMap.insert("name", name);
83  infoMap.insert("value", value);
84 
85  item->SetTextFromMap(infoMap);
86 }
87 
88 
94 {
95  Clear();
96 
97  // Create buttons for each data pair
98  for (const auto & pi : qAsConst(data))
99  {
100  if (m_infoVisible != kNone && std::get<2>(pi) <= m_infoVisible)
101  CreateButton(std::get<0>(pi), std::get<1>(pi));
102  }
103 
104  // Only give list focus if requested
105  if (m_btnList->CanTakeFocus())
107 }
ProgInfoList::kNone
@ kNone
Definition: proginfolist.h:17
MythUIType::CanTakeFocus
bool CanTakeFocus(void) const
Return if this widget can accept input focus.
Definition: mythuitype.cpp:334
ProgInfoList::kLevel1
@ kLevel1
Definition: proginfolist.h:17
mythcoreutil.h
MythUIType::SetCanTakeFocus
void SetCanTakeFocus(bool set=true)
Set whether this widget can take focus.
Definition: mythuitype.cpp:342
proginfolist.h
The info/details overlay.
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
MythUIButtonListItem
Definition: mythuibuttonlist.h:28
mythdate.h
ProgInfoList::Create
bool Create(bool focusable)
Initialise buttonlist from XML.
Definition: proginfolist.cpp:11
ProgInfoList::Toggle
void Toggle(void)
Toggle infolist state. Focusable widgets toggle between Basic & Full info. Non-focusable widgets togg...
Definition: proginfolist.cpp:28
MythScreenType::SetFocusWidget
bool SetFocusWidget(MythUIType *widget=nullptr)
Definition: mythscreentype.cpp:117
ProgInfoList::kLevel2
@ kLevel2
Definition: proginfolist.h:17
ProgInfoList::m_infoVisible
VisibleLevel m_infoVisible
Info list state.
Definition: proginfolist.h:44
ProgInfoList::Display
void Display(const DataList &data)
Build list of key:value buttons.
Definition: proginfolist.cpp:93
UIUtilDisp::Assign
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
ProgInfoList::DataList
QList< DataItem > DataList
Definition: proginfolist.h:21
ProgInfoList::CreateButton
void CreateButton(const QString &name, const QString &value)
Populate a buttonlist item with name & value.
Definition: proginfolist.cpp:74
MythUIType::SetVisible
virtual void SetVisible(bool visible)
Definition: mythuitype.cpp:1085
ProgInfoList::Clear
void Clear()
Definition: proginfolist.h:37
ProgInfoList::m_btnList
MythUIButtonList * m_btnList
Overlay buttonlist.
Definition: proginfolist.h:43
ProgInfoList::Hide
bool Hide(void)
Remove infolist from display.
Definition: proginfolist.cpp:56
ProgInfoList::m_screen
MythScreenType & m_screen
Parent screen.
Definition: proginfolist.h:42