00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef DATEBOOKMONTH
00021 #define DATEBOOKMONTH
00022
00023 #include <qtopia/private/event.h>
00024
00025 #include <qvbox.h>
00026 #include <qhbox.h>
00027 #include <qdatetime.h>
00028 #include <qvaluelist.h>
00029 #include <qtable.h>
00030 #include <qpushbutton.h>
00031 #include <qpopupmenu.h>
00032
00033 #include "calendar.h"
00034 #include "timestring.h"
00035
00036 class QToolButton;
00037 class QComboBox;
00038 class QSpinBox;
00039 class Event;
00040 class DateBookDB;
00041
00042 class DateBookMonthHeaderPrivate;
00043 class DateBookMonthHeader : public QHBox
00044 {
00045 Q_OBJECT
00046
00047 public:
00048 DateBookMonthHeader( QWidget *parent = 0, const char *name = 0 );
00049 ~DateBookMonthHeader();
00050 void setDate( int year, int month );
00051
00052 signals:
00053 void dateChanged( int year, int month );
00054
00055 protected slots:
00056 void keyPressEvent(QKeyEvent *e ) {
00057 e->ignore();
00058 }
00059
00060 private slots:
00061 void updateDate();
00062 void firstMonth();
00063 void lastMonth();
00064 void monthBack();
00065 void monthForward();
00066
00067 private:
00068 QToolButton *begin, *back, *next, *end;
00069 QComboBox *month;
00070 QSpinBox *year;
00071 DateBookMonthHeaderPrivate *d;
00072 int focus;
00073 };
00074
00075 class DayItemMonthPrivate;
00076 class DayItemMonth : public QTableItem
00077 {
00078 public:
00079 DayItemMonth( QTable *table, EditType et, const QString &t );
00080 ~DayItemMonth();
00081 void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected );
00082 void setDay( int d ) { dy = d; }
00083 void setEvents( const QValueList<Event> &events ) { daysEvents = events; };
00084 void setEvents( const QValueList<EffectiveEvent> &effEvents );
00085 void clearEvents() { daysEvents.clear(); };
00086 void clearEffEvents();
00087 int day() const { return dy; }
00088 void setType( Calendar::Day::Type t );
00089 Calendar::Day::Type type() const { return typ; }
00090
00091 private:
00092 QBrush back;
00093 QColor forg;
00094 int dy;
00095 Calendar::Day::Type typ;
00096 QValueList<Event> daysEvents;
00097 DayItemMonthPrivate *d;
00098 };
00099
00100 class DateBookMonthTablePrivate;
00101 class DateBookMonthTable : public QTable
00102 {
00103 Q_OBJECT
00104
00105 public:
00106 DateBookMonthTable( QWidget *parent = 0, const char *name = 0,
00107 DateBookDB *newDb = 0 );
00108 ~DateBookMonthTable();
00109 void setDate( int y, int m, int d );
00110 void redraw();
00111
00112 QSize minimumSizeHint() const { return sizeHint(); }
00113 QSize minimumSize() const { return sizeHint(); }
00114 void getDate( int& y, int &m, int &d ) const {y=selYear;m=selMonth;d=selDay;}
00115 void setWeekStart( bool onMonday );
00116 signals:
00117 void dateClicked( int year, int month, int day );
00118
00119 protected:
00120 void viewportMouseReleaseEvent( QMouseEvent * );
00121
00122 protected slots:
00123
00124 void keyPressEvent(QKeyEvent *e ) {
00125 e->ignore();
00126 }
00127
00128 private slots:
00129 void dayClicked( int row, int col );
00130 void dragDay( int row, int col );
00131
00132 private:
00133 void setupTable();
00134 void setupLabels();
00135
00136 void findDay( int day, int &row, int &col );
00137 void getEvents();
00138 void changeDaySelection( int row, int col );
00139
00140 int year, month, day;
00141 int selYear, selMonth, selDay;
00142 QValueList<Event> monthsEvents;
00143 DateBookDB *db;
00144 DateBookMonthTablePrivate *d;
00145 };
00146
00147 class DateBookMonthPrivate;
00148 class DateBookMonth : public QVBox
00149 {
00150 Q_OBJECT
00151
00152 public:
00153
00154 DateBookMonth( QWidget *parent = 0, const char *name = 0, bool ac = FALSE,
00155 DateBookDB *data = 0 );
00156 ~DateBookMonth();
00157 QDate selectedDate() const;
00158
00159 signals:
00160
00161 void dateClicked( int year, int month, int day );
00162
00163 public slots:
00164 void setDate( int y, int m );
00165 void setDate( int y, int m, int d );
00166 void setDate( QDate );
00167 void redraw();
00168 void slotWeekChange( bool );
00169
00170 protected slots:
00171 virtual void keyPressEvent(QKeyEvent *e);
00172
00173 private slots:
00174 void forwardDateClicked( int y, int m, int d ) { emit dateClicked( y, m, d ); }
00175 void finalDate(int, int, int);
00176
00177 private:
00178 DateBookMonthHeader *header;
00179 DateBookMonthTable *table;
00180 int year, month, day;
00181 bool autoClose;
00182 class DateBookMonthPrivate *d;
00183 };
00184
00185 class DateButton : public QPushButton
00186 {
00187 Q_OBJECT
00188
00189 public:
00190 DateButton( bool longDate, QWidget *parent, const char * name = 0 );
00191 QDate date() const { return currDate; }
00192
00193 bool customWhatsThis() const;
00194
00195 signals:
00196 void dateSelected( int year, int month, int day );
00197
00198 public slots:
00199 void setDate( int y, int m, int d );
00200 void setDate( QDate );
00201 void setWeekStartsMonday( int );
00202 void setDateFormat( DateFormat );
00203
00204 private slots:
00205 void pickDate();
00206 void gotHide();
00207
00208 private:
00209 bool longFormat;
00210 bool weekStartsMonday;
00211 QDate currDate;
00212 DateFormat df;
00213 };
00214
00215
00216
00217
00218
00219
00220 class DateBookMonthPopup : public QPopupMenu
00221 {
00222 Q_OBJECT
00223 public:
00224 DateBookMonthPopup ( QWidget *w );
00225
00226 private:
00227 DateBookMonth *m_dbm;
00228 };
00229
00230 #endif