Debian Codegraph @

samples/qtvidcap/epgwindow.h

raw
1 /*
2 EPG window for AviCap
3
4 written 2003 by Alexander Rawass ([email protected])
5 */
6
7 #ifndef EPGWINDOW_H
8 #define EPGWINDOW_H
9
10 #include <avm_stl.h>
11 #include <avm_locker.h>
12 #include <avm_output.h>
13
14 #include <qwidget.h>
15 #include <qtimer.h>
16 #include <qlistview.h>
17 #include <qdatetime.h>
18 #include <qdom.h>
19 #include <qvaluelist.h>
20 #include <qregexp.h>
21
22 class v4lxif;
23 class V4LWindow;
24
25 class QPopupMenu;
26 class QLabel;
27 class QListView;
28 class QComboBox;
29 class QDateTimeEdit;
30 class QTimeEdit;
31 class QSplitter;
32 class QGroupBox;
33 class QPushButton;
34 class QButtonGroup;
35 class QLineEdit;
36 class QListViewItem;
37 class QFrame;
38 class QMessageBox;
39 class QHBoxLayout;
40 class QVGroupBox;
41 class QHGroupBox;
42 class QHBox;
43 class QVBox;
44 class QTable;
45 class QSpinBox;
46
47 #if QT_VERSION >=300
48 class QTextEdit;
49 #else
50 #include <qmultilineedit.h>
51 #define QTextEdit QMultiLineEdit
52 #endif
53
54 class TimerTable;
55 class TimerTableItem;
56
57 #if QT_VERSION>=300
58 static const QString epg_timeformat="hh:mm";
59 static const QString epg_dateformat="dd MMM yyyy (ddd)";
60 static const QString epg_startdateformat=("dd MMM yyyy "+epg_timeformat+" ddd");
61 static const QString epg_stopdateformat=epg_timeformat;
62 #else
63 #define epg_timeformat
64 #define epg_dateformat
65 #define epg_startdateformat
66 #define epg_stopdateformat
67 #endif
68
69 static const QString block_string="block:";
70 static const QString high_string="high:";
71 static const QString both_string="both:";
72 static const QString title_string="title:";
73 static const QString desc_string="desc:";
74
75 static int strip_x_default=100;
76 static int strip_y_default=60*24;
77
78 static float zoom_increment=0.5f;
79
80 class EpgProgram {
81 public:
82 QDateTime start;
83 QDateTime stop;
84 QString title;
85 QString desc;
86 int blockmode;
87 int y_stop,y_start;
88 int channelnr;
89 };
90
91 typedef QValueList<EpgProgram *> EpgProgramList;
92 typedef QValueListIterator<EpgProgram *> EpgProgramListIterator;
93
94 class EpgIdChannel;
95
96 class EpgChannel {
97 public:
98 QString chid;
99 int channelnr;
100 EpgIdChannel *idchannel;
101 EpgProgramList programs;
102 };
103
104 typedef QValueList<EpgChannel *> EpgChannelList;
105 typedef QValueListIterator<EpgChannel *> EpgChannelListIterator;
106
107
108 class EpgDay {
109 public:
110 QDate date;
111 int itemnr;
112 EpgChannelList channels;
113 };
114
115 typedef QValueList<EpgDay *> EpgDayList;
116 typedef QValueListIterator<EpgDay *> EpgDayListIterator;
117
118 class EpgChannelStrip;
119
120 class EpgIdChannel {
121 public:
122 QString epgid;
123 QString epgname;
124 QString username;
125 int chnr;
126 EpgChannelStrip *strip;
127 QLabel *conf_channel_label;
128 QComboBox *conf_channel_box;
129 QPushButton *color_button;
130 QColor color;
131 };
132
133 typedef QValueList<EpgIdChannel *> EpgChIdList;
134 typedef QValueListIterator<EpgIdChannel *> EpgChIdListIterator;
135
136 class EpgWindow;
137
138 class EpgRegexp {
139 public:
140 QRegExp regexp;
141 QString regstr;
142 int blockmode;
143 int wheremode;
144 };
145 typedef QValueList<EpgRegexp *> EpgRegexpList;
146 typedef QValueListIterator<EpgRegexp *> EpgRegexpListIterator;
147
148 enum blockmode_t { regexp_errorblock,regexp_unset,regexp_nomatch,regexp_highlight,regexp_block };
149 enum wheremode_t { regexp_errorwhere,regexp_title,regexp_desc,regexp_both };
150
151 class EpgChannelStrip : public QWidget {
152 Q_OBJECT
153
154 public:
155 EpgChannelStrip(QWidget *parent,EpgWindow *win,EpgIdChannel *new_channel);
156 ~EpgChannelStrip() { return ; };
157
158 void paintEvent(QPaintEvent *event);
159 void resizeEvent(QResizeEvent *event);
160 void drawStrip(int x,int y);
161 void mouseMoveEvent(QMouseEvent *e);
162 void leaveEvent(QEvent *e);
163 int blockMode(EpgProgram *prog);
164 void mousePressEvent(QMouseEvent *e);
165 void mouseReleaseEvent(QMouseEvent *e);
166
167 public slots:
168 void addblock();
169 void addhighlight();
170 void addrecording();
171
172 private:
173 void calcYfromTime(int &y_start,int &y_stop,QTime starttime,QTime stoptime);
174
175 EpgIdChannel *chid;
176 EpgWindow *epgwin;
177 EpgProgram *last_mouse_program;
178 QPopupMenu *popmenu;
179 EpgProgram *pop_program;
180
181 bool mid_move;
182 int mid_move_x,mid_move_y;
183 };
184
185 class EpgTableItem : public QCheckListItem {
186 public:
187 EpgTableItem(QListView *parent,EpgWindow *epgwin,QDateTime start_date,QDateTime stop_date,QString channel_str,QString title,QString desc);
188 ~EpgTableItem();
189
190 int compare(QListViewItem *other,int col, bool ascend) const ;
191
192 QDateTime getStartTime() const { return start_date; };
193 QDateTime getStopDateTime() const { return stop_date; };
194
195 QDateTime start_date,stop_date;
196 QString channel,title,desc,chname;
197
198 EpgWindow *epgwin;
199 };
200
201 class EpgWindow : public QWidget, public avm::AvmOutputLog
202 {
203 Q_OBJECT;
204
205 public:
206 EpgWindow(V4LWindow *v4l,TimerTable *timer);
207 ~EpgWindow();
208 QString findNameToId(QString channel);
209 void makeConfigWidget(QWidget *parent);
210 void addRecording(EpgProgram *prog);
211 bool isBlocked(int chnr);
212 void lock(bool lock);
213 void calcStripSize();
214 void resizeStrips();
215
216 EpgDayList epglist;
217 EpgChIdList epgChannels;
218 int current_date_item;
219 bool regexp_dirty;
220 TimerTable *timertable;
221
222 EpgRegexpList regexpList;
223 TimerTableItem *next_recording,*current_recording;
224
225 QLabel *bottom_label;
226 QTextEdit *bottom_text;
227 QWidget *gridview;
228 QScrollView *gridscroll;
229 QHeader *gridheader;
230 QTable *gridtable;
231 QTextEdit *regexp_edit;
232 int zoom_step;
233
234 int strip_y_size,strip_x,strip_y,hours_before,hours_after;
235 int strip_y_before,strip_y_after,strip_y_today;
236 int strip_y_alldays,y_subtract;
237
238 signals:
239 void emitAddRecording(EpgProgram *prog);
240
241 public slots:
242 void display_toggled();
243 void day_selected(int nr);
244 void okSettings();
245 void colorSelector();
246 void rereadRegexps();
247 void show_config();
248 void show_regexps();
249 void setCurrentRecording(TimerTableItem *titem);
250 void setNextRecording(TimerTableItem *titem);
251 void timertableModified();
252 void timer();
253 void zoomIn();
254 void zoomOut();
255
256 private:
257 void load();
258 void load(QString fname);
259 void parse(QDomDocument &dom);
260 void printElem(QDomElement &elem);
261
262 void doProgramme(QDomElement &elem);
263 void doChannel(QDomElement &elem);
264
265 QDateTime parseDate(QString datestr);
266 void initWidgets();
267 void makeChannelStrips();
268
269 void addEntry(QDateTime start_date,QDateTime stop_date,QString channel_str,QString title,QString desc);
270
271 QTimer *epg_timer;
272
273 QListView *ctable,*ptable;
274 QComboBox *day_selector;
275 QPushButton *display_toggle;
276 QPushButton *config_button,*regexp_button;
277 QWidget *centralw;
278 QVGroupBox *regexp_box;
279 QPushButton *zoom_in_button,*zoom_out_button;
280 QHBoxLayout *gridlayout;
281
282 QString provider;
283 int channel_row;
284
285 QLineEdit *conf_dir_edit;
286 QScrollView *conf_channel_scroll;
287 QGridLayout *conf_channel_lay;
288 QVBox *conf_channel_view;
289 QVGroupBox *config_widget;
290 QPushButton *ok_button;
291
292 QSpinBox *hours_before_spinbox,*hours_after_spinbox;
293 QSpinBox *mins_before_spinbox,*mins_after_spinbox;
294
295 QPushButton *reg_ok_button,*reg_reread_button;
296
297 int display_mode;
298 int today_item;
299
300 V4LWindow *v4lwin;
301
302 long local_timediff;
303
304 int ACnumChannels(){ return v4lwin->getStations(); };
305 QString ACchannelName(int i) { return QString(v4lwin->getXawtvStation(i).c_str()); };
306 };
307
308 #endif