MythTV  master
mythuiutils.h
Go to the documentation of this file.
1 #ifndef MYTHUIUTILS_H_
2 #define MYTHUIUTILS_H_
3 
4 #include <cstdlib>
5 
6 #include "mythuiexp.h"
7 
8 class QString;
9 class MythUIType;
10 
12 {
13  static bool Child(const MythUIType *container, const QString &child_name);
14  static bool Container(const QString &child_name);
15 };
16 
18 {
19  static bool Child(const MythUIType *container, const QString &child_name);
20  static bool Container(const QString &child_name);
21 };
22 
23 template <typename ErrorDispatch = ETPrintWarning>
24 struct UIUtilDisp
25 {
26  template <typename ContainerType, typename UIType>
27  static bool Assign(ContainerType *container, UIType *&item,
28  const QString &name, bool *err = nullptr)
29  {
30  if (!container)
31  {
32  if (err)
33  *err |= ErrorDispatch::Container(name);
34  else
35  ErrorDispatch::Container(name);
36  return true;
37  }
38 
39  item = dynamic_cast<UIType *>(container->GetChild(name));
40 
41  if (item)
42  return false;
43 
44  if (err)
45  *err |= ErrorDispatch::Child(container, name);
46  else
47  ErrorDispatch::Child(container, name);
48  return true;
49  }
50 };
51 
54 
55 #endif
The base class on which all widgets and screens are based.
Definition: mythuitype.h:63
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
Definition: mythuiutils.h:27
const char * name
Definition: ParseText.cpp:328
#define MUI_PUBLIC
Definition: mythuiexp.h:9