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 #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 
00125     void setCalendar( Calendar * );
00126 
00134     void updateView( const QDate &actdate );
00135 
00140     void updateEvents();
00141 
00145     const QDate& getDate( int offset );
00146 
00150     QString getHolidayLabel( int offset );
00151 
00155     void addSelectedDaysTo( DateList & );
00156 
00161     void setSelectedDaysFrom( const QDate &start, const QDate &end );
00162 
00166     void clearSelection();
00167 
00171     bool isTodayVisible() const { return mToday >= 0; }
00172 
00179     bool isBeginningOfMonth() const { return mToday <= 8; }
00180     bool isEndOfMonth() const { return mToday >= 27; }
00181 
00182     /* reimplmented from KCal::Calendar::Observer */
00183     void calendarIncidenceAdded( Incidence *incidence );
00184     void calendarIncidenceChanged( Incidence *incidence );
00185     void calendarIncidenceDeleted( Incidence *incidence );
00186 
00187     void setUpdateNeeded();
00188 
00189   public slots:
00193     void updateView();
00194 
00199     void recalculateToday();
00200 
00204     void resourcesChanged();
00205 
00206   signals:
00212     void selected( const KCal::DateList &daylist );
00213 
00219     void incidenceDropped( Incidence *incidence, const QDate &dt );
00225     void incidenceDroppedMove( Incidence *oldincidence, const QDate &dt );
00226 
00227   protected:
00228     void paintEvent( QPaintEvent *ev );
00229 
00230     void mousePressEvent( QMouseEvent *e );
00231 
00232     void mouseReleaseEvent( QMouseEvent *e );
00233 
00234     void mouseMoveEvent( QMouseEvent *e );
00235 
00236     void dragEnterEvent( QDragEnterEvent * );
00237 
00238     void dragMoveEvent( QDragMoveEvent * );
00239 
00240     void dragLeaveEvent( QDragLeaveEvent * );
00241 
00242     void dropEvent( QDropEvent * );
00243 
00244     void resizeEvent( QResizeEvent * );
00245 
00246   private:
00252     int getDayIndexFrom( int x, int y );
00253 
00259     QColor getShadedColor( const QColor &color );
00260 
00263     static const int NUMDAYS;
00264 
00266     Calendar  *mCalendar;
00267 
00269     QDate     mStartDate;
00270 
00272     QString   *mDayLabels;
00273 
00276     QDate     *mDays;
00277 
00281     int      *mEvents;
00282 
00284     QMap<int,QString>  mHolidays;
00285 
00287     int       mToday;
00288 
00291     int       mSelInit;
00292 
00295     static const int NOSELECTION;
00296 
00298     int       mSelStart;
00299 
00301     int       mSelEnd;
00302 
00304     DynamicTip* mToolTip;
00305 
00307     int       mTodayMarginWidth;
00308 
00312     QRect     mDaySize;
00313 
00317     bool mPendingChanges;
00318 };
00319 
00320 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys