korganizer Library API Documentation

koagenda.h

00001 /* 00002 This file is part of KOrganizer. 00003 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 00022 */ 00023 #ifndef KOAGENDA_H 00024 #define KOAGENDA_H 00025 00026 #include <qscrollview.h> 00027 #include <qlabel.h> 00028 #include <qtimer.h> 00029 #include <qmemarray.h> 00030 #include <qguardedptr.h> 00031 00032 #include "koagendaitem.h" 00033 00034 class QPopupMenu; 00035 class QTime; 00036 class KConfig; 00037 class QFrame; 00038 class KOAgenda; 00039 00040 using namespace KCal; 00041 namespace KCal { 00042 class Event; 00043 class Todo; 00044 class Calendar; 00045 } 00046 00047 class MarcusBains : public QFrame { 00048 Q_OBJECT 00049 public: 00050 MarcusBains( KOAgenda *agenda = 0, const char *name = 0 ); 00051 virtual ~MarcusBains(); 00052 00053 public slots: 00054 void updateLocation( bool recalculate = false ); 00055 00056 private: 00057 int todayColumn(); 00058 QTimer *minutes; 00059 QLabel *mTimeBox; 00060 KOAgenda *agenda; 00061 QTime oldTime; 00062 int oldToday; 00063 }; 00064 00065 00066 class KOAgenda : public QScrollView 00067 { 00068 Q_OBJECT 00069 public: 00070 KOAgenda ( int columns, int rows, int columnSize, QWidget *parent=0, 00071 const char *name = 0, WFlags f = 0 ); 00072 KOAgenda ( int columns, QWidget *parent = 0, 00073 const char *name = 0, WFlags f = 0 ); 00074 virtual ~KOAgenda(); 00075 00076 Incidence *selectedIncidence() const; 00077 QDate selectedIncidenceDate() const; 00078 00079 virtual bool eventFilter ( QObject *, QEvent * ); 00080 00081 void contentsToGrid ( int x, int y, int &gx, int &gy ); 00082 void gridToContents ( int gx, int gy, int &x, int &y ); 00083 00084 int timeToY ( const QTime &time ); 00085 QTime gyToTime ( int y ); 00086 00087 void setStartHour( int startHour ); 00088 00089 KOAgendaItem *insertItem ( Incidence *event, QDate qd, int X, int YTop, 00090 int YBottom ); 00091 KOAgendaItem *insertAllDayItem ( Incidence *event, QDate qd, int XBegin, 00092 int XEnd ); 00093 void insertMultiItem ( Event *event, QDate qd, int XBegin, int XEnd, 00094 int YTop, int YBottom ); 00095 00100 void removeEvent( Event *event ); 00101 00102 void changeColumns( int columns ); 00103 00104 int columns() { return mColumns; } 00105 int rows() { return mRows; } 00106 00107 double gridSpacingX() const { return mGridSpacingX; } 00108 double gridSpacingY() const { return mGridSpacingY; } 00109 00110 // virtual QSizePolicy sizePolicy() const; 00111 00112 void clear(); 00113 00114 void clearSelection(); 00115 00117 virtual int minimumWidth() const; 00119 void updateConfig(); 00120 00121 void checkScrollBoundaries(); 00122 00123 void setHolidayMask( QMemArray<bool> * ); 00124 00125 void setDateList( const DateList &selectedDates ); 00126 DateList dateList() const; 00127 00128 void setTypeAheadReceiver( QObject * ); 00129 QObject *typeAheadReceiver() const; 00130 void finishTypeAhead(); 00131 00132 void setCalendar( Calendar*cal ) { mCalendar=cal; } 00133 00134 public slots: 00135 void scrollUp(); 00136 void scrollDown(); 00137 00138 void popupAlarm(); 00139 00140 void checkScrollBoundaries( int ); 00141 00143 void deselectItem(); 00149 void selectItem( KOAgendaItem * ); 00150 bool removeAgendaItem( KOAgendaItem *item ); 00151 void showAgendaItem( KOAgendaItem *item ); 00152 00153 signals: 00154 void newEventSignal(); 00155 void newEventSignal( int gx, int gy ); 00156 void newEventSignal( int gxStart, int gyStart, int gxEnd, int gyEnd ); 00157 void newTimeSpanSignal( int gxStart, int gyStart, int gxEnd, int gyEnd ); 00158 void newStartSelectSignal(); 00159 00160 void showIncidenceSignal( Incidence * ); 00161 void editIncidenceSignal( Incidence * ); 00162 void deleteIncidenceSignal( Incidence * ); 00163 void showIncidencePopupSignal( Incidence * ); 00164 void showNewEventPopupSignal(); 00165 00166 void itemModified( KOAgendaItem *item ); 00167 void incidenceSelected( Incidence * ); 00168 00169 void lowerYChanged( int ); 00170 void upperYChanged( int ); 00171 00172 void startDragSignal(Incidence *); 00173 void droppedToDo( Todo*todo, int gx, int gy, bool allDay ); 00174 00175 protected: 00176 void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); 00177 virtual void resizeEvent ( QResizeEvent * ); 00178 00180 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 00182 virtual bool eventFilter_key ( QObject *, QKeyEvent * ); 00183 00185 virtual bool eventFilter_drag( QObject *, QDropEvent * ); 00186 00188 void startSelectAction( const QPoint &viewportPos ); 00189 00191 void performSelectAction( const QPoint &viewportPos ); 00192 00194 void endSelectAction( const QPoint &viewportPos ); 00195 00197 void startItemAction(const QPoint& viewportPos); 00198 00200 void performItemAction(const QPoint& viewportPos); 00201 00203 void endItemAction(); 00204 00206 void setNoActionCursor( KOAgendaItem *moveItem, const QPoint &viewportPos ); 00207 00209 double calcSubCellWidth( KOAgendaItem *item ); 00211 void placeAgendaItem( KOAgendaItem *item, double subCellWidth ); 00213 void placeSubCells( KOAgendaItem *placeItem ); 00214 00218 void keyPressEvent( QKeyEvent * ); 00219 00220 void calculateWorkingHours(); 00221 00222 virtual void contentsMousePressEvent ( QMouseEvent * ); 00223 00224 void emitNewEventForSelection(); 00225 00226 protected slots: 00228 void deleteItemsToDelete(); 00229 00230 private: 00231 void init(); 00232 void marcus_bains(); 00233 bool mAllDayMode; 00234 00235 // We need the calendar for drag'n'drop 00236 Calendar *mCalendar; 00237 00238 // Width and height of agenda cells. mDesiredGridSpacingY is the height 00239 // set in the config. The actual height might be larger since otherwise 00240 // more than 24 hours might be displayed. 00241 double mGridSpacingX; 00242 double mGridSpacingY; 00243 double mDesiredGridSpacingY; 00244 00245 // size of border, where mouse action will resize the KOAgendaItem 00246 int mResizeBorderWidth; 00247 00248 // size of border, where mouse mve will cause a scroll of the agenda 00249 int mScrollBorderWidth; 00250 int mScrollDelay; 00251 int mScrollOffset; 00252 00253 QTimer mScrollUpTimer; 00254 QTimer mScrollDownTimer; 00255 00256 // Number of Columns/Rows of agenda grid 00257 int mColumns; 00258 int mRows; 00259 00260 // Cells to store Move and Resize coordiantes 00261 int mStartCellX; 00262 int mStartCellY; 00263 int mCurrentCellX; 00264 int mCurrentCellY; 00265 00266 // Working Hour coordiantes 00267 bool mWorkingHoursEnable; 00268 int mWorkingHoursYTop; 00269 int mWorkingHoursYBottom; 00270 00271 // Selection 00272 QPoint mSelectionStartPoint; 00273 int mSelectionCellX; 00274 int mSelectionYTop; 00275 int mSelectionHeight; 00276 00277 // List of dates to be displayed 00278 DateList mSelectedDates; 00279 00280 // The KOAgendaItem, which has been right-clicked last 00281 QGuardedPtr<KOAgendaItem> mClickedItem; 00282 00283 // The KOAgendaItem, which is being moved/resized 00284 QGuardedPtr<KOAgendaItem> mActionItem; 00285 00286 // Currently selected item 00287 QGuardedPtr<KOAgendaItem> mSelectedItem; 00288 00289 // The Marcus Bains Line widget. 00290 MarcusBains *mMarcusBains; 00291 00292 enum MouseActionType { NOP, MOVE, SELECT, 00293 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 00294 00295 MouseActionType mActionType; 00296 00297 bool mItemMoved; 00298 00299 // List of all Items contained in agenda 00300 QPtrList<KOAgendaItem> mItems; 00301 QPtrList<KOAgendaItem> mItemsToDelete; 00302 00303 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 00304 00305 int mOldLowerScrollValue; 00306 int mOldUpperScrollValue; 00307 00308 QMemArray<bool> *mHolidayMask; 00309 00310 bool mTypeAhead; 00311 QObject *mTypeAheadReceiver; 00312 QPtrList<QEvent> mTypeAheadEvents; 00313 00314 bool mReturnPressed; 00315 }; 00316 00317 #endif // KOAGENDA_H
KDE Logo
This file is part of the documentation for korganizer Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:13 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003