00001
00002 #ifndef GUIDEGRID_H_
00003 #define GUIDEGRID_H_
00004
00005
00006 #include <vector>
00007 using namespace std;
00008
00009
00010 #include <QString>
00011 #include <QDateTime>
00012 #include <QEvent>
00013
00014
00015 #include "mythscreentype.h"
00016 #include "programinfo.h"
00017 #include "channelgroup.h"
00018 #include "channelutil.h"
00019 #include "mythuiguidegrid.h"
00020
00021
00022 #include "schedulecommon.h"
00023
00024 using namespace std;
00025
00026 class ProgramInfo;
00027 class TV;
00028 class QTimer;
00029 class MythUIButtonList;
00030 class MythUIGuideGrid;
00031
00032 #define MAX_DISPLAY_TIMES 36
00033
00034 typedef vector<DBChannel> db_chan_list_t;
00035 typedef vector<db_chan_list_t> db_chan_list_list_t;
00036
00037 class JumpToChannel;
00038 class JumpToChannelListener
00039 {
00040 public:
00041 virtual ~JumpToChannelListener() {}
00042 virtual void GoTo(int start, int cur_row) = 0;
00043 virtual void SetJumpToChannel(JumpToChannel *ptr) = 0;
00044 virtual int FindChannel(uint chanid, const QString &channum,
00045 bool exact = true) const = 0;
00046 };
00047
00048 class JumpToChannel : public QObject
00049 {
00050 Q_OBJECT
00051
00052 public:
00053 JumpToChannel(
00054 JumpToChannelListener *parent, const QString &start_entry,
00055 int start_chan_idx, int cur_chan_idx, uint rows_disp);
00056
00057 bool ProcessEntry(const QStringList &actions, const QKeyEvent *e);
00058
00059 QString GetEntry(void) const { return m_entry; }
00060
00061 public slots:
00062 virtual void deleteLater(void);
00063
00064 private:
00065 ~JumpToChannel() {}
00066 bool Update(void);
00067
00068 private:
00069 JumpToChannelListener *m_listener;
00070 QString m_entry;
00071 int m_previous_start_channel_index;
00072 int m_previous_current_channel_index;
00073 uint m_rows_displayed;
00074 QTimer *m_timer;
00075
00076 static const uint kJumpToChannelTimeout = 3500;
00077 };
00078
00079 class GuideGrid : public ScheduleCommon, public JumpToChannelListener
00080 {
00081 Q_OBJECT
00082
00083 public:
00084
00085 static void RunProgramGuide(uint startChanId,
00086 const QString &startChanNum,
00087 TV *player = NULL,
00088 bool embedVideo = false,
00089 bool allowFinder = true,
00090 int changrpid = -1);
00091
00092 DBChanList GetSelection(void) const;
00093
00094 virtual void GoTo(int start, int cur_row);
00095 virtual void SetJumpToChannel(JumpToChannel *ptr);
00096
00097 bool Create(void);
00098 virtual void Load(void);
00099 virtual void Init(void);
00100 bool keyPressEvent(QKeyEvent *event);
00101
00102 virtual void aboutToShow();
00103 virtual void aboutToHide();
00104
00105 protected slots:
00106 void cursorLeft();
00107 void cursorRight();
00108 void cursorDown();
00109 void cursorUp();
00110
00111 void toggleGuideListing();
00112 void toggleChannelFavorite(int grpid = -1);
00113 void ChannelGroupMenu(int mode = 0);
00114 void generateListings();
00115
00116 void enter();
00117
00118 void showProgFinder();
00119 void channelUpdate();
00120 void volumeUpdate(bool);
00121 void toggleMute(const bool muteIndividualChannels = false);
00122
00123 void quickRecord();
00124 void editRecSchedule();
00125 void editSchedule();
00126 void customEdit();
00127 void deleteRule();
00128 void upcoming();
00129 void details();
00130
00131 void Close();
00132 void customEvent(QEvent *event);
00133
00134 protected:
00135 GuideGrid(MythScreenStack *parentStack,
00136 uint chanid = 0, QString channum = "",
00137 TV *player = NULL, bool embedVideo = false,
00138 bool allowFinder = true,
00139 int changrpid = -1);
00140 ~GuideGrid();
00141
00142 private slots:
00143 void updateTimeout(void);
00144 void refreshVideo(void);
00145 void updateInfo(void);
00146 void updateChannels(void);
00147 void updateJumpToChannel(void);
00148
00149 private:
00150
00151 enum MoveVector {
00152 kScrollUp,
00153 kScrollDown,
00154 kScrollLeft,
00155 kScrollRight,
00156 kPageUp,
00157 kPageDown,
00158 kPageLeft,
00159 kPageRight,
00160 kDayLeft,
00161 kDayRight,
00162 };
00163
00164 void moveLeftRight(MoveVector movement);
00165 void moveUpDown(MoveVector movement);
00166 void moveToTime(QDateTime datetime);
00167
00168 void ShowMenu(void);
00169 void ShowRecordingMenu(void);
00170 void ShowJumpToTime(void);
00171
00172 int FindChannel(uint chanid, const QString &channum,
00173 bool exact = true) const;
00174
00175 void fillChannelInfos(bool gotostartchannel = true);
00176 void fillTimeInfos(void);
00177 void fillProgramInfos(bool useExistingData = false);
00178 void fillProgramRowInfos(unsigned int row, bool useExistingData = false);
00179 ProgramList *getProgramListFromProgram(int chanNum);
00180
00181 void setStartChannel(int newStartChannel);
00182
00183 DBChannel *GetChannelInfo(uint chan_idx, int sel = -1);
00184 const DBChannel *GetChannelInfo(uint chan_idx, int sel = -1) const;
00185 uint GetChannelCount(void) const;
00186 int GetStartChannelOffset(int row = -1) const;
00187
00188 ProgramList GetProgramList(uint chanid) const;
00189 uint GetAlternateChannelIndex(uint chan_idx, bool with_same_channum) const;
00190 void updateDateText(void);
00191
00192 private:
00193 bool m_selectChangesChannel;
00194 int m_selectRecThreshold;
00195
00196 bool m_allowFinder;
00197 db_chan_list_list_t m_channelInfos;
00198 QMap<uint,uint> m_channelInfoIdx;
00199
00200 vector<ProgramList*> m_programs;
00201 ProgramInfo *m_programInfos[MAX_DISPLAY_CHANS][MAX_DISPLAY_TIMES];
00202 ProgramList m_recList;
00203
00204 QDateTime m_originalStartTime;
00205 QDateTime m_currentStartTime;
00206 QDateTime m_currentEndTime;
00207 uint m_currentStartChannel;
00208 uint m_startChanID;
00209 QString m_startChanNum;
00210
00211 int m_currentRow;
00212 int m_currentCol;
00213
00214 bool m_sortReverse;
00215
00216 int m_channelCount;
00217 int m_timeCount;
00218 bool m_verticalLayout;
00219
00220 QDateTime m_firstTime;
00221 QDateTime m_lastTime;
00222
00223 TV *m_player;
00224 bool m_usingNullVideo;
00225 bool m_embedVideo;
00226 QTimer *m_previewVideoRefreshTimer;
00227 void EmbedTVWindow(void);
00228 void HideTVWindow(void);
00229 QRect m_videoRect;
00230
00231 QString m_channelOrdering;
00232
00233 QTimer *m_updateTimer;
00234
00235 int m_changrpid;
00236 ChannelGroupList m_changrplist;
00237
00238 QMutex m_jumpToChannelLock;
00239 JumpToChannel *m_jumpToChannel;
00240
00241 MythUIButtonList *m_timeList;
00242 MythUIButtonList *m_channelList;
00243 MythUIGuideGrid *m_guideGrid;
00244 MythUIText *m_dateText;
00245 MythUIText *m_longdateText;
00246 MythUIText *m_jumpToText;
00247 MythUIText *m_changroupname;
00248 MythUIImage *m_channelImage;
00249 };
00250
00251 #endif