korganizer

kodaymatrix.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
00005     Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
00006     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00007 
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     This program is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with this program; if not, write to the Free Software
00020     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00021 
00022     As a special exception, permission is given to link this program
00023     with any edition of Qt, and distribute the resulting executable,
00024     without including the source code for Qt in the source distribution.
00025 */
00026 #ifndef KODAYMATRIX_H
00027 #define KODAYMATRIX_H
00028 
00029 #include <libkcal/incidencebase.h>
00030 
00031 #include <qframe.h>
00032 #include <qcolor.h>
00033 #include <qtooltip.h>
00034 #include <qmap.h>
00035 
00036 class QDragEnterEvent;
00037 class QDragMoveEvent;
00038 class QDragLeaveEvent;
00039 class QDropEvent;
00040 
00041 class KODayMatrix;
00042 
00043 namespace KCal {
00044 class Incidence;
00045 class Calendar;
00046 }
00047 using namespace KCal;
00048 
00049 
00055 class DynamicTip : public QToolTip
00056 {
00057   public:
00063     DynamicTip( QWidget *parent );
00064 
00065   protected:
00072     void maybeTip( const QPoint &pos );
00073 
00074   private:
00076     KODayMatrix *mMatrix;
00077 };
00078 
00104 class KODayMatrix: public QFrame
00105 {
00106     Q_OBJECT
00107   public:
00114     KODayMatrix( QWidget *parent, const char *name );
00115 
00118     ~KODayMatrix();
00119 
00124     void setCalendar( Calendar * );
00125 
00133     void updateView( const QDate &actdate );
00134 
00139     void updateEvents();
00140 
00144     const QDate& getDate( int offset );
00145 
00149     QString getHolidayLabel( int offset );
00150 
00154     void addSelectedDaysTo( DateList & );
00155 
00160     void setSelectedDaysFrom( const QDate &start, const QDate &end );
00161 
00165     void clearSelection();
00166 
00170     bool isTodayVisible() const { return mToday >= 0; }
00171 
00178     bool isBeginningOfMonth() const { return mToday <= 8; }
00179     bool isEndOfMonth() const { return mToday >= 27; }
00180 
00181   public slots:
00185     void updateView();
00186 
00191     void recalculateToday();
00192 
00193   signals:
00199     void selected( const KCal::DateList &daylist );
00200 
00206     void incidenceDropped( Incidence *incidence, const QDate &dt );
00212     void incidenceDroppedMove( Incidence *oldincidence, const QDate &dt );
00213 
00214   protected:
00215     void paintEvent( QPaintEvent *ev );
00216 
00217     void mousePressEvent( QMouseEvent *e );
00218 
00219     void mouseReleaseEvent( QMouseEvent *e );
00220 
00221     void mouseMoveEvent( QMouseEvent *e );
00222 
00223     void dragEnterEvent( QDragEnterEvent * );
00224 
00225     void dragMoveEvent( QDragMoveEvent * );
00226 
00227     void dragLeaveEvent( QDragLeaveEvent * );
00228 
00229     void dropEvent( QDropEvent * );
00230 
00231     void resizeEvent( QResizeEvent * );
00232 
00233   private:
00239     int getDayIndexFrom( int x, int y );
00240 
00246     QColor getShadedColor( const QColor &color );
00247 
00250     static const int NUMDAYS;
00251 
00253     Calendar  *mCalendar;
00254 
00256     QDate     mStartDate;
00257 
00259     QString   *mDayLabels;
00260 
00263     QDate     *mDays;
00264 
00268     int      *mEvents;
00269 
00271     QMap<int,QString>  mHolidays;
00272 
00274     int       mToday;
00275 
00278     int       mSelInit;
00279 
00282     static const int NOSELECTION;
00283 
00285     int       mSelStart;
00286 
00288     int       mSelEnd;
00289 
00291     DynamicTip* mToolTip;
00292 
00294     int       mTodayMarginWidth;
00295 
00299     QRect     mDaySize;
00300 };
00301 
00302 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys