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