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