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
19static constexpr size_t ARROWIMAGESIZE { 4 };
20static constexpr size_t RECSTATUSSIZE { 8 };
21
22
23// max number of channels to display in the guide grid
24static constexpr int MAX_DISPLAY_CHANS { 40 };
25
26// max number of 5 minute time slots to show in guide grid (48 = 4hrs)
27static constexpr int MAX_DISPLAY_TIMES { 48 };
28
29// bitmask
30static constexpr uint8_t GridTimeNormal { 0 };
31static constexpr uint8_t GridTimeStartsBefore { 1 };
32static constexpr uint8_t GridTimeEndsAfter { 2 };
33
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 : std::uint8_t { 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() = default;
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
100 QString m_title;
101 QString m_category;
103 int m_arrow { GridTimeNormal };
104 int m_recType { 0 };
105 int m_recStat { 0 };
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};
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
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
UIGTCon(const UIGTCon &o)=default
UIGTCon & operator=(const UIGTCon &)=default
UIGTCon(const QRect drawArea, QString title, const QString &category, int arrow, int recType, int recStat)
A narrow purpose widget used to show television programs and the timeslots they occupy on channels.
int getChannelCount(void) const
bool isVerticalLayout(void) const
void SetTextOffset(const QPoint to)
QMap< QString, QColor > m_categoryColors
int getTimeCount(void) const
The base class on which all widgets and screens are based.
Definition: mythuitype.h:86
virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect)
Definition: mythuitype.cpp:479
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.
virtual void CreateCopy(MythUIType *parent)
Copy the state of this widget to the one given, it must be of the same type.
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
#define MUI_PUBLIC
Definition: mythuiexp.h:9
static constexpr int MAX_DISPLAY_TIMES
static constexpr size_t ARROWIMAGESIZE
static constexpr uint8_t GridTimeNormal
static constexpr size_t RECSTATUSSIZE
static constexpr int MAX_DISPLAY_CHANS
static constexpr uint8_t GridTimeEndsAfter
static constexpr uint8_t GridTimeStartsBefore
STL namespace.