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 
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  DataList::const_iterator it = data.begin();
99  for (; it != data.end(); ++it)
100  {
101  if (m_infoVisible != kNone && std::get<2>(*it) <= m_infoVisible)
102  CreateButton(std::get<0>(*it), std::get<1>(*it));
103  }
104 
105  // Only give list focus if requested
106  if (m_btnList->CanTakeFocus())
108 }
MythScreenType & m_screen
Parent screen.
Definition: proginfolist.h:42
VisibleLevel m_infoVisible
Info list state.
Definition: proginfolist.h:44
bool Create(bool focusable)
Initialise buttonlist from XML.
void Display(const DataList &data)
Build list of key:value buttons.
void Toggle(void)
Toggle infolist state. Focusable widgets toggle between Basic & Full info. Non-focusable widgets togg...
virtual void SetVisible(bool visible)
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
QList< DataItem > DataList
Definition: proginfolist.h:21
The info/details overlay.
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
const char * name
Definition: ParseText.cpp:328
void Clear()
Definition: proginfolist.h:37
bool CanTakeFocus(void) const
Return if this widget can accept input focus.
Definition: mythuitype.cpp:336
MythUIButtonList * m_btnList
Overlay buttonlist.
Definition: proginfolist.h:43
void CreateButton(const QString &, const QString &)
Populate a buttonlist item with name & value.
bool Hide(void)
Remove infolist from display.
bool SetFocusWidget(MythUIType *widget=nullptr)
void SetTextFromMap(const InfoMap &infoMap, const QString &state="")
void SetCanTakeFocus(bool set=true)
Set whether this widget can take focus.
Definition: mythuitype.cpp:344