korganizer
kodaymatrix.h00001
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 #ifndef KODAYMATRIX_H
00027 #define KODAYMATRIX_H
00028
00029 #include <libkcal/incidencebase.h>
00030 #include <libkcal/calendar.h>
00031
00032 #include <qframe.h>
00033 #include <qcolor.h>
00034 #include <qtooltip.h>
00035 #include <qmap.h>
00036
00037 class QDragEnterEvent;
00038 class QDragMoveEvent;
00039 class QDragLeaveEvent;
00040 class QDropEvent;
00041
00042 class KODayMatrix;
00043
00044 namespace KCal {
00045 class Incidence;
00046 class Calendar;
00047 }
00048 using namespace KCal;
00049
00050
00056 class DynamicTip : public QToolTip
00057 {
00058 public:
00064 DynamicTip( QWidget *parent );
00065
00066 protected:
00073 void maybeTip( const QPoint &pos );
00074
00075 private:
00077 KODayMatrix *mMatrix;
00078 };
00079
00105 class KODayMatrix: public QFrame, public KCal::Calendar::Observer
00106 {
00107 Q_OBJECT
00108 public:
00115 KODayMatrix( QWidget *parent, const char *name );
00116
00119 ~KODayMatrix();
00120
00124 static QPair<QDate,QDate> matrixLimits( const QDate &month );
00125
00130 void setCalendar( Calendar * );
00131
00139 void updateView( const QDate &actdate );
00140
00145 void updateEvents();
00146
00150 const QDate& getDate( int offset );
00151
00155 QString getHolidayLabel( int offset );
00156
00160 void addSelectedDaysTo( DateList & );
00161
00166 void setSelectedDaysFrom( const QDate &start, const QDate &end );
00167
00171 void clearSelection();
00172
00176 bool isTodayVisible() const { return mToday >= 0; }
00177
00184 bool isBeginningOfMonth() const { return mToday <= 8; }
00185 bool isEndOfMonth() const { return mToday >= 27; }
00186
00187
00188 void calendarIncidenceAdded( Incidence *incidence );
00189 void calendarIncidenceChanged( Incidence *incidence );
00190 void calendarIncidenceDeleted( Incidence *incidence );
00191
00192 void setUpdateNeeded();
00193
00194 public slots:
00198 void updateView();
00199
00204 void recalculateToday();
00205
00209 void resourcesChanged();
00210
00211 signals:
00217 void selected( const KCal::DateList &daylist );
00218
00224 void incidenceDropped( Incidence *incidence, const QDate &dt );
00230 void incidenceDroppedMove( Incidence *oldincidence, const QDate &dt );
00231
00232 protected:
00233 void paintEvent( QPaintEvent *ev );
00234
00235 void mousePressEvent( QMouseEvent *e );
00236
00237 void mouseReleaseEvent( QMouseEvent *e );
00238
00239 void mouseMoveEvent( QMouseEvent *e );
00240
00241 void dragEnterEvent( QDragEnterEvent * );
00242
00243 void dragMoveEvent( QDragMoveEvent * );
00244
00245 void dragLeaveEvent( QDragLeaveEvent * );
00246
00247 void dropEvent( QDropEvent * );
00248
00249 void resizeEvent( QResizeEvent * );
00250
00251 private:
00257 int getDayIndexFrom( int x, int y );
00258
00264 QColor getShadedColor( const QColor &color );
00265
00268 static const int NUMDAYS;
00269
00271 Calendar *mCalendar;
00272
00274 QDate mStartDate;
00275
00277 QString *mDayLabels;
00278
00281 QDate *mDays;
00282
00286 int *mEvents;
00287
00289 QMap<int,QString> mHolidays;
00290
00292 int mToday;
00293
00296 int mSelInit;
00297
00300 static const int NOSELECTION;
00301
00303 int mSelStart;
00304
00306 int mSelEnd;
00307
00309 DynamicTip* mToolTip;
00310
00312 int mTodayMarginWidth;
00313
00317 QRect mDaySize;
00318
00322 bool mPendingChanges;
00323 };
00324
00325 #endif
|