MythTV master
guidegrid.h
Go to the documentation of this file.
1// -*- Mode: c++ -*-
2#ifndef GUIDEGRID_H_
3#define GUIDEGRID_H_
4
5// C++
6#include <list>
7#include <utility>
8#include <vector>
9
10// Qt
11#include <QString>
12#include <QDateTime>
13#include <QEvent>
14
15// MythTV
20#include "libmythtv/tv_play.h"
23
24// MythFrontend
25#include "schedulecommon.h"
26
27class ProgramInfo;
28class QTimer;
30class MythUIGuideGrid;
31
32using db_chan_list_t = std::vector<ChannelInfo> ;
33using db_chan_list_list_t = std::vector<db_chan_list_t>;
34using ProgInfoGuideArray = std::array<std::array<ProgramInfo *,MAX_DISPLAY_TIMES>,MAX_DISPLAY_CHANS>;
35
36class JumpToChannel;
38{
39 public:
40 virtual ~JumpToChannelListener() = default;
41 virtual void GoTo(int start, int cur_row) = 0;
42 virtual void SetJumpToChannel(JumpToChannel *ptr) = 0;
43 virtual int FindChannel(uint chanid, const QString &channum,
44 bool exact = true) const = 0;
45};
46
47class JumpToChannel : public QObject
48{
49 Q_OBJECT
50
51 public:
53 JumpToChannelListener *parent, QString start_entry,
54 int start_chan_idx, int cur_chan_idx, uint rows_disp);
55
56 bool ProcessEntry(const QStringList &actions, const QKeyEvent *e);
57
58 QString GetEntry(void) const { return m_entry; }
59
60 public slots:
61 virtual void deleteLater(void);
62
63 private:
64 ~JumpToChannel() override = default;
65 bool Update(void);
66
67 private:
69 QString m_entry;
73 QTimer *m_timer {nullptr}; // audited ref #5318
74
75 static const uint kJumpToChannelTimeout = 3500; // ms
76};
77
78// GuideUIElement encapsulates the arguments to
79// MythUIGuideGrid::SetProgramInfo(). The elements are prepared in a
80// background thread and then sent via an event to the UI thread for
81// rendering.
83public:
84 GuideUIElement(int row, int col, const QRect area,
85 QString title, QString category,
86 int arrow, int recType, int recStat, bool selected)
87 : m_row(row), m_col(col), m_area(area), m_title(std::move(title)),
88 m_category(std::move(category)), m_arrow(arrow), m_recType(recType),
89 m_recStat(recStat), m_selected(selected) {}
90 const int m_row;
91 const int m_col;
92 const QRect m_area;
93 const QString m_title;
94 const QString m_category;
95 const int m_arrow;
96 const int m_recType;
97 const int m_recStat;
98 const bool m_selected;
99};
100
102{
103 Q_OBJECT;
104
105 public:
106 // Use this function to instantiate a guidegrid instance.
107 static void RunProgramGuide(uint startChanId,
108 const QString &startChanNum,
109 const QDateTime &startTime,
110 TV *player = nullptr,
111 bool embedVideo = false,
112 bool allowFinder = true,
113 int changrpid = -1);
114
115 ChannelInfoList GetSelection(void) const;
116
117 void GoTo(int start, int cur_row) override; // JumpToChannelListener
118 void SetJumpToChannel(JumpToChannel *ptr) override; // JumpToChannelListener
119
120 bool Create(void) override; // MythScreenType
121 void Load(void) override; // MythScreenType
122 void Init(void) override; // MythScreenType
123 bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
124 bool gestureEvent(MythGestureEvent *event) override; // MythScreenType
125
126 void aboutToShow() override; // MythScreenType
127 void aboutToHide() override; // MythScreenType
128 // Allow class GuideUpdateProgramRow to figure out whether the
129 // current start time/channel coordinates are the same, so that it can
130 // skip the work if not.
132 QDateTime GetCurrentStartTime(void) const { return m_currentStartTime; }
133
134 public slots:
135 void PlayerExiting(TV* Player);
136
137 signals:
138 void ChangeVolume(bool Up, int NewVolume = -1);
139 void ToggleMute(bool CycleChannels);
140
141 protected slots:
142 void cursorLeft();
143 void cursorRight();
144 void cursorDown();
145 void cursorUp();
146
147 void toggleGuideListing();
148 void toggleChannelFavorite(int grpid = -1);
149 void ChannelGroupMenu(int mode = 0);
150 void generateListings();
151
152 void enter();
153
154 void showProgFinder();
155 void channelUpdate();
156
157 void deleteRule();
158
159 void Close() override; // MythScreenType
160 void customEvent(QEvent *event) override; // ScheduleCommon
161
162 protected:
163 GuideGrid(MythScreenStack *parentStack,
164 uint chanid, QString channum,
165 const QDateTime &startTime,
166 TV *player = nullptr,
167 bool embedVideo = false,
168 bool allowFinder = true,
169 int changrpid = -1);
170 ~GuideGrid() override;
171 ProgramInfo *GetCurrentProgram(void) const override // ScheduleCommon
172 //cppcheck-suppress CastIntegerToAddressAtReturn
174
175 private slots:
176 void updateTimeout(void);
177 void updateInfo(void);
178 void updateChannels(void);
179 void updateJumpToChannel(void);
180
181 private:
182
184
185 enum MoveVector : std::uint8_t {
196 };
197
198 void moveLeftRight(MoveVector movement);
199 void moveUpDown(MoveVector movement);
200 void moveToTime(const QDateTime& datetime);
201
202 void ShowMenu(void) override; // MythScreenType
203 void ShowRecordingMenu(void);
204 void ShowJumpToTime(void);
205
206 int FindChannel(uint chanid, const QString &channum,
207 bool exact = true) const override; // JumpToChannelListener
208
209 void fillChannelInfos(bool gotostartchannel = true);
210 void fillTimeInfos(void);
211 void fillProgramInfos(bool useExistingData = false);
212 // Set row=-1 to fill all rows.
213 void fillProgramRowInfos(int row, bool useExistingData);
214public:
215 // These need to be public so that the helper classes can operate.
217 void updateProgramsUI(unsigned int firstRow, unsigned int numRows,
218 int progPast,
219 const QVector<ProgramList*> &proglists,
220 const ProgInfoGuideArray &programInfos,
221 const std::list<GuideUIElement> &elements);
222 void updateChannelsNonUI(QVector<ChannelInfo *> &chinfos,
223 QVector<bool> &unavailables);
224 void updateChannelsUI(const QVector<ChannelInfo *> &chinfos,
225 const QVector<bool> &unavailables);
226private:
227
228 void setStartChannel(int newStartChannel);
229
230 ChannelInfo *GetChannelInfo(uint chan_idx, int sel = -1);
231 const ChannelInfo *GetChannelInfo(uint chan_idx, int sel = -1) const;
232 uint GetChannelCount(void) const;
233 int GetStartChannelOffset(int row = -1) const;
234
235 ProgramList GetProgramList(uint chanid) const;
236 uint GetAlternateChannelIndex(uint chan_idx, bool with_same_channum) const;
237 void updateDateText(void);
238
239 private:
240 std::chrono::minutes m_selectRecThreshold {16min};
241
242 bool m_allowFinder {false};
244 QMap<uint,uint> m_channelInfoIdx;
245
246 std::vector<ProgramList*> m_programs;
249
256
259
260 bool m_sortReverse {false};
261
263 int m_timeCount {30};
264 bool m_verticalLayout {false};
265
266 QDateTime m_firstTime;
267 QDateTime m_lastTime;
268
269 TV *m_player {nullptr};
270 bool m_embedVideo {false};
271 void EmbedTVWindow(void);
272 static void HideTVWindow(void);
274
276
277 QTimer *m_updateTimer {nullptr}; // audited ref #5318
278
280
281 int m_changrpid {-1};
284
285 QRecursiveMutex m_jumpToChannelLock;
287
296};
297
298#endif
std::vector< ChannelGroupItem > ChannelGroupList
Definition: channelgroup.h:31
std::vector< ChannelInfo > ChannelInfoList
Definition: channelinfo.h:131
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
Definition: guidegrid.cpp:609
void moveToTime(const QDateTime &datetime)
Definition: guidegrid.cpp:2529
bool m_sortReverse
Definition: guidegrid.h:260
void moveUpDown(MoveVector movement)
Definition: guidegrid.cpp:2505
ProgramInfo * GetCurrentProgram(void) const override
Definition: guidegrid.h:171
MythUIText * m_jumpToText
Definition: guidegrid.h:293
ChannelGroupList m_changrplist
Definition: guidegrid.h:282
db_chan_list_list_t m_channelInfos
Definition: guidegrid.h:243
QDateTime m_lastTime
Definition: guidegrid.h:267
MythUIText * m_dateText
Definition: guidegrid.h:291
ProgInfoGuideArray m_programInfos
Definition: guidegrid.h:247
void Close() override
Definition: guidegrid.cpp:2572
void PlayerExiting(TV *Player)
Definition: guidegrid.cpp:529
void cursorUp()
Definition: guidegrid.cpp:2459
@ kScrollLeft
Definition: guidegrid.h:188
@ kPageRight
Definition: guidegrid.h:193
@ kScrollRight
Definition: guidegrid.h:189
@ kScrollDown
Definition: guidegrid.h:187
QString m_startChanNum
Definition: guidegrid.h:255
MythUIImage * m_channelImage
Definition: guidegrid.h:295
MythUIButtonList * m_channelList
Definition: guidegrid.h:289
void GoTo(int start, int cur_row) override
Definition: guidegrid.cpp:2635
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
Definition: guidegrid.cpp:585
MythUIButtonList * m_timeList
Definition: guidegrid.h:288
QDateTime m_firstTime
Definition: guidegrid.h:266
ChannelGroupList m_channelGroupListManual
Definition: guidegrid.h:283
QRect m_videoRect
Definition: guidegrid.h:273
bool gestureEvent(MythGestureEvent *event) override
Mouse click/movement handler, receives mouse gesture events from the QCoreApplication event loop.
Definition: guidegrid.cpp:898
ProgramList GetProgramList(uint chanid) const
Definition: guidegrid.cpp:1214
void generateListings()
Definition: guidegrid.cpp:2276
ProgramList * getProgramListFromProgram(int chanNum)
Definition: guidegrid.cpp:1569
ProgramList m_recList
Definition: guidegrid.h:248
void updateChannelsUI(const QVector< ChannelInfo * > &chinfos, const QVector< bool > &unavailables)
Definition: guidegrid.cpp:2164
QRecursiveMutex m_jumpToChannelLock
Definition: guidegrid.h:285
QDateTime GetCurrentStartTime(void) const
Definition: guidegrid.h:132
void ShowMenu(void) override
Definition: guidegrid.cpp:1104
MythUIText * m_changroupname
Definition: guidegrid.h:294
~GuideGrid() override
Definition: guidegrid.cpp:632
void EmbedTVWindow(void)
Definition: guidegrid.cpp:2679
void deleteRule()
Definition: guidegrid.cpp:2590
int GetStartChannelOffset(int row=-1) const
Definition: guidegrid.cpp:1204
void updateChannelsNonUI(QVector< ChannelInfo * > &chinfos, QVector< bool > &unavailables)
Definition: guidegrid.cpp:2111
void updateProgramsUI(unsigned int firstRow, unsigned int numRows, int progPast, const QVector< ProgramList * > &proglists, const ProgInfoGuideArray &programInfos, const std::list< GuideUIElement > &elements)
Definition: guidegrid.cpp:2072
void setStartChannel(int newStartChannel)
Definition: guidegrid.cpp:2541
void cursorRight()
Definition: guidegrid.cpp:2418
QMap< uint, uint > m_channelInfoIdx
Definition: guidegrid.h:244
void SetJumpToChannel(JumpToChannel *ptr) override
Definition: guidegrid.cpp:2660
uint m_startChanID
Definition: guidegrid.h:254
JumpToChannel * m_jumpToChannel
Definition: guidegrid.h:286
uint GetCurrentStartChannel(void) const
Definition: guidegrid.h:131
int m_currentCol
Definition: guidegrid.h:258
uint m_currentStartChannel
Definition: guidegrid.h:253
bool Create(void) override
Definition: guidegrid.cpp:540
std::vector< ProgramList * > m_programs
Definition: guidegrid.h:246
int FindChannel(uint chanid, const QString &channum, bool exact=true) const override
Definition: guidegrid.cpp:1470
void updateJumpToChannel(void)
Definition: guidegrid.cpp:2644
void updateChannels(void)
Definition: guidegrid.cpp:2105
void showProgFinder()
Definition: guidegrid.cpp:2551
GuideGrid(MythScreenStack *parentStack, uint chanid, QString channum, const QDateTime &startTime, TV *player=nullptr, bool embedVideo=false, bool allowFinder=true, int changrpid=-1)
Definition: guidegrid.cpp:486
int m_currentRow
Definition: guidegrid.h:257
QString m_channelOrdering
Definition: guidegrid.h:275
void aboutToShow() override
Definition: guidegrid.cpp:2695
Q_DISABLE_COPY(GuideGrid)
void enter()
Definition: guidegrid.cpp:2557
bool m_embedVideo
Definition: guidegrid.h:270
uint GetChannelCount(void) const
Definition: guidegrid.cpp:1199
void fillChannelInfos(bool gotostartchannel=true)
Definition: guidegrid.cpp:1393
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: guidegrid.cpp:669
bool m_allowFinder
Definition: guidegrid.h:242
ChannelInfo * GetChannelInfo(uint chan_idx, int sel=-1)
Definition: guidegrid.cpp:1181
void updateInfo(void)
Definition: guidegrid.cpp:2202
int m_channelCount
Definition: guidegrid.h:262
void toggleGuideListing()
Definition: guidegrid.cpp:2258
void ToggleMute(bool CycleChannels)
QDateTime m_currentEndTime
Definition: guidegrid.h:252
bool m_verticalLayout
Definition: guidegrid.h:264
void ShowJumpToTime(void)
Definition: guidegrid.cpp:2703
int m_changrpid
Definition: guidegrid.h:281
void ShowRecordingMenu(void)
Definition: guidegrid.cpp:1150
uint GetAlternateChannelIndex(uint chan_idx, bool with_same_channum) const
Definition: guidegrid.cpp:1247
static void HideTVWindow(void)
Definition: guidegrid.cpp:2674
void fillProgramRowInfos(int row, bool useExistingData)
Definition: guidegrid.cpp:1594
void ChannelGroupMenu(int mode=0)
Definition: guidegrid.cpp:2293
void fillProgramInfos(bool useExistingData=false)
Definition: guidegrid.cpp:1564
QTimer * m_updateTimer
Definition: guidegrid.h:277
int m_timeCount
Definition: guidegrid.h:263
void updateDateText(void)
Definition: guidegrid.cpp:2063
TV * m_player
Definition: guidegrid.h:269
ChannelInfoList GetSelection(void) const
Definition: guidegrid.cpp:1309
void customEvent(QEvent *event) override
Definition: guidegrid.cpp:1894
void cursorDown()
Definition: guidegrid.cpp:2444
MThreadPool m_threadPool
Definition: guidegrid.h:279
void cursorLeft()
Definition: guidegrid.cpp:2394
MythUIText * m_longdateText
Definition: guidegrid.h:292
QDateTime m_originalStartTime
Definition: guidegrid.h:250
void channelUpdate()
Definition: guidegrid.cpp:2620
QDateTime m_currentStartTime
Definition: guidegrid.h:251
void toggleChannelFavorite(int grpid=-1)
Definition: guidegrid.cpp:2348
void aboutToHide() override
Definition: guidegrid.cpp:2687
void ChangeVolume(bool Up, int NewVolume=-1)
static void RunProgramGuide(uint startChanId, const QString &startChanNum, const QDateTime &startTime, TV *player=nullptr, bool embedVideo=false, bool allowFinder=true, int changrpid=-1)
Definition: guidegrid.cpp:411
void updateTimeout(void)
Definition: guidegrid.cpp:1386
void fillTimeInfos(void)
Definition: guidegrid.cpp:1530
std::chrono::minutes m_selectRecThreshold
Definition: guidegrid.h:240
void moveLeftRight(MoveVector movement)
Definition: guidegrid.cpp:2474
MythUIGuideGrid * m_guideGrid
Definition: guidegrid.h:290
const int m_arrow
Definition: guidegrid.h:95
const int m_recType
Definition: guidegrid.h:96
GuideUIElement(int row, int col, const QRect area, QString title, QString category, int arrow, int recType, int recStat, bool selected)
Definition: guidegrid.h:84
const int m_row
Definition: guidegrid.h:90
const bool m_selected
Definition: guidegrid.h:98
const QRect m_area
Definition: guidegrid.h:92
const int m_col
Definition: guidegrid.h:91
const QString m_category
Definition: guidegrid.h:94
const int m_recStat
Definition: guidegrid.h:97
const QString m_title
Definition: guidegrid.h:93
virtual void SetJumpToChannel(JumpToChannel *ptr)=0
virtual ~JumpToChannelListener()=default
virtual void GoTo(int start, int cur_row)=0
virtual int FindChannel(uint chanid, const QString &channum, bool exact=true) const =0
virtual void deleteLater(void)
Definition: guidegrid.cpp:84
JumpToChannel(JumpToChannelListener *parent, QString start_entry, int start_chan_idx, int cur_chan_idx, uint rows_disp)
Definition: guidegrid.cpp:65
JumpToChannelListener * m_listener
Definition: guidegrid.h:68
int m_previousStartChannelIndex
Definition: guidegrid.h:70
int m_previousCurrentChannelIndex
Definition: guidegrid.h:71
static const uint kJumpToChannelTimeout
Definition: guidegrid.h:75
QString m_entry
Definition: guidegrid.h:69
uint m_rowsDisplayed
Definition: guidegrid.h:72
bool ProcessEntry(const QStringList &actions, const QKeyEvent *e)
Definition: guidegrid.cpp:113
bool Update(void)
Definition: guidegrid.cpp:162
QTimer * m_timer
Definition: guidegrid.h:73
~JumpToChannel() override=default
QString GetEntry(void) const
Definition: guidegrid.h:58
A custom event that represents a mouse gesture.
Definition: mythgesture.h:40
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
A narrow purpose widget used to show television programs and the timeslots they occupy on channels.
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:98
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
Holds information on recordings and videos.
Definition: programinfo.h:68
Control TV playback.
Definition: tv_play.h:156
unsigned int uint
Definition: freesurround.h:24
std::vector< db_chan_list_t > db_chan_list_list_t
Definition: guidegrid.h:33
std::array< std::array< ProgramInfo *, MAX_DISPLAY_TIMES >, MAX_DISPLAY_CHANS > ProgInfoGuideArray
Definition: guidegrid.h:34
std::vector< ChannelInfo > db_chan_list_t
Definition: guidegrid.h:32
static constexpr int MAX_DISPLAY_CHANS
STL namespace.