-rw-r--r-- | korganizer/koagenda.cpp | 172 |
1 files changed, 80 insertions, 92 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 14f52b8..ed7a443 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -220,296 +220,287 @@ QDate KOAgenda::selectedIncidenceDate() const | |||
220 | 220 | ||
221 | 221 | ||
222 | void KOAgenda::init() | 222 | void KOAgenda::init() |
223 | { | 223 | { |
224 | mPopupTimer = new QTimer(this); | 224 | mPopupTimer = new QTimer(this); |
225 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 225 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
226 | 226 | ||
227 | mNewItemPopup = new QPopupMenu( this ); | 227 | mNewItemPopup = new QPopupMenu( this ); |
228 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 228 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
229 | QString pathString = ""; | 229 | QString pathString = ""; |
230 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 230 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
231 | if ( QApplication::desktop()->width() < 480 ) | 231 | if ( QApplication::desktop()->width() < 480 ) |
232 | pathString += "icons16/"; | 232 | pathString += "icons16/"; |
233 | } else | 233 | } else |
234 | pathString += "iconsmini/"; | 234 | pathString += "iconsmini/"; |
235 | 235 | ||
236 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 236 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
238 | mNewItemPopup->insertSeparator ( ); | 238 | mNewItemPopup->insertSeparator ( ); |
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
245 | #ifndef _WIN32_ | 245 | #ifndef _WIN32_ |
246 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 246 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
247 | viewport()->setWFlags ( wflags); | 247 | viewport()->setWFlags ( wflags); |
248 | #endif | 248 | #endif |
249 | mGridSpacingX = 80; | 249 | mGridSpacingX = 80; |
250 | mResizeBorderWidth = 8; | 250 | mResizeBorderWidth = 8; |
251 | mScrollBorderWidth = 8; | 251 | mScrollBorderWidth = 8; |
252 | mScrollDelay = 30; | 252 | mScrollDelay = 30; |
253 | mScrollOffset = 10; | 253 | mScrollOffset = 10; |
254 | mPaintPixmap.resize( 20,20); | 254 | mPaintPixmap.resize( 20,20); |
255 | //enableClipper(true); | 255 | //enableClipper(true); |
256 | 256 | ||
257 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 257 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
258 | // effect. Has to be fixed. | 258 | // effect. Has to be fixed. |
259 | setFocusPolicy(WheelFocus); | 259 | setFocusPolicy(WheelFocus); |
260 | 260 | ||
261 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 261 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
262 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 262 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
263 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 263 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
264 | 264 | ||
265 | mStartCellX = 0; | 265 | mStartCellX = 0; |
266 | mStartCellY = 0; | 266 | mStartCellY = 0; |
267 | mCurrentCellX = 0; | 267 | mCurrentCellX = 0; |
268 | mCurrentCellY = 0; | 268 | mCurrentCellY = 0; |
269 | 269 | ||
270 | mSelectionCellX = 0; | 270 | mSelectionCellX = 0; |
271 | mSelectionYTop = 0; | 271 | mSelectionYTop = 0; |
272 | mSelectionHeight = 0; | 272 | mSelectionHeight = 0; |
273 | 273 | ||
274 | mOldLowerScrollValue = -1; | 274 | mOldLowerScrollValue = -1; |
275 | mOldUpperScrollValue = -1; | 275 | mOldUpperScrollValue = -1; |
276 | 276 | ||
277 | mClickedItem = 0; | 277 | mClickedItem = 0; |
278 | 278 | ||
279 | mActionItem = 0; | 279 | mActionItem = 0; |
280 | mActionType = NOP; | 280 | mActionType = NOP; |
281 | mItemMoved = false; | 281 | mItemMoved = false; |
282 | 282 | ||
283 | mSelectedItem = 0; | 283 | mSelectedItem = 0; |
284 | 284 | ||
285 | // mItems.setAutoDelete(true); | 285 | // mItems.setAutoDelete(true); |
286 | 286 | ||
287 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 287 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
288 | 288 | ||
289 | viewport()->update(); | 289 | viewport()->update(); |
290 | 290 | ||
291 | setMinimumSize(30, 1); | 291 | setMinimumSize(30, 1); |
292 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 292 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
293 | 293 | ||
294 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 294 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
295 | // controlled in a way that the contents horizontally always fits. Then it is | 295 | // controlled in a way that the contents horizontally always fits. Then it is |
296 | // not necessary to turn off the scrollbar. | 296 | // not necessary to turn off the scrollbar. |
297 | setHScrollBarMode(AlwaysOff); | 297 | setHScrollBarMode(AlwaysOff); |
298 | if ( ! mAllDayMode ) | 298 | if ( ! mAllDayMode ) |
299 | setVScrollBarMode(AlwaysOn); | 299 | setVScrollBarMode(AlwaysOn); |
300 | else | 300 | else |
301 | setVScrollBarMode(AlwaysOff); | 301 | setVScrollBarMode(AlwaysOff); |
302 | 302 | ||
303 | setStartHour(KOPrefs::instance()->mDayBegins); | 303 | setStartHour(KOPrefs::instance()->mDayBegins); |
304 | 304 | ||
305 | calculateWorkingHours(); | 305 | calculateWorkingHours(); |
306 | 306 | ||
307 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 307 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
308 | SLOT(checkScrollBoundaries(int))); | 308 | SLOT(checkScrollBoundaries(int))); |
309 | 309 | ||
310 | // Create the Marcus Bains line. | 310 | // Create the Marcus Bains line. |
311 | if(mAllDayMode) | 311 | if(mAllDayMode) |
312 | mMarcusBains = 0; | 312 | mMarcusBains = 0; |
313 | else { | 313 | else { |
314 | mMarcusBains = new MarcusBains(this); | 314 | mMarcusBains = new MarcusBains(this); |
315 | addChild(mMarcusBains); | 315 | addChild(mMarcusBains); |
316 | } | 316 | } |
317 | mPopupKind = 0; | 317 | mPopupKind = 0; |
318 | mPopupItem = 0; | 318 | mPopupItem = 0; |
319 | } | 319 | } |
320 | 320 | ||
321 | void KOAgenda::clear() | 321 | void KOAgenda::clear() |
322 | { | 322 | { |
323 | KOAgendaItem *item; | 323 | KOAgendaItem *item; |
324 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 324 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
325 | mUnusedItems.append( item ); | 325 | mUnusedItems.append( item ); |
326 | //item->hide(); | 326 | //item->hide(); |
327 | } | 327 | } |
328 | mItems.clear(); | 328 | mItems.clear(); |
329 | mSelectedItem = 0; | 329 | mSelectedItem = 0; |
330 | clearSelection(); | 330 | clearSelection(); |
331 | } | 331 | } |
332 | 332 | ||
333 | void KOAgenda::clearSelection() | 333 | void KOAgenda::clearSelection() |
334 | { | 334 | { |
335 | mSelectionCellX = 0; | 335 | mSelectionCellX = 0; |
336 | mSelectionYTop = 0; | 336 | mSelectionYTop = 0; |
337 | mSelectionHeight = 0; | 337 | mSelectionHeight = 0; |
338 | } | 338 | } |
339 | 339 | ||
340 | void KOAgenda::marcus_bains() | 340 | void KOAgenda::marcus_bains() |
341 | { | 341 | { |
342 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 342 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | void KOAgenda::changeColumns(int columns) | 346 | void KOAgenda::changeColumns(int columns) |
347 | { | 347 | { |
348 | if (columns == 0) { | 348 | if (columns == 0) { |
349 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; | 349 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
350 | return; | 350 | return; |
351 | } | 351 | } |
352 | 352 | clear(); | |
353 | clear(); | 353 | mColumns = columns; |
354 | |||
355 | mColumns = columns; | ||
356 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); | ||
357 | // init(); | ||
358 | // update(); | ||
359 | //qDebug("KOAgenda::changeColumns "); | ||
360 | computeSizes(); | 354 | computeSizes(); |
361 | // QResizeEvent event( size(), size() ); | ||
362 | |||
363 | //QApplication::sendEvent( this, &event ); | ||
364 | } | 355 | } |
365 | 356 | ||
366 | /* | 357 | /* |
367 | This is the eventFilter function, which gets all events from the KOAgendaItems | 358 | This is the eventFilter function, which gets all events from the KOAgendaItems |
368 | contained in the agenda. It has to handle moving and resizing for all items. | 359 | contained in the agenda. It has to handle moving and resizing for all items. |
369 | */ | 360 | */ |
370 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 361 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
371 | { | 362 | { |
372 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 363 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
373 | switch(event->type()) { | 364 | switch(event->type()) { |
374 | case QEvent::MouseButtonPress: | 365 | case QEvent::MouseButtonPress: |
375 | case QEvent::MouseButtonDblClick: | 366 | case QEvent::MouseButtonDblClick: |
376 | case QEvent::MouseButtonRelease: | 367 | case QEvent::MouseButtonRelease: |
377 | case QEvent::MouseMove: | 368 | case QEvent::MouseMove: |
378 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 369 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
379 | 370 | ||
380 | case (QEvent::Leave): | 371 | case (QEvent::Leave): |
381 | if (!mActionItem) | 372 | if (!mActionItem) |
382 | setCursor(arrowCursor); | 373 | setCursor(arrowCursor); |
383 | return true; | 374 | return true; |
384 | 375 | ||
385 | default: | 376 | default: |
386 | return QScrollView::eventFilter(object,event); | 377 | return QScrollView::eventFilter(object,event); |
387 | } | 378 | } |
388 | } | 379 | } |
389 | void KOAgenda::popupMenu() | 380 | void KOAgenda::popupMenu() |
390 | { | 381 | { |
391 | mPopupTimer->stop(); | 382 | mPopupTimer->stop(); |
392 | if ( mPopupKind == 1 ) { | 383 | if ( mPopupKind == 1 ) { |
393 | if (mActionItem ) { | 384 | if (mActionItem ) { |
394 | endItemAction(); | 385 | endItemAction(); |
395 | } | 386 | } |
396 | mLeftMouseDown = false; // no more leftMouse computation | 387 | mLeftMouseDown = false; // no more leftMouse computation |
397 | if (mPopupItem) { | 388 | if (mPopupItem) { |
398 | selectItem(mPopupItem); | 389 | selectItem(mPopupItem); |
399 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 390 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
400 | 391 | ||
401 | } | 392 | } |
402 | } else if ( mPopupKind == 2 ) { | 393 | } else if ( mPopupKind == 2 ) { |
403 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 394 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
404 | endSelectAction( false ); // do not emit new event signal | 395 | endSelectAction( false ); // do not emit new event signal |
405 | mLeftMouseDown = false; // no more leftMouse computation | 396 | mLeftMouseDown = false; // no more leftMouse computation |
406 | } | 397 | } |
407 | mNewItemPopup->popup( mPopupPos); | 398 | mNewItemPopup->popup( mPopupPos); |
408 | } | 399 | } |
409 | mLeftMouseDown = false; | 400 | mLeftMouseDown = false; |
410 | mPopupItem = 0; | 401 | mPopupItem = 0; |
411 | mPopupKind = 0; | 402 | mPopupKind = 0; |
412 | } | 403 | } |
413 | 404 | ||
414 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 405 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
415 | { | 406 | { |
416 | //qDebug("KOAgenda::eventFilter_mous "); | 407 | //qDebug("KOAgenda::eventFilter_mous "); |
417 | QPoint viewportPos; | 408 | QPoint viewportPos; |
418 | if (object != viewport()) { | 409 | if (object != viewport()) { |
419 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 410 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
420 | } else { | 411 | } else { |
421 | viewportPos = me->pos(); | 412 | viewportPos = me->pos(); |
422 | } | 413 | } |
423 | static int startX = 0; | 414 | static int startX = 0; |
424 | static int startY = 0; | 415 | static int startY = 0; |
425 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 416 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
426 | static bool blockMoving = true; | 417 | static bool blockMoving = true; |
427 | switch (me->type()) { | 418 | switch (me->type()) { |
428 | case QEvent::MouseButtonPress: | 419 | case QEvent::MouseButtonPress: |
429 | if (me->button() == LeftButton) { | 420 | if (me->button() == LeftButton) { |
430 | mPopupTimer->start( 600 ); | 421 | mPopupTimer->start( 600 ); |
431 | mLeftMouseDown = true; | 422 | mLeftMouseDown = true; |
432 | } | 423 | } |
433 | blockMoving = true; | 424 | blockMoving = true; |
434 | startX = viewportPos.x(); | 425 | startX = viewportPos.x(); |
435 | startY = viewportPos.y(); | 426 | startY = viewportPos.y(); |
436 | if (object != viewport()) { | 427 | if (object != viewport()) { |
437 | mPopupItem = (KOAgendaItem *)object; | 428 | mPopupItem = (KOAgendaItem *)object; |
438 | mPopupKind = 1; | 429 | mPopupKind = 1; |
439 | if (me->button() == RightButton) { | 430 | if (me->button() == RightButton) { |
440 | popupMenu(); | 431 | popupMenu(); |
441 | } else if (me->button() == LeftButton) { | 432 | } else if (me->button() == LeftButton) { |
442 | mActionItem = (KOAgendaItem *)object; | 433 | mActionItem = (KOAgendaItem *)object; |
443 | if (mActionItem) { | 434 | if (mActionItem) { |
444 | if ( mSelectionHeight > 0 ) { | 435 | if ( mSelectionHeight > 0 ) { |
445 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 436 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
446 | int selectionYTop = mSelectionYTop; | 437 | int selectionYTop = mSelectionYTop; |
447 | int gridSpacingX = mGridSpacingX; | 438 | int gridSpacingX = mGridSpacingX; |
448 | int selectionHeight = mSelectionHeight; | 439 | int selectionHeight = mSelectionHeight; |
449 | clearSelection(); | 440 | clearSelection(); |
450 | repaintContents( selectionCellX, selectionYTop, | 441 | repaintContents( selectionCellX, selectionYTop, |
451 | gridSpacingX, selectionHeight,false ); | 442 | gridSpacingX, selectionHeight,false ); |
452 | } | 443 | } |
453 | selectItem(mActionItem); | 444 | selectItem(mActionItem); |
454 | Incidence *incidence = mActionItem->incidence(); | 445 | Incidence *incidence = mActionItem->incidence(); |
455 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 446 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
456 | mActionItem = 0; | 447 | mActionItem = 0; |
457 | } else { | 448 | } else { |
458 | startItemAction(viewportPos); | 449 | startItemAction(viewportPos); |
459 | } | 450 | } |
460 | } | 451 | } |
461 | } | 452 | } |
462 | } else { // ---------- viewport() | 453 | } else { // ---------- viewport() |
463 | mPopupItem = 0; | 454 | mPopupItem = 0; |
464 | mPopupKind = 2; | 455 | mPopupKind = 2; |
465 | selectItem(0); | 456 | selectItem(0); |
466 | mActionItem = 0; | 457 | mActionItem = 0; |
467 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 458 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
468 | if (me->button() == RightButton) { | 459 | if (me->button() == RightButton) { |
469 | popupMenu(); | 460 | popupMenu(); |
470 | } else if (me->button() == LeftButton) { | 461 | } else if (me->button() == LeftButton) { |
471 | setCursor(arrowCursor); | 462 | setCursor(arrowCursor); |
472 | startSelectAction(viewportPos); | 463 | startSelectAction(viewportPos); |
473 | } | 464 | } |
474 | } | 465 | } |
475 | break; | 466 | break; |
476 | 467 | ||
477 | case QEvent::MouseButtonRelease: | 468 | case QEvent::MouseButtonRelease: |
478 | if (me->button() == LeftButton ) { | 469 | if (me->button() == LeftButton ) { |
479 | mPopupTimer->stop(); | 470 | mPopupTimer->stop(); |
480 | } | 471 | } |
481 | if (object != viewport()) { | 472 | if (object != viewport()) { |
482 | if (me->button() == LeftButton && mLeftMouseDown) { | 473 | if (me->button() == LeftButton && mLeftMouseDown) { |
483 | if (mActionItem) { | 474 | if (mActionItem) { |
484 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 475 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
485 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 476 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
486 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 477 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
487 | mScrollUpTimer.stop(); | 478 | mScrollUpTimer.stop(); |
488 | mScrollDownTimer.stop(); | 479 | mScrollDownTimer.stop(); |
489 | mActionItem->resetMove(); | 480 | mActionItem->resetMove(); |
490 | placeSubCells( mActionItem ); | 481 | placeSubCells( mActionItem ); |
491 | // emit startDragSignal( mActionItem->incidence() ); | 482 | // emit startDragSignal( mActionItem->incidence() ); |
492 | setCursor( arrowCursor ); | 483 | setCursor( arrowCursor ); |
493 | mActionItem = 0; | 484 | mActionItem = 0; |
494 | mActionType = NOP; | 485 | mActionType = NOP; |
495 | mItemMoved = 0; | 486 | mItemMoved = 0; |
496 | mLeftMouseDown = false; | 487 | mLeftMouseDown = false; |
497 | return true; | 488 | return true; |
498 | } | 489 | } |
499 | endItemAction(); | 490 | endItemAction(); |
500 | } | 491 | } |
501 | } | 492 | } |
502 | 493 | ||
503 | } else { // ---------- viewport() | 494 | } else { // ---------- viewport() |
504 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 495 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
505 | endSelectAction( true ); // emit new event signal | 496 | endSelectAction( true ); // emit new event signal |
506 | } | 497 | } |
507 | } | 498 | } |
508 | if (me->button() == LeftButton) | 499 | if (me->button() == LeftButton) |
509 | mLeftMouseDown = false; | 500 | mLeftMouseDown = false; |
510 | 501 | ||
511 | break; | 502 | break; |
512 | 503 | ||
513 | case QEvent::MouseMove: | 504 | case QEvent::MouseMove: |
514 | if ( !mLeftMouseDown ) | 505 | if ( !mLeftMouseDown ) |
515 | return true; | 506 | return true; |
@@ -1623,482 +1614,479 @@ KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | |||
1623 | { | 1614 | { |
1624 | 1615 | ||
1625 | KOAgendaItem *fi; | 1616 | KOAgendaItem *fi; |
1626 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1617 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1627 | if ( fi->incidence() == event ) { | 1618 | if ( fi->incidence() == event ) { |
1628 | mUnusedItems.remove(); | 1619 | mUnusedItems.remove(); |
1629 | fi->init( event, qd ); | 1620 | fi->init( event, qd ); |
1630 | return fi; | 1621 | return fi; |
1631 | } | 1622 | } |
1632 | } | 1623 | } |
1633 | fi=mUnusedItems.first(); | 1624 | fi=mUnusedItems.first(); |
1634 | if ( fi ) { | 1625 | if ( fi ) { |
1635 | mUnusedItems.remove(); | 1626 | mUnusedItems.remove(); |
1636 | fi->init( event, qd ); | 1627 | fi->init( event, qd ); |
1637 | return fi; | 1628 | return fi; |
1638 | } | 1629 | } |
1639 | // qDebug("new KOAgendaItem "); | 1630 | // qDebug("new KOAgendaItem "); |
1640 | 1631 | ||
1641 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1632 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1642 | agendaItem->installEventFilter(this); | 1633 | agendaItem->installEventFilter(this); |
1643 | addChild(agendaItem,0,0); | 1634 | addChild(agendaItem,0,0); |
1644 | return agendaItem; | 1635 | return agendaItem; |
1645 | } | 1636 | } |
1646 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1637 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1647 | { | 1638 | { |
1648 | KOAgendaItem *item; | 1639 | KOAgendaItem *item; |
1649 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1640 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1650 | if ( item->incidence() == todo ) { | 1641 | if ( item->incidence() == todo ) { |
1651 | mItems.remove(); | 1642 | mItems.remove(); |
1652 | return item; | 1643 | return item; |
1653 | } | 1644 | } |
1654 | } | 1645 | } |
1655 | return 0; | 1646 | return 0; |
1656 | } | 1647 | } |
1657 | 1648 | ||
1658 | 1649 | ||
1659 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1650 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1660 | { | 1651 | { |
1661 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1652 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1662 | KOAgendaItem *item; | 1653 | KOAgendaItem *item; |
1663 | item = getItemForTodo ( todo ); | 1654 | item = getItemForTodo ( todo ); |
1664 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1655 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1665 | if ( item ) { | 1656 | if ( item ) { |
1666 | blockSignals( true ); | 1657 | blockSignals( true ); |
1667 | //qDebug("item found "); | 1658 | //qDebug("item found "); |
1668 | item->hide(); | 1659 | item->hide(); |
1669 | item->setCellX(-2, -1 ); | 1660 | item->setCellX(-2, -1 ); |
1670 | item->select(false); | 1661 | item->select(false); |
1671 | mUnusedItems.append( item ); | 1662 | mUnusedItems.append( item ); |
1672 | mItems.remove( item ); | 1663 | mItems.remove( item ); |
1673 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1664 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1674 | KOAgendaItem *itemit; | 1665 | KOAgendaItem *itemit; |
1675 | //globalFlagBlockAgendaItemPaint = 1; | 1666 | //globalFlagBlockAgendaItemPaint = 1; |
1676 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1667 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1677 | itemit=oldconflictItems.next() ) { | 1668 | itemit=oldconflictItems.next() ) { |
1678 | if ( itemit != item ) | 1669 | if ( itemit != item ) |
1679 | placeSubCells(itemit); | 1670 | placeSubCells(itemit); |
1680 | } | 1671 | } |
1681 | qApp->processEvents(); | 1672 | qApp->processEvents(); |
1682 | //globalFlagBlockAgendaItemPaint = 0; | 1673 | //globalFlagBlockAgendaItemPaint = 0; |
1683 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1674 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1684 | itemit=oldconflictItems.next() ) { | 1675 | itemit=oldconflictItems.next() ) { |
1685 | globalFlagBlockAgendaItemUpdate = 0; | 1676 | globalFlagBlockAgendaItemUpdate = 0; |
1686 | if ( itemit != item ) | 1677 | if ( itemit != item ) |
1687 | itemit->repaintMe(); | 1678 | itemit->repaintMe(); |
1688 | globalFlagBlockAgendaItemUpdate = 1; | 1679 | globalFlagBlockAgendaItemUpdate = 1; |
1689 | itemit->repaint(); | 1680 | itemit->repaint(); |
1690 | } | 1681 | } |
1691 | blockSignals( false ); | 1682 | blockSignals( false ); |
1692 | } | 1683 | } |
1693 | if ( remove ) { | 1684 | if ( remove ) { |
1694 | //qDebug("remove****************************************** "); | 1685 | //qDebug("remove****************************************** "); |
1695 | return; | 1686 | return; |
1696 | } | 1687 | } |
1697 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1688 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1698 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1689 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1699 | QDate currentDate; | 1690 | QDate currentDate; |
1700 | QDateTime dt; | 1691 | QDateTime dt; |
1701 | if ( todo->hasCompletedDate() ) | 1692 | if ( todo->hasCompletedDate() ) |
1702 | dt = todo->completed(); | 1693 | dt = todo->completed(); |
1703 | else | 1694 | else |
1704 | dt = todo->dtDue(); | 1695 | dt = todo->dtDue(); |
1705 | if ( overdue ) { | 1696 | if ( overdue ) { |
1706 | currentDate = QDate::currentDate(); | 1697 | currentDate = QDate::currentDate(); |
1707 | days += todo->dtDue().date().daysTo( currentDate ); | 1698 | days += todo->dtDue().date().daysTo( currentDate ); |
1708 | } | 1699 | } |
1709 | else | 1700 | else |
1710 | currentDate = dt.date(); | 1701 | currentDate = dt.date(); |
1711 | 1702 | ||
1712 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1703 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1713 | if ( ! mAllDayMode ) return; | 1704 | if ( ! mAllDayMode ) return; |
1714 | // aldayagenda | 1705 | // aldayagenda |
1715 | globalFlagBlockAgendaItemPaint = 1; | 1706 | globalFlagBlockAgendaItemPaint = 1; |
1716 | item = insertAllDayItem(todo, currentDate,days, days); | 1707 | item = insertAllDayItem(todo, currentDate,days, days); |
1717 | item->show(); | 1708 | item->show(); |
1718 | 1709 | ||
1719 | } | 1710 | } |
1720 | else { | 1711 | else { |
1721 | if ( mAllDayMode ) return; | 1712 | if ( mAllDayMode ) return; |
1722 | // mAgenda | 1713 | // mAgenda |
1723 | globalFlagBlockAgendaItemPaint = 1; | 1714 | globalFlagBlockAgendaItemPaint = 1; |
1724 | int endY = timeToY(dt.time()) - 1; | 1715 | int endY = timeToY(dt.time()) - 1; |
1725 | int hi = 12/KOPrefs::instance()->mHourSize; | 1716 | int hi = 12/KOPrefs::instance()->mHourSize; |
1726 | int startY = endY - 1-hi; | 1717 | int startY = endY - 1-hi; |
1727 | item = insertItem(todo,currentDate,days,startY,endY); | 1718 | item = insertItem(todo,currentDate,days,startY,endY); |
1728 | item->show(); | 1719 | item->show(); |
1729 | } | 1720 | } |
1730 | qApp->processEvents(); | 1721 | qApp->processEvents(); |
1731 | globalFlagBlockAgendaItemPaint = 0; | 1722 | globalFlagBlockAgendaItemPaint = 0; |
1732 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1723 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1733 | KOAgendaItem *itemit; | 1724 | KOAgendaItem *itemit; |
1734 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1725 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1735 | itemit=oldconflictItems.next() ) { | 1726 | itemit=oldconflictItems.next() ) { |
1736 | globalFlagBlockAgendaItemUpdate = 0; | 1727 | globalFlagBlockAgendaItemUpdate = 0; |
1737 | itemit->repaintMe(); | 1728 | itemit->repaintMe(); |
1738 | globalFlagBlockAgendaItemUpdate = 1; | 1729 | globalFlagBlockAgendaItemUpdate = 1; |
1739 | itemit->repaint(); | 1730 | itemit->repaint(); |
1740 | } | 1731 | } |
1741 | globalFlagBlockAgendaItemUpdate = 0; | 1732 | globalFlagBlockAgendaItemUpdate = 0; |
1742 | item->repaintMe(); | 1733 | item->repaintMe(); |
1743 | globalFlagBlockAgendaItemUpdate = 1; | 1734 | globalFlagBlockAgendaItemUpdate = 1; |
1744 | item->repaint(); | 1735 | item->repaint(); |
1745 | } | 1736 | } |
1746 | /* | 1737 | /* |
1747 | Insert KOAgendaItem into agenda. | 1738 | Insert KOAgendaItem into agenda. |
1748 | */ | 1739 | */ |
1749 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1740 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1750 | { | 1741 | { |
1751 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | ||
1752 | |||
1753 | if (mAllDayMode) { | 1742 | if (mAllDayMode) { |
1754 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1743 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1755 | return 0; | 1744 | return 0; |
1756 | } | 1745 | } |
1757 | 1746 | ||
1758 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1747 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1759 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1748 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1760 | 1749 | ||
1761 | int YSize = YBottom - YTop + 1; | 1750 | int YSize = YBottom - YTop + 1; |
1762 | if (YSize < 0) { | 1751 | if (YSize < 0) { |
1763 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | ||
1764 | YSize = 1; | 1752 | YSize = 1; |
1765 | } | 1753 | } |
1766 | int iheight = mGridSpacingY * YSize; | 1754 | int iheight = mGridSpacingY * YSize; |
1767 | 1755 | ||
1768 | agendaItem->resize(mGridSpacingX,iheight ); | 1756 | agendaItem->resize(mGridSpacingX,iheight ); |
1769 | agendaItem->setCellXY(X,YTop,YBottom); | 1757 | agendaItem->setCellXY(X,YTop,YBottom); |
1770 | agendaItem->setCellXWidth(X); | 1758 | agendaItem->setCellXWidth(X); |
1771 | 1759 | ||
1772 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1760 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1773 | mItems.append(agendaItem); | 1761 | mItems.append(agendaItem); |
1774 | 1762 | ||
1775 | placeSubCells(agendaItem); | 1763 | placeSubCells(agendaItem); |
1776 | 1764 | ||
1777 | //agendaItem->show(); | 1765 | //agendaItem->show(); |
1778 | 1766 | ||
1779 | marcus_bains(); | 1767 | marcus_bains(); |
1780 | 1768 | ||
1781 | return agendaItem; | 1769 | return agendaItem; |
1782 | } | 1770 | } |
1783 | 1771 | ||
1784 | 1772 | ||
1785 | /* | 1773 | /* |
1786 | Insert all-day KOAgendaItem into agenda. | 1774 | Insert all-day KOAgendaItem into agenda. |
1787 | */ | 1775 | */ |
1788 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1776 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1789 | { | 1777 | { |
1790 | if (!mAllDayMode) { | 1778 | if (!mAllDayMode) { |
1791 | return 0; | 1779 | return 0; |
1792 | } | 1780 | } |
1793 | 1781 | ||
1794 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1782 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1795 | 1783 | ||
1796 | agendaItem->setCellXY(XBegin,0,0); | 1784 | agendaItem->setCellXY(XBegin,0,0); |
1797 | agendaItem->setCellXWidth(XEnd); | 1785 | agendaItem->setCellXWidth(XEnd); |
1798 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1786 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1799 | 1787 | ||
1800 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1788 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1801 | mItems.append(agendaItem); | 1789 | mItems.append(agendaItem); |
1802 | 1790 | ||
1803 | placeSubCells(agendaItem); | 1791 | placeSubCells(agendaItem); |
1804 | 1792 | ||
1805 | //agendaItem->show(); | 1793 | //agendaItem->show(); |
1806 | 1794 | ||
1807 | return agendaItem; | 1795 | return agendaItem; |
1808 | } | 1796 | } |
1809 | 1797 | ||
1810 | 1798 | ||
1811 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1799 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1812 | int YTop,int YBottom) | 1800 | int YTop,int YBottom) |
1813 | { | 1801 | { |
1814 | if (mAllDayMode) { | 1802 | if (mAllDayMode) { |
1815 | ; | 1803 | ; |
1816 | return; | 1804 | return; |
1817 | } | 1805 | } |
1818 | 1806 | ||
1819 | int cellX,cellYTop,cellYBottom; | 1807 | int cellX,cellYTop,cellYBottom; |
1820 | QString newtext; | 1808 | QString newtext; |
1821 | int width = XEnd - XBegin + 1; | 1809 | int width = XEnd - XBegin + 1; |
1822 | int count = 0; | 1810 | int count = 0; |
1823 | KOAgendaItem *current = 0; | 1811 | KOAgendaItem *current = 0; |
1824 | QPtrList<KOAgendaItem> multiItems; | 1812 | QPtrList<KOAgendaItem> multiItems; |
1825 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1813 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1826 | if (cellX == XBegin) cellYTop = YTop; | 1814 | if (cellX == XBegin) cellYTop = YTop; |
1827 | else cellYTop = 0; | 1815 | else cellYTop = 0; |
1828 | if (cellX == XEnd) cellYBottom = YBottom; | 1816 | if (cellX == XEnd) cellYBottom = YBottom; |
1829 | else cellYBottom = rows() - 1; | 1817 | else cellYBottom = rows() - 1; |
1830 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1818 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1831 | newtext.append(event->summary()); | 1819 | newtext.append(event->summary()); |
1832 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1820 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1833 | current->setText(newtext); | 1821 | current->setText(newtext); |
1834 | multiItems.append(current); | 1822 | multiItems.append(current); |
1835 | } | 1823 | } |
1836 | 1824 | ||
1837 | KOAgendaItem *next = 0; | 1825 | KOAgendaItem *next = 0; |
1838 | KOAgendaItem *last = multiItems.last(); | 1826 | KOAgendaItem *last = multiItems.last(); |
1839 | KOAgendaItem *first = multiItems.first(); | 1827 | KOAgendaItem *first = multiItems.first(); |
1840 | KOAgendaItem *setFirst,*setLast; | 1828 | KOAgendaItem *setFirst,*setLast; |
1841 | current = first; | 1829 | current = first; |
1842 | while (current) { | 1830 | while (current) { |
1843 | next = multiItems.next(); | 1831 | next = multiItems.next(); |
1844 | if (current == first) setFirst = 0; | 1832 | if (current == first) setFirst = 0; |
1845 | else setFirst = first; | 1833 | else setFirst = first; |
1846 | if (current == last) setLast = 0; | 1834 | if (current == last) setLast = 0; |
1847 | else setLast = last; | 1835 | else setLast = last; |
1848 | 1836 | ||
1849 | current->setMultiItem(setFirst,next,setLast); | 1837 | current->setMultiItem(setFirst,next,setLast); |
1850 | current = next; | 1838 | current = next; |
1851 | } | 1839 | } |
1852 | 1840 | ||
1853 | marcus_bains(); | 1841 | marcus_bains(); |
1854 | } | 1842 | } |
1855 | 1843 | ||
1856 | 1844 | ||
1857 | //QSizePolicy KOAgenda::sizePolicy() const | 1845 | //QSizePolicy KOAgenda::sizePolicy() const |
1858 | //{ | 1846 | //{ |
1859 | // Thought this would make the all-day event agenda minimum size and the | 1847 | // Thought this would make the all-day event agenda minimum size and the |
1860 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1848 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1861 | // don´t seem to think that an Expanding widget needs more space than a | 1849 | // don´t seem to think that an Expanding widget needs more space than a |
1862 | // Preferred one. | 1850 | // Preferred one. |
1863 | // But it doesn´t hurt, so it stays. | 1851 | // But it doesn´t hurt, so it stays. |
1864 | // if (mAllDayMode) { | 1852 | // if (mAllDayMode) { |
1865 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1853 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1866 | // } else { | 1854 | // } else { |
1867 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1855 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1868 | // } | 1856 | // } |
1869 | //} | 1857 | //} |
1870 | void KOAgenda::finishResize ( ) | 1858 | void KOAgenda::finishResize ( ) |
1871 | { | 1859 | { |
1872 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1860 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1873 | if ( globalFlagBlockAgenda == 0 ) { | 1861 | if ( globalFlagBlockAgenda == 0 ) { |
1874 | finishUpdate(); | 1862 | finishUpdate(); |
1875 | //qDebug("finishUpdate() called "); | 1863 | //qDebug("finishUpdate() called "); |
1876 | } | 1864 | } |
1877 | } | 1865 | } |
1878 | /* | 1866 | /* |
1879 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1867 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1880 | */ | 1868 | */ |
1881 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1869 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1882 | { | 1870 | { |
1883 | 1871 | ||
1884 | mResizeTimer.start( 150 , true ); | 1872 | mResizeTimer.start( 150 , true ); |
1885 | computeSizes(); | 1873 | computeSizes(); |
1886 | return; | 1874 | return; |
1887 | 1875 | ||
1888 | } | 1876 | } |
1889 | void KOAgenda::computeSizes() | 1877 | void KOAgenda::computeSizes() |
1890 | { | 1878 | { |
1891 | if ( globalFlagBlockStartup ) | 1879 | if ( globalFlagBlockStartup ) |
1892 | return; | 1880 | return; |
1881 | int frameOffset = frameWidth() * 2 +1; | ||
1882 | if (mAllDayMode) { | ||
1883 | mGridSpacingX = (width()-frameOffset) / mColumns; | ||
1884 | mGridSpacingY = height() - 2 * frameWidth() - 1; | ||
1885 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | ||
1886 | // mGridSpacingY = height(); | ||
1887 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | ||
1893 | 1888 | ||
1894 | if (mAllDayMode) { | 1889 | KOAgendaItem *item; |
1895 | mGridSpacingX = (width()-3) / mColumns; | 1890 | int subCellWidth; |
1896 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1891 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1897 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1892 | subCellWidth = mGridSpacingY / item->subCells(); |
1898 | // mGridSpacingY = height(); | 1893 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1899 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1894 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1900 | 1895 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | |
1901 | KOAgendaItem *item; | ||
1902 | int subCellWidth; | ||
1903 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | ||
1904 | subCellWidth = mGridSpacingY / item->subCells(); | ||
1905 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | ||
1906 | moveChild(item,KOGlobals::self()->reverseLayout() ? | ||
1907 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | ||
1908 | item->cellX() * mGridSpacingX, | 1896 | item->cellX() * mGridSpacingX, |
1909 | item->subCell() * subCellWidth); | 1897 | item->subCell() * subCellWidth); |
1910 | } | 1898 | } |
1911 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1899 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1912 | } else { | 1900 | } else { |
1913 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; | 1901 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1914 | if (height() > mGridSpacingY * mRows + 1 ) { | 1902 | if (height() > mGridSpacingY * mRows + 1 ) { |
1915 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1903 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1916 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1904 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1917 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1905 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1918 | emit resizedSignal(); | 1906 | emit resizedSignal(); |
1919 | } else | 1907 | } else |
1920 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1908 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1921 | KOAgendaItem *item; | 1909 | KOAgendaItem *item; |
1922 | int subCellWidth; | 1910 | int subCellWidth; |
1923 | 1911 | ||
1924 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1912 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1925 | subCellWidth = mGridSpacingX / item->subCells(); | 1913 | subCellWidth = mGridSpacingX / item->subCells(); |
1926 | item->resize(subCellWidth,item->height()); | 1914 | item->resize(subCellWidth,item->height()); |
1927 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1915 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1928 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1916 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1929 | item->cellX() * mGridSpacingX) + | 1917 | item->cellX() * mGridSpacingX) + |
1930 | item->subCell() * subCellWidth,childY(item)); | 1918 | item->subCell() * subCellWidth,childY(item)); |
1919 | } | ||
1920 | } | ||
1921 | int cw = contentsWidth(); | ||
1922 | int ch = contentsHeight(); | ||
1923 | if ( mAllDayMode ) { | ||
1924 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | ||
1925 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | ||
1926 | paintPixAll->resize( cw, ch ); | ||
1927 | } else { | ||
1928 | QPixmap* paintPix = KOAgendaItem::paintPix(); | ||
1929 | if ( paintPix->width() < cw || paintPix->height() < ch ) | ||
1930 | KOAgendaItem::resizePixmap( cw , ch ); | ||
1931 | } | 1931 | } |
1932 | } | ||
1933 | int cw = contentsWidth(); | ||
1934 | int ch = contentsHeight(); | ||
1935 | if ( mAllDayMode ) { | ||
1936 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | ||
1937 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | ||
1938 | paintPixAll->resize( cw, ch ); | ||
1939 | } else { | ||
1940 | QPixmap* paintPix = KOAgendaItem::paintPix(); | ||
1941 | if ( paintPix->width() < cw || paintPix->height() < ch ) | ||
1942 | KOAgendaItem::resizePixmap( cw , ch ); | ||
1943 | } | ||
1944 | 1932 | ||
1945 | checkScrollBoundaries(); | 1933 | checkScrollBoundaries(); |
1946 | marcus_bains(); | 1934 | marcus_bains(); |
1947 | drawContentsToPainter(); | 1935 | drawContentsToPainter(); |
1948 | viewport()->repaint(false); | 1936 | viewport()->repaint(false); |
1949 | } | 1937 | } |
1950 | 1938 | ||
1951 | void KOAgenda::scrollUp() | 1939 | void KOAgenda::scrollUp() |
1952 | { | 1940 | { |
1953 | scrollBy(0,-mScrollOffset); | 1941 | scrollBy(0,-mScrollOffset); |
1954 | } | 1942 | } |
1955 | 1943 | ||
1956 | 1944 | ||
1957 | void KOAgenda::scrollDown() | 1945 | void KOAgenda::scrollDown() |
1958 | { | 1946 | { |
1959 | scrollBy(0,mScrollOffset); | 1947 | scrollBy(0,mScrollOffset); |
1960 | } | 1948 | } |
1961 | 1949 | ||
1962 | void KOAgenda::popupAlarm() | 1950 | void KOAgenda::popupAlarm() |
1963 | { | 1951 | { |
1964 | if (!mClickedItem) { | 1952 | if (!mClickedItem) { |
1965 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1953 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1966 | return; | 1954 | return; |
1967 | } | 1955 | } |
1968 | // TODO: deal correctly with multiple alarms | 1956 | // TODO: deal correctly with multiple alarms |
1969 | Alarm* alarm; | 1957 | Alarm* alarm; |
1970 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1958 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1971 | for(alarm=list.first();alarm;alarm=list.next()) { | 1959 | for(alarm=list.first();alarm;alarm=list.next()) { |
1972 | alarm->toggleAlarm(); | 1960 | alarm->toggleAlarm(); |
1973 | } | 1961 | } |
1974 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1962 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1975 | mClickedItem->paintMe( true ); | 1963 | mClickedItem->paintMe( true ); |
1976 | mClickedItem->repaint( false ); | 1964 | mClickedItem->repaint( false ); |
1977 | } | 1965 | } |
1978 | 1966 | ||
1979 | /* | 1967 | /* |
1980 | Calculates the minimum width | 1968 | Calculates the minimum width |
1981 | */ | 1969 | */ |
1982 | int KOAgenda::minimumWidth() const | 1970 | int KOAgenda::minimumWidth() const |
1983 | { | 1971 | { |
1984 | // TODO:: develop a way to dynamically determine the minimum width | 1972 | // TODO:: develop a way to dynamically determine the minimum width |
1985 | int min = 100; | 1973 | int min = 100; |
1986 | 1974 | ||
1987 | return min; | 1975 | return min; |
1988 | } | 1976 | } |
1989 | 1977 | ||
1990 | void KOAgenda::updateConfig() | 1978 | void KOAgenda::updateConfig() |
1991 | { | 1979 | { |
1992 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1980 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1993 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1981 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1994 | if ( mAllDayMode ) { | 1982 | if ( mAllDayMode ) { |
1995 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1983 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1996 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1984 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1997 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1985 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1998 | // setMaximumHeight( mGridSpacingY+1 ); | 1986 | // setMaximumHeight( mGridSpacingY+1 ); |
1999 | viewport()->repaint( false ); | 1987 | viewport()->repaint( false ); |
2000 | //setFixedHeight( mGridSpacingY+1 ); | 1988 | //setFixedHeight( mGridSpacingY+1 ); |
2001 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1989 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2002 | } | 1990 | } |
2003 | else { | 1991 | else { |
2004 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1992 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2005 | calculateWorkingHours(); | 1993 | calculateWorkingHours(); |
2006 | marcus_bains(); | 1994 | marcus_bains(); |
2007 | } | 1995 | } |
2008 | } | 1996 | } |
2009 | 1997 | ||
2010 | void KOAgenda::checkScrollBoundaries() | 1998 | void KOAgenda::checkScrollBoundaries() |
2011 | { | 1999 | { |
2012 | // Invalidate old values to force update | 2000 | // Invalidate old values to force update |
2013 | mOldLowerScrollValue = -1; | 2001 | mOldLowerScrollValue = -1; |
2014 | mOldUpperScrollValue = -1; | 2002 | mOldUpperScrollValue = -1; |
2015 | 2003 | ||
2016 | checkScrollBoundaries(verticalScrollBar()->value()); | 2004 | checkScrollBoundaries(verticalScrollBar()->value()); |
2017 | } | 2005 | } |
2018 | 2006 | ||
2019 | void KOAgenda::checkScrollBoundaries(int v) | 2007 | void KOAgenda::checkScrollBoundaries(int v) |
2020 | { | 2008 | { |
2021 | if ( mGridSpacingY == 0 ) | 2009 | if ( mGridSpacingY == 0 ) |
2022 | return; | 2010 | return; |
2023 | int yMin = v/mGridSpacingY; | 2011 | int yMin = v/mGridSpacingY; |
2024 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2012 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2025 | 2013 | ||
2026 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2014 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2027 | 2015 | ||
2028 | if (yMin != mOldLowerScrollValue) { | 2016 | if (yMin != mOldLowerScrollValue) { |
2029 | mOldLowerScrollValue = yMin; | 2017 | mOldLowerScrollValue = yMin; |
2030 | emit lowerYChanged(yMin); | 2018 | emit lowerYChanged(yMin); |
2031 | } | 2019 | } |
2032 | if (yMax != mOldUpperScrollValue) { | 2020 | if (yMax != mOldUpperScrollValue) { |
2033 | mOldUpperScrollValue = yMax; | 2021 | mOldUpperScrollValue = yMax; |
2034 | emit upperYChanged(yMax); | 2022 | emit upperYChanged(yMax); |
2035 | } | 2023 | } |
2036 | } | 2024 | } |
2037 | 2025 | ||
2038 | void KOAgenda::deselectItem() | 2026 | void KOAgenda::deselectItem() |
2039 | { | 2027 | { |
2040 | if (mSelectedItem.isNull()) return; | 2028 | if (mSelectedItem.isNull()) return; |
2041 | mSelectedItem->select(false); | 2029 | mSelectedItem->select(false); |
2042 | mSelectedItem = 0; | 2030 | mSelectedItem = 0; |
2043 | } | 2031 | } |
2044 | 2032 | ||
2045 | void KOAgenda::selectItem(KOAgendaItem *item) | 2033 | void KOAgenda::selectItem(KOAgendaItem *item) |
2046 | { | 2034 | { |
2047 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2035 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2048 | deselectItem(); | 2036 | deselectItem(); |
2049 | if (item == 0) { | 2037 | if (item == 0) { |
2050 | emit incidenceSelected( 0 ); | 2038 | emit incidenceSelected( 0 ); |
2051 | return; | 2039 | return; |
2052 | } | 2040 | } |
2053 | mSelectedItem = item; | 2041 | mSelectedItem = item; |
2054 | mSelectedItem->select(); | 2042 | mSelectedItem->select(); |
2055 | emit incidenceSelected( mSelectedItem->incidence() ); | 2043 | emit incidenceSelected( mSelectedItem->incidence() ); |
2056 | } | 2044 | } |
2057 | 2045 | ||
2058 | // This function seems never be called. | 2046 | // This function seems never be called. |
2059 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2047 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2060 | { | 2048 | { |
2061 | switch(kev->key()) { | 2049 | switch(kev->key()) { |
2062 | case Key_PageDown: | 2050 | case Key_PageDown: |
2063 | verticalScrollBar()->addPage(); | 2051 | verticalScrollBar()->addPage(); |
2064 | break; | 2052 | break; |
2065 | case Key_PageUp: | 2053 | case Key_PageUp: |
2066 | verticalScrollBar()->subtractPage(); | 2054 | verticalScrollBar()->subtractPage(); |
2067 | break; | 2055 | break; |
2068 | case Key_Down: | 2056 | case Key_Down: |
2069 | verticalScrollBar()->addLine(); | 2057 | verticalScrollBar()->addLine(); |
2070 | break; | 2058 | break; |
2071 | case Key_Up: | 2059 | case Key_Up: |
2072 | verticalScrollBar()->subtractLine(); | 2060 | verticalScrollBar()->subtractLine(); |
2073 | break; | 2061 | break; |
2074 | default: | 2062 | default: |
2075 | ; | 2063 | ; |
2076 | } | 2064 | } |
2077 | } | 2065 | } |
2078 | 2066 | ||
2079 | void KOAgenda::calculateWorkingHours() | 2067 | void KOAgenda::calculateWorkingHours() |
2080 | { | 2068 | { |
2081 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2069 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2082 | mWorkingHoursEnable = !mAllDayMode; | 2070 | mWorkingHoursEnable = !mAllDayMode; |
2083 | 2071 | ||
2084 | mWorkingHoursYTop = mGridSpacingY * | 2072 | mWorkingHoursYTop = mGridSpacingY * |
2085 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2073 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2086 | mWorkingHoursYBottom = mGridSpacingY * | 2074 | mWorkingHoursYBottom = mGridSpacingY * |
2087 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2075 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2088 | } | 2076 | } |
2089 | 2077 | ||
2090 | 2078 | ||
2091 | DateList KOAgenda::dateList() const | 2079 | DateList KOAgenda::dateList() const |
2092 | { | 2080 | { |
2093 | return mSelectedDates; | 2081 | return mSelectedDates; |
2094 | } | 2082 | } |
2095 | 2083 | ||
2096 | void KOAgenda::setDateList(const DateList &selectedDates) | 2084 | void KOAgenda::setDateList(const DateList &selectedDates) |
2097 | { | 2085 | { |
2098 | mSelectedDates = selectedDates; | 2086 | mSelectedDates = selectedDates; |
2099 | marcus_bains(); | 2087 | marcus_bains(); |
2100 | } | 2088 | } |
2101 | 2089 | ||
2102 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2090 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2103 | { | 2091 | { |
2104 | mHolidayMask = mask; | 2092 | mHolidayMask = mask; |