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 enum FillType : std::uint8_t { Alpha = 10, Dense, Eco, Solid };
51
52 bool isVerticalLayout(void) const { return m_verticalLayout; }
53 int getChannelCount(void) const { return m_channelCount; }
54 int getTimeCount(void) const { return m_timeCount; }
55
56 void SetCategoryColors(const QMap<QString, QString> &catColors);
57
58 void SetTextOffset(const QPoint to) { m_textOffset = to; }
59 void SetArrow(int direction, const QString &file);
60 void LoadImage(int recType, const QString &file);
61 void SetProgramInfo(int row, int col, QRect area,
62 const QString &title, const QString &genre,
63 int arrow, int recType, int recStat, bool selected);
64 void ResetData();
65 void ResetRow(int row);
66 void SetProgPast(int ppast);
67 void SetMultiLine(bool multiline);
68
69 QPoint GetRowAndColumn(QPoint position);
70
71 protected:
72 void Finalize(void) override; // MythUIType
73 bool ParseElement(const QString &filename, QDomElement &element,
74 bool showWarnings) override; // MythUIType
75 void DrawSelf(MythPainter *p, int xoffset, int yoffset,
76 int alphaMod, QRect clipRect) 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() = default;
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
99 QString m_title;
100 QString m_category;
102 int m_arrow { GridTimeNormal };
103 int m_recType { 0 };
104 int m_recStat { 0 };
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};
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
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
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:97
virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect)
Definition: mythuitype.cpp:465
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