00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef DATEBOOKWEEK
00032 #define DATEBOOKWEEK
00033
00034 #include <qpe/event.h>
00035
00036 #include <qlist.h>
00037 #include <qscrollview.h>
00038 #include <qstring.h>
00039 #include <qvaluelist.h>
00040
00041 class DateBookDB;
00042 class DateBookDBHoliday;
00043 class DateBookWeekHeader;
00044 class QDate;
00045 class QLabel;
00046 class QResizeEvent;
00047 class QSpinBox;
00048 class QTimer;
00049 class QHeader;
00050
00051 class DateBookWeekItem
00052 {
00053 public:
00054 DateBookWeekItem( const EffectiveEvent e );
00055
00056 void setGeometry( int x, int y, int w, int h );
00057 QRect geometry() const { return r; }
00058
00059 const QColor &color() const { return c; }
00060 const EffectiveEvent event() const { return ev; }
00061
00062 private:
00063 const EffectiveEvent ev;
00064 QRect r;
00065 QColor c;
00066 };
00067
00068 class DateBookWeekView : public QScrollView
00069 {
00070 Q_OBJECT
00071 public:
00072 DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0,
00073 const char *name = 0 );
00074
00075 bool whichClock() const;
00076 void showEvents( QValueList<EffectiveEvent> &ev );
00077 void moveToHour( int h );
00078 void setStartOfWeek( bool bOnMonday );
00079
00080 signals:
00081 void showDay( int d );
00082 void signalShowEvent( const EffectiveEvent & );
00083 void signalHideEvent();
00084
00085 protected slots:
00086 void keyPressEvent(QKeyEvent *);
00087
00088 private slots:
00089 void slotChangeClock( bool );
00090 void alterDay( int );
00091
00092 private:
00093 void positionItem( DateBookWeekItem *i );
00094 DateBookWeekItem *intersects( const DateBookWeekItem * );
00095 void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
00096 void contentsMousePressEvent( QMouseEvent * );
00097 void contentsMouseReleaseEvent( QMouseEvent * );
00098 void resizeEvent( QResizeEvent * );
00099 void initNames();
00100
00101 private:
00102 bool ampm;
00103 bool bOnMonday;
00104 QHeader *header;
00105 QList<DateBookWeekItem> items;
00106 int rowHeight;
00107 bool showingEvent;
00108 };
00109
00110 class DateBookWeek : public QWidget
00111 {
00112 Q_OBJECT
00113
00114 public:
00115 DateBookWeek( bool ampm, bool weekOnMonday, DateBookDBHoliday *newDB,
00116 QWidget *parent = 0, const char *name = 0 );
00117 void setDate( int y, int m, int d );
00118 void setDate( QDate d );
00119 QDate date() const;
00120 DateBookWeekView *weekView() const { return view; }
00121 void setStartViewTime( int startHere );
00122 int startViewTime() const;
00123 int week() const { return _week; };
00124 QDate weekDate() const;
00125
00126 public slots:
00127 void redraw();
00128 void slotWeekChanged( bool bStartOnMonday );
00129 void slotClockChanged( bool a );
00130
00131 signals:
00132 void showDate( int y, int m, int d );
00133
00134 protected slots:
00135 void keyPressEvent(QKeyEvent *);
00136
00137 private slots:
00138 void showDay( int day );
00139 void dateChanged( QDate &newdate );
00140 void slotShowEvent( const EffectiveEvent & );
00141 void slotHideEvent();
00142 void slotYearChanged( int );
00143
00144 private:
00145 void getEvents();
00146
00154 void generateAllDayTooltext( QString& text );
00155
00160 void generateNormalTooltext( QString& text,
00161 const EffectiveEvent &ev);
00162 int year;
00163 int _week;
00164 int dow;
00165 QDate bdate;
00166 DateBookWeekHeader *header;
00167 DateBookWeekView *view;
00168 DateBookDBHoliday *db;
00169 QLabel *lblDesc;
00170 QTimer *tHide;
00171 int startTime;
00172 bool ampm;
00173 bool bStartOnMonday;
00174 };
00175
00176
00177 bool calcWeek( const QDate &d, int &week, int &year, bool startOnMonday = false );
00178 #endif