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 * ); 00153 void selectItemByUID( const QString& uid ); 00154 bool removeAgendaItem( KOAgendaItem *item ); 00155 void showAgendaItem( KOAgendaItem *item ); 00156 00157 signals: 00158 void newEventSignal(); 00159 void newEventSignal( const QPoint &pos ); 00160 void newEventSignal( const QPoint &start, const QPoint &end ); 00161 void newTimeSpanSignal( const QPoint &, const QPoint & ); 00162 void newStartSelectSignal(); 00163 00164 void showIncidenceSignal( Incidence * ); 00165 void editIncidenceSignal( Incidence * ); 00166 void deleteIncidenceSignal( Incidence * ); 00167 void showIncidencePopupSignal( Incidence *, const QDate &); 00168 void showNewEventPopupSignal(); 00169 00170 void itemModified( KOAgendaItem *item ); 00171 void incidenceSelected( Incidence * ); 00172 void incidenceChanged( Incidence*, Incidence* ); 00173 void incidenceAdded( Incidence* ); 00174 void startMultiModify( const QString & ); 00175 void endMultiModify(); 00176 00177 void lowerYChanged( int ); 00178 void upperYChanged( int ); 00179 00180 void startDragSignal(Incidence *); 00181 void droppedToDo( Todo*todo, const QPoint &gpos, bool allDay ); 00182 00183 void enableAgendaUpdate( bool enable ); 00184 00185 private: 00186 enum MouseActionType { NOP, MOVE, SELECT, 00187 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 00188 00189 protected: 00190 void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); 00191 int columnWidth( int column ); 00192 virtual void resizeEvent ( QResizeEvent * ); 00193 00195 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 00197 virtual bool eventFilter_key ( QObject *, QKeyEvent * ); 00198 00200 virtual bool eventFilter_drag( QObject *, QDropEvent * ); 00201 00208 MouseActionType isInResizeArea( bool horizontal, const QPoint &pos, KOAgendaItem *item ); 00211 bool ptInSelection( QPoint gpos ) const; 00212 00213 00215 void startSelectAction( const QPoint &viewportPos ); 00216 00218 void performSelectAction( const QPoint &viewportPos ); 00219 00221 void endSelectAction( const QPoint &viewportPos ); 00222 00224 void startItemAction(const QPoint& viewportPos); 00225 00227 void performItemAction(const QPoint& viewportPos); 00228 00230 void endItemAction(); 00231 00233 void setNoActionCursor( KOAgendaItem *moveItem, const QPoint &viewportPos ); 00238 void setActionCursor( int actionType, bool acting=false ); 00239 00241 double calcSubCellWidth( KOAgendaItem *item ); 00243 void placeAgendaItem( KOAgendaItem *item, double subCellWidth ); 00245 void placeSubCells( KOAgendaItem *placeItem ); 00247 void adjustItemPosition( KOAgendaItem *item ); 00248 00252 void keyPressEvent( QKeyEvent * ); 00253 00254 void calculateWorkingHours(); 00255 00256 virtual void contentsMousePressEvent ( QMouseEvent * ); 00257 00258 void emitNewEventForSelection(); 00259 00260 protected slots: 00262 void deleteItemsToDelete(); 00263 00264 private: 00265 void init(); 00266 void marcus_bains(); 00267 bool mAllDayMode; 00268 00269 // We need the calendar for drag'n'drop 00270 Calendar *mCalendar; 00271 00272 // Width and height of agenda cells. mDesiredGridSpacingY is the height 00273 // set in the config. The actual height might be larger since otherwise 00274 // more than 24 hours might be displayed. 00275 double mGridSpacingX; 00276 double mGridSpacingY; 00277 double mDesiredGridSpacingY; 00278 00279 // size of border, where mouse action will resize the KOAgendaItem 00280 int mResizeBorderWidth; 00281 00282 // size of border, where mouse mve will cause a scroll of the agenda 00283 int mScrollBorderWidth; 00284 int mScrollDelay; 00285 int mScrollOffset; 00286 00287 QTimer mScrollUpTimer; 00288 QTimer mScrollDownTimer; 00289 00290 // Number of Columns/Rows of agenda grid 00291 int mColumns; 00292 int mRows; 00293 00294 // Cells to store Move and Resize coordiantes while performing the action 00295 QPoint mStartCell; 00296 QPoint mEndCell; 00297 00298 // Working Hour coordiantes 00299 bool mWorkingHoursEnable; 00300 QMemArray<bool> *mHolidayMask; 00301 int mWorkingHoursYTop; 00302 int mWorkingHoursYBottom; 00303 00304 // Selection 00305 bool mHasSelection; 00306 QPoint mSelectionStartPoint; 00307 QPoint mSelectionStartCell; 00308 QPoint mSelectionEndCell; 00309 00310 // List of dates to be displayed 00311 DateList mSelectedDates; 00312 00313 // The KOAgendaItem, which has been right-clicked last 00314 QGuardedPtr<KOAgendaItem> mClickedItem; 00315 00316 // The KOAgendaItem, which is being moved/resized 00317 QGuardedPtr<KOAgendaItem> mActionItem; 00318 00319 // Currently selected item 00320 QGuardedPtr<KOAgendaItem> mSelectedItem; 00321 00322 // The Marcus Bains Line widget. 00323 MarcusBains *mMarcusBains; 00324 00325 MouseActionType mActionType; 00326 00327 bool mItemMoved; 00328 00329 // List of all Items contained in agenda 00330 QPtrList<KOAgendaItem> mItems; 00331 QPtrList<KOAgendaItem> mItemsToDelete; 00332 00333 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 00334 00335 int mOldLowerScrollValue; 00336 int mOldUpperScrollValue; 00337 00338 bool mTypeAhead; 00339 QObject *mTypeAheadReceiver; 00340 QPtrList<QEvent> mTypeAheadEvents; 00341 00342 bool mReturnPressed; 00343 }; 00344 00345 #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 Oct 1 15:19:30 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003