| 1 |
/* |
| 2 |
TimerTable window for AviCap |
| 3 |
|
| 4 |
written 2003 by Alexander Rawass ([email protected]) |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef TIMERTABLE_H |
| 8 |
#define TIMERTABLE_H |
| 9 |
|
| 10 |
#include <avm_stl.h> |
| 11 |
#include <avm_locker.h> |
| 12 |
#include <avm_output.h> |
| 13 |
|
| 14 |
#include <qdialog.h> |
| 15 |
#include <qdatetime.h> |
| 16 |
#include <qlistview.h> |
| 17 |
#include <qtimer.h> |
| 18 |
|
| 19 |
class v4lxif; |
| 20 |
class V4LWindow; |
| 21 |
|
| 22 |
class QPopupMenu; |
| 23 |
class QLabel; |
| 24 |
class QListView; |
| 25 |
class QComboBox; |
| 26 |
class QCheckBox; |
| 27 |
class QDateTimeEdit; |
| 28 |
class QTimeEdit; |
| 29 |
class QSplitter; |
| 30 |
class QGroupBox; |
| 31 |
class QPushButton; |
| 32 |
class QButtonGroup; |
| 33 |
class QLineEdit; |
| 34 |
class QListViewItem; |
| 35 |
class QFrame; |
| 36 |
class QMessageBox; |
| 37 |
|
| 38 |
class TimerTable; |
| 39 |
class EpgWindow; |
| 40 |
class EpgProgram; |
| 41 |
|
| 42 |
#define WATCHDOG_TIMERTABLE "/tmp/avicap-watchdog/timertable" |
| 43 |
|
| 44 |
QDateTime dateTimeFromString(QString datestr); |
| 45 |
QString dateTimeToString(QDateTime dt); |
| 46 |
|
| 47 |
#if QT_VERSION<300 |
| 48 |
class ADateTimeEdit : public QLineEdit |
| 49 |
{ |
| 50 |
public: |
| 51 |
ADateTimeEdit(QWidget *w,QString name); |
| 52 |
void setDateTime(QDateTime datetime); |
| 53 |
void setTime(QTime time); |
| 54 |
void updateFromWidget(); |
| 55 |
QDateTime dateTime() { updateFromWidget(); printf("datetime: %s\n",datetime.toString().latin1()); return datetime; }; |
| 56 |
QTime time() { updateFromWidget(); return datetime.time(); }; |
| 57 |
QString toString(QDateTime dt); |
| 58 |
|
| 59 |
private: |
| 60 |
QDateTime datetime; |
| 61 |
|
| 62 |
#define QDateTimeEdit ADateTimeEdit |
| 63 |
#define ATimeEdit ADateTimeEdit |
| 64 |
#define QTimeEdit ATimeEdit |
| 65 |
}; |
| 66 |
#endif |
| 67 |
|
| 68 |
#if QT_VERSION>=300 |
| 69 |
static QString my_timeformat="hh:mm:ss"; |
| 70 |
static QString my_dateformat=("dd MMM yyyy "+my_timeformat+" ddd"); |
| 71 |
#else |
| 72 |
#define my_timeformat |
| 73 |
#define my_dateformat |
| 74 |
#endif |
| 75 |
|
| 76 |
enum TimerMode { TimerOff,TimerWaiting,TimerRecording }; |
| 77 |
|
| 78 |
//#define my_tabletype QListView |
| 79 |
//#define my_tableitemtype QListViewItem |
| 80 |
|
| 81 |
class TimerTableItem: public QCheckListItem, public avm::AvmOutputLog |
| 82 |
{ |
| 83 |
|
| 84 |
public: |
| 85 |
TimerTableItem(QListView *parent,TimerTable *timer_win,V4LWindow *v4lw,int ch,QDateTime start,QTime stop,QString fname,QString description,int when,int day,QString codec); |
| 86 |
//TimerTableItem(QWidget *parent); |
| 87 |
~TimerTableItem(); |
| 88 |
|
| 89 |
void setTable(int ch,QDateTime start,QTime stop,QString fname,QString description,int when,int day,QString codec); |
| 90 |
|
| 91 |
void checkWhen(); |
| 92 |
|
| 93 |
int compare(QListViewItem *other,int col, bool ascend) const; |
| 94 |
void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ); |
| 95 |
|
| 96 |
|
| 97 |
private: |
| 98 |
QDateTime start_time; |
| 99 |
QTime stop_time; |
| 100 |
QDateTime stop_datetime; |
| 101 |
int channel_nr; |
| 102 |
QString filename; |
| 103 |
QString description; |
| 104 |
int when,day; |
| 105 |
QString named_codec; |
| 106 |
|
| 107 |
TimerTable *timer_window; |
| 108 |
V4LWindow *my_v4lwin; |
| 109 |
|
| 110 |
public: |
| 111 |
QDateTime getStartTime() const { return start_time; }; |
| 112 |
QTime getStopTime() const { return stop_time; }; |
| 113 |
QDateTime getStopDateTime() const { return stop_datetime; }; |
| 114 |
QString getFilename() const { return filename; }; |
| 115 |
int getWhen() const { return when; }; |
| 116 |
int getDay() const { return day; }; |
| 117 |
int getChannel() const { return channel_nr; }; |
| 118 |
QString getNamedCodec() const { return named_codec; }; |
| 119 |
QString getDescription() const { return description; }; |
| 120 |
|
| 121 |
}; |
| 122 |
|
| 123 |
class TimerTable: public QDialog, public avm::AvmOutputLog |
| 124 |
{ |
| 125 |
Q_OBJECT; |
| 126 |
public: |
| 127 |
|
| 128 |
TimerTable( QWidget* parent, v4lxif* v4l, V4LWindow* w); |
| 129 |
~TimerTable(); |
| 130 |
void save(); |
| 131 |
void load(); |
| 132 |
void startTimer(bool set_shutdown); |
| 133 |
QDateTime calc_stopDateTime(QDateTime start_datetime,QTime stop_time); |
| 134 |
void setEpgWindow(EpgWindow *win); |
| 135 |
TimerTableItem *firstTableItem() { return (TimerTableItem *)table->firstChild(); }; |
| 136 |
public slots: |
| 137 |
void addEpgRecording(EpgProgram *prog); |
| 138 |
void button_new_pressed(); |
| 139 |
void button_remove_pressed(); |
| 140 |
void button_modify_pressed(); |
| 141 |
void button_start_pressed(); |
| 142 |
void item_clicked(QListViewItem *item); |
| 143 |
void timer(); |
| 144 |
|
| 145 |
signals: |
| 146 |
void nextRecordingChanged(TimerTableItem *next_recording); |
| 147 |
void currentRecordingChanged(TimerTableItem *current_recording); |
| 148 |
void timertableChanged(); |
| 149 |
|
| 150 |
protected: |
| 151 |
|
| 152 |
private: |
| 153 |
void recreateCodecBox(QString set_name); |
| 154 |
void init_entry_widgets(); |
| 155 |
void set_status_label(); |
| 156 |
TimerTableItem* find_first_recording(); |
| 157 |
TimerTableItem* set_tableitem(TimerTableItem *item); |
| 158 |
void stop_current_recording(); |
| 159 |
QString add_current_time_info(); |
| 160 |
QString add_current_recording_info(); |
| 161 |
QString add_next_recording_info(); |
| 162 |
QString add_sanity_check_info(); |
| 163 |
void check_for_shutdown(); |
| 164 |
QString find_filename(QString filename); |
| 165 |
|
| 166 |
TimerMode timer_mode; |
| 167 |
|
| 168 |
v4lxif *my_v4lxif; |
| 169 |
V4LWindow *my_v4lw; |
| 170 |
EpgWindow *epgwin; |
| 171 |
|
| 172 |
QSplitter *splitter1; |
| 173 |
//QGroupBox *edit_box; |
| 174 |
QWidget *edit_box; |
| 175 |
QGroupBox *all_box; |
| 176 |
|
| 177 |
QListView *table; |
| 178 |
QComboBox *channelbox; |
| 179 |
QComboBox *codecbox; |
| 180 |
|
| 181 |
QDateTimeEdit *begin_timeedit; |
| 182 |
QTimeEdit *end_timeedit; |
| 183 |
QLineEdit *filename_edit; |
| 184 |
QLineEdit *description_edit; |
| 185 |
|
| 186 |
QButtonGroup *edit_buttons; |
| 187 |
QPushButton *new_button; |
| 188 |
QPushButton *modify_button; |
| 189 |
QPushButton *remove_button; |
| 190 |
|
| 191 |
QButtonGroup *rec_buttons; |
| 192 |
QPushButton *rec_start_button; |
| 193 |
QPushButton *rec_stop_button; |
| 194 |
QCheckBox *shutdown_checkbox; |
| 195 |
|
| 196 |
QFrame *status_frame; |
| 197 |
QLabel *status_label; |
| 198 |
|
| 199 |
QComboBox *when_combobox; |
| 200 |
QComboBox *day_combobox; |
| 201 |
|
| 202 |
QMessageBox *shutdown_message; |
| 203 |
QDateTime shutdown_time; |
| 204 |
|
| 205 |
TimerTableItem *next_recording,*last_next_recording; |
| 206 |
TimerTableItem *current_recording,*last_current_recording; |
| 207 |
TimerTableItem *last_item_clicked; |
| 208 |
|
| 209 |
QTimer *my_timer; |
| 210 |
|
| 211 |
public: |
| 212 |
TimerTableItem *getCurrentRecording() { return current_recording; }; |
| 213 |
TimerTableItem *getNextRecording() { return next_recording; }; |
| 214 |
}; |
| 215 |
|
| 216 |
#endif |