MythTV  master
mythuiguidegrid.h
Go to the documentation of this file.
1 #ifndef MYTHUIGUIDEGRID_H_
2 #define MYTHUIGUIDEGRID_H_
3 
4 #include <utility>
5 
6 // QT
7 #include <QBrush>
8 #include <QPen>
9 #include <QPixmap>
10 
11 // MythDB
12 #include "mythuiexp.h"
13 
14 // MythUI
15 #include "mythuitype.h"
16 #include "mythuiimage.h"
17 
18 #define ARROWIMAGESIZE 4
19 #define RECSTATUSSIZE 8
20 
21 
22 // max number of channels to display in the guide grid
23 #define MAX_DISPLAY_CHANS 40
24 
25 // max number of 5 minute time slots to show in guide grid (48 = 4hrs)
26 #define MAX_DISPLAY_TIMES 48
27 
28 #define GridTimeNormal 0
29 #define GridTimeStartsBefore 1
30 #define GridTimeEndsAfter 2
31 
32 class MythFontProperties;
33 
42 {
43  Q_OBJECT
44  public:
45  MythUIGuideGrid(MythUIType *parent, const QString &name);
46  ~MythUIGuideGrid() override;
47 
48  void DrawSelf(MythPainter *p, int xoffset, int yoffset,
49  int alphaMod, QRect clipRect) override; // MythUIType
50 
51  enum FillType { Alpha = 10, Dense, Eco, Solid };
52 
53  bool isVerticalLayout(void) const { return m_verticalLayout; }
54  int getChannelCount(void) const { return m_channelCount; }
55  int getTimeCount(void) const { return m_timeCount; }
56 
57  void SetCategoryColors(const QMap<QString, QString> &catColors);
58 
59  void SetTextOffset(const QPoint to) { m_textOffset = to; }
60  void SetArrow(int direction, const QString &file);
61  void LoadImage(int recType, const QString &file);
62  void SetProgramInfo(int row, int col, QRect area,
63  const QString &title, const QString &genre,
64  int arrow, int recType, int recStat, bool selected);
65  void ResetData();
66  void ResetRow(int row);
67  void SetProgPast(int ppast);
68  void SetMultiLine(bool multiline);
69 
70  QPoint GetRowAndColumn(QPoint position);
71 
72  protected:
73  void Finalize(void) override; // MythUIType
74  bool ParseElement(const QString &filename, QDomElement &element,
75  bool showWarnings) override; // MythUIType
76  void CopyFrom(MythUIType *base) override; // MythUIType
77  void CreateCopy(MythUIType *parent) override; // MythUIType
78 
79  static bool parseDefaultCategoryColors(QMap<QString, QString> &catColors);
80 
81  private:
82 
83  class UIGTCon
84  {
85  public:
86  UIGTCon() { m_arrow = GridTimeNormal; m_recType = m_recStat = 0; };
87  UIGTCon(const QRect drawArea, QString title,
88  const QString &category, int arrow, int recType, int recStat) :
89  m_drawArea(drawArea), m_title(std::move(title)),
90  m_category(category.trimmed()), m_arrow(arrow),
91  m_recType(recType), m_recStat(recStat)
92  {}
93 
94  UIGTCon(const UIGTCon &o) = default;
95  UIGTCon& operator=(const UIGTCon&) = default;
96 
97  QRect m_drawArea;
98  QString m_title;
99  QString m_category;
101  int m_arrow;
104  };
105 
106  void drawBackground(MythPainter *p, int xoffset, int yoffset,
107  UIGTCon *data, int alphaMod);
108  void drawBox(MythPainter *p, int xoffset, int yoffset, UIGTCon *data,
109  const QColor &color, int alphaMod);
110  void drawText(MythPainter *p, int xoffset, int yoffset, UIGTCon *data,
111  int alphaMod);
112  void drawRecDecoration(MythPainter *p, int xoffset, int yoffset,
113  UIGTCon *data, int alphaMod);
114  void drawCurrent(MythPainter *p, int xoffset, int yoffset, UIGTCon *data,
115  int alphaMod);
116 
117  static QColor calcColor(const QColor &color, int alpha);
118 
119  QList<UIGTCon*> *m_allData {nullptr};
121 
122  std::array<MythUIImage*,RECSTATUSSIZE> m_recImages {};
123  std::array<MythUIImage*,ARROWIMAGESIZE> m_arrowImages {};
124 
125  // themeable settings
126  int m_channelCount {5};
127  int m_timeCount {4};
128  bool m_verticalLayout {false};
129  QPoint m_textOffset;
130 
131  MythFontProperties *m_font {nullptr};
132  int m_justification {Qt::AlignLeft | Qt::AlignTop |
133  Qt::TextWordWrap};
134  bool m_multilineText {true};
135  bool m_cutdown {true};
136 
137  QString m_selType {"box"};
138  QPen m_drawSelLine {Qt::NoPen};
139  QBrush m_drawSelFill {Qt::NoBrush};
140 
141  QColor m_solidColor;
144 
145  int m_fillType {Solid};
146 
147  int m_rowCount {0};
148  int m_progPastCol {0};
149 
150  bool m_drawCategoryColors {true};
151  bool m_drawCategoryText {true};
152  int m_categoryAlpha {255};
153 
154  QMap<QString, QColor> m_categoryColors;
155 
156 };
157 
158 #endif
MythUIGuideGrid::UIGTCon
Definition: mythuiguidegrid.h:83
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythUIGuideGrid::UIGTCon::m_drawArea
QRect m_drawArea
Definition: mythuiguidegrid.h:97
MythUIGuideGrid::m_textOffset
QPoint m_textOffset
Definition: mythuiguidegrid.h:129
MythUIGuideGrid::FillType
FillType
Definition: mythuiguidegrid.h:51
MythUIGuideGrid::UIGTCon::m_title
QString m_title
Definition: mythuiguidegrid.h:98
MythUIGuideGrid::isVerticalLayout
bool isVerticalLayout(void) const
Definition: mythuiguidegrid.h:53
MythUIGuideGrid::m_conflictingColor
QColor m_conflictingColor
Definition: mythuiguidegrid.h:143
MythUIGuideGrid::UIGTCon::m_recStat
int m_recStat
Definition: mythuiguidegrid.h:103
build_compdb.file
file
Definition: build_compdb.py:55
MythUIGuideGrid
A narrow purpose widget used to show television programs and the timeslots they occupy on channels....
Definition: mythuiguidegrid.h:41
MythUIType::CreateCopy
virtual void CreateCopy(MythUIType *parent)
Copy the state of this widget to the one given, it must be of the same type.
Definition: mythuitype.cpp:1209
MythUIGuideGrid::getChannelCount
int getChannelCount(void) const
Definition: mythuiguidegrid.h:54
MythUIType::DrawSelf
virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect)
Definition: mythuitype.cpp:464
mythuiimage.h
MythUIGuideGrid::UIGTCon::m_recType
int m_recType
Definition: mythuiguidegrid.h:102
MythUIGuideGrid::m_recordingColor
QColor m_recordingColor
Definition: mythuiguidegrid.h:142
hardwareprofile.config.p
p
Definition: config.py:33
MythFontProperties
Definition: mythfontproperties.h:13
MythUIGuideGrid::UIGTCon::m_arrow
int m_arrow
Definition: mythuiguidegrid.h:101
MythUIType::CopyFrom
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
Definition: mythuitype.cpp:1152
MythUIGuideGrid::UIGTCon::m_category
QString m_category
Definition: mythuiguidegrid.h:99
MythUIGuideGrid::m_solidColor
QColor m_solidColor
Definition: mythuiguidegrid.h:141
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:84
MythUIGuideGrid::SetTextOffset
void SetTextOffset(const QPoint to)
Definition: mythuiguidegrid.h:59
MythUIGuideGrid::UIGTCon::m_categoryColor
QColor m_categoryColor
Definition: mythuiguidegrid.h:100
MythUIGuideGrid::getTimeCount
int getTimeCount(void) const
Definition: mythuiguidegrid.h:55
MythUIGuideGrid::m_categoryColors
QMap< QString, QColor > m_categoryColors
Definition: mythuiguidegrid.h:154
MythPainter
Definition: mythpainter.h:32
std
Definition: mythchrono.h:23
GridTimeNormal
#define GridTimeNormal
Definition: mythuiguidegrid.h:28
MythUIGuideGrid::m_selectedItem
UIGTCon m_selectedItem
Definition: mythuiguidegrid.h:120
MythUIGuideGrid::UIGTCon::UIGTCon
UIGTCon(const QRect drawArea, QString title, const QString &category, int arrow, int recType, int recStat)
Definition: mythuiguidegrid.h:87
MythUIType::ParseElement
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
Definition: mythuitype.cpp:1218
build_compdb.filename
filename
Definition: build_compdb.py:21
mythuiexp.h
MythUIType::Finalize
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.
Definition: mythuitype.cpp:1294
MythUIGuideGrid::UIGTCon::UIGTCon
UIGTCon()
Definition: mythuiguidegrid.h:86
mythuitype.h