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  public:
44  MythUIGuideGrid(MythUIType *parent, const QString &name);
45  ~MythUIGuideGrid() override;
46 
47  void DrawSelf(MythPainter *p, int xoffset, int yoffset,
48  int alphaMod, QRect clipRect) override; // MythUIType
49 
50  enum FillType { 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, const 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 CopyFrom(MythUIType *base) override; // MythUIType
76  void CreateCopy(MythUIType *parent) override; // MythUIType
77 
78  static bool parseDefaultCategoryColors(QMap<QString, QString> &catColors);
79 
80  private:
81 
82  class UIGTCon
83  {
84  public:
85  UIGTCon() { m_arrow = GridTimeNormal; m_recType = m_recStat = 0; };
86  UIGTCon(const QRect &drawArea, QString title,
87  const QString &category, int arrow, int recType, int recStat) :
88  m_drawArea(drawArea), m_title(std::move(title)),
89  m_category(category.trimmed()), m_arrow(arrow),
90  m_recType(recType), m_recStat(recStat)
91  {}
92 
93  UIGTCon(const UIGTCon &o) = default;
94  UIGTCon& operator=(const UIGTCon&) = default;
95 
96  QRect m_drawArea;
97  QString m_title;
98  QString m_category;
100  int m_arrow;
103  };
104 
105  void drawBackground(MythPainter *p, int xoffset, int yoffset,
106  UIGTCon *data, int alphaMod);
107  void drawBox(MythPainter *p, int xoffset, int yoffset, UIGTCon *data,
108  const QColor &color, int alphaMod);
109  void drawText(MythPainter *p, int xoffset, int yoffset, UIGTCon *data,
110  int alphaMod);
111  void drawRecDecoration(MythPainter *p, int xoffset, int yoffset,
112  UIGTCon *data, int alphaMod);
113  void drawCurrent(MythPainter *p, int xoffset, int yoffset, UIGTCon *data,
114  int alphaMod);
115 
116  static QColor calcColor(const QColor &color, int alpha);
117 
118  QList<UIGTCon*> *m_allData {nullptr};
120 
121  std::array<MythUIImage*,RECSTATUSSIZE> m_recImages {};
122  std::array<MythUIImage*,ARROWIMAGESIZE> m_arrowImages {};
123 
124  // themeable settings
125  int m_channelCount {5};
126  int m_timeCount {4};
127  bool m_verticalLayout {false};
128  QPoint m_textOffset;
129 
130  MythFontProperties *m_font {nullptr};
131  int m_justification {Qt::AlignLeft | Qt::AlignTop |
132  Qt::TextWordWrap};
133  bool m_multilineText {true};
134  bool m_cutdown {true};
135 
136  QString m_selType {"box"};
137  QPen m_drawSelLine {Qt::NoPen};
138  QBrush m_drawSelFill {Qt::NoBrush};
139 
140  QColor m_solidColor;
143 
144  int m_fillType {Solid};
145 
146  int m_rowCount {0};
147  int m_progPastCol {0};
148 
149  bool m_drawCategoryColors {true};
150  bool m_drawCategoryText {true};
151  int m_categoryAlpha {255};
152 
153  QMap<QString, QColor> m_categoryColors;
154 
155 };
156 
157 #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:96
MythUIGuideGrid::UIGTCon::UIGTCon
UIGTCon(const QRect &drawArea, QString title, const QString &category, int arrow, int recType, int recStat)
Definition: mythuiguidegrid.h:86
MythUIGuideGrid::m_textOffset
QPoint m_textOffset
Definition: mythuiguidegrid.h:128
MythUIGuideGrid::FillType
FillType
Definition: mythuiguidegrid.h:50
MythUIGuideGrid::UIGTCon::operator=
UIGTCon & operator=(const UIGTCon &)=default
title
QString title
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:633
MythUIGuideGrid::UIGTCon::m_title
QString m_title
Definition: mythuiguidegrid.h:97
MythUIGuideGrid::isVerticalLayout
bool isVerticalLayout(void) const
Definition: mythuiguidegrid.h:52
MythUIGuideGrid::m_conflictingColor
QColor m_conflictingColor
Definition: mythuiguidegrid.h:142
MythUIGuideGrid::UIGTCon::m_recStat
int m_recStat
Definition: mythuiguidegrid.h:102
category
QString category
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1419
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:1209
MythUIGuideGrid::getChannelCount
int getChannelCount(void) const
Definition: mythuiguidegrid.h:53
MythUIType::DrawSelf
virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect)
Definition: mythuitype.cpp:463
mythuiimage.h
MythUIGuideGrid::SetTextOffset
void SetTextOffset(const QPoint &to)
Definition: mythuiguidegrid.h:58
MythUIGuideGrid::UIGTCon::m_recType
int m_recType
Definition: mythuiguidegrid.h:101
MythUIGuideGrid::m_recordingColor
QColor m_recordingColor
Definition: mythuiguidegrid.h:141
hardwareprofile.config.p
p
Definition: config.py:33
MythUIGuideGrid::UIGTCon::UIGTCon
UIGTCon(const UIGTCon &o)=default
MythFontProperties
Definition: mythfontproperties.h:14
MythUIGuideGrid::UIGTCon::m_arrow
int m_arrow
Definition: mythuiguidegrid.h:100
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:634
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:98
MythUIGuideGrid::m_solidColor
QColor m_solidColor
Definition: mythuiguidegrid.h:140
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:64
MythUIGuideGrid::UIGTCon::m_categoryColor
QColor m_categoryColor
Definition: mythuiguidegrid.h:99
MythUIGuideGrid::getTimeCount
int getTimeCount(void) const
Definition: mythuiguidegrid.h:54
MythUIGuideGrid::m_categoryColors
QMap< QString, QColor > m_categoryColors
Definition: mythuiguidegrid.h:153
MythPainter
Definition: mythpainter.h:33
GridTimeNormal
#define GridTimeNormal
Definition: mythuiguidegrid.h:28
MythUIGuideGrid::m_selectedItem
UIGTCon m_selectedItem
Definition: mythuiguidegrid.h:119
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
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:85
mythuitype.h