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., 675 Mass Ave, Cambridge, MA 02139, 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 <qmemarray.h>
00029 
00030 #include <libkcal/event.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 
00042 class MarcusBains : public QFrame {
00043     Q_OBJECT
00044   public:
00045     MarcusBains(KOAgenda *agenda=0,const char *name=0);
00046     virtual ~MarcusBains();
00047 
00048   public slots:
00049     void updateLocation(bool recalculate=false);
00050 
00051   private:
00052     int todayColumn();
00053     QTimer *minutes;
00054     QLabel *mTimeBox;
00055     KOAgenda *agenda;
00056     QTime oldTime;
00057     int oldToday;
00058 };
00059 
00060 
00061 class KOAgenda : public QScrollView
00062 {
00063     Q_OBJECT
00064   public:
00065     KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
00066                const char * name=0, WFlags f=0 );
00067     KOAgenda ( int columns, QWidget * parent=0,
00068                const char * name=0, WFlags f=0 );
00069     virtual ~KOAgenda();
00070 
00071     Event *selectedEvent();
00072     QDate selectedEventDate();
00073 
00074     virtual bool eventFilter ( QObject *, QEvent * );
00075 
00076     void contentsToGrid (int x, int y, int& gx, int& gy);
00077     void gridToContents (int gx, int gy, int& x, int& y);
00078 
00079     int timeToY (const QTime &time);
00080     QTime gyToTime (int y);
00081 
00082     void setStartHour(int startHour);
00083 
00084     KOAgendaItem *insertItem (Event *event,QDate qd,int X,int YTop,int YBottom);
00085     KOAgendaItem *insertAllDayItem (Event *event,QDate qd,int XBegin,int XEnd);
00086     void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
00087                           int YTop,int YBottom);
00088 
00089     void changeColumns(int columns);
00090 
00091     int columns() { return mColumns; }
00092     int rows() { return mRows; }
00093 
00094     int gridSpacingX() const { return mGridSpacingX; }
00095     int gridSpacingY() const { return mGridSpacingY; }
00096 
00097 //    virtual QSizePolicy sizePolicy() const;
00098 
00099     void clear();
00100     
00101     void clearSelection();
00102 
00104     virtual int minimumWidth() const;
00106     void updateConfig();
00107 
00108     void checkScrollBoundaries();
00109 
00110     void setHolidayMask(QMemArray<bool> *);
00111 
00112     void setDateList(const DateList &selectedDates);
00113     DateList dateList() const;
00114 
00115   public slots:
00116     void scrollUp();
00117     void scrollDown();
00118 
00119     void popupAlarm();
00120 
00121     void checkScrollBoundaries(int);
00122 
00124     void deselectItem();
00128     void selectItem(KOAgendaItem *);
00129 
00130   signals:
00131     void newEventSignal();
00132     void newEventSignal(int gx,int gy);
00133     void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
00134     void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
00135     void newStartSelectSignal();
00136     void editEventSignal(Event *event);
00137     void showEventSignal(Event *event);
00138     void deleteEventSignal(Event *event);
00139 
00140     void itemModified(KOAgendaItem *item);
00141     void incidenceSelected( Incidence * );
00142 
00143     void showEventPopupSignal(Event *);
00144 
00145     void lowerYChanged(int);
00146     void upperYChanged(int);
00147 
00148     void startDragSignal(Event *);
00149 
00150   protected:
00151     void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
00152     virtual void resizeEvent ( QResizeEvent * );
00153 
00155     virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
00156 
00158     void startSelectAction(QPoint viewportPos);
00159 
00161     void performSelectAction(QPoint viewportPos);
00162 
00164     void endSelectAction();
00165 
00167     void startItemAction(QPoint viewportPos);
00168 
00170     void performItemAction(QPoint viewportPos);
00171 
00173     void endItemAction();
00174 
00176     void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
00177 
00179     void placeSubCells(KOAgendaItem *placeItem);
00180 
00184     void keyPressEvent( QKeyEvent * );
00185 
00186     void calculateWorkingHours();
00187 
00188     virtual void contentsMousePressEvent ( QMouseEvent * );
00189 
00190   private:
00191     void init();
00192     void marcus_bains();
00193     bool mAllDayMode;
00194 
00195     // Width and height of agenda cells
00196     int mGridSpacingX;
00197     int mGridSpacingY;
00198 
00199     // size of border, where mouse action will resize the KOAgendaItem
00200     int mResizeBorderWidth;
00201 
00202     // size of border, where mouse mve will cause a scroll of the agenda
00203     int mScrollBorderWidth;
00204     int mScrollDelay;
00205     int mScrollOffset;
00206 
00207     QTimer mScrollUpTimer;
00208     QTimer mScrollDownTimer;
00209 
00210     // Number of Columns/Rows of agenda grid
00211     int mColumns;
00212     int mRows;
00213 
00214     // Cells to store Move and Resize coordiantes
00215     int mStartCellX;
00216     int mStartCellY;
00217     int mCurrentCellX;
00218     int mCurrentCellY;
00219 
00220     // Working Hour coordiantes
00221     bool mWorkingHoursEnable;
00222     int mWorkingHoursYTop;
00223     int mWorkingHoursYBottom;
00224 
00225     // Selection
00226     int mSelectionCellX;
00227     int mSelectionYTop;
00228     int mSelectionHeight;
00229 
00230     // List of dates to be displayed
00231     DateList mSelectedDates;
00232 
00233     // The KOAgendaItem, which has been right-clicked last
00234     KOAgendaItem *mClickedItem;
00235 
00236     // The KOAgendaItem, which is being moved/resized
00237     KOAgendaItem *mActionItem;
00238 
00239     // Currently selected item
00240     KOAgendaItem *mSelectedItem;
00241 
00242     // The Marcus Bains Line widget.
00243     MarcusBains *mMarcusBains;
00244 
00245     enum MouseActionType { NOP, MOVE, SELECT,
00246                            RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
00247 
00248     MouseActionType mActionType;
00249 
00250     bool mItemMoved;
00251 
00252     // List of all Items contained in agenda
00253     QPtrList<KOAgendaItem> mItems;
00254 
00255     QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
00256 
00257     int mOldLowerScrollValue;
00258     int mOldUpperScrollValue;
00259 
00260     QMemArray<bool> *mHolidayMask;
00261 };
00262 
00263 #endif // KOAGENDA_H
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:31 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001