-rw-r--r-- | korganizer/koagenda.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index eb3791e..7e0b216 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -99,1838 +99,1838 @@ int MarcusBains::todayColumn() | |||
99 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
113 | 113 | ||
114 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 117 | recalculate = true; |
118 | 118 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 125 | ||
126 | oldTime = tim; | 126 | oldTime = tim; |
127 | oldToday = today; | 127 | oldToday = today; |
128 | 128 | ||
129 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | 154 | ||
155 | mTimeBox->raise(); | 155 | mTimeBox->raise(); |
156 | //mTimeBox->setAutoMask(true); | 156 | //mTimeBox->setAutoMask(true); |
157 | minutes->start(5000,true); | 157 | minutes->start(5000,true); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
162 | 162 | ||
163 | 163 | ||
164 | /* | 164 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 166 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
170 | { | 170 | { |
171 | 171 | ||
172 | mColumns = columns; | 172 | mColumns = columns; |
173 | mRows = rows; | 173 | mRows = rows; |
174 | mGridSpacingY = rowSize; | 174 | mGridSpacingY = rowSize; |
175 | mAllDayMode = false; | 175 | mAllDayMode = false; |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 177 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
178 | #endif | 178 | #endif |
179 | mHolidayMask = 0; | 179 | mHolidayMask = 0; |
180 | init(); | 180 | init(); |
181 | } | 181 | } |
182 | 182 | ||
183 | /* | 183 | /* |
184 | Create an agenda widget with columns columns and one row. This is used for | 184 | Create an agenda widget with columns columns and one row. This is used for |
185 | all-day events. | 185 | all-day events. |
186 | */ | 186 | */ |
187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
188 | QScrollView(parent,name,f) | 188 | QScrollView(parent,name,f) |
189 | { | 189 | { |
190 | 190 | ||
191 | blockResize = false; | 191 | blockResize = false; |
192 | mColumns = columns; | 192 | mColumns = columns; |
193 | mRows = 1; | 193 | mRows = 1; |
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 196 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 197 | #ifndef DESKTOP_VERSION |
198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 199 | #endif |
200 | mHolidayMask = 0; | 200 | mHolidayMask = 0; |
201 | init(); | 201 | init(); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | KOAgenda::~KOAgenda() | 205 | KOAgenda::~KOAgenda() |
206 | { | 206 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 207 | if(mMarcusBains) delete mMarcusBains; |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 211 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 212 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 217 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 218 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void KOAgenda::init() | 223 | void KOAgenda::init() |
224 | { | 224 | { |
225 | #ifndef _WIN32_ | 225 | #ifndef _WIN32_ |
226 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 226 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
227 | viewport()->setWFlags ( wflags); | 227 | viewport()->setWFlags ( wflags); |
228 | #endif | 228 | #endif |
229 | mGridSpacingX = 80; | 229 | mGridSpacingX = 80; |
230 | mResizeBorderWidth = 8; | 230 | mResizeBorderWidth = 8; |
231 | mScrollBorderWidth = 8; | 231 | mScrollBorderWidth = 8; |
232 | mScrollDelay = 30; | 232 | mScrollDelay = 30; |
233 | mScrollOffset = 10; | 233 | mScrollOffset = 10; |
234 | mPaintPixmap.resize( 20,20); | 234 | mPaintPixmap.resize( 20,20); |
235 | //enableClipper(true); | 235 | //enableClipper(true); |
236 | 236 | ||
237 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 237 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
238 | // effect. Has to be fixed. | 238 | // effect. Has to be fixed. |
239 | setFocusPolicy(WheelFocus); | 239 | setFocusPolicy(WheelFocus); |
240 | 240 | ||
241 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 241 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
242 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 242 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
243 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 243 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
244 | 244 | ||
245 | mStartCellX = 0; | 245 | mStartCellX = 0; |
246 | mStartCellY = 0; | 246 | mStartCellY = 0; |
247 | mCurrentCellX = 0; | 247 | mCurrentCellX = 0; |
248 | mCurrentCellY = 0; | 248 | mCurrentCellY = 0; |
249 | 249 | ||
250 | mSelectionCellX = 0; | 250 | mSelectionCellX = 0; |
251 | mSelectionYTop = 0; | 251 | mSelectionYTop = 0; |
252 | mSelectionHeight = 0; | 252 | mSelectionHeight = 0; |
253 | 253 | ||
254 | mOldLowerScrollValue = -1; | 254 | mOldLowerScrollValue = -1; |
255 | mOldUpperScrollValue = -1; | 255 | mOldUpperScrollValue = -1; |
256 | 256 | ||
257 | mClickedItem = 0; | 257 | mClickedItem = 0; |
258 | 258 | ||
259 | mActionItem = 0; | 259 | mActionItem = 0; |
260 | mActionType = NOP; | 260 | mActionType = NOP; |
261 | mItemMoved = false; | 261 | mItemMoved = false; |
262 | 262 | ||
263 | mSelectedItem = 0; | 263 | mSelectedItem = 0; |
264 | 264 | ||
265 | // mItems.setAutoDelete(true); | 265 | // mItems.setAutoDelete(true); |
266 | 266 | ||
267 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 267 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
268 | 268 | ||
269 | viewport()->update(); | 269 | viewport()->update(); |
270 | 270 | ||
271 | setMinimumSize(30, 1); | 271 | setMinimumSize(30, 1); |
272 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 272 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
273 | 273 | ||
274 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 274 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
275 | // controlled in a way that the contents horizontally always fits. Then it is | 275 | // controlled in a way that the contents horizontally always fits. Then it is |
276 | // not necessary to turn off the scrollbar. | 276 | // not necessary to turn off the scrollbar. |
277 | setHScrollBarMode(AlwaysOff); | 277 | setHScrollBarMode(AlwaysOff); |
278 | if ( ! mAllDayMode ) | 278 | if ( ! mAllDayMode ) |
279 | setVScrollBarMode(AlwaysOn); | 279 | setVScrollBarMode(AlwaysOn); |
280 | else | 280 | else |
281 | setVScrollBarMode(AlwaysOff); | 281 | setVScrollBarMode(AlwaysOff); |
282 | 282 | ||
283 | setStartHour(KOPrefs::instance()->mDayBegins); | 283 | setStartHour(KOPrefs::instance()->mDayBegins); |
284 | 284 | ||
285 | calculateWorkingHours(); | 285 | calculateWorkingHours(); |
286 | 286 | ||
287 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 287 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
288 | SLOT(checkScrollBoundaries(int))); | 288 | SLOT(checkScrollBoundaries(int))); |
289 | 289 | ||
290 | // Create the Marcus Bains line. | 290 | // Create the Marcus Bains line. |
291 | if(mAllDayMode) | 291 | if(mAllDayMode) |
292 | mMarcusBains = 0; | 292 | mMarcusBains = 0; |
293 | else { | 293 | else { |
294 | mMarcusBains = new MarcusBains(this); | 294 | mMarcusBains = new MarcusBains(this); |
295 | addChild(mMarcusBains); | 295 | addChild(mMarcusBains); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | void KOAgenda::clear() | 299 | void KOAgenda::clear() |
300 | { | 300 | { |
301 | KOAgendaItem *item; | 301 | KOAgendaItem *item; |
302 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 302 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
303 | mUnusedItems.append( item ); | 303 | mUnusedItems.append( item ); |
304 | //item->hide(); | 304 | //item->hide(); |
305 | } | 305 | } |
306 | mItems.clear(); | 306 | mItems.clear(); |
307 | mSelectedItem = 0; | 307 | mSelectedItem = 0; |
308 | clearSelection(); | 308 | clearSelection(); |
309 | } | 309 | } |
310 | 310 | ||
311 | void KOAgenda::clearSelection() | 311 | void KOAgenda::clearSelection() |
312 | { | 312 | { |
313 | mSelectionCellX = 0; | 313 | mSelectionCellX = 0; |
314 | mSelectionYTop = 0; | 314 | mSelectionYTop = 0; |
315 | mSelectionHeight = 0; | 315 | mSelectionHeight = 0; |
316 | } | 316 | } |
317 | 317 | ||
318 | void KOAgenda::marcus_bains() | 318 | void KOAgenda::marcus_bains() |
319 | { | 319 | { |
320 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 320 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
321 | } | 321 | } |
322 | 322 | ||
323 | 323 | ||
324 | void KOAgenda::changeColumns(int columns) | 324 | void KOAgenda::changeColumns(int columns) |
325 | { | 325 | { |
326 | if (columns == 0) { | 326 | if (columns == 0) { |
327 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; | 327 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; |
328 | return; | 328 | return; |
329 | } | 329 | } |
330 | 330 | ||
331 | clear(); | 331 | clear(); |
332 | 332 | ||
333 | mColumns = columns; | 333 | mColumns = columns; |
334 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); | 334 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); |
335 | // init(); | 335 | // init(); |
336 | // update(); | 336 | // update(); |
337 | //qDebug("KOAgenda::changeColumns "); | 337 | //qDebug("KOAgenda::changeColumns "); |
338 | computeSizes(); | 338 | computeSizes(); |
339 | // QResizeEvent event( size(), size() ); | 339 | // QResizeEvent event( size(), size() ); |
340 | 340 | ||
341 | //QApplication::sendEvent( this, &event ); | 341 | //QApplication::sendEvent( this, &event ); |
342 | } | 342 | } |
343 | 343 | ||
344 | /* | 344 | /* |
345 | This is the eventFilter function, which gets all events from the KOAgendaItems | 345 | This is the eventFilter function, which gets all events from the KOAgendaItems |
346 | contained in the agenda. It has to handle moving and resizing for all items. | 346 | contained in the agenda. It has to handle moving and resizing for all items. |
347 | */ | 347 | */ |
348 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 348 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
349 | { | 349 | { |
350 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 350 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
351 | switch(event->type()) { | 351 | switch(event->type()) { |
352 | case QEvent::MouseButtonPress: | 352 | case QEvent::MouseButtonPress: |
353 | case QEvent::MouseButtonDblClick: | 353 | case QEvent::MouseButtonDblClick: |
354 | case QEvent::MouseButtonRelease: | 354 | case QEvent::MouseButtonRelease: |
355 | case QEvent::MouseMove: | 355 | case QEvent::MouseMove: |
356 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 356 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
357 | 357 | ||
358 | case (QEvent::Leave): | 358 | case (QEvent::Leave): |
359 | if (!mActionItem) | 359 | if (!mActionItem) |
360 | setCursor(arrowCursor); | 360 | setCursor(arrowCursor); |
361 | return true; | 361 | return true; |
362 | 362 | ||
363 | default: | 363 | default: |
364 | return QScrollView::eventFilter(object,event); | 364 | return QScrollView::eventFilter(object,event); |
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 369 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
370 | { | 370 | { |
371 | //qDebug("KOAgenda::eventFilter_mous "); | 371 | //qDebug("KOAgenda::eventFilter_mous "); |
372 | QPoint viewportPos; | 372 | QPoint viewportPos; |
373 | if (object != viewport()) { | 373 | if (object != viewport()) { |
374 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 374 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
375 | } else { | 375 | } else { |
376 | viewportPos = me->pos(); | 376 | viewportPos = me->pos(); |
377 | } | 377 | } |
378 | static int startX = 0; | 378 | static int startX = 0; |
379 | static int startY = 0; | 379 | static int startY = 0; |
380 | static bool block = true; | 380 | static bool block = true; |
381 | switch (me->type()) { | 381 | switch (me->type()) { |
382 | case QEvent::MouseButtonPress: | 382 | case QEvent::MouseButtonPress: |
383 | //qDebug("QEvent::MouseButtonPress: "); | 383 | //qDebug("QEvent::MouseButtonPress: "); |
384 | // kdDebug() << "koagenda: filtered button press" << endl; | 384 | // kdDebug() << "koagenda: filtered button press" << endl; |
385 | if (object != viewport()) { | 385 | if (object != viewport()) { |
386 | if (me->button() == RightButton) { | 386 | if (me->button() == RightButton) { |
387 | 387 | ||
388 | mClickedItem = (KOAgendaItem *)object; | 388 | mClickedItem = (KOAgendaItem *)object; |
389 | if (mClickedItem) { | 389 | if (mClickedItem) { |
390 | selectItem(mClickedItem); | 390 | selectItem(mClickedItem); |
391 | // emit showIncidencePopupSignal(mClickedItem->incidence()); | 391 | // emit showIncidencePopupSignal(mClickedItem->incidence()); |
392 | } | 392 | } |
393 | //mItemPopup->popup(QCursor::pos()); | 393 | //mItemPopup->popup(QCursor::pos()); |
394 | } else { | 394 | } else { |
395 | mActionItem = (KOAgendaItem *)object; | 395 | mActionItem = (KOAgendaItem *)object; |
396 | if (mActionItem) { | 396 | if (mActionItem) { |
397 | if ( mSelectionHeight > 0 ) { | 397 | if ( mSelectionHeight > 0 ) { |
398 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 398 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
399 | int selectionYTop = mSelectionYTop; | 399 | int selectionYTop = mSelectionYTop; |
400 | int gridSpacingX = mGridSpacingX; | 400 | int gridSpacingX = mGridSpacingX; |
401 | int selectionHeight = mSelectionHeight; | 401 | int selectionHeight = mSelectionHeight; |
402 | clearSelection(); | 402 | clearSelection(); |
403 | repaintContents( selectionCellX, selectionYTop, | 403 | repaintContents( selectionCellX, selectionYTop, |
404 | gridSpacingX, selectionHeight,false ); | 404 | gridSpacingX, selectionHeight,false ); |
405 | } | 405 | } |
406 | selectItem(mActionItem); | 406 | selectItem(mActionItem); |
407 | Incidence *incidence = mActionItem->incidence(); | 407 | Incidence *incidence = mActionItem->incidence(); |
408 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 408 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
409 | mActionItem = 0; | 409 | mActionItem = 0; |
410 | } else { | 410 | } else { |
411 | startItemAction(viewportPos); | 411 | startItemAction(viewportPos); |
412 | startX = viewportPos.x(); | 412 | startX = viewportPos.x(); |
413 | startY = viewportPos.y(); | 413 | startY = viewportPos.y(); |
414 | block = true; | 414 | block = true; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | } | 417 | } |
418 | } else { | 418 | } else { |
419 | selectItem(0); | 419 | selectItem(0); |
420 | mActionItem = 0; | 420 | mActionItem = 0; |
421 | setCursor(arrowCursor); | 421 | setCursor(arrowCursor); |
422 | startSelectAction(viewportPos); | 422 | startSelectAction(viewportPos); |
423 | } | 423 | } |
424 | break; | 424 | break; |
425 | 425 | ||
426 | case QEvent::MouseButtonRelease: | 426 | case QEvent::MouseButtonRelease: |
427 | //qDebug("QEvent::MouseButtonRelease: "); | 427 | //qDebug("QEvent::MouseButtonRelease: "); |
428 | if (me->button() == RightButton && block ) { | 428 | if (me->button() == RightButton && block ) { |
429 | if (object != viewport()) { | 429 | if (object != viewport()) { |
430 | mClickedItem = (KOAgendaItem *)object; | 430 | mClickedItem = (KOAgendaItem *)object; |
431 | if (mActionItem ) { | 431 | if (mActionItem ) { |
432 | endItemAction(); | 432 | endItemAction(); |
433 | } | 433 | } |
434 | if (mClickedItem) { | 434 | if (mClickedItem) { |
435 | selectItem(mClickedItem); | 435 | selectItem(mClickedItem); |
436 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 436 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | break; | 439 | break; |
440 | } | 440 | } |
441 | block = true; | 441 | block = true; |
442 | if (mActionItem) { | 442 | if (mActionItem) { |
443 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 443 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
444 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 444 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
445 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 445 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
446 | mScrollUpTimer.stop(); | 446 | mScrollUpTimer.stop(); |
447 | mScrollDownTimer.stop(); | 447 | mScrollDownTimer.stop(); |
448 | mActionItem->resetMove(); | 448 | mActionItem->resetMove(); |
449 | placeSubCells( mActionItem ); | 449 | placeSubCells( mActionItem ); |
450 | // emit startDragSignal( mActionItem->incidence() ); | 450 | // emit startDragSignal( mActionItem->incidence() ); |
451 | setCursor( arrowCursor ); | 451 | setCursor( arrowCursor ); |
452 | mActionItem = 0; | 452 | mActionItem = 0; |
453 | mActionType = NOP; | 453 | mActionType = NOP; |
454 | mItemMoved = 0; | 454 | mItemMoved = 0; |
455 | return true; | 455 | return true; |
456 | } | 456 | } |
457 | endItemAction(); | 457 | endItemAction(); |
458 | } else if ( mActionType == SELECT ) { | 458 | } else if ( mActionType == SELECT ) { |
459 | endSelectAction(); | 459 | endSelectAction(); |
460 | } | 460 | } |
461 | break; | 461 | break; |
462 | 462 | ||
463 | case QEvent::MouseMove: | 463 | case QEvent::MouseMove: |
464 | if (object != viewport()) { | 464 | if (object != viewport()) { |
465 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 465 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
466 | //qDebug("moveItem %d ",moveItem ); | 466 | //qDebug("moveItem %d ",moveItem ); |
467 | if (!moveItem->incidence()->isReadOnly() /*&& | 467 | if (!moveItem->incidence()->isReadOnly() /*&& |
468 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) | 468 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) |
469 | if (!mActionItem) | 469 | if (!mActionItem) |
470 | setNoActionCursor(moveItem,viewportPos); | 470 | setNoActionCursor(moveItem,viewportPos); |
471 | else { | 471 | else { |
472 | if ( block ) { | 472 | if ( block ) { |
473 | int dX, dY; | 473 | int dX, dY; |
474 | dX = startX - viewportPos.x(); | 474 | dX = startX - viewportPos.x(); |
475 | if ( dX < 0 ) | 475 | if ( dX < 0 ) |
476 | dX = -dX; | 476 | dX = -dX; |
477 | dY = viewportPos.y() - startY; | 477 | dY = viewportPos.y() - startY; |
478 | if ( dY < 0 ) | 478 | if ( dY < 0 ) |
479 | dY = -dY; | 479 | dY = -dY; |
480 | int diff = 30; | 480 | int diff = 30; |
481 | if ( QApplication::desktop()->width() < 480 ) | 481 | if ( QApplication::desktop()->width() < 480 ) |
482 | diff = 15; | 482 | diff = 15; |
483 | // qDebug(" %d %d ",dX, dY ); | 483 | // qDebug(" %d %d ",dX, dY ); |
484 | if ( dX > diff || dY > diff ) { | 484 | if ( dX > diff || dY > diff ) { |
485 | block = false; | 485 | block = false; |
486 | } | 486 | } |
487 | } | 487 | } |
488 | if ( !block ) | 488 | if ( !block ) |
489 | performItemAction(viewportPos); | 489 | performItemAction(viewportPos); |
490 | } | 490 | } |
491 | } else { | 491 | } else { |
492 | if ( mActionType == SELECT ) { | 492 | if ( mActionType == SELECT ) { |
493 | performSelectAction( viewportPos ); | 493 | performSelectAction( viewportPos ); |
494 | } | 494 | } |
495 | } | 495 | } |
496 | break; | 496 | break; |
497 | 497 | ||
498 | case QEvent::MouseButtonDblClick: | 498 | case QEvent::MouseButtonDblClick: |
499 | if (object == viewport()) { | 499 | if (object == viewport()) { |
500 | selectItem(0); | 500 | selectItem(0); |
501 | int x,y; | 501 | int x,y; |
502 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 502 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
503 | int gx,gy; | 503 | int gx,gy; |
504 | contentsToGrid(x,y,gx,gy); | 504 | contentsToGrid(x,y,gx,gy); |
505 | emit newEventSignal(gx,gy); | 505 | emit newEventSignal(gx,gy); |
506 | } else { | 506 | } else { |
507 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 507 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
508 | selectItem(doubleClickedItem); | 508 | selectItem(doubleClickedItem); |
509 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 509 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
510 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 510 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
511 | else | 511 | else |
512 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 512 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
513 | } | 513 | } |
514 | break; | 514 | break; |
515 | 515 | ||
516 | default: | 516 | default: |
517 | break; | 517 | break; |
518 | } | 518 | } |
519 | 519 | ||
520 | return true; | 520 | return true; |
521 | } | 521 | } |
522 | 522 | ||
523 | void KOAgenda::startSelectAction(QPoint viewportPos) | 523 | void KOAgenda::startSelectAction(QPoint viewportPos) |
524 | { | 524 | { |
525 | //emit newStartSelectSignal(); | 525 | //emit newStartSelectSignal(); |
526 | 526 | ||
527 | mActionType = SELECT; | 527 | mActionType = SELECT; |
528 | 528 | ||
529 | int x,y; | 529 | int x,y; |
530 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 530 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
531 | int gx,gy; | 531 | int gx,gy; |
532 | contentsToGrid(x,y,gx,gy); | 532 | contentsToGrid(x,y,gx,gy); |
533 | 533 | ||
534 | mStartCellX = gx; | 534 | mStartCellX = gx; |
535 | mStartCellY = gy; | 535 | mStartCellY = gy; |
536 | mCurrentCellX = gx; | 536 | mCurrentCellX = gx; |
537 | mCurrentCellY = gy; | 537 | mCurrentCellY = gy; |
538 | 538 | ||
539 | // Store coordinates of old selection | 539 | // Store coordinates of old selection |
540 | int selectionX = mSelectionCellX * mGridSpacingX; | 540 | int selectionX = mSelectionCellX * mGridSpacingX; |
541 | int selectionYTop = mSelectionYTop; | 541 | int selectionYTop = mSelectionYTop; |
542 | int selectionHeight = mSelectionHeight; | 542 | int selectionHeight = mSelectionHeight; |
543 | 543 | ||
544 | // Store new selection | 544 | // Store new selection |
545 | mSelectionCellX = gx; | 545 | mSelectionCellX = gx; |
546 | mSelectionYTop = gy * mGridSpacingY; | 546 | mSelectionYTop = gy * mGridSpacingY; |
547 | mSelectionHeight = mGridSpacingY; | 547 | mSelectionHeight = mGridSpacingY; |
548 | 548 | ||
549 | // Clear old selection | 549 | // Clear old selection |
550 | repaintContents( selectionX, selectionYTop, | 550 | repaintContents( selectionX, selectionYTop, |
551 | mGridSpacingX, selectionHeight,false ); | 551 | mGridSpacingX, selectionHeight,false ); |
552 | 552 | ||
553 | // Paint new selection | 553 | // Paint new selection |
554 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 554 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
555 | // mGridSpacingX, mSelectionHeight ); | 555 | // mGridSpacingX, mSelectionHeight ); |
556 | } | 556 | } |
557 | 557 | ||
558 | void KOAgenda::performSelectAction(QPoint viewportPos) | 558 | void KOAgenda::performSelectAction(QPoint viewportPos) |
559 | { | 559 | { |
560 | int x,y; | 560 | int x,y; |
561 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 561 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
562 | int gx,gy; | 562 | int gx,gy; |
563 | contentsToGrid(x,y,gx,gy); | 563 | contentsToGrid(x,y,gx,gy); |
564 | 564 | ||
565 | QPoint clipperPos = clipper()-> | 565 | QPoint clipperPos = clipper()-> |
566 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 566 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
567 | 567 | ||
568 | // Scroll if cursor was moved to upper or lower end of agenda. | 568 | // Scroll if cursor was moved to upper or lower end of agenda. |
569 | if (clipperPos.y() < mScrollBorderWidth) { | 569 | if (clipperPos.y() < mScrollBorderWidth) { |
570 | mScrollUpTimer.start(mScrollDelay); | 570 | mScrollUpTimer.start(mScrollDelay); |
571 | } else if (visibleHeight() - clipperPos.y() < | 571 | } else if (visibleHeight() - clipperPos.y() < |
572 | mScrollBorderWidth) { | 572 | mScrollBorderWidth) { |
573 | mScrollDownTimer.start(mScrollDelay); | 573 | mScrollDownTimer.start(mScrollDelay); |
574 | } else { | 574 | } else { |
575 | mScrollUpTimer.stop(); | 575 | mScrollUpTimer.stop(); |
576 | mScrollDownTimer.stop(); | 576 | mScrollDownTimer.stop(); |
577 | } | 577 | } |
578 | 578 | ||
579 | if ( gy > mCurrentCellY ) { | 579 | if ( gy > mCurrentCellY ) { |
580 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 580 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
581 | 581 | ||
582 | #if 0 | 582 | #if 0 |
583 | // FIXME: Repaint only the newly selected region | 583 | // FIXME: Repaint only the newly selected region |
584 | repaintContents( mSelectionCellX * mGridSpacingX, | 584 | repaintContents( mSelectionCellX * mGridSpacingX, |
585 | mCurrentCellY + mGridSpacingY, | 585 | mCurrentCellY + mGridSpacingY, |
586 | mGridSpacingX, | 586 | mGridSpacingX, |
587 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 587 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
588 | #else | 588 | #else |
589 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 589 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
590 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 590 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
591 | mGridSpacingX, mSelectionYTop, | 591 | mGridSpacingX, mSelectionYTop, |
592 | mGridSpacingX, mSelectionHeight , false); | 592 | mGridSpacingX, mSelectionHeight , false); |
593 | #endif | 593 | #endif |
594 | 594 | ||
595 | mCurrentCellY = gy; | 595 | mCurrentCellY = gy; |
596 | } else if ( gy < mCurrentCellY ) { | 596 | } else if ( gy < mCurrentCellY ) { |
597 | if ( gy >= mStartCellY ) { | 597 | if ( gy >= mStartCellY ) { |
598 | int selectionHeight = mSelectionHeight; | 598 | int selectionHeight = mSelectionHeight; |
599 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 599 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
600 | 600 | ||
601 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 601 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
602 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 602 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
603 | mGridSpacingX, mSelectionYTop, | 603 | mGridSpacingX, mSelectionYTop, |
604 | mGridSpacingX, selectionHeight,false ); | 604 | mGridSpacingX, selectionHeight,false ); |
605 | 605 | ||
606 | mCurrentCellY = gy; | 606 | mCurrentCellY = gy; |
607 | } else { | 607 | } else { |
608 | } | 608 | } |
609 | } | 609 | } |
610 | } | 610 | } |
611 | 611 | ||
612 | void KOAgenda::endSelectAction() | 612 | void KOAgenda::endSelectAction() |
613 | { | 613 | { |
614 | mActionType = NOP; | 614 | mActionType = NOP; |
615 | mScrollUpTimer.stop(); | 615 | mScrollUpTimer.stop(); |
616 | mScrollDownTimer.stop(); | 616 | mScrollDownTimer.stop(); |
617 | 617 | ||
618 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 618 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
619 | } | 619 | } |
620 | 620 | ||
621 | void KOAgenda::startItemAction(QPoint viewportPos) | 621 | void KOAgenda::startItemAction(QPoint viewportPos) |
622 | { | 622 | { |
623 | int x,y; | 623 | int x,y; |
624 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 624 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
625 | int gx,gy; | 625 | int gx,gy; |
626 | contentsToGrid(x,y,gx,gy); | 626 | contentsToGrid(x,y,gx,gy); |
627 | 627 | ||
628 | mStartCellX = gx; | 628 | mStartCellX = gx; |
629 | mStartCellY = gy; | 629 | mStartCellY = gy; |
630 | mCurrentCellX = gx; | 630 | mCurrentCellX = gx; |
631 | mCurrentCellY = gy; | 631 | mCurrentCellY = gy; |
632 | 632 | ||
633 | if (mAllDayMode) { | 633 | if (mAllDayMode) { |
634 | int gridDistanceX = (x - gx * mGridSpacingX); | 634 | int gridDistanceX = (x - gx * mGridSpacingX); |
635 | if (gridDistanceX < mResizeBorderWidth && | 635 | if (gridDistanceX < mResizeBorderWidth && |
636 | mActionItem->cellX() == mCurrentCellX) { | 636 | mActionItem->cellX() == mCurrentCellX) { |
637 | mActionType = RESIZELEFT; | 637 | mActionType = RESIZELEFT; |
638 | setCursor(sizeHorCursor); | 638 | setCursor(sizeHorCursor); |
639 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 639 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
640 | mActionItem->cellXWidth() == mCurrentCellX) { | 640 | mActionItem->cellXWidth() == mCurrentCellX) { |
641 | mActionType = RESIZERIGHT; | 641 | mActionType = RESIZERIGHT; |
642 | setCursor(sizeHorCursor); | 642 | setCursor(sizeHorCursor); |
643 | } else { | 643 | } else { |
644 | mActionType = MOVE; | 644 | mActionType = MOVE; |
645 | mActionItem->startMove(); | 645 | mActionItem->startMove(); |
646 | setCursor(sizeAllCursor); | 646 | setCursor(sizeAllCursor); |
647 | } | 647 | } |
648 | } else { | 648 | } else { |
649 | int gridDistanceY = (y - gy * mGridSpacingY); | 649 | int gridDistanceY = (y - gy * mGridSpacingY); |
650 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 650 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
651 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 651 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
652 | mActionItem->cellYTop() == mCurrentCellY && | 652 | mActionItem->cellYTop() == mCurrentCellY && |
653 | !mActionItem->firstMultiItem()) { | 653 | !mActionItem->firstMultiItem()) { |
654 | mActionType = RESIZETOP; | 654 | mActionType = RESIZETOP; |
655 | setCursor(sizeVerCursor); | 655 | setCursor(sizeVerCursor); |
656 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 656 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
657 | mActionItem->cellYBottom() == mCurrentCellY && | 657 | mActionItem->cellYBottom() == mCurrentCellY && |
658 | !mActionItem->lastMultiItem()) { | 658 | !mActionItem->lastMultiItem()) { |
659 | mActionType = RESIZEBOTTOM; | 659 | mActionType = RESIZEBOTTOM; |
660 | setCursor(sizeVerCursor); | 660 | setCursor(sizeVerCursor); |
661 | } else { | 661 | } else { |
662 | mActionType = MOVE; | 662 | mActionType = MOVE; |
663 | mActionItem->startMove(); | 663 | mActionItem->startMove(); |
664 | setCursor(sizeAllCursor); | 664 | setCursor(sizeAllCursor); |
665 | } | 665 | } |
666 | } | 666 | } |
667 | } | 667 | } |
668 | 668 | ||
669 | void KOAgenda::performItemAction(QPoint viewportPos) | 669 | void KOAgenda::performItemAction(QPoint viewportPos) |
670 | { | 670 | { |
671 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 671 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
672 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 672 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
673 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 673 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
674 | // point = clipper()->mapFromGlobal(point); | 674 | // point = clipper()->mapFromGlobal(point); |
675 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 675 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
676 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 676 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
677 | int x,y; | 677 | int x,y; |
678 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 678 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
679 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 679 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
680 | int gx,gy; | 680 | int gx,gy; |
681 | contentsToGrid(x,y,gx,gy); | 681 | contentsToGrid(x,y,gx,gy); |
682 | QPoint clipperPos = clipper()-> | 682 | QPoint clipperPos = clipper()-> |
683 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 683 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
684 | 684 | ||
685 | // Cursor left active agenda area. | 685 | // Cursor left active agenda area. |
686 | // This starts a drag. | 686 | // This starts a drag. |
687 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 687 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
688 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 688 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
689 | if ( mActionType == MOVE ) { | 689 | if ( mActionType == MOVE ) { |
690 | mScrollUpTimer.stop(); | 690 | mScrollUpTimer.stop(); |
691 | mScrollDownTimer.stop(); | 691 | mScrollDownTimer.stop(); |
692 | mActionItem->resetMove(); | 692 | mActionItem->resetMove(); |
693 | placeSubCells( mActionItem ); | 693 | placeSubCells( mActionItem ); |
694 | // emit startDragSignal( mActionItem->incidence() ); | 694 | // emit startDragSignal( mActionItem->incidence() ); |
695 | setCursor( arrowCursor ); | 695 | setCursor( arrowCursor ); |
696 | mActionItem = 0; | 696 | mActionItem = 0; |
697 | mActionType = NOP; | 697 | mActionType = NOP; |
698 | mItemMoved = 0; | 698 | mItemMoved = 0; |
699 | return; | 699 | return; |
700 | } | 700 | } |
701 | } else { | 701 | } else { |
702 | switch ( mActionType ) { | 702 | switch ( mActionType ) { |
703 | case MOVE: | 703 | case MOVE: |
704 | setCursor( sizeAllCursor ); | 704 | setCursor( sizeAllCursor ); |
705 | break; | 705 | break; |
706 | case RESIZETOP: | 706 | case RESIZETOP: |
707 | case RESIZEBOTTOM: | 707 | case RESIZEBOTTOM: |
708 | setCursor( sizeVerCursor ); | 708 | setCursor( sizeVerCursor ); |
709 | break; | 709 | break; |
710 | case RESIZELEFT: | 710 | case RESIZELEFT: |
711 | case RESIZERIGHT: | 711 | case RESIZERIGHT: |
712 | setCursor( sizeHorCursor ); | 712 | setCursor( sizeHorCursor ); |
713 | break; | 713 | break; |
714 | default: | 714 | default: |
715 | setCursor( arrowCursor ); | 715 | setCursor( arrowCursor ); |
716 | } | 716 | } |
717 | } | 717 | } |
718 | 718 | ||
719 | // Scroll if item was moved to upper or lower end of agenda. | 719 | // Scroll if item was moved to upper or lower end of agenda. |
720 | if (clipperPos.y() < mScrollBorderWidth) { | 720 | if (clipperPos.y() < mScrollBorderWidth) { |
721 | mScrollUpTimer.start(mScrollDelay); | 721 | mScrollUpTimer.start(mScrollDelay); |
722 | } else if (visibleHeight() - clipperPos.y() < | 722 | } else if (visibleHeight() - clipperPos.y() < |
723 | mScrollBorderWidth) { | 723 | mScrollBorderWidth) { |
724 | mScrollDownTimer.start(mScrollDelay); | 724 | mScrollDownTimer.start(mScrollDelay); |
725 | } else { | 725 | } else { |
726 | mScrollUpTimer.stop(); | 726 | mScrollUpTimer.stop(); |
727 | mScrollDownTimer.stop(); | 727 | mScrollDownTimer.stop(); |
728 | } | 728 | } |
729 | 729 | ||
730 | // Move or resize item if necessary | 730 | // Move or resize item if necessary |
731 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 731 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
732 | mItemMoved = true; | 732 | mItemMoved = true; |
733 | mActionItem->raise(); | 733 | mActionItem->raise(); |
734 | if (mActionType == MOVE) { | 734 | if (mActionType == MOVE) { |
735 | // Move all items belonging to a multi item | 735 | // Move all items belonging to a multi item |
736 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 736 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
737 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 737 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
738 | if (!moveItem) moveItem = mActionItem; | 738 | if (!moveItem) moveItem = mActionItem; |
739 | while (moveItem) { | 739 | while (moveItem) { |
740 | int dy; | 740 | int dy; |
741 | if (isMultiItem) dy = 0; | 741 | if (isMultiItem) dy = 0; |
742 | else dy = gy - mCurrentCellY; | 742 | else dy = gy - mCurrentCellY; |
743 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 743 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
744 | int x,y; | 744 | int x,y; |
745 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 745 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
746 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 746 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
747 | mGridSpacingY * moveItem->cellHeight()); | 747 | mGridSpacingY * moveItem->cellHeight()); |
748 | moveChild(moveItem,x,y); | 748 | moveChild(moveItem,x,y); |
749 | moveItem = moveItem->nextMultiItem(); | 749 | moveItem = moveItem->nextMultiItem(); |
750 | } | 750 | } |
751 | } else if (mActionType == RESIZETOP) { | 751 | } else if (mActionType == RESIZETOP) { |
752 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 752 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
753 | mActionItem->expandTop(gy - mCurrentCellY); | 753 | mActionItem->expandTop(gy - mCurrentCellY); |
754 | mActionItem->resize(mActionItem->width(), | 754 | mActionItem->resize(mActionItem->width(), |
755 | mGridSpacingY * mActionItem->cellHeight()); | 755 | mGridSpacingY * mActionItem->cellHeight()); |
756 | int x,y; | 756 | int x,y; |
757 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 757 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
758 | //moveChild(mActionItem,childX(mActionItem),y); | 758 | //moveChild(mActionItem,childX(mActionItem),y); |
759 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 759 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
760 | } | 760 | } |
761 | } else if (mActionType == RESIZEBOTTOM) { | 761 | } else if (mActionType == RESIZEBOTTOM) { |
762 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 762 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
763 | mActionItem->expandBottom(gy - mCurrentCellY); | 763 | mActionItem->expandBottom(gy - mCurrentCellY); |
764 | mActionItem->resize(mActionItem->width(), | 764 | mActionItem->resize(mActionItem->width(), |
765 | mGridSpacingY * mActionItem->cellHeight()); | 765 | mGridSpacingY * mActionItem->cellHeight()); |
766 | } | 766 | } |
767 | } else if (mActionType == RESIZELEFT) { | 767 | } else if (mActionType == RESIZELEFT) { |
768 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 768 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
769 | mActionItem->expandLeft(gx - mCurrentCellX); | 769 | mActionItem->expandLeft(gx - mCurrentCellX); |
770 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 770 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
771 | mActionItem->height()); | 771 | mActionItem->height()); |
772 | int x,y; | 772 | int x,y; |
773 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 773 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
774 | moveChild(mActionItem,x,childY(mActionItem)); | 774 | moveChild(mActionItem,x,childY(mActionItem)); |
775 | } | 775 | } |
776 | } else if (mActionType == RESIZERIGHT) { | 776 | } else if (mActionType == RESIZERIGHT) { |
777 | if (mCurrentCellX >= mActionItem->cellX()) { | 777 | if (mCurrentCellX >= mActionItem->cellX()) { |
778 | mActionItem->expandRight(gx - mCurrentCellX); | 778 | mActionItem->expandRight(gx - mCurrentCellX); |
779 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 779 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
780 | mActionItem->height()); | 780 | mActionItem->height()); |
781 | } | 781 | } |
782 | } | 782 | } |
783 | mCurrentCellX = gx; | 783 | mCurrentCellX = gx; |
784 | mCurrentCellY = gy; | 784 | mCurrentCellY = gy; |
785 | } | 785 | } |
786 | } | 786 | } |
787 | 787 | ||
788 | void KOAgenda::endItemAction() | 788 | void KOAgenda::endItemAction() |
789 | { | 789 | { |
790 | 790 | ||
791 | if ( mItemMoved ) { | 791 | if ( mItemMoved ) { |
792 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 792 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
793 | if ( !placeItem ) { | 793 | if ( !placeItem ) { |
794 | placeItem = mActionItem; | 794 | placeItem = mActionItem; |
795 | } | 795 | } |
796 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 796 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
797 | Incidence* oldInc = placeItem->incidence(); | 797 | Incidence* oldInc = placeItem->incidence(); |
798 | placeItem->recreateIncidence(); | 798 | placeItem->recreateIncidence(); |
799 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 799 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
800 | } | 800 | } |
801 | int type = mActionType; | 801 | int type = mActionType; |
802 | if ( mAllDayMode ) | 802 | if ( mAllDayMode ) |
803 | type = -1; | 803 | type = -1; |
804 | KOAgendaItem *modifiedItem = placeItem; | 804 | KOAgendaItem *modifiedItem = placeItem; |
805 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 805 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
806 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 806 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
807 | KOAgendaItem *item; | 807 | KOAgendaItem *item; |
808 | 808 | ||
809 | if ( placeItem->incidence()->type() == "Todo" ) { | 809 | if ( placeItem->incidence()->type() == "Todo" ) { |
810 | mSelectedItem = 0; | 810 | mSelectedItem = 0; |
811 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 811 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
812 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 812 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
813 | emit itemModified( modifiedItem, mActionType ); | 813 | emit itemModified( modifiedItem, mActionType ); |
814 | } | 814 | } |
815 | else { | 815 | else { |
816 | #if 0 | 816 | #if 0 |
817 | for ( item=oldconflictItems.first(); item != 0; | 817 | for ( item=oldconflictItems.first(); item != 0; |
818 | item=oldconflictItems.next() ) { | 818 | item=oldconflictItems.next() ) { |
819 | placeSubCells(item); | 819 | placeSubCells(item); |
820 | } | 820 | } |
821 | while ( placeItem ) { | 821 | while ( placeItem ) { |
822 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 822 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
823 | placeSubCells( placeItem ); | 823 | placeSubCells( placeItem ); |
824 | placeItem = placeItem->nextMultiItem(); | 824 | placeItem = placeItem->nextMultiItem(); |
825 | } | 825 | } |
826 | #endif | 826 | #endif |
827 | 827 | ||
828 | globalFlagBlockAgendaItemPaint = 1; | 828 | globalFlagBlockAgendaItemPaint = 1; |
829 | for ( item=oldconflictItems.first(); item != 0; | 829 | for ( item=oldconflictItems.first(); item != 0; |
830 | item=oldconflictItems.next() ) { | 830 | item=oldconflictItems.next() ) { |
831 | placeSubCells(item); | 831 | placeSubCells(item); |
832 | } | 832 | } |
833 | while ( placeItem ) { | 833 | while ( placeItem ) { |
834 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 834 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
835 | oldconflictItems = placeItem->conflictItems(); | 835 | oldconflictItems = placeItem->conflictItems(); |
836 | for ( item=oldconflictItems.first(); item != 0; | 836 | for ( item=oldconflictItems.first(); item != 0; |
837 | item=oldconflictItems.next() ) { | 837 | item=oldconflictItems.next() ) { |
838 | placeSubCells(item); | 838 | placeSubCells(item); |
839 | } | 839 | } |
840 | placeSubCells( placeItem ); | 840 | placeSubCells( placeItem ); |
841 | placeItem = placeItem->nextMultiItem(); | 841 | placeItem = placeItem->nextMultiItem(); |
842 | } | 842 | } |
843 | globalFlagBlockAgendaItemPaint = 0; | 843 | globalFlagBlockAgendaItemPaint = 0; |
844 | for ( item=oldconflictItems.first(); item != 0; | 844 | for ( item=oldconflictItems.first(); item != 0; |
845 | item=oldconflictItems.next() ) { | 845 | item=oldconflictItems.next() ) { |
846 | globalFlagBlockAgendaItemUpdate = 0; | 846 | globalFlagBlockAgendaItemUpdate = 0; |
847 | item->repaintMe(); | 847 | item->repaintMe(); |
848 | globalFlagBlockAgendaItemUpdate = 1; | 848 | globalFlagBlockAgendaItemUpdate = 1; |
849 | item->repaint( false ); | 849 | item->repaint( false ); |
850 | } | 850 | } |
851 | placeItem = modifiedItem; | 851 | placeItem = modifiedItem; |
852 | 852 | ||
853 | while ( placeItem ) { | 853 | while ( placeItem ) { |
854 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 854 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
855 | globalFlagBlockAgendaItemUpdate = 0; | 855 | globalFlagBlockAgendaItemUpdate = 0; |
856 | placeItem->repaintMe(); | 856 | placeItem->repaintMe(); |
857 | globalFlagBlockAgendaItemUpdate = 1; | 857 | globalFlagBlockAgendaItemUpdate = 1; |
858 | placeItem->repaint(false); | 858 | placeItem->repaint(false); |
859 | placeItem = placeItem->nextMultiItem(); | 859 | placeItem = placeItem->nextMultiItem(); |
860 | } | 860 | } |
861 | emit itemModified( modifiedItem, mActionType ); | 861 | emit itemModified( modifiedItem, mActionType ); |
862 | 862 | ||
863 | 863 | ||
864 | placeItem = modifiedItem; | 864 | placeItem = modifiedItem; |
865 | while ( placeItem ) { | 865 | while ( placeItem ) { |
866 | oldconflictItems = placeItem->conflictItems(); | 866 | oldconflictItems = placeItem->conflictItems(); |
867 | for ( item=oldconflictItems.first(); item != 0; | 867 | for ( item=oldconflictItems.first(); item != 0; |
868 | item=oldconflictItems.next() ) { | 868 | item=oldconflictItems.next() ) { |
869 | placeSubCells(item); | 869 | placeSubCells(item); |
870 | } | 870 | } |
871 | placeSubCells( placeItem ); | 871 | placeSubCells( placeItem ); |
872 | placeItem = placeItem->nextMultiItem(); | 872 | placeItem = placeItem->nextMultiItem(); |
873 | 873 | ||
874 | } | 874 | } |
875 | placeItem = modifiedItem; | 875 | placeItem = modifiedItem; |
876 | while ( placeItem ) { | 876 | while ( placeItem ) { |
877 | oldconflictItems = placeItem->conflictItems(); | 877 | oldconflictItems = placeItem->conflictItems(); |
878 | for ( item=oldconflictItems.first(); item != 0; | 878 | for ( item=oldconflictItems.first(); item != 0; |
879 | item=oldconflictItems.next() ) { | 879 | item=oldconflictItems.next() ) { |
880 | globalFlagBlockAgendaItemUpdate = 0; | 880 | globalFlagBlockAgendaItemUpdate = 0; |
881 | item->repaintMe(); | 881 | item->repaintMe(); |
882 | globalFlagBlockAgendaItemUpdate = 1; | 882 | globalFlagBlockAgendaItemUpdate = 1; |
883 | item->repaint(false); | 883 | item->repaint(false); |
884 | } | 884 | } |
885 | placeItem = placeItem->nextMultiItem(); | 885 | placeItem = placeItem->nextMultiItem(); |
886 | } | 886 | } |
887 | /* | 887 | /* |
888 | 888 | ||
889 | oldconflictItems = modifiedItem->conflictItems(); | 889 | oldconflictItems = modifiedItem->conflictItems(); |
890 | for ( item=oldconflictItems.first(); item != 0; | 890 | for ( item=oldconflictItems.first(); item != 0; |
891 | item=oldconflictItems.next() ) { | 891 | item=oldconflictItems.next() ) { |
892 | globalFlagBlockAgendaItemUpdate = 0; | 892 | globalFlagBlockAgendaItemUpdate = 0; |
893 | item->paintMe(false); | 893 | item->paintMe(false); |
894 | globalFlagBlockAgendaItemUpdate = 1; | 894 | globalFlagBlockAgendaItemUpdate = 1; |
895 | item->repaint(false); | 895 | item->repaint(false); |
896 | } | 896 | } |
897 | */ | 897 | */ |
898 | 898 | ||
899 | 899 | ||
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | 903 | ||
904 | mScrollUpTimer.stop(); | 904 | mScrollUpTimer.stop(); |
905 | mScrollDownTimer.stop(); | 905 | mScrollDownTimer.stop(); |
906 | setCursor( arrowCursor ); | 906 | setCursor( arrowCursor ); |
907 | mActionItem = 0; | 907 | mActionItem = 0; |
908 | mActionType = NOP; | 908 | mActionType = NOP; |
909 | mItemMoved = 0; | 909 | mItemMoved = 0; |
910 | 910 | ||
911 | } | 911 | } |
912 | 912 | ||
913 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 913 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
914 | { | 914 | { |
915 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 915 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
916 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 916 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
917 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 917 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
918 | // point = clipper()->mapFromGlobal(point); | 918 | // point = clipper()->mapFromGlobal(point); |
919 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 919 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
920 | 920 | ||
921 | int x,y; | 921 | int x,y; |
922 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 922 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
923 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 923 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
924 | int gx,gy; | 924 | int gx,gy; |
925 | contentsToGrid(x,y,gx,gy); | 925 | contentsToGrid(x,y,gx,gy); |
926 | 926 | ||
927 | // Change cursor to resize cursor if appropriate | 927 | // Change cursor to resize cursor if appropriate |
928 | if (mAllDayMode) { | 928 | if (mAllDayMode) { |
929 | int gridDistanceX = (x - gx * mGridSpacingX); | 929 | int gridDistanceX = (x - gx * mGridSpacingX); |
930 | if (gridDistanceX < mResizeBorderWidth && | 930 | if (gridDistanceX < mResizeBorderWidth && |
931 | moveItem->cellX() == gx) { | 931 | moveItem->cellX() == gx) { |
932 | setCursor(sizeHorCursor); | 932 | setCursor(sizeHorCursor); |
933 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 933 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
934 | moveItem->cellXWidth() == gx) { | 934 | moveItem->cellXWidth() == gx) { |
935 | setCursor(sizeHorCursor); | 935 | setCursor(sizeHorCursor); |
936 | } else { | 936 | } else { |
937 | setCursor(arrowCursor); | 937 | setCursor(arrowCursor); |
938 | } | 938 | } |
939 | } else { | 939 | } else { |
940 | int gridDistanceY = (y - gy * mGridSpacingY); | 940 | int gridDistanceY = (y - gy * mGridSpacingY); |
941 | if (gridDistanceY < mResizeBorderWidth && | 941 | if (gridDistanceY < mResizeBorderWidth && |
942 | moveItem->cellYTop() == gy && | 942 | moveItem->cellYTop() == gy && |
943 | !moveItem->firstMultiItem()) { | 943 | !moveItem->firstMultiItem()) { |
944 | setCursor(sizeVerCursor); | 944 | setCursor(sizeVerCursor); |
945 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 945 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
946 | moveItem->cellYBottom() == gy && | 946 | moveItem->cellYBottom() == gy && |
947 | !moveItem->lastMultiItem()) { | 947 | !moveItem->lastMultiItem()) { |
948 | setCursor(sizeVerCursor); | 948 | setCursor(sizeVerCursor); |
949 | } else { | 949 | } else { |
950 | setCursor(arrowCursor); | 950 | setCursor(arrowCursor); |
951 | } | 951 | } |
952 | } | 952 | } |
953 | } | 953 | } |
954 | 954 | ||
955 | 955 | ||
956 | /* | 956 | /* |
957 | Place item in cell and take care that multiple items using the same cell do | 957 | Place item in cell and take care that multiple items using the same cell do |
958 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 958 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
959 | it can get in all cases. | 959 | it can get in all cases. |
960 | At the moment the method has a bug: When an item is placed only the sub cell | 960 | At the moment the method has a bug: When an item is placed only the sub cell |
961 | widths of the items are changed, which are within the Y region the item to | 961 | widths of the items are changed, which are within the Y region the item to |
962 | place spans. When the sub cell width change of one of this items affects a | 962 | place spans. When the sub cell width change of one of this items affects a |
963 | cell, where other items are, which do not overlap in Y with the item to place, | 963 | cell, where other items are, which do not overlap in Y with the item to place, |
964 | the display gets corrupted, although the corruption looks quite nice. | 964 | the display gets corrupted, although the corruption looks quite nice. |
965 | */ | 965 | */ |
966 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 966 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
967 | { | 967 | { |
968 | 968 | ||
969 | QPtrList<KOAgendaItem> conflictItems; | 969 | QPtrList<KOAgendaItem> conflictItems; |
970 | int maxSubCells = 0; | 970 | int maxSubCells = 0; |
971 | QIntDict<KOAgendaItem> subCellDict(5); | 971 | QIntDict<KOAgendaItem> subCellDict(5); |
972 | 972 | ||
973 | KOAgendaItem *item; | 973 | KOAgendaItem *item; |
974 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 974 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
975 | if (item != placeItem) { | 975 | if (item != placeItem) { |
976 | if (placeItem->cellX() <= item->cellXWidth() && | 976 | if (placeItem->cellX() <= item->cellXWidth() && |
977 | placeItem->cellXWidth() >= item->cellX()) { | 977 | placeItem->cellXWidth() >= item->cellX()) { |
978 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 978 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
979 | (placeItem->cellYBottom() >= item->cellYTop())) { | 979 | (placeItem->cellYBottom() >= item->cellYTop())) { |
980 | conflictItems.append(item); | 980 | conflictItems.append(item); |
981 | if (item->subCells() > maxSubCells) | 981 | if (item->subCells() > maxSubCells) |
982 | maxSubCells = item->subCells(); | 982 | maxSubCells = item->subCells(); |
983 | subCellDict.insert(item->subCell(),item); | 983 | subCellDict.insert(item->subCell(),item); |
984 | } | 984 | } |
985 | } | 985 | } |
986 | } | 986 | } |
987 | } | 987 | } |
988 | 988 | ||
989 | if (conflictItems.count() > 0) { | 989 | if (conflictItems.count() > 0) { |
990 | // Look for unused sub cell and insert item | 990 | // Look for unused sub cell and insert item |
991 | int i; | 991 | int i; |
992 | for(i=0;i<maxSubCells;++i) { | 992 | for(i=0;i<maxSubCells;++i) { |
993 | if (!subCellDict.find(i)) { | 993 | if (!subCellDict.find(i)) { |
994 | placeItem->setSubCell(i); | 994 | placeItem->setSubCell(i); |
995 | break; | 995 | break; |
996 | } | 996 | } |
997 | } | 997 | } |
998 | if (i == maxSubCells) { | 998 | if (i == maxSubCells) { |
999 | placeItem->setSubCell(maxSubCells); | 999 | placeItem->setSubCell(maxSubCells); |
1000 | maxSubCells++; // add new item to number of sub cells | 1000 | maxSubCells++; // add new item to number of sub cells |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | // Prepare for sub cell geometry adjustment | 1003 | // Prepare for sub cell geometry adjustment |
1004 | int newSubCellWidth; | 1004 | int newSubCellWidth; |
1005 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1005 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1006 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1006 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1007 | conflictItems.append(placeItem); | 1007 | conflictItems.append(placeItem); |
1008 | 1008 | ||
1009 | 1009 | ||
1010 | // Adjust sub cell geometry of all items | 1010 | // Adjust sub cell geometry of all items |
1011 | for ( item=conflictItems.first(); item != 0; | 1011 | for ( item=conflictItems.first(); item != 0; |
1012 | item=conflictItems.next() ) { | 1012 | item=conflictItems.next() ) { |
1013 | item->setSubCells(maxSubCells); | 1013 | item->setSubCells(maxSubCells); |
1014 | if (mAllDayMode) { | 1014 | if (mAllDayMode) { |
1015 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1015 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1016 | } else { | 1016 | } else { |
1017 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1017 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1018 | } | 1018 | } |
1019 | int x,y; | 1019 | int x,y; |
1020 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1020 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1021 | if (mAllDayMode) { | 1021 | if (mAllDayMode) { |
1022 | y += item->subCell() * newSubCellWidth; | 1022 | y += item->subCell() * newSubCellWidth; |
1023 | } else { | 1023 | } else { |
1024 | x += item->subCell() * newSubCellWidth; | 1024 | x += item->subCell() * newSubCellWidth; |
1025 | } | 1025 | } |
1026 | moveChild(item,x,y); | 1026 | moveChild(item,x,y); |
1027 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1027 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1028 | //item->updateItem(); | 1028 | //item->updateItem(); |
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | } else { | 1031 | } else { |
1032 | placeItem->setSubCell(0); | 1032 | placeItem->setSubCell(0); |
1033 | placeItem->setSubCells(1); | 1033 | placeItem->setSubCells(1); |
1034 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1034 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1035 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1035 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1036 | int x,y; | 1036 | int x,y; |
1037 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1037 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1038 | moveChild(placeItem,x,y); | 1038 | moveChild(placeItem,x,y); |
1039 | } | 1039 | } |
1040 | placeItem->setConflictItems(conflictItems); | 1040 | placeItem->setConflictItems(conflictItems); |
1041 | // for ( item=conflictItems.first(); item != 0; | 1041 | // for ( item=conflictItems.first(); item != 0; |
1042 | // item=conflictItems.next() ) { | 1042 | // item=conflictItems.next() ) { |
1043 | // //item->updateItem(); | 1043 | // //item->updateItem(); |
1044 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1044 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1045 | // } | 1045 | // } |
1046 | // placeItem->updateItem(); | 1046 | // placeItem->updateItem(); |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1049 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1050 | { | 1050 | { |
1051 | if ( globalFlagBlockAgenda ) | 1051 | if ( globalFlagBlockAgenda ) |
1052 | return; | 1052 | return; |
1053 | //qDebug("KOAgenda::drawContents "); | 1053 | //qDebug("KOAgenda::drawContents "); |
1054 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1054 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1055 | ;//drawContentsToPainter(); | 1055 | ;//drawContentsToPainter(); |
1056 | 1056 | ||
1057 | QPaintDevice* pd = p->device(); | 1057 | QPaintDevice* pd = p->device(); |
1058 | p->end(); | 1058 | p->end(); |
1059 | int vx, vy; | 1059 | int vx, vy; |
1060 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1060 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1061 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1061 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1062 | mSelectionCellX * mGridSpacingX; | 1062 | mSelectionCellX * mGridSpacingX; |
1063 | contentsToViewport ( cx, cy, vx,vy); | 1063 | contentsToViewport ( cx, cy, vx,vy); |
1064 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1064 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1065 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1065 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1066 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1066 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1067 | 1067 | ||
1068 | if ( mSelectionHeight > 0 ) { | 1068 | if ( mSelectionHeight > 0 ) { |
1069 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1069 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1070 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1070 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1071 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1071 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1072 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1072 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1073 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1073 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1074 | } | 1074 | } |
1075 | } | 1075 | } |
1076 | //qDebug("btbl "); | 1076 | //qDebug("btbl "); |
1077 | p->begin( pd ); | 1077 | p->begin( pd ); |
1078 | //qDebug("end "); | 1078 | //qDebug("end "); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | void KOAgenda::finishUpdate() | 1081 | void KOAgenda::finishUpdate() |
1082 | { | 1082 | { |
1083 | 1083 | ||
1084 | KOAgendaItem *item; | 1084 | KOAgendaItem *item; |
1085 | globalFlagBlockAgendaItemPaint = 1; | 1085 | globalFlagBlockAgendaItemPaint = 1; |
1086 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1086 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1087 | if ( !item->isVisible() ) | 1087 | if ( !item->isVisible() ) |
1088 | item->show(); | 1088 | item->show(); |
1089 | 1089 | ||
1090 | } | 1090 | } |
1091 | globalFlagBlockAgendaItemUpdate = 0; | 1091 | globalFlagBlockAgendaItemUpdate = 0; |
1092 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1092 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1093 | item->repaintMe( ); | 1093 | item->repaintMe( ); |
1094 | } | 1094 | } |
1095 | globalFlagBlockAgendaItemUpdate = 1; | 1095 | globalFlagBlockAgendaItemUpdate = 1; |
1096 | qApp->processEvents(); | 1096 | qApp->processEvents(); |
1097 | globalFlagBlockAgendaItemPaint = 0; | 1097 | globalFlagBlockAgendaItemPaint = 0; |
1098 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1098 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1099 | item->repaint( false ); | 1099 | item->repaint( false ); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | /* | 1104 | /* |
1105 | Draw grid in the background of the agenda. | 1105 | Draw grid in the background of the agenda. |
1106 | */ | 1106 | */ |
1107 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1107 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1108 | { | 1108 | { |
1109 | 1109 | ||
1110 | 1110 | ||
1111 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1111 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1112 | return; | 1112 | return; |
1113 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1113 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1114 | return; | 1114 | return; |
1115 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1115 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1116 | if ( ch < 1 ) | 1116 | if ( ch < 1 ) |
1117 | ch = 1; | 1117 | ch = 1; |
1118 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1118 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1119 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1119 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1120 | } | 1120 | } |
1121 | mCurPixWid = contentsWidth(); | 1121 | mCurPixWid = contentsWidth(); |
1122 | mCurPixHei = ch; | 1122 | mCurPixHei = ch; |
1123 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1123 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1124 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1124 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1125 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1125 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1126 | } | 1126 | } |
1127 | mPixPainter.begin( &mPaintPixmap) ; | 1127 | mPixPainter.begin( &mPaintPixmap) ; |
1128 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1128 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1129 | QPainter * p ; | 1129 | QPainter * p ; |
1130 | if (paint == 0) { | 1130 | if (paint == 0) { |
1131 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1131 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1132 | p = &mPixPainter; | 1132 | p = &mPixPainter; |
1133 | } | 1133 | } |
1134 | else | 1134 | else |
1135 | p = paint ; | 1135 | p = paint ; |
1136 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1136 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1137 | 1137 | ||
1138 | //--cx;++cw; | 1138 | //--cx;++cw; |
1139 | int lGridSpacingY = mGridSpacingY*2; | 1139 | int lGridSpacingY = mGridSpacingY*2; |
1140 | int selDay; | 1140 | int selDay; |
1141 | if ( !backgroundOnly ) | 1141 | if ( !backgroundOnly ) |
1142 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1142 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1143 | { | 1143 | { |
1144 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1144 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1145 | int x1 = cx; | 1145 | int x1 = cx; |
1146 | int y1 = 0; | 1146 | int y1 = 0; |
1147 | if (y1 < cy) y1 = cy; | 1147 | if (y1 < cy) y1 = cy; |
1148 | int x2 = cx+cw-1; | 1148 | int x2 = cx+cw-1; |
1149 | int y2 = contentsHeight(); | 1149 | int y2 = contentsHeight(); |
1150 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1150 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1151 | if (x2 >= x1 && y2 >= y1) { | 1151 | if (x2 >= x1 && y2 >= y1) { |
1152 | int gxStart = selDay; | 1152 | int gxStart = selDay; |
1153 | int gxEnd = gxStart ; | 1153 | int gxEnd = gxStart ; |
1154 | int xStart = KOGlobals::self()->reverseLayout() ? | 1154 | int xStart = KOGlobals::self()->reverseLayout() ? |
1155 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1155 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1156 | gxStart*mGridSpacingX; | 1156 | gxStart*mGridSpacingX; |
1157 | if (xStart < x1) xStart = x1; | 1157 | if (xStart < x1) xStart = x1; |
1158 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1158 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1159 | (mColumns - gxStart)*mGridSpacingX-1 : | 1159 | (mColumns - gxStart)*mGridSpacingX-1 : |
1160 | (gxStart+1)*mGridSpacingX-1; | 1160 | (gxStart+1)*mGridSpacingX-1; |
1161 | if (xEnd > x2) xEnd = x2; | 1161 | if (xEnd > x2) xEnd = x2; |
1162 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1162 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1163 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1163 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1164 | KOPrefs::instance()->mAgendaBgColor.light()); | 1164 | KOPrefs::instance()->mAgendaBgColor.light()); |
1165 | else | 1165 | else |
1166 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1166 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1167 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1167 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1168 | 1168 | ||
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | } | 1171 | } |
1172 | // Highlight working hours | 1172 | // Highlight working hours |
1173 | 1173 | ||
1174 | if ( !backgroundOnly ) | 1174 | if ( !backgroundOnly ) |
1175 | if (mWorkingHoursEnable) { | 1175 | if (mWorkingHoursEnable) { |
1176 | int x1 = cx; | 1176 | int x1 = cx; |
1177 | int y1 = mWorkingHoursYTop; | 1177 | int y1 = mWorkingHoursYTop; |
1178 | if (y1 < cy) y1 = cy; | 1178 | if (y1 < cy) y1 = cy; |
1179 | int x2 = cx+cw-1; | 1179 | int x2 = cx+cw-1; |
1180 | // int x2 = mGridSpacingX * 5 - 1; | 1180 | // int x2 = mGridSpacingX * 5 - 1; |
1181 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1181 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1182 | int y2 = mWorkingHoursYBottom; | 1182 | int y2 = mWorkingHoursYBottom; |
1183 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1183 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1184 | 1184 | ||
1185 | if (x2 >= x1 && y2 >= y1) { | 1185 | if (x2 >= x1 && y2 >= y1) { |
1186 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1186 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1187 | int gxStart = x1/mGridSpacingX; | 1187 | int gxStart = x1/mGridSpacingX; |
1188 | int gxEnd = x2/mGridSpacingX; | 1188 | int gxEnd = x2/mGridSpacingX; |
1189 | while(gxStart <= gxEnd) { | 1189 | while(gxStart <= gxEnd) { |
1190 | if (gxStart < int(mHolidayMask->count()) && | 1190 | if (gxStart < int(mHolidayMask->count()) && |
1191 | !mHolidayMask->at(gxStart)) { | 1191 | !mHolidayMask->at(gxStart)) { |
1192 | int xStart = KOGlobals::self()->reverseLayout() ? | 1192 | int xStart = KOGlobals::self()->reverseLayout() ? |
1193 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1193 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1194 | gxStart*mGridSpacingX; | 1194 | gxStart*mGridSpacingX; |
1195 | if (xStart < x1) xStart = x1; | 1195 | if (xStart < x1) xStart = x1; |
1196 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1196 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1197 | (mColumns - gxStart)*mGridSpacingX-1 : | 1197 | (mColumns - gxStart)*mGridSpacingX-1 : |
1198 | (gxStart+1)*mGridSpacingX-1; | 1198 | (gxStart+1)*mGridSpacingX-1; |
1199 | if (xEnd > x2) xEnd = x2; | 1199 | if (xEnd > x2) xEnd = x2; |
1200 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1200 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1201 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1201 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1202 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1202 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1203 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1203 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1204 | else | 1204 | else |
1205 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1205 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1206 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1206 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1207 | } else { | 1207 | } else { |
1208 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1208 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1209 | KOPrefs::instance()->mWorkingHoursColor); | 1209 | KOPrefs::instance()->mWorkingHoursColor); |
1210 | } | 1210 | } |
1211 | } | 1211 | } |
1212 | ++gxStart; | 1212 | ++gxStart; |
1213 | } | 1213 | } |
1214 | } | 1214 | } |
1215 | } | 1215 | } |
1216 | /* | 1216 | /* |
1217 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1217 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1218 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1218 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1219 | mSelectionCellX * mGridSpacingX; | 1219 | mSelectionCellX * mGridSpacingX; |
1220 | 1220 | ||
1221 | // Draw selection | 1221 | // Draw selection |
1222 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1222 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1223 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1223 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1224 | // TODO: paint only part within cx,cy,cw,ch | 1224 | // TODO: paint only part within cx,cy,cw,ch |
1225 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1225 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1226 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1226 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1227 | } | 1227 | } |
1228 | */ | 1228 | */ |
1229 | // Draw vertical lines of grid | 1229 | // Draw vertical lines of grid |
1230 | 1230 | ||
1231 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1231 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1232 | if ( mGridSpacingX > 0 ) { | 1232 | if ( mGridSpacingX > 0 ) { |
1233 | while (x < cx + cw) { | 1233 | while (x < cx + cw) { |
1234 | p->drawLine(x,cy,x,cy+ch); | 1234 | p->drawLine(x,cy,x,cy+ch); |
1235 | x+=mGridSpacingX; | 1235 | x+=mGridSpacingX; |
1236 | } | 1236 | } |
1237 | } | 1237 | } |
1238 | // Draw horizontal lines of grid | 1238 | // Draw horizontal lines of grid |
1239 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1239 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1240 | if ( lGridSpacingY > 0 ) { | 1240 | if ( lGridSpacingY > 0 ) { |
1241 | while (y < cy + ch) { | 1241 | while (y < cy + ch) { |
1242 | p->setPen( SolidLine ); | 1242 | p->setPen( SolidLine ); |
1243 | p->drawLine(cx,y,cx+cw,y); | 1243 | p->drawLine(cx,y,cx+cw,y); |
1244 | y+=lGridSpacingY; | 1244 | y+=lGridSpacingY; |
1245 | p->setPen( DotLine ); | 1245 | p->setPen( DotLine ); |
1246 | p->drawLine(cx,y,cx+cw,y); | 1246 | p->drawLine(cx,y,cx+cw,y); |
1247 | y+=lGridSpacingY; | 1247 | y+=lGridSpacingY; |
1248 | } | 1248 | } |
1249 | p->setPen( SolidLine ); | 1249 | p->setPen( SolidLine ); |
1250 | } | 1250 | } |
1251 | mPixPainter.end() ; | 1251 | mPixPainter.end() ; |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | /* | 1254 | /* |
1255 | Convert srcollview contents coordinates to agenda grid coordinates. | 1255 | Convert srcollview contents coordinates to agenda grid coordinates. |
1256 | */ | 1256 | */ |
1257 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1257 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1258 | { | 1258 | { |
1259 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1259 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1260 | x/mGridSpacingX; | 1260 | x/mGridSpacingX; |
1261 | gy = y/mGridSpacingY; | 1261 | gy = y/mGridSpacingY; |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | /* | 1264 | /* |
1265 | Convert agenda grid coordinates to scrollview contents coordinates. | 1265 | Convert agenda grid coordinates to scrollview contents coordinates. |
1266 | */ | 1266 | */ |
1267 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1267 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1268 | { | 1268 | { |
1269 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1269 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1270 | gx*mGridSpacingX; | 1270 | gx*mGridSpacingX; |
1271 | y = gy*mGridSpacingY; | 1271 | y = gy*mGridSpacingY; |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | 1274 | ||
1275 | /* | 1275 | /* |
1276 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1276 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1277 | the grid. | 1277 | the grid. |
1278 | */ | 1278 | */ |
1279 | int KOAgenda::timeToY(const QTime &time) | 1279 | int KOAgenda::timeToY(const QTime &time) |
1280 | { | 1280 | { |
1281 | int minutesPerCell = 24 * 60 / mRows; | 1281 | int minutesPerCell = 24 * 60 / mRows; |
1282 | int timeMinutes = time.hour() * 60 + time.minute(); | 1282 | int timeMinutes = time.hour() * 60 + time.minute(); |
1283 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1283 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1284 | return Y; | 1284 | return Y; |
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | 1287 | ||
1288 | /* | 1288 | /* |
1289 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1289 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1290 | fit into the grid. | 1290 | fit into the grid. |
1291 | */ | 1291 | */ |
1292 | QTime KOAgenda::gyToTime(int gy) | 1292 | QTime KOAgenda::gyToTime(int gy) |
1293 | { | 1293 | { |
1294 | 1294 | ||
1295 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1295 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1296 | 1296 | ||
1297 | int timeSeconds = secondsPerCell * gy; | 1297 | int timeSeconds = secondsPerCell * gy; |
1298 | 1298 | ||
1299 | QTime time( 0, 0, 0 ); | 1299 | QTime time( 0, 0, 0 ); |
1300 | if ( timeSeconds < 24 * 60 * 60 ) { | 1300 | if ( timeSeconds < 24 * 60 * 60 ) { |
1301 | time = time.addSecs(timeSeconds); | 1301 | time = time.addSecs(timeSeconds); |
1302 | } else { | 1302 | } else { |
1303 | time.setHMS( 23, 59, 59 ); | 1303 | time.setHMS( 23, 59, 59 ); |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | return time; | 1306 | return time; |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | void KOAgenda::setStartHour(int startHour) | 1309 | void KOAgenda::setStartHour(int startHour) |
1310 | { | 1310 | { |
1311 | int startCell = startHour * mRows / 24; | 1311 | int startCell = startHour * mRows / 24; |
1312 | setContentsPos(0,startCell * gridSpacingY()); | 1312 | setContentsPos(0,startCell * gridSpacingY()); |
1313 | } | 1313 | } |
1314 | void KOAgenda::hideUnused() | 1314 | void KOAgenda::hideUnused() |
1315 | { | 1315 | { |
1316 | // experimental only | 1316 | // experimental only |
1317 | // return; | 1317 | // return; |
1318 | KOAgendaItem *item; | 1318 | KOAgendaItem *item; |
1319 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1319 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1320 | item->hide(); | 1320 | item->hide(); |
1321 | } | 1321 | } |
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | 1324 | ||
1325 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1325 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1326 | { | 1326 | { |
1327 | 1327 | ||
1328 | KOAgendaItem *fi; | 1328 | KOAgendaItem *fi; |
1329 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1329 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1330 | if ( fi->incidence() == event ) { | 1330 | if ( fi->incidence() == event ) { |
1331 | mUnusedItems.remove(); | 1331 | mUnusedItems.remove(); |
1332 | fi->init( event, qd ); | 1332 | fi->init( event, qd ); |
1333 | return fi; | 1333 | return fi; |
1334 | } | 1334 | } |
1335 | } | 1335 | } |
1336 | fi=mUnusedItems.first(); | 1336 | fi=mUnusedItems.first(); |
1337 | if ( fi ) { | 1337 | if ( fi ) { |
1338 | mUnusedItems.remove(); | 1338 | mUnusedItems.remove(); |
1339 | fi->init( event, qd ); | 1339 | fi->init( event, qd ); |
1340 | return fi; | 1340 | return fi; |
1341 | } | 1341 | } |
1342 | // qDebug("new KOAgendaItem "); | 1342 | // qDebug("new KOAgendaItem "); |
1343 | 1343 | ||
1344 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1344 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1345 | agendaItem->installEventFilter(this); | 1345 | agendaItem->installEventFilter(this); |
1346 | addChild(agendaItem,0,0); | 1346 | addChild(agendaItem,0,0); |
1347 | return agendaItem; | 1347 | return agendaItem; |
1348 | } | 1348 | } |
1349 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1349 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1350 | { | 1350 | { |
1351 | KOAgendaItem *item; | 1351 | KOAgendaItem *item; |
1352 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1352 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1353 | if ( item->incidence() == todo ) { | 1353 | if ( item->incidence() == todo ) { |
1354 | mItems.remove(); | 1354 | mItems.remove(); |
1355 | return item; | 1355 | return item; |
1356 | } | 1356 | } |
1357 | } | 1357 | } |
1358 | return 0; | 1358 | return 0; |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | 1361 | ||
1362 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1362 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1363 | { | 1363 | { |
1364 | 1364 | ||
1365 | KOAgendaItem *item; | 1365 | KOAgendaItem *item; |
1366 | item = getItemForTodo ( todo ); | 1366 | item = getItemForTodo ( todo ); |
1367 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1367 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1368 | if ( item ) { | 1368 | if ( item ) { |
1369 | blockSignals( true ); | 1369 | blockSignals( true ); |
1370 | //qDebug("item found "); | 1370 | //qDebug("item found "); |
1371 | item->hide(); | 1371 | item->hide(); |
1372 | item->setCellX(-2, -1 ); | 1372 | item->setCellX(-2, -1 ); |
1373 | item->select(false); | 1373 | item->select(false); |
1374 | mUnusedItems.append( item ); | 1374 | mUnusedItems.append( item ); |
1375 | mItems.remove( item ); | 1375 | mItems.remove( item ); |
1376 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1376 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1377 | KOAgendaItem *itemit; | 1377 | KOAgendaItem *itemit; |
1378 | //globalFlagBlockAgendaItemPaint = 1; | 1378 | //globalFlagBlockAgendaItemPaint = 1; |
1379 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1379 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1380 | itemit=oldconflictItems.next() ) { | 1380 | itemit=oldconflictItems.next() ) { |
1381 | if ( itemit != item ) | 1381 | if ( itemit != item ) |
1382 | placeSubCells(itemit); | 1382 | placeSubCells(itemit); |
1383 | } | 1383 | } |
1384 | qApp->processEvents(); | 1384 | qApp->processEvents(); |
1385 | //globalFlagBlockAgendaItemPaint = 0; | 1385 | //globalFlagBlockAgendaItemPaint = 0; |
1386 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1386 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1387 | itemit=oldconflictItems.next() ) { | 1387 | itemit=oldconflictItems.next() ) { |
1388 | globalFlagBlockAgendaItemUpdate = 0; | 1388 | globalFlagBlockAgendaItemUpdate = 0; |
1389 | if ( itemit != item ) | 1389 | if ( itemit != item ) |
1390 | itemit->repaintMe(); | 1390 | itemit->repaintMe(); |
1391 | globalFlagBlockAgendaItemUpdate = 1; | 1391 | globalFlagBlockAgendaItemUpdate = 1; |
1392 | itemit->repaint(); | 1392 | itemit->repaint(); |
1393 | } | 1393 | } |
1394 | blockSignals( false ); | 1394 | blockSignals( false ); |
1395 | } | 1395 | } |
1396 | if ( remove ) { | 1396 | if ( remove ) { |
1397 | //qDebug("remove****************************************** "); | 1397 | //qDebug("remove****************************************** "); |
1398 | return; | 1398 | return; |
1399 | } | 1399 | } |
1400 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1400 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1401 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1401 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1402 | QDate currentDate; | 1402 | QDate currentDate; |
1403 | if ( overdue ) { | 1403 | if ( overdue ) { |
1404 | currentDate = QDate::currentDate(); | 1404 | currentDate = QDate::currentDate(); |
1405 | days += todo->dtDue().date().daysTo( currentDate ); | 1405 | days += todo->dtDue().date().daysTo( currentDate ); |
1406 | } | 1406 | } |
1407 | else | 1407 | else |
1408 | currentDate = todo->dtDue().date(); | 1408 | currentDate = todo->dtDue().date(); |
1409 | 1409 | ||
1410 | if ( todo->doesFloat() || overdue ) { | 1410 | if ( todo->doesFloat() || overdue ) { |
1411 | if ( ! mAllDayMode ) return; | 1411 | if ( ! mAllDayMode ) return; |
1412 | // aldayagenda | 1412 | // aldayagenda |
1413 | globalFlagBlockAgendaItemPaint = 1; | 1413 | globalFlagBlockAgendaItemPaint = 1; |
1414 | item = insertAllDayItem(todo, currentDate,days, days); | 1414 | item = insertAllDayItem(todo, currentDate,days, days); |
1415 | item->show(); | 1415 | item->show(); |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | else { | 1418 | else { |
1419 | if ( mAllDayMode ) return; | 1419 | if ( mAllDayMode ) return; |
1420 | // mAgenda | 1420 | // mAgenda |
1421 | globalFlagBlockAgendaItemPaint = 1; | 1421 | globalFlagBlockAgendaItemPaint = 1; |
1422 | int endY = timeToY(todo->dtDue().time()) - 1; | 1422 | int endY = timeToY(todo->dtDue().time()) - 1; |
1423 | int hi = 12/KOPrefs::instance()->mHourSize; | 1423 | int hi = 12/KOPrefs::instance()->mHourSize; |
1424 | int startY = endY - 1-hi; | 1424 | int startY = endY - 1-hi; |
1425 | item = insertItem(todo,currentDate,days,startY,endY); | 1425 | item = insertItem(todo,currentDate,days,startY,endY); |
1426 | item->show(); | 1426 | item->show(); |
1427 | } | 1427 | } |
1428 | qApp->processEvents(); | 1428 | qApp->processEvents(); |
1429 | globalFlagBlockAgendaItemPaint = 0; | 1429 | globalFlagBlockAgendaItemPaint = 0; |
1430 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1430 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1431 | KOAgendaItem *itemit; | 1431 | KOAgendaItem *itemit; |
1432 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1432 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1433 | itemit=oldconflictItems.next() ) { | 1433 | itemit=oldconflictItems.next() ) { |
1434 | globalFlagBlockAgendaItemUpdate = 0; | 1434 | globalFlagBlockAgendaItemUpdate = 0; |
1435 | itemit->repaintMe(); | 1435 | itemit->repaintMe(); |
1436 | globalFlagBlockAgendaItemUpdate = 1; | 1436 | globalFlagBlockAgendaItemUpdate = 1; |
1437 | itemit->repaint(); | 1437 | itemit->repaint(); |
1438 | } | 1438 | } |
1439 | globalFlagBlockAgendaItemUpdate = 0; | 1439 | globalFlagBlockAgendaItemUpdate = 0; |
1440 | item->repaintMe(); | 1440 | item->repaintMe(); |
1441 | globalFlagBlockAgendaItemUpdate = 1; | 1441 | globalFlagBlockAgendaItemUpdate = 1; |
1442 | item->repaint(); | 1442 | item->repaint(); |
1443 | } | 1443 | } |
1444 | /* | 1444 | /* |
1445 | Insert KOAgendaItem into agenda. | 1445 | Insert KOAgendaItem into agenda. |
1446 | */ | 1446 | */ |
1447 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1447 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1448 | { | 1448 | { |
1449 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | 1449 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; |
1450 | 1450 | ||
1451 | if (mAllDayMode) { | 1451 | if (mAllDayMode) { |
1452 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1452 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; |
1453 | return 0; | 1453 | return 0; |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1456 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1457 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1457 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1458 | 1458 | ||
1459 | int YSize = YBottom - YTop + 1; | 1459 | int YSize = YBottom - YTop + 1; |
1460 | if (YSize < 0) { | 1460 | if (YSize < 0) { |
1461 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | 1461 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; |
1462 | YSize = 1; | 1462 | YSize = 1; |
1463 | } | 1463 | } |
1464 | int iheight = mGridSpacingY * YSize; | 1464 | int iheight = mGridSpacingY * YSize; |
1465 | 1465 | ||
1466 | agendaItem->resize(mGridSpacingX,iheight ); | 1466 | agendaItem->resize(mGridSpacingX,iheight ); |
1467 | agendaItem->setCellXY(X,YTop,YBottom); | 1467 | agendaItem->setCellXY(X,YTop,YBottom); |
1468 | agendaItem->setCellXWidth(X); | 1468 | agendaItem->setCellXWidth(X); |
1469 | 1469 | ||
1470 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1470 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1471 | mItems.append(agendaItem); | 1471 | mItems.append(agendaItem); |
1472 | 1472 | ||
1473 | placeSubCells(agendaItem); | 1473 | placeSubCells(agendaItem); |
1474 | 1474 | ||
1475 | //agendaItem->show(); | 1475 | //agendaItem->show(); |
1476 | 1476 | ||
1477 | marcus_bains(); | 1477 | marcus_bains(); |
1478 | 1478 | ||
1479 | return agendaItem; | 1479 | return agendaItem; |
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | 1482 | ||
1483 | /* | 1483 | /* |
1484 | Insert all-day KOAgendaItem into agenda. | 1484 | Insert all-day KOAgendaItem into agenda. |
1485 | */ | 1485 | */ |
1486 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1486 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1487 | { | 1487 | { |
1488 | if (!mAllDayMode) { | 1488 | if (!mAllDayMode) { |
1489 | return 0; | 1489 | return 0; |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1492 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1493 | 1493 | ||
1494 | agendaItem->setCellXY(XBegin,0,0); | 1494 | agendaItem->setCellXY(XBegin,0,0); |
1495 | agendaItem->setCellXWidth(XEnd); | 1495 | agendaItem->setCellXWidth(XEnd); |
1496 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1496 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1497 | 1497 | ||
1498 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1498 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1499 | mItems.append(agendaItem); | 1499 | mItems.append(agendaItem); |
1500 | 1500 | ||
1501 | placeSubCells(agendaItem); | 1501 | placeSubCells(agendaItem); |
1502 | 1502 | ||
1503 | //agendaItem->show(); | 1503 | //agendaItem->show(); |
1504 | 1504 | ||
1505 | return agendaItem; | 1505 | return agendaItem; |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | 1508 | ||
1509 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1509 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1510 | int YTop,int YBottom) | 1510 | int YTop,int YBottom) |
1511 | { | 1511 | { |
1512 | if (mAllDayMode) { | 1512 | if (mAllDayMode) { |
1513 | ; | 1513 | ; |
1514 | return; | 1514 | return; |
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | int cellX,cellYTop,cellYBottom; | 1517 | int cellX,cellYTop,cellYBottom; |
1518 | QString newtext; | 1518 | QString newtext; |
1519 | int width = XEnd - XBegin + 1; | 1519 | int width = XEnd - XBegin + 1; |
1520 | int count = 0; | 1520 | int count = 0; |
1521 | KOAgendaItem *current = 0; | 1521 | KOAgendaItem *current = 0; |
1522 | QPtrList<KOAgendaItem> multiItems; | 1522 | QPtrList<KOAgendaItem> multiItems; |
1523 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1523 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1524 | if (cellX == XBegin) cellYTop = YTop; | 1524 | if (cellX == XBegin) cellYTop = YTop; |
1525 | else cellYTop = 0; | 1525 | else cellYTop = 0; |
1526 | if (cellX == XEnd) cellYBottom = YBottom; | 1526 | if (cellX == XEnd) cellYBottom = YBottom; |
1527 | else cellYBottom = rows() - 1; | 1527 | else cellYBottom = rows() - 1; |
1528 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1528 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1529 | newtext.append(event->summary()); | 1529 | newtext.append(event->summary()); |
1530 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1530 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1531 | current->setText(newtext); | 1531 | current->setText(newtext); |
1532 | multiItems.append(current); | 1532 | multiItems.append(current); |
1533 | } | 1533 | } |
1534 | 1534 | ||
1535 | KOAgendaItem *next = 0; | 1535 | KOAgendaItem *next = 0; |
1536 | KOAgendaItem *last = multiItems.last(); | 1536 | KOAgendaItem *last = multiItems.last(); |
1537 | KOAgendaItem *first = multiItems.first(); | 1537 | KOAgendaItem *first = multiItems.first(); |
1538 | KOAgendaItem *setFirst,*setLast; | 1538 | KOAgendaItem *setFirst,*setLast; |
1539 | current = first; | 1539 | current = first; |
1540 | while (current) { | 1540 | while (current) { |
1541 | next = multiItems.next(); | 1541 | next = multiItems.next(); |
1542 | if (current == first) setFirst = 0; | 1542 | if (current == first) setFirst = 0; |
1543 | else setFirst = first; | 1543 | else setFirst = first; |
1544 | if (current == last) setLast = 0; | 1544 | if (current == last) setLast = 0; |
1545 | else setLast = last; | 1545 | else setLast = last; |
1546 | 1546 | ||
1547 | current->setMultiItem(setFirst,next,setLast); | 1547 | current->setMultiItem(setFirst,next,setLast); |
1548 | current = next; | 1548 | current = next; |
1549 | } | 1549 | } |
1550 | 1550 | ||
1551 | marcus_bains(); | 1551 | marcus_bains(); |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | 1554 | ||
1555 | //QSizePolicy KOAgenda::sizePolicy() const | 1555 | //QSizePolicy KOAgenda::sizePolicy() const |
1556 | //{ | 1556 | //{ |
1557 | // Thought this would make the all-day event agenda minimum size and the | 1557 | // Thought this would make the all-day event agenda minimum size and the |
1558 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1558 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1559 | // don´t seem to think that an Expanding widget needs more space than a | 1559 | // don´t seem to think that an Expanding widget needs more space than a |
1560 | // Preferred one. | 1560 | // Preferred one. |
1561 | // But it doesn´t hurt, so it stays. | 1561 | // But it doesn´t hurt, so it stays. |
1562 | // if (mAllDayMode) { | 1562 | // if (mAllDayMode) { |
1563 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1563 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1564 | // } else { | 1564 | // } else { |
1565 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1565 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1566 | // } | 1566 | // } |
1567 | //} | 1567 | //} |
1568 | void KOAgenda::finishResize ( ) | 1568 | void KOAgenda::finishResize ( ) |
1569 | { | 1569 | { |
1570 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1570 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1571 | if ( globalFlagBlockAgenda == 0 ) { | 1571 | if ( globalFlagBlockAgenda == 0 ) { |
1572 | finishUpdate(); | 1572 | finishUpdate(); |
1573 | //qDebug("finishUpdate() called "); | 1573 | //qDebug("finishUpdate() called "); |
1574 | } | 1574 | } |
1575 | } | 1575 | } |
1576 | /* | 1576 | /* |
1577 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1577 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1578 | */ | 1578 | */ |
1579 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1579 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1580 | { | 1580 | { |
1581 | 1581 | ||
1582 | mResizeTimer.start( 150 , true ); | 1582 | mResizeTimer.start( 150 , true ); |
1583 | computeSizes(); | 1583 | computeSizes(); |
1584 | return; | 1584 | return; |
1585 | 1585 | ||
1586 | } | 1586 | } |
1587 | void KOAgenda::computeSizes() | 1587 | void KOAgenda::computeSizes() |
1588 | { | 1588 | { |
1589 | if ( globalFlagBlockStartup ) | 1589 | if ( globalFlagBlockStartup ) |
1590 | return; | 1590 | return; |
1591 | 1591 | ||
1592 | if (mAllDayMode) { | 1592 | if (mAllDayMode) { |
1593 | mGridSpacingX = (width()-3) / mColumns; | 1593 | mGridSpacingX = (width()-3) / mColumns; |
1594 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1594 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1595 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1595 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1596 | // mGridSpacingY = height(); | 1596 | // mGridSpacingY = height(); |
1597 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1597 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1598 | 1598 | ||
1599 | KOAgendaItem *item; | 1599 | KOAgendaItem *item; |
1600 | int subCellWidth; | 1600 | int subCellWidth; |
1601 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1601 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1602 | subCellWidth = mGridSpacingY / item->subCells(); | 1602 | subCellWidth = mGridSpacingY / item->subCells(); |
1603 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1603 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1604 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1604 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1605 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1605 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1606 | item->cellX() * mGridSpacingX, | 1606 | item->cellX() * mGridSpacingX, |
1607 | item->subCell() * subCellWidth); | 1607 | item->subCell() * subCellWidth); |
1608 | } | 1608 | } |
1609 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1609 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1610 | } else { | 1610 | } else { |
1611 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; | 1611 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; |
1612 | if (height() > mGridSpacingY * mRows + 1 ) { | 1612 | if (height() > mGridSpacingY * mRows + 1 ) { |
1613 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1613 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1614 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1614 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1615 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1615 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1616 | emit resizedSignal(); | 1616 | emit resizedSignal(); |
1617 | } else | 1617 | } else |
1618 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1618 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1619 | KOAgendaItem *item; | 1619 | KOAgendaItem *item; |
1620 | int subCellWidth; | 1620 | int subCellWidth; |
1621 | 1621 | ||
1622 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1622 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1623 | subCellWidth = mGridSpacingX / item->subCells(); | 1623 | subCellWidth = mGridSpacingX / item->subCells(); |
1624 | item->resize(subCellWidth,item->height()); | 1624 | item->resize(subCellWidth,item->height()); |
1625 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1625 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1626 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1626 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1627 | item->cellX() * mGridSpacingX) + | 1627 | item->cellX() * mGridSpacingX) + |
1628 | item->subCell() * subCellWidth,childY(item)); | 1628 | item->subCell() * subCellWidth,childY(item)); |
1629 | } | 1629 | } |
1630 | } | 1630 | } |
1631 | int cw = contentsWidth(); | 1631 | int cw = contentsWidth(); |
1632 | int ch = contentsHeight(); | 1632 | int ch = contentsHeight(); |
1633 | if ( mAllDayMode ) { | 1633 | if ( mAllDayMode ) { |
1634 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1634 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1635 | if ( paintPixAll->width() < cw || paintPixAll->height() < ch ) | 1635 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
1636 | paintPixAll->resize( cw, ch ); | 1636 | paintPixAll->resize( cw, ch ); |
1637 | } else { | 1637 | } else { |
1638 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1638 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1639 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1639 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
1640 | KOAgendaItem::resizePixmap( cw , ch ); | 1640 | KOAgendaItem::resizePixmap( cw , ch ); |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | checkScrollBoundaries(); | 1643 | checkScrollBoundaries(); |
1644 | marcus_bains(); | 1644 | marcus_bains(); |
1645 | drawContentsToPainter(); | 1645 | drawContentsToPainter(); |
1646 | viewport()->repaint(false); | 1646 | viewport()->repaint(false); |
1647 | } | 1647 | } |
1648 | 1648 | ||
1649 | void KOAgenda::scrollUp() | 1649 | void KOAgenda::scrollUp() |
1650 | { | 1650 | { |
1651 | scrollBy(0,-mScrollOffset); | 1651 | scrollBy(0,-mScrollOffset); |
1652 | } | 1652 | } |
1653 | 1653 | ||
1654 | 1654 | ||
1655 | void KOAgenda::scrollDown() | 1655 | void KOAgenda::scrollDown() |
1656 | { | 1656 | { |
1657 | scrollBy(0,mScrollOffset); | 1657 | scrollBy(0,mScrollOffset); |
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | void KOAgenda::popupAlarm() | 1660 | void KOAgenda::popupAlarm() |
1661 | { | 1661 | { |
1662 | if (!mClickedItem) { | 1662 | if (!mClickedItem) { |
1663 | kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; | 1663 | kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; |
1664 | return; | 1664 | return; |
1665 | } | 1665 | } |
1666 | // TODO: deal correctly with multiple alarms | 1666 | // TODO: deal correctly with multiple alarms |
1667 | Alarm* alarm; | 1667 | Alarm* alarm; |
1668 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1668 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1669 | for(alarm=list.first();alarm;alarm=list.next()) { | 1669 | for(alarm=list.first();alarm;alarm=list.next()) { |
1670 | alarm->toggleAlarm(); | 1670 | alarm->toggleAlarm(); |
1671 | } | 1671 | } |
1672 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1672 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1673 | mClickedItem->paintMe( true ); | 1673 | mClickedItem->paintMe( true ); |
1674 | mClickedItem->repaint( false ); | 1674 | mClickedItem->repaint( false ); |
1675 | } | 1675 | } |
1676 | 1676 | ||
1677 | /* | 1677 | /* |
1678 | Calculates the minimum width | 1678 | Calculates the minimum width |
1679 | */ | 1679 | */ |
1680 | int KOAgenda::minimumWidth() const | 1680 | int KOAgenda::minimumWidth() const |
1681 | { | 1681 | { |
1682 | // TODO:: develop a way to dynamically determine the minimum width | 1682 | // TODO:: develop a way to dynamically determine the minimum width |
1683 | int min = 100; | 1683 | int min = 100; |
1684 | 1684 | ||
1685 | return min; | 1685 | return min; |
1686 | } | 1686 | } |
1687 | 1687 | ||
1688 | void KOAgenda::updateConfig() | 1688 | void KOAgenda::updateConfig() |
1689 | { | 1689 | { |
1690 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1690 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1691 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1691 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1692 | if ( mAllDayMode ) { | 1692 | if ( mAllDayMode ) { |
1693 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1693 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1694 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1694 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1695 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1695 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1696 | // setMaximumHeight( mGridSpacingY+1 ); | 1696 | // setMaximumHeight( mGridSpacingY+1 ); |
1697 | viewport()->repaint( false ); | 1697 | viewport()->repaint( false ); |
1698 | //setFixedHeight( mGridSpacingY+1 ); | 1698 | //setFixedHeight( mGridSpacingY+1 ); |
1699 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1699 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1700 | } | 1700 | } |
1701 | else { | 1701 | else { |
1702 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1702 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1703 | calculateWorkingHours(); | 1703 | calculateWorkingHours(); |
1704 | marcus_bains(); | 1704 | marcus_bains(); |
1705 | } | 1705 | } |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | void KOAgenda::checkScrollBoundaries() | 1708 | void KOAgenda::checkScrollBoundaries() |
1709 | { | 1709 | { |
1710 | // Invalidate old values to force update | 1710 | // Invalidate old values to force update |
1711 | mOldLowerScrollValue = -1; | 1711 | mOldLowerScrollValue = -1; |
1712 | mOldUpperScrollValue = -1; | 1712 | mOldUpperScrollValue = -1; |
1713 | 1713 | ||
1714 | checkScrollBoundaries(verticalScrollBar()->value()); | 1714 | checkScrollBoundaries(verticalScrollBar()->value()); |
1715 | } | 1715 | } |
1716 | 1716 | ||
1717 | void KOAgenda::checkScrollBoundaries(int v) | 1717 | void KOAgenda::checkScrollBoundaries(int v) |
1718 | { | 1718 | { |
1719 | if ( mGridSpacingY == 0 ) | 1719 | if ( mGridSpacingY == 0 ) |
1720 | return; | 1720 | return; |
1721 | int yMin = v/mGridSpacingY; | 1721 | int yMin = v/mGridSpacingY; |
1722 | int yMax = (v+visibleHeight())/mGridSpacingY; | 1722 | int yMax = (v+visibleHeight())/mGridSpacingY; |
1723 | 1723 | ||
1724 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 1724 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
1725 | 1725 | ||
1726 | if (yMin != mOldLowerScrollValue) { | 1726 | if (yMin != mOldLowerScrollValue) { |
1727 | mOldLowerScrollValue = yMin; | 1727 | mOldLowerScrollValue = yMin; |
1728 | emit lowerYChanged(yMin); | 1728 | emit lowerYChanged(yMin); |
1729 | } | 1729 | } |
1730 | if (yMax != mOldUpperScrollValue) { | 1730 | if (yMax != mOldUpperScrollValue) { |
1731 | mOldUpperScrollValue = yMax; | 1731 | mOldUpperScrollValue = yMax; |
1732 | emit upperYChanged(yMax); | 1732 | emit upperYChanged(yMax); |
1733 | } | 1733 | } |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | void KOAgenda::deselectItem() | 1736 | void KOAgenda::deselectItem() |
1737 | { | 1737 | { |
1738 | if (mSelectedItem.isNull()) return; | 1738 | if (mSelectedItem.isNull()) return; |
1739 | mSelectedItem->select(false); | 1739 | mSelectedItem->select(false); |
1740 | mSelectedItem = 0; | 1740 | mSelectedItem = 0; |
1741 | } | 1741 | } |
1742 | 1742 | ||
1743 | void KOAgenda::selectItem(KOAgendaItem *item) | 1743 | void KOAgenda::selectItem(KOAgendaItem *item) |
1744 | { | 1744 | { |
1745 | if ((KOAgendaItem *)mSelectedItem == item) return; | 1745 | if ((KOAgendaItem *)mSelectedItem == item) return; |
1746 | deselectItem(); | 1746 | deselectItem(); |
1747 | if (item == 0) { | 1747 | if (item == 0) { |
1748 | emit incidenceSelected( 0 ); | 1748 | emit incidenceSelected( 0 ); |
1749 | return; | 1749 | return; |
1750 | } | 1750 | } |
1751 | mSelectedItem = item; | 1751 | mSelectedItem = item; |
1752 | mSelectedItem->select(); | 1752 | mSelectedItem->select(); |
1753 | emit incidenceSelected( mSelectedItem->incidence() ); | 1753 | emit incidenceSelected( mSelectedItem->incidence() ); |
1754 | } | 1754 | } |
1755 | 1755 | ||
1756 | // This function seems never be called. | 1756 | // This function seems never be called. |
1757 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 1757 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
1758 | { | 1758 | { |
1759 | switch(kev->key()) { | 1759 | switch(kev->key()) { |
1760 | case Key_PageDown: | 1760 | case Key_PageDown: |
1761 | verticalScrollBar()->addPage(); | 1761 | verticalScrollBar()->addPage(); |
1762 | break; | 1762 | break; |
1763 | case Key_PageUp: | 1763 | case Key_PageUp: |
1764 | verticalScrollBar()->subtractPage(); | 1764 | verticalScrollBar()->subtractPage(); |
1765 | break; | 1765 | break; |
1766 | case Key_Down: | 1766 | case Key_Down: |
1767 | verticalScrollBar()->addLine(); | 1767 | verticalScrollBar()->addLine(); |
1768 | break; | 1768 | break; |
1769 | case Key_Up: | 1769 | case Key_Up: |
1770 | verticalScrollBar()->subtractLine(); | 1770 | verticalScrollBar()->subtractLine(); |
1771 | break; | 1771 | break; |
1772 | default: | 1772 | default: |
1773 | ; | 1773 | ; |
1774 | } | 1774 | } |
1775 | } | 1775 | } |
1776 | 1776 | ||
1777 | void KOAgenda::calculateWorkingHours() | 1777 | void KOAgenda::calculateWorkingHours() |
1778 | { | 1778 | { |
1779 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 1779 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
1780 | mWorkingHoursEnable = !mAllDayMode; | 1780 | mWorkingHoursEnable = !mAllDayMode; |
1781 | 1781 | ||
1782 | mWorkingHoursYTop = mGridSpacingY * | 1782 | mWorkingHoursYTop = mGridSpacingY * |
1783 | KOPrefs::instance()->mWorkingHoursStart * 4; | 1783 | KOPrefs::instance()->mWorkingHoursStart * 4; |
1784 | mWorkingHoursYBottom = mGridSpacingY * | 1784 | mWorkingHoursYBottom = mGridSpacingY * |
1785 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 1785 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
1786 | } | 1786 | } |
1787 | 1787 | ||
1788 | 1788 | ||
1789 | DateList KOAgenda::dateList() const | 1789 | DateList KOAgenda::dateList() const |
1790 | { | 1790 | { |
1791 | return mSelectedDates; | 1791 | return mSelectedDates; |
1792 | } | 1792 | } |
1793 | 1793 | ||
1794 | void KOAgenda::setDateList(const DateList &selectedDates) | 1794 | void KOAgenda::setDateList(const DateList &selectedDates) |
1795 | { | 1795 | { |
1796 | mSelectedDates = selectedDates; | 1796 | mSelectedDates = selectedDates; |
1797 | marcus_bains(); | 1797 | marcus_bains(); |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 1800 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
1801 | { | 1801 | { |
1802 | mHolidayMask = mask; | 1802 | mHolidayMask = mask; |
1803 | 1803 | ||
1804 | /* | 1804 | /* |
1805 | kdDebug() << "HolidayMask: "; | 1805 | kdDebug() << "HolidayMask: "; |
1806 | for(uint i=0;i<mask->count();++i) { | 1806 | for(uint i=0;i<mask->count();++i) { |
1807 | kdDebug() << (mask->at(i) ? "*" : "o"); | 1807 | kdDebug() << (mask->at(i) ? "*" : "o"); |
1808 | } | 1808 | } |
1809 | kdDebug() << endl; | 1809 | kdDebug() << endl; |
1810 | */ | 1810 | */ |
1811 | } | 1811 | } |
1812 | 1812 | ||
1813 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 1813 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
1814 | { | 1814 | { |
1815 | 1815 | ||
1816 | QScrollView::contentsMousePressEvent(event); | 1816 | QScrollView::contentsMousePressEvent(event); |
1817 | } | 1817 | } |
1818 | 1818 | ||
1819 | void KOAgenda::storePosition() | 1819 | void KOAgenda::storePosition() |
1820 | { | 1820 | { |
1821 | //mContentPosition | 1821 | //mContentPosition |
1822 | int max = mGridSpacingY*4*24; | 1822 | int max = mGridSpacingY*4*24; |
1823 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 1823 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
1824 | mContentPosition = 0; | 1824 | mContentPosition = 0; |
1825 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 1825 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
1826 | mContentPosition = -1.0; | 1826 | mContentPosition = -1.0; |
1827 | else | 1827 | else |
1828 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 1828 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
1829 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 1829 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
1830 | 1830 | ||
1831 | } | 1831 | } |
1832 | void KOAgenda::restorePosition() | 1832 | void KOAgenda::restorePosition() |
1833 | { | 1833 | { |
1834 | int posY; | 1834 | int posY; |
1835 | int max = mGridSpacingY*4*24; | 1835 | int max = mGridSpacingY*4*24; |
1836 | if ( mContentPosition < 0 ) | 1836 | if ( mContentPosition < 0 ) |
1837 | posY = max-viewport()->height(); | 1837 | posY = max-viewport()->height(); |
1838 | else | 1838 | else |
1839 | if ( mContentPosition == 0 ) | 1839 | if ( mContentPosition == 0 ) |
1840 | posY = 0; | 1840 | posY = 0; |
1841 | else | 1841 | else |
1842 | posY = (max/mContentPosition)-(viewport()->height()/2); | 1842 | posY = (max/mContentPosition)-(viewport()->height()/2); |
1843 | setContentsPos (0, posY ); | 1843 | setContentsPos (0, posY ); |
1844 | //qDebug("posY %d hei %d", posY, max); | 1844 | //qDebug("posY %d hei %d", posY, max); |
1845 | 1845 | ||
1846 | } | 1846 | } |
1847 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 1847 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
1848 | { | 1848 | { |
1849 | ++x; | 1849 | ++x; |
1850 | QScrollView::moveChild( w, x , y ); | 1850 | QScrollView::moveChild( w, x , y ); |
1851 | } | 1851 | } |
1852 | #include <qmessagebox.h> | 1852 | #include <qmessagebox.h> |
1853 | #ifdef DESKTOP_VERSION | 1853 | #ifdef DESKTOP_VERSION |
1854 | #include <qprinter.h> | 1854 | #include <qprinter.h> |
1855 | #include <qpainter.h> | 1855 | #include <qpainter.h> |
1856 | #include <qpaintdevicemetrics.h> | 1856 | #include <qpaintdevicemetrics.h> |
1857 | 1857 | ||
1858 | #endif | 1858 | #endif |
1859 | void KOAgenda::printSelection() | 1859 | void KOAgenda::printSelection() |
1860 | { | 1860 | { |
1861 | #ifdef DESKTOP_VERSION | 1861 | #ifdef DESKTOP_VERSION |
1862 | if ( mStartCellY == mCurrentCellY ) { | 1862 | if ( mStartCellY == mCurrentCellY ) { |
1863 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1863 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1864 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 1864 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
1865 | i18n("OK"), 0, 0, | 1865 | i18n("OK"), 0, 0, |
1866 | 0, 1 ); | 1866 | 0, 1 ); |
1867 | return; | 1867 | return; |
1868 | } | 1868 | } |
1869 | 1869 | ||
1870 | float dx, dy; | 1870 | float dx, dy; |
1871 | int x,y,w,h; | 1871 | int x,y,w,h; |
1872 | x= 0; | 1872 | x= 0; |
1873 | w= contentsWidth()+2; | 1873 | w= contentsWidth()+2; |
1874 | // h= contentsHeight(); | 1874 | // h= contentsHeight(); |
1875 | y = mGridSpacingY*mStartCellY; | 1875 | y = mGridSpacingY*mStartCellY; |
1876 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 1876 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
1877 | 1877 | ||
1878 | //return; | 1878 | //return; |
1879 | QPrinter* printer = new QPrinter(); | 1879 | QPrinter* printer = new QPrinter(); |
1880 | if ( !printer->setup()) { | 1880 | if ( !printer->setup()) { |
1881 | delete printer; | 1881 | delete printer; |
1882 | return; | 1882 | return; |
1883 | } | 1883 | } |
1884 | QPainter p( printer ); | 1884 | QPainter p( printer ); |
1885 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 1885 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
1886 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 1886 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
1887 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 1887 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
1888 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 1888 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
1889 | // p.drawText( 0, 0, date ); | 1889 | // p.drawText( 0, 0, date ); |
1890 | int offset = m.width()/8; | 1890 | int offset = m.width()/8; |
1891 | // compute the scale | 1891 | // compute the scale |
1892 | dx = ((float) m.width()-offset) / (float)w; | 1892 | dx = ((float) m.width()-offset) / (float)w; |
1893 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 1893 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
1894 | float scale; | 1894 | float scale; |
1895 | // scale to fit the width or height of the paper | 1895 | // scale to fit the width or height of the paper |
1896 | if ( dx < dy ) | 1896 | if ( dx < dy ) |
1897 | scale = dx; | 1897 | scale = dx; |
1898 | else | 1898 | else |
1899 | scale = dy; | 1899 | scale = dy; |
1900 | // set the scale | 1900 | // set the scale |
1901 | p.drawText( offset* scale, offset* scale*3/4, date ); | 1901 | p.drawText( offset* scale, offset* scale*3/4, date ); |
1902 | 1902 | ||
1903 | int selDay; | 1903 | int selDay; |
1904 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 1904 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
1905 | float startX = 1; | 1905 | float startX = 1; |
1906 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1906 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1907 | { | 1907 | { |
1908 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 1908 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
1909 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 1909 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
1910 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 1910 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
1911 | startX += widOffset; | 1911 | startX += widOffset; |
1912 | 1912 | ||
1913 | } | 1913 | } |
1914 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 1914 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
1915 | p.scale( scale, scale ); | 1915 | p.scale( scale, scale ); |
1916 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 1916 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
1917 | // now printing with y offset: 2 hei | 1917 | // now printing with y offset: 2 hei |
1918 | // p.translate( 0, -y*scale); | 1918 | // p.translate( 0, -y*scale); |
1919 | 1919 | ||
1920 | drawContentsToPainter(&p, true ); | 1920 | drawContentsToPainter(&p, true ); |
1921 | globalFlagBlockAgendaItemUpdate = false; | 1921 | globalFlagBlockAgendaItemUpdate = false; |
1922 | KOAgendaItem *item; | 1922 | KOAgendaItem *item; |
1923 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1923 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1924 | item->select(false); | 1924 | item->select(false); |
1925 | item->paintMe( false, &p ); | 1925 | item->paintMe( false, &p ); |
1926 | } | 1926 | } |
1927 | globalFlagBlockAgendaItemUpdate = true; | 1927 | globalFlagBlockAgendaItemUpdate = true; |
1928 | p.end(); | 1928 | p.end(); |
1929 | delete printer; | 1929 | delete printer; |
1930 | #else | 1930 | #else |
1931 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1931 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1932 | i18n("Not supported \non PDA!\n"), | 1932 | i18n("Not supported \non PDA!\n"), |
1933 | i18n("OK"), 0, 0, | 1933 | i18n("OK"), 0, 0, |
1934 | 0, 1 ); | 1934 | 0, 1 ); |
1935 | #endif | 1935 | #endif |
1936 | } | 1936 | } |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 6965ba7..62281d4 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,722 +1,722 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #define AGENDA_ICON_SIZE 7 | 38 | #define AGENDA_ICON_SIZE 7 |
39 | #endif | 39 | #endif |
40 | #include <libkcal/icaldrag.h> | 40 | #include <libkcal/icaldrag.h> |
41 | #include <libkcal/vcaldrag.h> | 41 | #include <libkcal/vcaldrag.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern int globalFlagBlockAgendaItemUpdate; |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 59 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
60 | const char *name,WFlags) : | 60 | const char *name,WFlags) : |
61 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 61 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
62 | { | 62 | { |
63 | #ifndef DESKTOP_VERSION | 63 | #ifndef DESKTOP_VERSION |
64 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 64 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
65 | #endif | 65 | #endif |
66 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 66 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
67 | setWFlags ( wflags); | 67 | setWFlags ( wflags); |
68 | mAllDay = allday; | 68 | mAllDay = allday; |
69 | init ( incidence, qd ); | 69 | init ( incidence, qd ); |
70 | setMouseTracking(true); | 70 | setMouseTracking(true); |
71 | //setAcceptDrops(true); | 71 | //setAcceptDrops(true); |
72 | xPaintCoord = -1; | 72 | xPaintCoord = -1; |
73 | yPaintCoord = -1; | 73 | yPaintCoord = -1; |
74 | } | 74 | } |
75 | 75 | ||
76 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 76 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
77 | { | 77 | { |
78 | mIncidence = incidence; | 78 | mIncidence = incidence; |
79 | mDate = qd; | 79 | mDate = qd; |
80 | mFirstMultiItem = 0; | 80 | mFirstMultiItem = 0; |
81 | mNextMultiItem = 0; | 81 | mNextMultiItem = 0; |
82 | mLastMultiItem = 0; | 82 | mLastMultiItem = 0; |
83 | computeText(); | 83 | computeText(); |
84 | 84 | ||
85 | if ( (incidence->type() == "Todo") && | 85 | if ( (incidence->type() == "Todo") && |
86 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 86 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
87 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 87 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
88 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 88 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
89 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 89 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
90 | else | 90 | else |
91 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 91 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
92 | } | 92 | } |
93 | else { | 93 | else { |
94 | QStringList categories = mIncidence->categories(); | 94 | QStringList categories = mIncidence->categories(); |
95 | QString cat = categories.first(); | 95 | QString cat = categories.first(); |
96 | if (cat.isEmpty()) { | 96 | if (cat.isEmpty()) { |
97 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 97 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
98 | } else { | 98 | } else { |
99 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 99 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 102 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
103 | mBackgroundColor.dark(),mBackgroundColor.light(), | 103 | mBackgroundColor.dark(),mBackgroundColor.light(), |
104 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 104 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
105 | setBackgroundColor( mBackgroundColor ); | 105 | setBackgroundColor( mBackgroundColor ); |
106 | 106 | ||
107 | setCellXY(0,0,1); | 107 | setCellXY(0,0,1); |
108 | setCellXWidth(0); | 108 | setCellXWidth(0); |
109 | setSubCell(0); | 109 | setSubCell(0); |
110 | setSubCells(1); | 110 | setSubCells(1); |
111 | setMultiItem(0,0,0); | 111 | setMultiItem(0,0,0); |
112 | startMove(); | 112 | startMove(); |
113 | mSelected = true; | 113 | mSelected = true; |
114 | select(false); | 114 | select(false); |
115 | QString tipText = mIncidence->summary(); | 115 | QString tipText = mIncidence->summary(); |
116 | // QToolTip::add(this,tipText); | 116 | // QToolTip::add(this,tipText); |
117 | QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 117 | QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
118 | if ( !mIncidence->doesFloat() ) | 118 | if ( !mIncidence->doesFloat() ) |
119 | if ( mIncidence->type() == "Event" ) { | 119 | if ( mIncidence->type() == "Event" ) { |
120 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 120 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
121 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 121 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
122 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 122 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
123 | } | 123 | } |
124 | else { | 124 | else { |
125 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 125 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
126 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 126 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | else if ( mIncidence->type() == "Todo" ) { | 129 | else if ( mIncidence->type() == "Todo" ) { |
130 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr(); | 130 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr(); |
131 | } | 131 | } |
132 | 132 | ||
133 | if (!mIncidence->location().isEmpty()) { | 133 | if (!mIncidence->location().isEmpty()) { |
134 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 134 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
135 | } | 135 | } |
136 | QToolTip::add(this,tipText,toolTipGroup(),""); | 136 | QToolTip::add(this,tipText,toolTipGroup(),""); |
137 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 137 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
138 | mFontPixelSize = fontinf.height();; | 138 | mFontPixelSize = fontinf.height();; |
139 | hide(); | 139 | hide(); |
140 | xPaintCoord = -1; | 140 | xPaintCoord = -1; |
141 | yPaintCoord = -1; | 141 | yPaintCoord = -1; |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | KOAgendaItem::~KOAgendaItem() | 145 | KOAgendaItem::~KOAgendaItem() |
146 | { | 146 | { |
147 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 147 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
148 | 148 | ||
149 | } | 149 | } |
150 | 150 | ||
151 | void KOAgendaItem::recreateIncidence() | 151 | void KOAgendaItem::recreateIncidence() |
152 | { | 152 | { |
153 | #if 0 | 153 | #if 0 |
154 | Incidence* newInc = mIncidence->clone(); | 154 | Incidence* newInc = mIncidence->clone(); |
155 | newInc->recreate(); | 155 | newInc->recreate(); |
156 | if ( mIncidence->doesRecur() ) { | 156 | if ( mIncidence->doesRecur() ) { |
157 | mIncidence->addExDate( mDate ); | 157 | mIncidence->addExDate( mDate ); |
158 | newInc->recurrence()->unsetRecurs(); | 158 | newInc->recurrence()->unsetRecurs(); |
159 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 159 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
160 | QTime tim = mIncidence->dtStart().time(); | 160 | QTime tim = mIncidence->dtStart().time(); |
161 | newInc->setDtStart( QDateTime(mDate, tim) ); | 161 | newInc->setDtStart( QDateTime(mDate, tim) ); |
162 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 162 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
163 | } | 163 | } |
164 | #endif | 164 | #endif |
165 | mIncidence = mIncidence->recreateCloneException( mDate ); | 165 | mIncidence = mIncidence->recreateCloneException( mDate ); |
166 | } | 166 | } |
167 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 167 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
168 | { | 168 | { |
169 | int size = AGENDA_ICON_SIZE; | 169 | int size = AGENDA_ICON_SIZE; |
170 | 170 | ||
171 | int yOff = 0; | 171 | int yOff = 0; |
172 | int xOff = 0; | 172 | int xOff = 0; |
173 | int x = pos().x() +3; | 173 | int x = pos().x() +3; |
174 | int y; | 174 | int y; |
175 | if ( mAllDay ) | 175 | if ( mAllDay ) |
176 | y = pos().y()+3; | 176 | y = pos().y()+3; |
177 | else | 177 | else |
178 | y = mCellYTop * ( height() / cellHeight() ) +3; | 178 | y = mCellYTop * ( height() / cellHeight() ) +3; |
179 | if (mIncidence->cancelled()) { | 179 | if (mIncidence->cancelled()) { |
180 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 180 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
181 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 181 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
182 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 182 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
183 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 183 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
184 | if ( horLayout ) | 184 | if ( horLayout ) |
185 | ++xOff; | 185 | ++xOff; |
186 | else | 186 | else |
187 | ++yOff; | 187 | ++yOff; |
188 | } | 188 | } |
189 | if (mIncidence->isAlarmEnabled()) { | 189 | if (mIncidence->isAlarmEnabled()) { |
190 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 190 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
191 | if ( horLayout ) | 191 | if ( horLayout ) |
192 | ++xOff; | 192 | ++xOff; |
193 | else | 193 | else |
194 | ++yOff; | 194 | ++yOff; |
195 | } | 195 | } |
196 | if (mIncidence->recurrence()->doesRecur()) { | 196 | if (mIncidence->recurrence()->doesRecur()) { |
197 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 197 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
198 | if ( horLayout ) | 198 | if ( horLayout ) |
199 | ++xOff; | 199 | ++xOff; |
200 | else | 200 | else |
201 | ++yOff; | 201 | ++yOff; |
202 | } | 202 | } |
203 | if (mIncidence->description().length() > 0) { | 203 | if (mIncidence->description().length() > 0) { |
204 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 204 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
205 | if ( horLayout ) | 205 | if ( horLayout ) |
206 | ++xOff; | 206 | ++xOff; |
207 | else | 207 | else |
208 | ++yOff; | 208 | ++yOff; |
209 | } | 209 | } |
210 | if (mIncidence->isReadOnly()) { | 210 | if (mIncidence->isReadOnly()) { |
211 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 211 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
212 | if ( horLayout ) | 212 | if ( horLayout ) |
213 | ++xOff; | 213 | ++xOff; |
214 | else | 214 | else |
215 | ++yOff; | 215 | ++yOff; |
216 | } | 216 | } |
217 | 217 | ||
218 | if (mIncidence->attendeeCount()>0) { | 218 | if (mIncidence->attendeeCount()>0) { |
219 | 219 | ||
220 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 220 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
222 | if ( horLayout ) | 222 | if ( horLayout ) |
223 | ++xOff; | 223 | ++xOff; |
224 | else | 224 | else |
225 | ++yOff; | 225 | ++yOff; |
226 | } else { | 226 | } else { |
227 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 227 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
228 | if (me!=0) { | 228 | if (me!=0) { |
229 | 229 | ||
230 | 230 | ||
231 | } else { | 231 | } else { |
232 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 232 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
233 | if ( horLayout ) | 233 | if ( horLayout ) |
234 | ++xOff; | 234 | ++xOff; |
235 | else | 235 | else |
236 | ++yOff; | 236 | ++yOff; |
237 | 237 | ||
238 | } | 238 | } |
239 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 239 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
240 | if ( horLayout ) | 240 | if ( horLayout ) |
241 | ++xOff; | 241 | ++xOff; |
242 | else | 242 | else |
243 | ++yOff; | 243 | ++yOff; |
244 | 244 | ||
245 | } | 245 | } |
246 | 246 | ||
247 | } | 247 | } |
248 | return ( yOff || xOff ); | 248 | return ( yOff || xOff ); |
249 | } | 249 | } |
250 | 250 | ||
251 | 251 | ||
252 | void KOAgendaItem::select(bool selected) | 252 | void KOAgendaItem::select(bool selected) |
253 | { | 253 | { |
254 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 254 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
255 | if (mSelected == selected) return; | 255 | if (mSelected == selected) return; |
256 | mSelected = selected; | 256 | mSelected = selected; |
257 | if ( ! isVisible() ) | 257 | if ( ! isVisible() ) |
258 | return; | 258 | return; |
259 | if ( firstMultiItem() ) | 259 | if ( firstMultiItem() ) |
260 | firstMultiItem()->select( selected ); | 260 | firstMultiItem()->select( selected ); |
261 | if ( !firstMultiItem() && nextMultiItem() ) { | 261 | if ( !firstMultiItem() && nextMultiItem() ) { |
262 | KOAgendaItem * placeItem = nextMultiItem(); | 262 | KOAgendaItem * placeItem = nextMultiItem(); |
263 | while ( placeItem ) { | 263 | while ( placeItem ) { |
264 | placeItem->select( selected ); | 264 | placeItem->select( selected ); |
265 | placeItem = placeItem->nextMultiItem(); | 265 | placeItem = placeItem->nextMultiItem(); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | globalFlagBlockAgendaItemUpdate = 0; | 268 | globalFlagBlockAgendaItemUpdate = 0; |
269 | paintMe( selected ); | 269 | paintMe( selected ); |
270 | globalFlagBlockAgendaItemUpdate = 1; | 270 | globalFlagBlockAgendaItemUpdate = 1; |
271 | repaint( false ); | 271 | repaint( false ); |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | /* | 275 | /* |
276 | The eventFilter has to filter the mouse events of the agenda item childs. The | 276 | The eventFilter has to filter the mouse events of the agenda item childs. The |
277 | events are fed into the event handling method of KOAgendaItem. This allows the | 277 | events are fed into the event handling method of KOAgendaItem. This allows the |
278 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 278 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
279 | */ | 279 | */ |
280 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 280 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
281 | { | 281 | { |
282 | if (e->type() == QEvent::MouseButtonPress || | 282 | if (e->type() == QEvent::MouseButtonPress || |
283 | e->type() == QEvent::MouseButtonDblClick || | 283 | e->type() == QEvent::MouseButtonDblClick || |
284 | e->type() == QEvent::MouseButtonRelease || | 284 | e->type() == QEvent::MouseButtonRelease || |
285 | e->type() == QEvent::MouseMove) { | 285 | e->type() == QEvent::MouseMove) { |
286 | QMouseEvent *me = (QMouseEvent *)e; | 286 | QMouseEvent *me = (QMouseEvent *)e; |
287 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 287 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
288 | mapToGlobal(me->pos())); | 288 | mapToGlobal(me->pos())); |
289 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 289 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
290 | return event(&returnEvent); | 290 | return event(&returnEvent); |
291 | } else { | 291 | } else { |
292 | return false; | 292 | return false; |
293 | } | 293 | } |
294 | } | 294 | } |
295 | void KOAgendaItem::repaintMe( ) | 295 | void KOAgendaItem::repaintMe( ) |
296 | { | 296 | { |
297 | paintMe ( mSelected ); | 297 | paintMe ( mSelected ); |
298 | } | 298 | } |
299 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 299 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
300 | { | 300 | { |
301 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 301 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
302 | return; | 302 | return; |
303 | QPainter pa; | 303 | QPainter pa; |
304 | 304 | ||
305 | if ( mSelected ) { | 305 | if ( mSelected ) { |
306 | pa.begin( paintPixSel() ); | 306 | pa.begin( paintPixSel() ); |
307 | } else { | 307 | } else { |
308 | if ( mAllDay ) | 308 | if ( mAllDay ) |
309 | pa.begin( paintPixAllday() ); | 309 | pa.begin( paintPixAllday() ); |
310 | else | 310 | else |
311 | pa.begin( paintPix() ); | 311 | pa.begin( paintPix() ); |
312 | } | 312 | } |
313 | int x, yy, w, h; | 313 | int x, yy, w, h; |
314 | float nfh; | 314 | float nfh; |
315 | x = pos().x(); w = width(); h = height (); | 315 | x = pos().x(); w = width(); h = height (); |
316 | if ( mAllDay ) | 316 | if ( mAllDay ) |
317 | yy = y(); | 317 | yy = y(); |
318 | else | 318 | else |
319 | yy = mCellYTop * ( height() / cellHeight() ); | 319 | yy = mCellYTop * ( height() / cellHeight() ); |
320 | xPaintCoord= x; | 320 | xPaintCoord= x; |
321 | yPaintCoord = yy; | 321 | yPaintCoord = yy; |
322 | wPaintCoord = width(); | 322 | wPaintCoord = width(); |
323 | hPaintCoord = height(); | 323 | hPaintCoord = height(); |
324 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 324 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
325 | if ( paint == 0 ) | 325 | if ( paint == 0 ) |
326 | paint = &pa; | 326 | paint = &pa; |
327 | bool horLayout = ( w < h ); | 327 | bool horLayout = ( w < h ); |
328 | int maxhei = mFontPixelSize+4; | 328 | int maxhei = mFontPixelSize+4; |
329 | if ( horLayout ) | 329 | if ( horLayout ) |
330 | maxhei += AGENDA_ICON_SIZE -4; | 330 | maxhei += AGENDA_ICON_SIZE -4; |
331 | bool small = ( h < maxhei ); | 331 | bool small = ( h < maxhei ); |
332 | if ( ! small ) | 332 | if ( ! small ) |
333 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 333 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
334 | else { | 334 | else { |
335 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 335 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
336 | f.setBold( false ); | 336 | f.setBold( false ); |
337 | int fh = f.pointSize(); | 337 | int fh = f.pointSize(); |
338 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 338 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
339 | if ( nfh < 6 ) | 339 | if ( nfh < 6 ) |
340 | nfh = 6; | 340 | nfh = 6; |
341 | f.setPointSize( nfh ); | 341 | f.setPointSize( nfh ); |
342 | paint->setFont(f); | 342 | paint->setFont(f); |
343 | } | 343 | } |
344 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 344 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
345 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 345 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
346 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 346 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
347 | if ( mIncidence->type() == "Todo" ) { | 347 | if ( mIncidence->type() == "Todo" ) { |
348 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 348 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
349 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 349 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
350 | int yyy = yy+3; | 350 | int yyy = yy+3; |
351 | if ( tempTodo->isCompleted() ) | 351 | if ( tempTodo->isCompleted() ) |
352 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 352 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
353 | else { | 353 | else { |
354 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 354 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
355 | 355 | ||
356 | } | 356 | } |
357 | } | 357 | } |
358 | bool addIcon = false; | 358 | bool addIcon = false; |
359 | if ( ! small || w > 3 * h || h > 3* w ) | 359 | if ( ! small || w > 3 * h || h > 3* w ) |
360 | addIcon = updateIcons( paint, horLayout ); | 360 | addIcon = updateIcons( paint, horLayout ); |
361 | 361 | ||
362 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 362 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
363 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 363 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
364 | if ( ! small ) { | 364 | if ( ! small ) { |
365 | x += 3; yy += 3;w -= 6; h-= 5; | 365 | x += 3; yy += 3;w -= 6; h-= 5; |
366 | } else { | 366 | } else { |
367 | x += 2; yy += 1;w -= 4; h-= 4; | 367 | x += 2; yy += 1;w -= 4; h-= 4; |
368 | if ( nfh < 6.01 ) { | 368 | if ( nfh < 6.01 ) { |
369 | yy -= 2; | 369 | yy -= 2; |
370 | h += 4; | 370 | h += 4; |
371 | } | 371 | } |
372 | else | 372 | else |
373 | if ( nfh < h -2 ) | 373 | if ( nfh < h -2 ) |
374 | ++yy; | 374 | ++yy; |
375 | } | 375 | } |
376 | int align; | 376 | int align; |
377 | #ifndef DESKTOP_VERSION | 377 | #ifndef DESKTOP_VERSION |
378 | align = ( AlignLeft|WordBreak|AlignTop); | 378 | align = ( AlignLeft|WordBreak|AlignTop); |
379 | #else | 379 | #else |
380 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 380 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
381 | #endif | 381 | #endif |
382 | if ( addIcon ) { | 382 | if ( addIcon ) { |
383 | if ( ! horLayout ) { | 383 | if ( ! horLayout ) { |
384 | x += AGENDA_ICON_SIZE+3; | 384 | x += AGENDA_ICON_SIZE+3; |
385 | w -= (AGENDA_ICON_SIZE+3); | 385 | w -= (AGENDA_ICON_SIZE+3); |
386 | } | 386 | } |
387 | else { | 387 | else { |
388 | yy+= AGENDA_ICON_SIZE+2; | 388 | yy+= AGENDA_ICON_SIZE+2; |
389 | h -=(AGENDA_ICON_SIZE+3); | 389 | h -=(AGENDA_ICON_SIZE+3); |
390 | } | 390 | } |
391 | } | 391 | } |
392 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 392 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
393 | if ( colsum < 250 ) | 393 | if ( colsum < 250 ) |
394 | paint->setPen ( white); | 394 | paint->setPen ( white); |
395 | if ( x < 0 ) { | 395 | if ( x < 0 ) { |
396 | w = w+x-3; | 396 | w = w+x-3; |
397 | x = 3; | 397 | x = 3; |
398 | if ( w > parentWidget()->width() ){ | 398 | if ( w > parentWidget()->width() ){ |
399 | w = parentWidget()->width() - 6; | 399 | w = parentWidget()->width() - 6; |
400 | #ifndef DESKTOP_VERSION | 400 | #ifndef DESKTOP_VERSION |
401 | align = ( AlignCenter|WordBreak); | 401 | align = ( AlignCenter|WordBreak); |
402 | #else | 402 | #else |
403 | align = ( AlignCenter|BreakAnywhere|WordBreak); | 403 | align = ( AlignCenter|BreakAnywhere|WordBreak); |
404 | #endif | 404 | #endif |
405 | 405 | ||
406 | } | 406 | } |
407 | } | 407 | } |
408 | QRect dr; | 408 | QRect dr; |
409 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 409 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
410 | if ( mIncidence->cancelled() ){ | 410 | if ( mIncidence->cancelled() ){ |
411 | if ( ! small ) { | 411 | if ( ! small ) { |
412 | QFontMetrics fm ( paint->font() ); | 412 | QFontMetrics fm ( paint->font() ); |
413 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 413 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
414 | } | 414 | } |
415 | 415 | ||
416 | } | 416 | } |
417 | pa.end(); | 417 | pa.end(); |
418 | 418 | ||
419 | } | 419 | } |
420 | void KOAgendaItem::resizePixmap( int w , int h ) | 420 | void KOAgendaItem::resizePixmap( int w , int h ) |
421 | { | 421 | { |
422 | paintPix()->resize( w, h ); | 422 | paintPix()->resize( w, h ); |
423 | paintPixSel()->resize( w, h ); | 423 | paintPixSel()->resize( w, h ); |
424 | 424 | ||
425 | } | 425 | } |
426 | QPixmap * KOAgendaItem::paintPix() | 426 | QPixmap * KOAgendaItem::paintPix() |
427 | { | 427 | { |
428 | static QPixmap* mPaintPix = 0; | 428 | static QPixmap* mPaintPix = 0; |
429 | if ( ! mPaintPix ) | 429 | if ( ! mPaintPix ) |
430 | mPaintPix = new QPixmap(); | 430 | mPaintPix = new QPixmap(1,1); |
431 | return mPaintPix ; | 431 | return mPaintPix ; |
432 | } | 432 | } |
433 | QPixmap * KOAgendaItem::paintPixAllday() | 433 | QPixmap * KOAgendaItem::paintPixAllday() |
434 | { | 434 | { |
435 | static QPixmap* mPaintPixA = 0; | 435 | static QPixmap* mPaintPixA = 0; |
436 | if ( ! mPaintPixA ) | 436 | if ( ! mPaintPixA ) |
437 | mPaintPixA = new QPixmap(); | 437 | mPaintPixA = new QPixmap(1,1); |
438 | return mPaintPixA ; | 438 | return mPaintPixA ; |
439 | } | 439 | } |
440 | QPixmap * KOAgendaItem::paintPixSel() | 440 | QPixmap * KOAgendaItem::paintPixSel() |
441 | { | 441 | { |
442 | static QPixmap* mPaintPixSel = 0; | 442 | static QPixmap* mPaintPixSel = 0; |
443 | if ( ! mPaintPixSel ) | 443 | if ( ! mPaintPixSel ) |
444 | mPaintPixSel = new QPixmap(); | 444 | mPaintPixSel = new QPixmap(1,1); |
445 | return mPaintPixSel ; | 445 | return mPaintPixSel ; |
446 | } | 446 | } |
447 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 447 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
448 | { | 448 | { |
449 | 449 | ||
450 | if ( globalFlagBlockAgendaItemPaint ) | 450 | if ( globalFlagBlockAgendaItemPaint ) |
451 | return; | 451 | return; |
452 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 452 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
453 | return; | 453 | return; |
454 | int yy; | 454 | int yy; |
455 | if ( mAllDay ) | 455 | if ( mAllDay ) |
456 | yy = y(); | 456 | yy = y(); |
457 | else | 457 | else |
458 | yy = mCellYTop * ( height() / cellHeight() ); | 458 | yy = mCellYTop * ( height() / cellHeight() ); |
459 | int xx = x(); | 459 | int xx = x(); |
460 | if ( xPaintCoord != xx || yPaintCoord != yy || | 460 | if ( xPaintCoord != xx || yPaintCoord != yy || |
461 | wPaintCoord != width() || hPaintCoord != height()) { | 461 | wPaintCoord != width() || hPaintCoord != height()) { |
462 | xPaintCoord= xx; | 462 | xPaintCoord= xx; |
463 | yPaintCoord = yy; | 463 | yPaintCoord = yy; |
464 | wPaintCoord = width(); | 464 | wPaintCoord = width(); |
465 | hPaintCoord = height(); | 465 | hPaintCoord = height(); |
466 | globalFlagBlockAgendaItemUpdate = 0; | 466 | globalFlagBlockAgendaItemUpdate = 0; |
467 | paintMe( mSelected ); | 467 | paintMe( mSelected ); |
468 | //qDebug("calling paintMe "); | 468 | //qDebug("calling paintMe "); |
469 | globalFlagBlockAgendaItemUpdate = 1; | 469 | globalFlagBlockAgendaItemUpdate = 1; |
470 | } | 470 | } |
471 | int rx, ry, rw, rh; | 471 | int rx, ry, rw, rh; |
472 | rx = e->rect().x(); | 472 | rx = e->rect().x(); |
473 | ry = e->rect().y(); | 473 | ry = e->rect().y(); |
474 | rw = e->rect().width(); | 474 | rw = e->rect().width(); |
475 | rh = e->rect().height(); | 475 | rh = e->rect().height(); |
476 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 476 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
477 | 477 | ||
478 | QPixmap* paintFrom ; | 478 | QPixmap* paintFrom ; |
479 | if ( mSelected ) { | 479 | if ( mSelected ) { |
480 | paintFrom = paintPixSel(); | 480 | paintFrom = paintPixSel(); |
481 | } else { | 481 | } else { |
482 | if ( mAllDay ) | 482 | if ( mAllDay ) |
483 | paintFrom = paintPixAllday(); | 483 | paintFrom = paintPixAllday(); |
484 | else | 484 | else |
485 | paintFrom = paintPix(); | 485 | paintFrom = paintPix(); |
486 | } | 486 | } |
487 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 487 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
488 | } | 488 | } |
489 | void KOAgendaItem::computeText() | 489 | void KOAgendaItem::computeText() |
490 | { | 490 | { |
491 | mDisplayedText = mIncidence->summary(); | 491 | mDisplayedText = mIncidence->summary(); |
492 | if ( (mIncidence->type() == "Todo") ) { | 492 | if ( (mIncidence->type() == "Todo") ) { |
493 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 493 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
494 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 494 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
495 | else if ( !(mIncidence->doesFloat())) | 495 | else if ( !(mIncidence->doesFloat())) |
496 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 496 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
497 | 497 | ||
498 | 498 | ||
499 | 499 | ||
500 | } else { | 500 | } else { |
501 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 501 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
502 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 502 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
503 | 503 | ||
504 | if ( mAllDay ) { | 504 | if ( mAllDay ) { |
505 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 505 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
506 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 506 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | } | 510 | } |
511 | 511 | ||
512 | if ( !mIncidence->location().isEmpty() ) { | 512 | if ( !mIncidence->location().isEmpty() ) { |
513 | if ( mAllDay ) | 513 | if ( mAllDay ) |
514 | mDisplayedText += " ("; | 514 | mDisplayedText += " ("; |
515 | else | 515 | else |
516 | mDisplayedText += "\n("; | 516 | mDisplayedText += "\n("; |
517 | mDisplayedText += mIncidence->location() +")"; | 517 | mDisplayedText += mIncidence->location() +")"; |
518 | } | 518 | } |
519 | } | 519 | } |
520 | void KOAgendaItem::updateItem() | 520 | void KOAgendaItem::updateItem() |
521 | { | 521 | { |
522 | computeText(); | 522 | computeText(); |
523 | 523 | ||
524 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 524 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
525 | paintMe( mSelected ); | 525 | paintMe( mSelected ); |
526 | repaint( false); | 526 | repaint( false); |
527 | } | 527 | } |
528 | 528 | ||
529 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 529 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
530 | { | 530 | { |
531 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 531 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
532 | paintMe( mSelected ); | 532 | paintMe( mSelected ); |
533 | repaint( false ); | 533 | repaint( false ); |
534 | } | 534 | } |
535 | 535 | ||
536 | /* | 536 | /* |
537 | Return height of item in units of agenda cells | 537 | Return height of item in units of agenda cells |
538 | */ | 538 | */ |
539 | int KOAgendaItem::cellHeight() | 539 | int KOAgendaItem::cellHeight() |
540 | { | 540 | { |
541 | int ret = mCellYBottom - mCellYTop + 1; | 541 | int ret = mCellYBottom - mCellYTop + 1; |
542 | if ( ret <= 0 ) { | 542 | if ( ret <= 0 ) { |
543 | ret = 1; | 543 | ret = 1; |
544 | mCellYBottom = 0; | 544 | mCellYBottom = 0; |
545 | mCellYTop = 0; | 545 | mCellYTop = 0; |
546 | } | 546 | } |
547 | return ret; | 547 | return ret; |
548 | } | 548 | } |
549 | 549 | ||
550 | /* | 550 | /* |
551 | Return height of item in units of agenda cells | 551 | Return height of item in units of agenda cells |
552 | */ | 552 | */ |
553 | int KOAgendaItem::cellWidth() | 553 | int KOAgendaItem::cellWidth() |
554 | { | 554 | { |
555 | return mCellXWidth - mCellX + 1; | 555 | return mCellXWidth - mCellX + 1; |
556 | } | 556 | } |
557 | 557 | ||
558 | void KOAgendaItem::setItemDate(QDate qd) | 558 | void KOAgendaItem::setItemDate(QDate qd) |
559 | { | 559 | { |
560 | mDate = qd; | 560 | mDate = qd; |
561 | } | 561 | } |
562 | 562 | ||
563 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 563 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
564 | { | 564 | { |
565 | mCellX = X; | 565 | mCellX = X; |
566 | mCellYTop = YTop; | 566 | mCellYTop = YTop; |
567 | mCellYBottom = YBottom; | 567 | mCellYBottom = YBottom; |
568 | } | 568 | } |
569 | 569 | ||
570 | void KOAgendaItem::setCellXWidth(int xwidth) | 570 | void KOAgendaItem::setCellXWidth(int xwidth) |
571 | { | 571 | { |
572 | mCellXWidth = xwidth; | 572 | mCellXWidth = xwidth; |
573 | } | 573 | } |
574 | 574 | ||
575 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 575 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
576 | { | 576 | { |
577 | mCellX = XLeft; | 577 | mCellX = XLeft; |
578 | mCellXWidth = XRight; | 578 | mCellXWidth = XRight; |
579 | } | 579 | } |
580 | 580 | ||
581 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 581 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
582 | { | 582 | { |
583 | mCellYTop = YTop; | 583 | mCellYTop = YTop; |
584 | mCellYBottom = YBottom; | 584 | mCellYBottom = YBottom; |
585 | } | 585 | } |
586 | 586 | ||
587 | void KOAgendaItem::setSubCell(int subCell) | 587 | void KOAgendaItem::setSubCell(int subCell) |
588 | { | 588 | { |
589 | mSubCell = subCell; | 589 | mSubCell = subCell; |
590 | } | 590 | } |
591 | 591 | ||
592 | void KOAgendaItem::setSubCells(int subCells) | 592 | void KOAgendaItem::setSubCells(int subCells) |
593 | { | 593 | { |
594 | mSubCells = subCells; | 594 | mSubCells = subCells; |
595 | } | 595 | } |
596 | 596 | ||
597 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 597 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
598 | KOAgendaItem *last) | 598 | KOAgendaItem *last) |
599 | { | 599 | { |
600 | mFirstMultiItem = first; | 600 | mFirstMultiItem = first; |
601 | mNextMultiItem = next; | 601 | mNextMultiItem = next; |
602 | mLastMultiItem = last; | 602 | mLastMultiItem = last; |
603 | } | 603 | } |
604 | 604 | ||
605 | void KOAgendaItem::startMove() | 605 | void KOAgendaItem::startMove() |
606 | { | 606 | { |
607 | mStartCellX = mCellX; | 607 | mStartCellX = mCellX; |
608 | mStartCellXWidth = mCellXWidth; | 608 | mStartCellXWidth = mCellXWidth; |
609 | mStartCellYTop = mCellYTop; | 609 | mStartCellYTop = mCellYTop; |
610 | mStartCellYBottom = mCellYBottom; | 610 | mStartCellYBottom = mCellYBottom; |
611 | } | 611 | } |
612 | 612 | ||
613 | void KOAgendaItem::resetMove() | 613 | void KOAgendaItem::resetMove() |
614 | { | 614 | { |
615 | mCellX = mStartCellX; | 615 | mCellX = mStartCellX; |
616 | mCellXWidth = mStartCellXWidth; | 616 | mCellXWidth = mStartCellXWidth; |
617 | mCellYTop = mStartCellYTop; | 617 | mCellYTop = mStartCellYTop; |
618 | mCellYBottom = mStartCellYBottom; | 618 | mCellYBottom = mStartCellYBottom; |
619 | } | 619 | } |
620 | 620 | ||
621 | void KOAgendaItem::moveRelative(int dx, int dy) | 621 | void KOAgendaItem::moveRelative(int dx, int dy) |
622 | { | 622 | { |
623 | int newX = cellX() + dx; | 623 | int newX = cellX() + dx; |
624 | int newXWidth = cellXWidth() + dx; | 624 | int newXWidth = cellXWidth() + dx; |
625 | int newYTop = cellYTop() + dy; | 625 | int newYTop = cellYTop() + dy; |
626 | int newYBottom = cellYBottom() + dy; | 626 | int newYBottom = cellYBottom() + dy; |
627 | setCellXY(newX,newYTop,newYBottom); | 627 | setCellXY(newX,newYTop,newYBottom); |
628 | setCellXWidth(newXWidth); | 628 | setCellXWidth(newXWidth); |
629 | } | 629 | } |
630 | 630 | ||
631 | void KOAgendaItem::expandTop(int dy) | 631 | void KOAgendaItem::expandTop(int dy) |
632 | { | 632 | { |
633 | int newYTop = cellYTop() + dy; | 633 | int newYTop = cellYTop() + dy; |
634 | int newYBottom = cellYBottom(); | 634 | int newYBottom = cellYBottom(); |
635 | if (newYTop > newYBottom) newYTop = newYBottom; | 635 | if (newYTop > newYBottom) newYTop = newYBottom; |
636 | setCellY(newYTop, newYBottom); | 636 | setCellY(newYTop, newYBottom); |
637 | } | 637 | } |
638 | 638 | ||
639 | void KOAgendaItem::expandBottom(int dy) | 639 | void KOAgendaItem::expandBottom(int dy) |
640 | { | 640 | { |
641 | int newYTop = cellYTop(); | 641 | int newYTop = cellYTop(); |
642 | int newYBottom = cellYBottom() + dy; | 642 | int newYBottom = cellYBottom() + dy; |
643 | if (newYBottom < newYTop) newYBottom = newYTop; | 643 | if (newYBottom < newYTop) newYBottom = newYTop; |
644 | setCellY(newYTop, newYBottom); | 644 | setCellY(newYTop, newYBottom); |
645 | } | 645 | } |
646 | 646 | ||
647 | void KOAgendaItem::expandLeft(int dx) | 647 | void KOAgendaItem::expandLeft(int dx) |
648 | { | 648 | { |
649 | int newX = cellX() + dx; | 649 | int newX = cellX() + dx; |
650 | int newXWidth = cellXWidth(); | 650 | int newXWidth = cellXWidth(); |
651 | if (newX > newXWidth) newX = newXWidth; | 651 | if (newX > newXWidth) newX = newXWidth; |
652 | setCellX(newX,newXWidth); | 652 | setCellX(newX,newXWidth); |
653 | } | 653 | } |
654 | 654 | ||
655 | void KOAgendaItem::expandRight(int dx) | 655 | void KOAgendaItem::expandRight(int dx) |
656 | { | 656 | { |
657 | int newX = cellX(); | 657 | int newX = cellX(); |
658 | int newXWidth = cellXWidth() + dx; | 658 | int newXWidth = cellXWidth() + dx; |
659 | if (newXWidth < newX) newXWidth = newX; | 659 | if (newXWidth < newX) newXWidth = newX; |
660 | setCellX(newX,newXWidth); | 660 | setCellX(newX,newXWidth); |
661 | } | 661 | } |
662 | 662 | ||
663 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 663 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
664 | { | 664 | { |
665 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 665 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
666 | return mToolTipGroup; | 666 | return mToolTipGroup; |
667 | } | 667 | } |
668 | 668 | ||
669 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 669 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
670 | { | 670 | { |
671 | #ifndef KORG_NODND | 671 | #ifndef KORG_NODND |
672 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 672 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
673 | !QTextDrag::canDecode( e ) ) { | 673 | !QTextDrag::canDecode( e ) ) { |
674 | e->ignore(); | 674 | e->ignore(); |
675 | return; | 675 | return; |
676 | } | 676 | } |
677 | e->accept(); | 677 | e->accept(); |
678 | #endif | 678 | #endif |
679 | } | 679 | } |
680 | 680 | ||
681 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 681 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
682 | { | 682 | { |
683 | #ifndef KORG_NODND | 683 | #ifndef KORG_NODND |
684 | QString text; | 684 | QString text; |
685 | if(QTextDrag::decode(e,text)) | 685 | if(QTextDrag::decode(e,text)) |
686 | { | 686 | { |
687 | kdDebug() << "Dropped : " << text << endl; | 687 | kdDebug() << "Dropped : " << text << endl; |
688 | QStringList emails = QStringList::split(",",text); | 688 | QStringList emails = QStringList::split(",",text); |
689 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 689 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
690 | kdDebug() << " Email: " << (*it) << endl; | 690 | kdDebug() << " Email: " << (*it) << endl; |
691 | int pos = (*it).find("<"); | 691 | int pos = (*it).find("<"); |
692 | QString name = (*it).left(pos); | 692 | QString name = (*it).left(pos); |
693 | QString email = (*it).mid(pos); | 693 | QString email = (*it).mid(pos); |
694 | if (!email.isEmpty()) { | 694 | if (!email.isEmpty()) { |
695 | mIncidence->addAttendee(new Attendee(name,email)); | 695 | mIncidence->addAttendee(new Attendee(name,email)); |
696 | } | 696 | } |
697 | } | 697 | } |
698 | } | 698 | } |
699 | #endif | 699 | #endif |
700 | } | 700 | } |
701 | 701 | ||
702 | 702 | ||
703 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 703 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
704 | { | 704 | { |
705 | return mConflictItems; | 705 | return mConflictItems; |
706 | } | 706 | } |
707 | 707 | ||
708 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 708 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
709 | { | 709 | { |
710 | mConflictItems = ci; | 710 | mConflictItems = ci; |
711 | KOAgendaItem *item; | 711 | KOAgendaItem *item; |
712 | for ( item=mConflictItems.first(); item != 0; | 712 | for ( item=mConflictItems.first(); item != 0; |
713 | item=mConflictItems.next() ) { | 713 | item=mConflictItems.next() ) { |
714 | item->addConflictItem(this); | 714 | item->addConflictItem(this); |
715 | } | 715 | } |
716 | } | 716 | } |
717 | 717 | ||
718 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 718 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
719 | { | 719 | { |
720 | if (mConflictItems.find(ci)<0) | 720 | if (mConflictItems.find(ci)<0) |
721 | mConflictItems.append(ci); | 721 | mConflictItems.append(ci); |
722 | } | 722 | } |