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 <qtimer.h> 00028 #include <qguardedptr.h> 00029 #include <libkcal/incidencebase.h> 00030 00031 class QPopupMenu; 00032 class QTime; 00033 class QLabel; 00034 class KConfig; 00035 class KOAgenda; 00036 class KOAgendaItem; 00037 00038 using namespace KCal; 00039 namespace KCal { 00040 class Event; 00041 class Todo; 00042 class Calendar; 00043 } 00044 00045 class MarcusBains : public QFrame { 00046 Q_OBJECT 00047 public: 00048 MarcusBains( KOAgenda *agenda = 0, const char *name = 0 ); 00049 virtual ~MarcusBains(); 00050 00051 public slots: 00052 void updateLocation( bool recalculate = false ); 00053 00054 private: 00055 int todayColumn(); 00056 QTimer *minutes; 00057 QLabel *mTimeBox; 00058 KOAgenda *agenda; 00059 QTime oldTime; 00060 int oldToday; 00061 }; 00062 00063 00064 class KOAgenda : public QScrollView 00065 { 00066 Q_OBJECT 00067 public: 00068 KOAgenda ( int columns, int rows, int columnSize, QWidget *parent=0, 00069 const char *name = 0, WFlags f = 0 ); 00070 KOAgenda ( int columns, QWidget *parent = 0, 00071 const char *name = 0, WFlags f = 0 ); 00072 virtual ~KOAgenda(); 00073 00074 Incidence *selectedIncidence() const; 00075 QDate selectedIncidenceDate() const; 00076 00077 virtual bool eventFilter ( QObject *, QEvent * ); 00078 00079 QPoint contentsToGrid ( const QPoint &pos ) const; 00080 QPoint gridToContents ( const QPoint &gpos ) const; 00081 00082 int timeToY ( const QTime &time ); 00083 QTime gyToTime ( int y ); 00084 00085 QMemArray<int> minContentsY(); 00086 QMemArray<int> maxContentsY(); 00087 00088 void setStartTime( QTime startHour ); 00089 00090 KOAgendaItem *insertItem ( Incidence *incidence, QDate qd, int X, int YTop, 00091 int YBottom ); 00092 KOAgendaItem *insertAllDayItem ( Incidence *event, QDate qd, int XBegin, 00093 int XEnd ); 00094 void insertMultiItem ( Event *event, QDate qd, int XBegin, int XEnd, 00095 int YTop, int YBottom ); 00096 00101 void removeIncidence( Incidence *incidence ); 00102 00103 void changeColumns( int columns ); 00104 00105 int columns() { return mColumns; } 00106 int rows() { return mRows; } 00107 00108 double gridSpacingX() const { return mGridSpacingX; } 00109 double gridSpacingY() const { return mGridSpacingY; } 00110 00111 // virtual QSizePolicy sizePolicy() const; 00112 00113 void clear(); 00114 00116 virtual int minimumWidth() const; 00118 void updateConfig(); 00119 00120 void checkScrollBoundaries(); 00121 00122 void setHolidayMask( QMemArray<bool> * ); 00123 00124 void setDateList( const DateList &selectedDates ); 00125 DateList dateList() const; 00126 00127 void setTypeAheadReceiver( QObject * ); 00128 QObject *typeAheadReceiver() const; 00129 void finishTypeAhead(); 00130 00131 void setCalendar( Calendar*cal ) { mCalendar=cal; } 00132 00133 public slots: 00134 void scrollUp(); 00135 void scrollDown(); 00136 00137 void checkScrollBoundaries( int ); 00138 00140 void deselectItem(); 00141 00142 void clearSelection(); 00143 00149 void selectItem( KOAgendaItem * ); 00150 bool removeAgendaItem( KOAgendaItem *item ); 00151 void showAgendaItem( KOAgendaItem *item ); 00152 00153 signals: 00154 void newEventSignal(); 00155 void newEventSignal( const QPoint &pos ); 00156 void newEventSignal( const QPoint &start, const QPoint &end ); 00157 void newTimeSpanSignal( const QPoint &, const QPoint & ); 00158 void newStartSelectSignal(); 00159 00160 void showIncidenceSignal( Incidence * ); 00161 void editIncidenceSignal( Incidence * ); 00162 void deleteIncidenceSignal( Incidence * ); 00163 void showIncidencePopupSignal( Incidence *, const QDate &); 00164 void showNewEventPopupSignal(); 00165 00166 void itemModified( KOAgendaItem *item ); 00167 void incidenceSelected( Incidence * ); 00168 void incidenceChanged( Incidence*, Incidence* ); 00169 void incidenceAdded( Incidence* ); 00170 void startMultiModify( const QString & ); 00171 void endMultiModify(); 00172 00173 void lowerYChanged( int ); 00174 void upperYChanged( int ); 00175 00176 void startDragSignal(Incidence *); 00177 void droppedToDo( Todo*todo, const QPoint &gpos, bool allDay ); 00178 00179 void enableAgendaUpdate( bool enable ); 00180 00181 private: 00182 enum MouseActionType { NOP, MOVE, SELECT, 00183 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 00184 00185 protected: 00186 void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); 00187 int columnWidth( int column ); 00188 virtual void resizeEvent ( QResizeEvent * ); 00189 00191 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 00193 virtual bool eventFilter_key ( QObject *, QKeyEvent * ); 00194 00196 virtual bool eventFilter_drag( QObject *, QDropEvent * ); 00197 00204 MouseActionType isInResizeArea( bool horizontal, const QPoint &pos, KOAgendaItem *item ); 00207 bool ptInSelection( QPoint gpos ) const; 00208 00209 00211 void startSelectAction( const QPoint &viewportPos ); 00212 00214 void performSelectAction( const QPoint &viewportPos ); 00215 00217 void endSelectAction( const QPoint &viewportPos ); 00218 00220 void startItemAction(const QPoint& viewportPos); 00221 00223 void performItemAction(const QPoint& viewportPos); 00224 00226 void endItemAction(); 00227 00229 void setNoActionCursor( KOAgendaItem *moveItem, const QPoint &viewportPos ); 00234 void setActionCursor( int actionType, bool acting=false ); 00235 00237 double calcSubCellWidth( KOAgendaItem *item ); 00239 void placeAgendaItem( KOAgendaItem *item, double subCellWidth ); 00241 void placeSubCells( KOAgendaItem *placeItem ); 00243 void adjustItemPosition( KOAgendaItem *item ); 00244 00248 void keyPressEvent( QKeyEvent * ); 00249 00250 void calculateWorkingHours(); 00251 00252 virtual void contentsMousePressEvent ( QMouseEvent * ); 00253 00254 void emitNewEventForSelection(); 00255 00256 protected slots: 00258 void deleteItemsToDelete(); 00259 00260 private: 00261 void init(); 00262 void marcus_bains(); 00263 bool mAllDayMode; 00264 00265 // We need the calendar for drag'n'drop 00266 Calendar *mCalendar; 00267 00268 // Width and height of agenda cells. mDesiredGridSpacingY is the height 00269 // set in the config. The actual height might be larger since otherwise 00270 // more than 24 hours might be displayed. 00271 double mGridSpacingX; 00272 double mGridSpacingY; 00273 double mDesiredGridSpacingY; 00274 00275 // size of border, where mouse action will resize the KOAgendaItem 00276 int mResizeBorderWidth; 00277 00278 // size of border, where mouse mve will cause a scroll of the agenda 00279 int mScrollBorderWidth; 00280 int mScrollDelay; 00281 int mScrollOffset; 00282 00283 QTimer mScrollUpTimer; 00284 QTimer mScrollDownTimer; 00285 00286 // Number of Columns/Rows of agenda grid 00287 int mColumns; 00288 int mRows; 00289 00290 // Cells to store Move and Resize coordiantes while performing the action 00291 QPoint mStartCell; 00292 QPoint mEndCell; 00293 00294 // Working Hour coordiantes 00295 bool mWorkingHoursEnable; 00296 QMemArray<bool> *mHolidayMask; 00297 int mWorkingHoursYTop; 00298 int mWorkingHoursYBottom; 00299 00300 // Selection 00301 bool mHasSelection; 00302 QPoint mSelectionStartPoint; 00303 QPoint mSelectionStartCell; 00304 QPoint mSelectionEndCell; 00305 00306 // List of dates to be displayed 00307 DateList mSelectedDates; 00308 00309 // The KOAgendaItem, which has been right-clicked last 00310 QGuardedPtr<KOAgendaItem> mClickedItem; 00311 00312 // The KOAgendaItem, which is being moved/resized 00313 QGuardedPtr<KOAgendaItem> mActionItem; 00314 00315 // Currently selected item 00316 QGuardedPtr<KOAgendaItem> mSelectedItem; 00317 00318 // The Marcus Bains Line widget. 00319 MarcusBains *mMarcusBains; 00320 00321 MouseActionType mActionType; 00322 00323 bool mItemMoved; 00324 00325 // List of all Items contained in agenda 00326 QPtrList<KOAgendaItem> mItems; 00327 QPtrList<KOAgendaItem> mItemsToDelete; 00328 00329 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 00330 00331 int mOldLowerScrollValue; 00332 int mOldUpperScrollValue; 00333 00334 bool mTypeAhead; 00335 QObject *mTypeAheadReceiver; 00336 QPtrList<QEvent> mTypeAheadEvents; 00337 00338 bool mReturnPressed; 00339 }; 00340 00341 #endif // KOAGENDA_H
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:53:21 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003