author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /korganizer/koagenda.h | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | korganizer/koagenda.h | 286 |
1 files changed, 286 insertions, 0 deletions
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h new file mode 100644 index 0000000..111242f --- a/dev/null +++ b/korganizer/koagenda.h | |||
@@ -0,0 +1,286 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | #ifndef KOAGENDA_H | ||
24 | #define KOAGENDA_H | ||
25 | |||
26 | #include <qscrollview.h> | ||
27 | #include <qtimer.h> | ||
28 | #include <qmemarray.h> | ||
29 | #include <qpainter.h> | ||
30 | #include <qpixmap.h> | ||
31 | #include <qguardedptr.h> | ||
32 | |||
33 | #include "koagendaitem.h" | ||
34 | |||
35 | class QPopupMenu; | ||
36 | class QTime; | ||
37 | class KConfig; | ||
38 | class QFrame; | ||
39 | class KOAgenda; | ||
40 | class KCal::Event; | ||
41 | class KCal::Todo; | ||
42 | |||
43 | using namespace KCal; | ||
44 | |||
45 | class MarcusBains : public QFrame { | ||
46 | Q_OBJECT | ||
47 | public: | ||
48 | MarcusBains(KOAgenda *agenda=0,const char *name=0); | ||
49 | virtual ~MarcusBains(); | ||
50 | |||
51 | public slots: | ||
52 | void updateLocation(bool recalculate=false); | ||
53 | void updateLoc(); | ||
54 | |||
55 | private: | ||
56 | int todayColumn(); | ||
57 | QTimer *minutes; | ||
58 | QLabel *mTimeBox; | ||
59 | KOAgenda *agenda; | ||
60 | QTime oldTime; | ||
61 | int oldToday; | ||
62 | }; | ||
63 | |||
64 | |||
65 | class KOAgenda : public QScrollView | ||
66 | { | ||
67 | Q_OBJECT | ||
68 | public: | ||
69 | enum MouseActionType { NOP, MOVE, SELECT, | ||
70 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; | ||
71 | |||
72 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, | ||
73 | const char * name=0, WFlags f=0 ); | ||
74 | KOAgenda ( int columns, QWidget * parent=0, | ||
75 | const char * name=0, WFlags f=0 ); | ||
76 | virtual ~KOAgenda(); | ||
77 | |||
78 | Incidence *selectedIncidence() const; | ||
79 | QDate selectedIncidenceDate() const; | ||
80 | |||
81 | virtual bool eventFilter ( QObject *, QEvent * ); | ||
82 | |||
83 | void contentsToGrid (int x, int y, int& gx, int& gy); | ||
84 | void gridToContents (int gx, int gy, int& x, int& y); | ||
85 | |||
86 | int timeToY (const QTime &time); | ||
87 | QTime gyToTime (int y); | ||
88 | |||
89 | void setStartHour(int startHour); | ||
90 | |||
91 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); | ||
92 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); | ||
93 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | ||
94 | int YTop,int YBottom); | ||
95 | |||
96 | void changeColumns(int columns); | ||
97 | |||
98 | int columns() { return mColumns; } | ||
99 | int rows() { return mRows; } | ||
100 | |||
101 | int gridSpacingX() const { return mGridSpacingX; } | ||
102 | int gridSpacingY() const { return mGridSpacingY; } | ||
103 | |||
104 | // virtual QSizePolicy sizePolicy() const; | ||
105 | |||
106 | void clear(); | ||
107 | |||
108 | void clearSelection(); | ||
109 | void hideUnused(); | ||
110 | |||
111 | /** Calculates the minimum width */ | ||
112 | virtual int minimumWidth() const; | ||
113 | /** Update configuration from preference settings */ | ||
114 | void updateConfig(); | ||
115 | |||
116 | void checkScrollBoundaries(); | ||
117 | |||
118 | void setHolidayMask(QMemArray<bool> *); | ||
119 | void setDateList(const DateList &selectedDates); | ||
120 | DateList dateList() const; | ||
121 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); | ||
122 | void finishUpdate(); | ||
123 | void printSelection(); | ||
124 | void storePosition(); | ||
125 | void restorePosition(); | ||
126 | |||
127 | |||
128 | public slots: | ||
129 | void moveChild( QWidget *, int, int ); | ||
130 | void scrollUp(); | ||
131 | void scrollDown(); | ||
132 | void updateTodo( Todo * t, int , bool ); | ||
133 | void popupAlarm(); | ||
134 | |||
135 | void checkScrollBoundaries(int); | ||
136 | |||
137 | /** Deselect selected items. This function does not emit any signals. */ | ||
138 | void deselectItem(); | ||
139 | /** Select item. If the argument is 0, the currently selected item gets | ||
140 | deselected. This function emits the itemSelected(bool) signal to inform | ||
141 | about selection/deseelction of events. */ | ||
142 | void selectItem(KOAgendaItem *); | ||
143 | void finishResize(); | ||
144 | |||
145 | signals: | ||
146 | void newEventSignal(); | ||
147 | void newEventSignal(int gx,int gy); | ||
148 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | ||
149 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | ||
150 | void newStartSelectSignal(); | ||
151 | void showIncidenceSignal(Incidence *); | ||
152 | void editIncidenceSignal(Incidence *); | ||
153 | void deleteIncidenceSignal(Incidence *); | ||
154 | void showIncidencePopupSignal(Incidence *); | ||
155 | |||
156 | void itemModified(KOAgendaItem *item, int ); | ||
157 | void incidenceSelected(Incidence *); | ||
158 | |||
159 | void lowerYChanged(int); | ||
160 | void upperYChanged(int); | ||
161 | |||
162 | void startDragSignal(Incidence *); | ||
163 | void addToCalSignal(Incidence *, Incidence *); | ||
164 | void resizedSignal(); | ||
165 | |||
166 | protected: | ||
167 | QPainter mPixPainter; | ||
168 | QPixmap mPaintPixmap; | ||
169 | QPixmap mHighlightPixmap; | ||
170 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); | ||
171 | virtual void resizeEvent ( QResizeEvent * ); | ||
172 | |||
173 | /** Handles mouse events. Called from eventFilter */ | ||
174 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); | ||
175 | |||
176 | /** Start selecting time span. */ | ||
177 | void startSelectAction(QPoint viewportPos); | ||
178 | |||
179 | /** Select time span. */ | ||
180 | void performSelectAction(QPoint viewportPos); | ||
181 | |||
182 | /** Emd selecting time span. */ | ||
183 | void endSelectAction(); | ||
184 | |||
185 | /** Start moving/resizing agenda item */ | ||
186 | void startItemAction(QPoint viewportPos); | ||
187 | |||
188 | /** Move/resize agenda item */ | ||
189 | void performItemAction(QPoint viewportPos); | ||
190 | |||
191 | /** End moving/resizing agenda item */ | ||
192 | void endItemAction(); | ||
193 | |||
194 | /** Set cursor, when no item action is in progress */ | ||
195 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); | ||
196 | |||
197 | /** Place agenda item in agenda and adjust other cells if necessary */ | ||
198 | void placeSubCells(KOAgendaItem *placeItem); | ||
199 | |||
200 | /** Process the keyevent, including the ignored keyevents of eventwidgets. | ||
201 | * Implements pgup/pgdn and cursor key navigation in the view. | ||
202 | */ | ||
203 | void keyPressEvent( QKeyEvent * ); | ||
204 | |||
205 | void calculateWorkingHours(); | ||
206 | |||
207 | virtual void contentsMousePressEvent ( QMouseEvent * ); | ||
208 | |||
209 | private: | ||
210 | void init(); | ||
211 | void marcus_bains(); | ||
212 | bool mAllDayMode; | ||
213 | bool blockResize; | ||
214 | QTimer mResizeTimer; | ||
215 | double mContentPosition; | ||
216 | |||
217 | // Width and height of agenda cells | ||
218 | int mGridSpacingX; | ||
219 | int mGridSpacingY; | ||
220 | |||
221 | // size of border, where mouse action will resize the KOAgendaItem | ||
222 | int mResizeBorderWidth; | ||
223 | |||
224 | // size of border, where mouse mve will cause a scroll of the agenda | ||
225 | int mScrollBorderWidth; | ||
226 | int mScrollDelay; | ||
227 | int mScrollOffset; | ||
228 | |||
229 | QTimer mScrollUpTimer; | ||
230 | QTimer mScrollDownTimer; | ||
231 | |||
232 | // Number of Columns/Rows of agenda grid | ||
233 | int mColumns; | ||
234 | int mRows; | ||
235 | |||
236 | // Cells to store Move and Resize coordiantes | ||
237 | int mStartCellX; | ||
238 | int mStartCellY; | ||
239 | int mCurrentCellX; | ||
240 | int mCurrentCellY; | ||
241 | |||
242 | // Working Hour coordiantes | ||
243 | bool mWorkingHoursEnable; | ||
244 | int mWorkingHoursYTop; | ||
245 | int mWorkingHoursYBottom; | ||
246 | |||
247 | // Selection | ||
248 | int mSelectionCellX; | ||
249 | int mSelectionYTop; | ||
250 | int mSelectionHeight; | ||
251 | |||
252 | // List of dates to be displayed | ||
253 | DateList mSelectedDates; | ||
254 | |||
255 | // The KOAgendaItem, which has been right-clicked last | ||
256 | KOAgendaItem *mClickedItem; | ||
257 | |||
258 | // The KOAgendaItem, which is being moved/resized | ||
259 | QGuardedPtr<KOAgendaItem> mActionItem; | ||
260 | |||
261 | // Currently selected item | ||
262 | QGuardedPtr<KOAgendaItem> mSelectedItem; | ||
263 | |||
264 | // The Marcus Bains Line widget. | ||
265 | MarcusBains *mMarcusBains; | ||
266 | void computeSizes(); | ||
267 | |||
268 | MouseActionType mActionType; | ||
269 | |||
270 | bool mItemMoved; | ||
271 | |||
272 | // List of all Items contained in agenda | ||
273 | QPtrList<KOAgendaItem> mItems; | ||
274 | QPtrList<KOAgendaItem> mUnusedItems; | ||
275 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); | ||
276 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems | ||
277 | |||
278 | int mOldLowerScrollValue; | ||
279 | int mOldUpperScrollValue; | ||
280 | KOAgendaItem * getItemForTodo ( Todo * todo ); | ||
281 | QMemArray<bool> *mHolidayMask; | ||
282 | int mCurPixWid; | ||
283 | int mCurPixHei; | ||
284 | }; | ||
285 | |||
286 | #endif // KOAGENDA_H | ||