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