author | zautrix <zautrix> | 2005-07-06 11:26:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-06 11:26:40 (UTC) |
commit | 62a3094163367227c98494d7f69724aba4927584 (patch) (unidiff) | |
tree | d48fdf9012da83a68f563f24ba72cc610b38da2f | |
parent | 7e22293b1ec1ee190ca8db6c8ecd079bafdae520 (diff) | |
download | kdepimpi-62a3094163367227c98494d7f69724aba4927584.zip kdepimpi-62a3094163367227c98494d7f69724aba4927584.tar.gz kdepimpi-62a3094163367227c98494d7f69724aba4927584.tar.bz2 |
fixx
-rw-r--r-- | korganizer/koagenda.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index acdf5a0..b290020 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -331,1537 +331,1538 @@ void KOAgenda::shrinkPixmap() | |||
331 | void KOAgenda::slotContentMove(int,int) | 331 | void KOAgenda::slotContentMove(int,int) |
332 | { | 332 | { |
333 | emit sendPing(); | 333 | emit sendPing(); |
334 | if ( mActionType == NOP ) | 334 | if ( mActionType == NOP ) |
335 | slotClearSelection(); | 335 | slotClearSelection(); |
336 | if ( mSelectedItem && !mActionItem ) { | 336 | if ( mSelectedItem && !mActionItem ) { |
337 | deselectItem(); | 337 | deselectItem(); |
338 | emit incidenceSelected( 0 ); | 338 | emit incidenceSelected( 0 ); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | void KOAgenda::clear() | 341 | void KOAgenda::clear() |
342 | { | 342 | { |
343 | KOAgendaItem *item; | 343 | KOAgendaItem *item; |
344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
345 | mUnusedItems.append( item ); | 345 | mUnusedItems.append( item ); |
346 | //item->hide(); | 346 | //item->hide(); |
347 | } | 347 | } |
348 | mItems.clear(); | 348 | mItems.clear(); |
349 | mSelectedItem = 0; | 349 | mSelectedItem = 0; |
350 | clearSelection(); | 350 | clearSelection(); |
351 | } | 351 | } |
352 | 352 | ||
353 | void KOAgenda::clearSelection() | 353 | void KOAgenda::clearSelection() |
354 | { | 354 | { |
355 | mSelectionCellX = 0; | 355 | mSelectionCellX = 0; |
356 | mSelectionYTop = 0; | 356 | mSelectionYTop = 0; |
357 | mSelectionHeight = 0; | 357 | mSelectionHeight = 0; |
358 | } | 358 | } |
359 | 359 | ||
360 | void KOAgenda::marcus_bains() | 360 | void KOAgenda::marcus_bains() |
361 | { | 361 | { |
362 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 362 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | void KOAgenda::changeColumns(int columns) | 366 | void KOAgenda::changeColumns(int columns) |
367 | { | 367 | { |
368 | if (columns == 0) { | 368 | if (columns == 0) { |
369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | clear(); | 372 | clear(); |
373 | mColumns = columns; | 373 | mColumns = columns; |
374 | computeSizes(); | 374 | computeSizes(); |
375 | } | 375 | } |
376 | 376 | ||
377 | /* | 377 | /* |
378 | This is the eventFilter function, which gets all events from the KOAgendaItems | 378 | This is the eventFilter function, which gets all events from the KOAgendaItems |
379 | contained in the agenda. It has to handle moving and resizing for all items. | 379 | contained in the agenda. It has to handle moving and resizing for all items. |
380 | */ | 380 | */ |
381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
382 | { | 382 | { |
383 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 383 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
384 | switch(event->type()) { | 384 | switch(event->type()) { |
385 | case QEvent::MouseButtonPress: | 385 | case QEvent::MouseButtonPress: |
386 | case QEvent::MouseButtonDblClick: | 386 | case QEvent::MouseButtonDblClick: |
387 | case QEvent::MouseButtonRelease: | 387 | case QEvent::MouseButtonRelease: |
388 | case QEvent::MouseMove: | 388 | case QEvent::MouseMove: |
389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
390 | 390 | ||
391 | case (QEvent::Leave): | 391 | case (QEvent::Leave): |
392 | if (!mActionItem) | 392 | if (!mActionItem) |
393 | setCursor(arrowCursor); | 393 | setCursor(arrowCursor); |
394 | return true; | 394 | return true; |
395 | 395 | ||
396 | default: | 396 | default: |
397 | return QScrollView::eventFilter(object,event); | 397 | return QScrollView::eventFilter(object,event); |
398 | } | 398 | } |
399 | } | 399 | } |
400 | void KOAgenda::popupMenu() | 400 | void KOAgenda::popupMenu() |
401 | { | 401 | { |
402 | mPopupTimer->stop(); | 402 | mPopupTimer->stop(); |
403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
404 | if (mActionItem ) { | 404 | if (mActionItem ) { |
405 | endItemAction(); | 405 | endItemAction(); |
406 | } | 406 | } |
407 | mLeftMouseDown = false; // no more leftMouse computation | 407 | mLeftMouseDown = false; // no more leftMouse computation |
408 | if (mPopupItem) { | 408 | if (mPopupItem) { |
409 | //mClickedItem = mPopupItem; | 409 | //mClickedItem = mPopupItem; |
410 | selectItem(mPopupItem); | 410 | selectItem(mPopupItem); |
411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
412 | mAllAgendaPopup->installEventFilter( this ); | 412 | mAllAgendaPopup->installEventFilter( this ); |
413 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 413 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
414 | 414 | ||
415 | } | 415 | } |
416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
418 | endSelectAction( false ); // do not emit new event signal | 418 | endSelectAction( false ); // do not emit new event signal |
419 | mLeftMouseDown = false; // no more leftMouse computation | 419 | mLeftMouseDown = false; // no more leftMouse computation |
420 | } | 420 | } |
421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
422 | mNewItemPopup->installEventFilter( this ); | 422 | mNewItemPopup->installEventFilter( this ); |
423 | mNewItemPopup->popup( mPopupPos); | 423 | mNewItemPopup->popup( mPopupPos); |
424 | 424 | ||
425 | } | 425 | } |
426 | mLeftMouseDown = false; | 426 | mLeftMouseDown = false; |
427 | mPopupItem = 0; | 427 | mPopupItem = 0; |
428 | mPopupKind = 0; | 428 | mPopupKind = 0; |
429 | } | 429 | } |
430 | void KOAgenda::categoryChanged(Incidence * inc) | 430 | void KOAgenda::categoryChanged(Incidence * inc) |
431 | { | 431 | { |
432 | KOAgendaItem *item; | 432 | KOAgendaItem *item; |
433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
434 | if ( item->incidence() == inc ) { | 434 | if ( item->incidence() == inc ) { |
435 | item->initColor (); | 435 | item->initColor (); |
436 | item->updateItem(); | 436 | item->updateItem(); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | } | 439 | } |
440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
441 | { | 441 | { |
442 | 442 | ||
443 | if ( mInvalidPixmap ) { | 443 | if ( mInvalidPixmap ) { |
444 | mInvalidPixmap = false; | 444 | mInvalidPixmap = false; |
445 | qDebug("KO: Upsizing Pixmaps "); | 445 | qDebug("KO: Upsizing Pixmaps "); |
446 | computeSizes(); | 446 | computeSizes(); |
447 | emit updateViewSignal(); | 447 | emit updateViewSignal(); |
448 | return true; | 448 | return true; |
449 | } | 449 | } |
450 | emit sendPing(); | 450 | emit sendPing(); |
451 | static int startX = 0; | 451 | static int startX = 0; |
452 | static int startY = 0; | 452 | static int startY = 0; |
453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
454 | static bool blockMoving = true; | 454 | static bool blockMoving = true; |
455 | 455 | ||
456 | //qDebug("KOAgenda::eventFilter_mous "); | 456 | //qDebug("KOAgenda::eventFilter_mous "); |
457 | if ( object == mNewItemPopup ) { | 457 | if ( object == mNewItemPopup ) { |
458 | //qDebug("mNewItemPopup "); | 458 | //qDebug("mNewItemPopup "); |
459 | if ( me->type() == QEvent::MouseButtonRelease ) { | 459 | if ( me->type() == QEvent::MouseButtonRelease ) { |
460 | mNewItemPopup->removeEventFilter( this ); | 460 | mNewItemPopup->removeEventFilter( this ); |
461 | int dX = me->globalPos().x() - mPopupPos.x();; | 461 | int dX = me->globalPos().x() - mPopupPos.x();; |
462 | if ( dX < 0 ) | 462 | if ( dX < 0 ) |
463 | dX = -dX; | 463 | dX = -dX; |
464 | int dY = me->globalPos().y() - mPopupPos.y(); | 464 | int dY = me->globalPos().y() - mPopupPos.y(); |
465 | if ( dY < 0 ) | 465 | if ( dY < 0 ) |
466 | dY = -dY; | 466 | dY = -dY; |
467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
468 | mNewItemPopup->hide(); | 468 | mNewItemPopup->hide(); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | return true; | 471 | return true; |
472 | } | 472 | } |
473 | if ( object == mAllAgendaPopup ) { | 473 | if ( object == mAllAgendaPopup ) { |
474 | //qDebug(" mAllAgendaPopup "); | 474 | //qDebug(" mAllAgendaPopup "); |
475 | if ( me->type() == QEvent::MouseButtonRelease ) { | 475 | if ( me->type() == QEvent::MouseButtonRelease ) { |
476 | mAllAgendaPopup->removeEventFilter( this ); | 476 | mAllAgendaPopup->removeEventFilter( this ); |
477 | int dX = me->globalPos().x() - mPopupPos.x();; | 477 | int dX = me->globalPos().x() - mPopupPos.x();; |
478 | if ( dX < 0 ) | 478 | if ( dX < 0 ) |
479 | dX = -dX; | 479 | dX = -dX; |
480 | int dY = me->globalPos().y() - mPopupPos.y(); | 480 | int dY = me->globalPos().y() - mPopupPos.y(); |
481 | if ( dY < 0 ) | 481 | if ( dY < 0 ) |
482 | dY = -dY; | 482 | dY = -dY; |
483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
484 | mAllAgendaPopup->hide(); | 484 | mAllAgendaPopup->hide(); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | return true; | 487 | return true; |
488 | } | 488 | } |
489 | QPoint viewportPos; | 489 | QPoint viewportPos; |
490 | if (object != viewport()) { | 490 | if (object != viewport()) { |
491 | blockmoveDist = blockmoveDist*2; | 491 | blockmoveDist = blockmoveDist*2; |
492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
493 | } else { | 493 | } else { |
494 | viewportPos = me->pos(); | 494 | viewportPos = me->pos(); |
495 | } | 495 | } |
496 | bool objIsNotViewport = (object != viewport()); | 496 | bool objIsNotViewport = (object != viewport()); |
497 | bool leftButt = false; | 497 | bool leftButt = false; |
498 | #ifdef DESKTOP_VERSION | 498 | #ifdef DESKTOP_VERSION |
499 | leftButt = (me->button() == LeftButton); | 499 | leftButt = (me->button() == LeftButton); |
500 | #endif | 500 | #endif |
501 | switch (me->type()) { | 501 | switch (me->type()) { |
502 | case QEvent::MouseButtonPress: | 502 | case QEvent::MouseButtonPress: |
503 | if (me->button() == LeftButton) { | 503 | if (me->button() == LeftButton) { |
504 | mPopupTimer->start( 600 ); | 504 | mPopupTimer->start( 600 ); |
505 | mLeftMouseDown = true; | 505 | mLeftMouseDown = true; |
506 | } | 506 | } |
507 | blockMoving = true; | 507 | blockMoving = true; |
508 | startX = viewportPos.x(); | 508 | startX = viewportPos.x(); |
509 | startY = viewportPos.y(); | 509 | startY = viewportPos.y(); |
510 | mPopupPos = me->globalPos(); | 510 | mPopupPos = me->globalPos(); |
511 | if ( objIsNotViewport && !leftButt ) { | 511 | if ( objIsNotViewport && !leftButt ) { |
512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
513 | if (mAllDayMode) { | 513 | if (mAllDayMode) { |
514 | if ( tempItem->height() > 10 ) { | 514 | if ( tempItem->height() > 10 ) { |
515 | int minV = tempItem->height()/4; | 515 | int minV = tempItem->height()/4; |
516 | if ( minV > (blockmoveDist/2)-2 ) { | 516 | if ( minV > (blockmoveDist/2)-2 ) { |
517 | if ( minV > blockmoveDist ) | 517 | if ( minV > blockmoveDist ) |
518 | minV = blockmoveDist; | 518 | minV = blockmoveDist; |
519 | else | 519 | else |
520 | minV = (blockmoveDist/2); | 520 | minV = (blockmoveDist/2); |
521 | } | 521 | } |
522 | bool border = false; | 522 | bool border = false; |
523 | int diff = tempItem->y() - viewportPos.y(); | 523 | int diff = tempItem->y() - viewportPos.y(); |
524 | if ( diff < 0 ) | 524 | if ( diff < 0 ) |
525 | diff *= -1; | 525 | diff *= -1; |
526 | if ( diff < minV ) { | 526 | if ( diff < minV ) { |
527 | border = true; | 527 | border = true; |
528 | objIsNotViewport = false; | 528 | objIsNotViewport = false; |
529 | } | 529 | } |
530 | if ( ! border ) { | 530 | if ( ! border ) { |
531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
532 | if ( diff < 0 ) | 532 | if ( diff < 0 ) |
533 | diff *= -1; | 533 | diff *= -1; |
534 | if ( diff < minV ) { | 534 | if ( diff < minV ) { |
535 | border = true; | 535 | border = true; |
536 | objIsNotViewport = false; | 536 | objIsNotViewport = false; |
537 | } | 537 | } |
538 | } | 538 | } |
539 | } | 539 | } |
540 | } else { // not allday | 540 | } else { // not allday |
541 | if ( tempItem->width() > 10 ) { | 541 | if ( tempItem->width() > 10 ) { |
542 | int minH = tempItem->width()/4; | 542 | int minH = tempItem->width()/4; |
543 | if ( minH > (blockmoveDist/2)-2 ) { | 543 | if ( minH > (blockmoveDist/2)-2 ) { |
544 | if ( minH > blockmoveDist ) | 544 | if ( minH > blockmoveDist ) |
545 | minH = blockmoveDist; | 545 | minH = blockmoveDist; |
546 | else | 546 | else |
547 | minH = (blockmoveDist/2); | 547 | minH = (blockmoveDist/2); |
548 | } | 548 | } |
549 | bool border = false; | 549 | bool border = false; |
550 | int diff = tempItem->x() - viewportPos.x(); | 550 | int diff = tempItem->x() - viewportPos.x(); |
551 | if ( diff < 0 ) | 551 | if ( diff < 0 ) |
552 | diff *= -1; | 552 | diff *= -1; |
553 | if ( diff < minH ) { | 553 | if ( diff < minH ) { |
554 | border = true; | 554 | border = true; |
555 | objIsNotViewport = false; | 555 | objIsNotViewport = false; |
556 | } | 556 | } |
557 | if ( ! border ) { | 557 | if ( ! border ) { |
558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
559 | if ( diff < 0 ) | 559 | if ( diff < 0 ) |
560 | diff *= -1; | 560 | diff *= -1; |
561 | if ( diff < minH ) { | 561 | if ( diff < minH ) { |
562 | border = true; | 562 | border = true; |
563 | objIsNotViewport = false; | 563 | objIsNotViewport = false; |
564 | } | 564 | } |
565 | } | 565 | } |
566 | } | 566 | } |
567 | } | 567 | } |
568 | } | 568 | } |
569 | if ( objIsNotViewport ) { | 569 | if ( objIsNotViewport ) { |
570 | mPopupItem = (KOAgendaItem *)object; | 570 | mPopupItem = (KOAgendaItem *)object; |
571 | mPopupKind = 1; | 571 | mPopupKind = 1; |
572 | if (me->button() == RightButton) { | 572 | if (me->button() == RightButton) { |
573 | mPopupKind = 3; | 573 | mPopupKind = 3; |
574 | popupMenu(); | 574 | popupMenu(); |
575 | } else if (me->button() == LeftButton) { | 575 | } else if (me->button() == LeftButton) { |
576 | mActionItem = (KOAgendaItem *)object; | 576 | mActionItem = (KOAgendaItem *)object; |
577 | if (mActionItem) { | 577 | if (mActionItem) { |
578 | emit signalClearSelection(); | 578 | emit signalClearSelection(); |
579 | slotClearSelection(); | 579 | slotClearSelection(); |
580 | selectItem(mActionItem); | 580 | selectItem(mActionItem); |
581 | Incidence *incidence = mActionItem->incidence(); | 581 | Incidence *incidence = mActionItem->incidence(); |
582 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 582 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
583 | mActionItem = 0; | 583 | mActionItem = 0; |
584 | } else { | 584 | } else { |
585 | startItemAction(viewportPos); | 585 | startItemAction(viewportPos); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } else { // ---------- viewport() | 589 | } else { // ---------- viewport() |
590 | mPopupItem = 0; | 590 | mPopupItem = 0; |
591 | mPopupKind = 2; | 591 | mPopupKind = 2; |
592 | selectItem(0); | 592 | selectItem(0); |
593 | mActionItem = 0; | 593 | mActionItem = 0; |
594 | if (me->button() == RightButton) { | 594 | if (me->button() == RightButton) { |
595 | int x,y; | 595 | int x,y; |
596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
597 | int gx,gy; | 597 | int gx,gy; |
598 | contentsToGrid(x,y,gx,gy); | 598 | contentsToGrid(x,y,gx,gy); |
599 | mCurrentCellX = gx; | 599 | mCurrentCellX = gx; |
600 | mCurrentCellY = gy; | 600 | mCurrentCellY = gy; |
601 | mStartCellX = gx; | 601 | mStartCellX = gx; |
602 | mStartCellY = gy; | 602 | mStartCellY = gy; |
603 | mPopupKind = 4; | 603 | mPopupKind = 4; |
604 | popupMenu(); | 604 | popupMenu(); |
605 | } else if (me->button() == LeftButton) { | 605 | } else if (me->button() == LeftButton) { |
606 | setCursor(arrowCursor); | 606 | setCursor(arrowCursor); |
607 | startSelectAction(viewportPos); | 607 | startSelectAction(viewportPos); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | break; | 610 | break; |
611 | 611 | ||
612 | case QEvent::MouseButtonRelease: | 612 | case QEvent::MouseButtonRelease: |
613 | if (me->button() == LeftButton ) { | 613 | if (me->button() == LeftButton ) { |
614 | mPopupTimer->stop(); | 614 | mPopupTimer->stop(); |
615 | } | 615 | } |
616 | if (object != viewport()) { | 616 | if (object != viewport()) { |
617 | if (me->button() == LeftButton && mLeftMouseDown) { | 617 | if (me->button() == LeftButton && mLeftMouseDown) { |
618 | if (mActionItem) { | 618 | if (mActionItem) { |
619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
622 | mScrollUpTimer.stop(); | 622 | mScrollUpTimer.stop(); |
623 | mScrollDownTimer.stop(); | 623 | mScrollDownTimer.stop(); |
624 | mActionItem->resetMove(); | 624 | mActionItem->resetMove(); |
625 | placeSubCells( mActionItem ); | 625 | placeSubCells( mActionItem ); |
626 | // emit startDragSignal( mActionItem->incidence() ); | 626 | // emit startDragSignal( mActionItem->incidence() ); |
627 | setCursor( arrowCursor ); | 627 | setCursor( arrowCursor ); |
628 | mActionItem = 0; | 628 | mActionItem = 0; |
629 | mActionType = NOP; | 629 | mActionType = NOP; |
630 | mItemMoved = 0; | 630 | mItemMoved = 0; |
631 | mLeftMouseDown = false; | 631 | mLeftMouseDown = false; |
632 | return true; | 632 | return true; |
633 | } | 633 | } |
634 | endItemAction(); | 634 | endItemAction(); |
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | } else { // ---------- viewport() | 638 | } else { // ---------- viewport() |
639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
640 | endSelectAction( true ); // emit new event signal | 640 | endSelectAction( true ); // emit new event signal |
641 | } | 641 | } |
642 | } | 642 | } |
643 | if (me->button() == LeftButton) | 643 | if (me->button() == LeftButton) |
644 | mLeftMouseDown = false; | 644 | mLeftMouseDown = false; |
645 | 645 | ||
646 | break; | 646 | break; |
647 | 647 | ||
648 | case QEvent::MouseMove: | 648 | case QEvent::MouseMove: |
649 | //qDebug("mm "); | 649 | //qDebug("mm "); |
650 | if ( !mLeftMouseDown ) | 650 | if ( !mLeftMouseDown ) |
651 | return false; | 651 | return false; |
652 | if ( blockMoving ) { | 652 | if ( blockMoving ) { |
653 | int dX, dY; | 653 | int dX, dY; |
654 | dX = startX - viewportPos.x(); | 654 | dX = startX - viewportPos.x(); |
655 | if ( dX < 0 ) | 655 | if ( dX < 0 ) |
656 | dX = -dX; | 656 | dX = -dX; |
657 | dY = viewportPos.y() - startY; | 657 | dY = viewportPos.y() - startY; |
658 | if ( dY < 0 ) | 658 | if ( dY < 0 ) |
659 | dY = -dY; | 659 | dY = -dY; |
660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
662 | blockMoving = false; | 662 | blockMoving = false; |
663 | } | 663 | } |
664 | } | 664 | } |
665 | if ( ! blockMoving ) | 665 | if ( ! blockMoving ) |
666 | mPopupTimer->stop(); | 666 | mPopupTimer->stop(); |
667 | if (object != viewport()) { | 667 | if (object != viewport()) { |
668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
669 | if (!moveItem->incidence()->isReadOnly() ) { | 669 | if (!moveItem->incidence()->isReadOnly() ) { |
670 | if (!mActionItem) | 670 | if (!mActionItem) |
671 | setNoActionCursor(moveItem,viewportPos); | 671 | setNoActionCursor(moveItem,viewportPos); |
672 | else { | 672 | else { |
673 | if ( !blockMoving ) | 673 | if ( !blockMoving ) |
674 | performItemAction(viewportPos); | 674 | performItemAction(viewportPos); |
675 | } | 675 | } |
676 | } | 676 | } |
677 | } else { // ---------- viewport() | 677 | } else { // ---------- viewport() |
678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
679 | if ( mActionType == SELECT ) { | 679 | if ( mActionType == SELECT ) { |
680 | performSelectAction( viewportPos ); | 680 | performSelectAction( viewportPos ); |
681 | } | 681 | } |
682 | } | 682 | } |
683 | break; | 683 | break; |
684 | 684 | ||
685 | case QEvent::MouseButtonDblClick: | 685 | case QEvent::MouseButtonDblClick: |
686 | mPopupTimer->stop(); | 686 | mPopupTimer->stop(); |
687 | if (object == viewport()) { | 687 | if (object == viewport()) { |
688 | selectItem(0); | 688 | selectItem(0); |
689 | int x,y; | 689 | int x,y; |
690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
691 | int gx,gy; | 691 | int gx,gy; |
692 | contentsToGrid(x,y,gx,gy); | 692 | contentsToGrid(x,y,gx,gy); |
693 | emit newEventSignal(gx,gy); | 693 | emit newEventSignal(gx,gy); |
694 | } else { | 694 | } else { |
695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
696 | selectItem(doubleClickedItem); | 696 | selectItem(doubleClickedItem); |
697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
698 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 698 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
699 | else | 699 | else |
700 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 700 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
701 | } | 701 | } |
702 | break; | 702 | break; |
703 | 703 | ||
704 | default: | 704 | default: |
705 | break; | 705 | break; |
706 | } | 706 | } |
707 | return true; | 707 | return true; |
708 | 708 | ||
709 | } | 709 | } |
710 | 710 | ||
711 | void KOAgenda::newItem( int item ) | 711 | void KOAgenda::newItem( int item ) |
712 | { | 712 | { |
713 | if ( item == 1 ) { //new event | 713 | if ( item == 1 ) { //new event |
714 | newEventSignal(mStartCellX ,mStartCellY ); | 714 | newEventSignal(mStartCellX ,mStartCellY ); |
715 | } else | 715 | } else |
716 | if ( item == 2 ) { //new event | 716 | if ( item == 2 ) { //new event |
717 | newTodoSignal(mStartCellX ,mStartCellY ); | 717 | newTodoSignal(mStartCellX ,mStartCellY ); |
718 | } else | 718 | } else |
719 | { | 719 | { |
720 | emit showDateView( item, mStartCellX ); | 720 | emit showDateView( item, mStartCellX ); |
721 | // 3Day view | 721 | // 3Day view |
722 | // 4Week view | 722 | // 4Week view |
723 | // 5Month view | 723 | // 5Month view |
724 | // 6Journal view | 724 | // 6Journal view |
725 | } | 725 | } |
726 | } | 726 | } |
727 | void KOAgenda::slotClearSelection() | 727 | void KOAgenda::slotClearSelection() |
728 | { | 728 | { |
729 | if (mSelectionHeight) { | 729 | if (mSelectionHeight) { |
730 | int selectionX = mSelectionCellX * mGridSpacingX; | 730 | int selectionX = mSelectionCellX * mGridSpacingX; |
731 | int top = mSelectionYTop - 2 *mGridSpacingY; | 731 | int top = mSelectionYTop - 2 *mGridSpacingY; |
732 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 732 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
733 | clearSelection(); | 733 | clearSelection(); |
734 | repaintContents( selectionX, top, | 734 | repaintContents( selectionX, top, |
735 | mGridSpacingX, hei ,false ); | 735 | mGridSpacingX, hei ,false ); |
736 | } | 736 | } |
737 | 737 | ||
738 | } | 738 | } |
739 | void KOAgenda::startSelectAction(QPoint viewportPos) | 739 | void KOAgenda::startSelectAction(QPoint viewportPos) |
740 | { | 740 | { |
741 | 741 | ||
742 | emit signalClearSelection(); | 742 | emit signalClearSelection(); |
743 | slotClearSelection(); | 743 | slotClearSelection(); |
744 | 744 | ||
745 | mActionType = SELECT; | 745 | mActionType = SELECT; |
746 | 746 | ||
747 | int x,y; | 747 | int x,y; |
748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
749 | int gx,gy; | 749 | int gx,gy; |
750 | contentsToGrid(x,y,gx,gy); | 750 | contentsToGrid(x,y,gx,gy); |
751 | 751 | ||
752 | mStartCellX = gx; | 752 | mStartCellX = gx; |
753 | mStartCellY = gy; | 753 | mStartCellY = gy; |
754 | mCurrentCellX = gx; | 754 | mCurrentCellX = gx; |
755 | mCurrentCellY = gy; | 755 | mCurrentCellY = gy; |
756 | 756 | ||
757 | // Store new selection | 757 | // Store new selection |
758 | mSelectionCellX = gx; | 758 | mSelectionCellX = gx; |
759 | mSelectionYTop = gy * mGridSpacingY; | 759 | mSelectionYTop = gy * mGridSpacingY; |
760 | mSelectionHeight = mGridSpacingY; | 760 | mSelectionHeight = mGridSpacingY; |
761 | 761 | ||
762 | // Paint new selection | 762 | // Paint new selection |
763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
764 | mGridSpacingX-1, mSelectionHeight ); | 764 | mGridSpacingX-1, mSelectionHeight ); |
765 | } | 765 | } |
766 | 766 | ||
767 | void KOAgenda::performSelectAction(QPoint viewportPos) | 767 | void KOAgenda::performSelectAction(QPoint viewportPos) |
768 | { | 768 | { |
769 | int x,y; | 769 | int x,y; |
770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
771 | int gx,gy; | 771 | int gx,gy; |
772 | contentsToGrid(x,y,gx,gy); | 772 | contentsToGrid(x,y,gx,gy); |
773 | 773 | ||
774 | QPoint clipperPos = clipper()-> | 774 | QPoint clipperPos = clipper()-> |
775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
776 | 776 | ||
777 | // Scroll if cursor was moved to upper or lower end of agenda. | 777 | // Scroll if cursor was moved to upper or lower end of agenda. |
778 | if (clipperPos.y() < mScrollBorderWidth) { | 778 | if (clipperPos.y() < mScrollBorderWidth) { |
779 | mScrollUpTimer.start(mScrollDelay); | 779 | mScrollUpTimer.start(mScrollDelay); |
780 | } else if (visibleHeight() - clipperPos.y() < | 780 | } else if (visibleHeight() - clipperPos.y() < |
781 | mScrollBorderWidth) { | 781 | mScrollBorderWidth) { |
782 | mScrollDownTimer.start(mScrollDelay); | 782 | mScrollDownTimer.start(mScrollDelay); |
783 | } else { | 783 | } else { |
784 | mScrollUpTimer.stop(); | 784 | mScrollUpTimer.stop(); |
785 | mScrollDownTimer.stop(); | 785 | mScrollDownTimer.stop(); |
786 | } | 786 | } |
787 | 787 | ||
788 | if ( gy > mCurrentCellY ) { | 788 | if ( gy > mCurrentCellY ) { |
789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
790 | 790 | ||
791 | 791 | ||
792 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 792 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
794 | mGridSpacingX, mSelectionYTop, | 794 | mGridSpacingX, mSelectionYTop, |
795 | mGridSpacingX, mSelectionHeight , false); | 795 | mGridSpacingX, mSelectionHeight , false); |
796 | 796 | ||
797 | mCurrentCellY = gy; | 797 | mCurrentCellY = gy; |
798 | } else if ( gy < mCurrentCellY ) { | 798 | } else if ( gy < mCurrentCellY ) { |
799 | if ( gy >= mStartCellY ) { | 799 | if ( gy >= mStartCellY ) { |
800 | int selectionHeight = mSelectionHeight; | 800 | int selectionHeight = mSelectionHeight; |
801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
802 | 802 | ||
803 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 803 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
805 | mGridSpacingX, mSelectionYTop, | 805 | mGridSpacingX, mSelectionYTop, |
806 | mGridSpacingX, selectionHeight,false ); | 806 | mGridSpacingX, selectionHeight,false ); |
807 | 807 | ||
808 | mCurrentCellY = gy; | 808 | mCurrentCellY = gy; |
809 | } else { | 809 | } else { |
810 | } | 810 | } |
811 | } | 811 | } |
812 | } | 812 | } |
813 | 813 | ||
814 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 814 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
815 | { | 815 | { |
816 | mActionType = NOP; | 816 | mActionType = NOP; |
817 | mScrollUpTimer.stop(); | 817 | mScrollUpTimer.stop(); |
818 | mScrollDownTimer.stop(); | 818 | mScrollDownTimer.stop(); |
819 | 819 | ||
820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
823 | } | 823 | } |
824 | } | 824 | } |
825 | 825 | ||
826 | void KOAgenda::startItemAction(QPoint viewportPos) | 826 | void KOAgenda::startItemAction(QPoint viewportPos) |
827 | { | 827 | { |
828 | int x,y; | 828 | int x,y; |
829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
830 | int gx,gy; | 830 | int gx,gy; |
831 | contentsToGrid(x,y,gx,gy); | 831 | contentsToGrid(x,y,gx,gy); |
832 | 832 | ||
833 | mStartCellX = gx; | 833 | mStartCellX = gx; |
834 | mStartCellY = gy; | 834 | mStartCellY = gy; |
835 | mCurrentCellX = gx; | 835 | mCurrentCellX = gx; |
836 | mCurrentCellY = gy; | 836 | mCurrentCellY = gy; |
837 | 837 | ||
838 | if (mAllDayMode) { | 838 | if (mAllDayMode) { |
839 | int gridDistanceX = (x - gx * mGridSpacingX); | 839 | int gridDistanceX = (x - gx * mGridSpacingX); |
840 | if (gridDistanceX < mResizeBorderWidth && | 840 | if (gridDistanceX < mResizeBorderWidth && |
841 | mActionItem->cellX() == mCurrentCellX) { | 841 | mActionItem->cellX() == mCurrentCellX) { |
842 | mActionType = RESIZELEFT; | 842 | mActionType = RESIZELEFT; |
843 | setCursor(sizeHorCursor); | 843 | setCursor(sizeHorCursor); |
844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
845 | mActionItem->cellXWidth() == mCurrentCellX) { | 845 | mActionItem->cellXWidth() == mCurrentCellX) { |
846 | mActionType = RESIZERIGHT; | 846 | mActionType = RESIZERIGHT; |
847 | setCursor(sizeHorCursor); | 847 | setCursor(sizeHorCursor); |
848 | } else { | 848 | } else { |
849 | mActionType = MOVE; | 849 | mActionType = MOVE; |
850 | mActionItem->startMove(); | 850 | mActionItem->startMove(); |
851 | setCursor(sizeAllCursor); | 851 | setCursor(sizeAllCursor); |
852 | } | 852 | } |
853 | } else { | 853 | } else { |
854 | int gridDistanceY = (y - gy * mGridSpacingY); | 854 | int gridDistanceY = (y - gy * mGridSpacingY); |
855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | 855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); |
856 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 856 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
857 | mActionItem->cellYTop() == mCurrentCellY && | 857 | mActionItem->cellYTop() == mCurrentCellY && |
858 | !mActionItem->firstMultiItem()) { | 858 | !mActionItem->firstMultiItem()) { |
859 | mActionType = RESIZETOP; | 859 | mActionType = RESIZETOP; |
860 | setCursor(sizeVerCursor); | 860 | setCursor(sizeVerCursor); |
861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
862 | mActionItem->cellYBottom() == mCurrentCellY && | 862 | mActionItem->cellYBottom() == mCurrentCellY && |
863 | !mActionItem->lastMultiItem()) { | 863 | !mActionItem->lastMultiItem()) { |
864 | mActionType = RESIZEBOTTOM; | 864 | mActionType = RESIZEBOTTOM; |
865 | setCursor(sizeVerCursor); | 865 | setCursor(sizeVerCursor); |
866 | } else { | 866 | } else { |
867 | mActionType = MOVE; | 867 | mActionType = MOVE; |
868 | mActionItem->startMove(); | 868 | mActionItem->startMove(); |
869 | setCursor(sizeAllCursor); | 869 | setCursor(sizeAllCursor); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | void KOAgenda::performItemAction(QPoint viewportPos) | 874 | void KOAgenda::performItemAction(QPoint viewportPos) |
875 | { | 875 | { |
876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
877 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 877 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
879 | // point = clipper()->mapFromGlobal(point); | 879 | // point = clipper()->mapFromGlobal(point); |
880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
881 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 881 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
882 | int x,y; | 882 | int x,y; |
883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
885 | int gx,gy; | 885 | int gx,gy; |
886 | contentsToGrid(x,y,gx,gy); | 886 | contentsToGrid(x,y,gx,gy); |
887 | QPoint clipperPos = clipper()-> | 887 | QPoint clipperPos = clipper()-> |
888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
889 | 889 | ||
890 | // Cursor left active agenda area. | 890 | // Cursor left active agenda area. |
891 | // This starts a drag. | 891 | // This starts a drag. |
892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
894 | if ( mActionType == MOVE ) { | 894 | if ( mActionType == MOVE ) { |
895 | mScrollUpTimer.stop(); | 895 | mScrollUpTimer.stop(); |
896 | mScrollDownTimer.stop(); | 896 | mScrollDownTimer.stop(); |
897 | mActionItem->resetMove(); | 897 | mActionItem->resetMove(); |
898 | placeSubCells( mActionItem ); | 898 | placeSubCells( mActionItem ); |
899 | // emit startDragSignal( mActionItem->incidence() ); | 899 | // emit startDragSignal( mActionItem->incidence() ); |
900 | setCursor( arrowCursor ); | 900 | setCursor( arrowCursor ); |
901 | mActionItem = 0; | 901 | mActionItem = 0; |
902 | mActionType = NOP; | 902 | mActionType = NOP; |
903 | mItemMoved = 0; | 903 | mItemMoved = 0; |
904 | return; | 904 | return; |
905 | } | 905 | } |
906 | } else { | 906 | } else { |
907 | switch ( mActionType ) { | 907 | switch ( mActionType ) { |
908 | case MOVE: | 908 | case MOVE: |
909 | setCursor( sizeAllCursor ); | 909 | setCursor( sizeAllCursor ); |
910 | break; | 910 | break; |
911 | case RESIZETOP: | 911 | case RESIZETOP: |
912 | case RESIZEBOTTOM: | 912 | case RESIZEBOTTOM: |
913 | setCursor( sizeVerCursor ); | 913 | setCursor( sizeVerCursor ); |
914 | break; | 914 | break; |
915 | case RESIZELEFT: | 915 | case RESIZELEFT: |
916 | case RESIZERIGHT: | 916 | case RESIZERIGHT: |
917 | setCursor( sizeHorCursor ); | 917 | setCursor( sizeHorCursor ); |
918 | break; | 918 | break; |
919 | default: | 919 | default: |
920 | setCursor( arrowCursor ); | 920 | setCursor( arrowCursor ); |
921 | } | 921 | } |
922 | } | 922 | } |
923 | 923 | ||
924 | // Scroll if item was moved to upper or lower end of agenda. | 924 | // Scroll if item was moved to upper or lower end of agenda. |
925 | if (clipperPos.y() < mScrollBorderWidth) { | 925 | if (clipperPos.y() < mScrollBorderWidth) { |
926 | mScrollUpTimer.start(mScrollDelay); | 926 | mScrollUpTimer.start(mScrollDelay); |
927 | } else if (visibleHeight() - clipperPos.y() < | 927 | } else if (visibleHeight() - clipperPos.y() < |
928 | mScrollBorderWidth) { | 928 | mScrollBorderWidth) { |
929 | mScrollDownTimer.start(mScrollDelay); | 929 | mScrollDownTimer.start(mScrollDelay); |
930 | } else { | 930 | } else { |
931 | mScrollUpTimer.stop(); | 931 | mScrollUpTimer.stop(); |
932 | mScrollDownTimer.stop(); | 932 | mScrollDownTimer.stop(); |
933 | } | 933 | } |
934 | 934 | ||
935 | // Move or resize item if necessary | 935 | // Move or resize item if necessary |
936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
937 | mItemMoved = true; | 937 | mItemMoved = true; |
938 | mActionItem->raise(); | 938 | mActionItem->raise(); |
939 | if (mActionType == MOVE) { | 939 | if (mActionType == MOVE) { |
940 | // Move all items belonging to a multi item | 940 | // Move all items belonging to a multi item |
941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
943 | if (!moveItem) moveItem = mActionItem; | 943 | if (!moveItem) moveItem = mActionItem; |
944 | while (moveItem) { | 944 | while (moveItem) { |
945 | int dy; | 945 | int dy; |
946 | if (isMultiItem) dy = 0; | 946 | if (isMultiItem) dy = 0; |
947 | else dy = gy - mCurrentCellY; | 947 | else dy = gy - mCurrentCellY; |
948 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 948 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
949 | int x,y; | 949 | int x,y; |
950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
952 | mGridSpacingY * moveItem->cellHeight()); | 952 | mGridSpacingY * moveItem->cellHeight()); |
953 | moveItem->raise(); | 953 | moveItem->raise(); |
954 | moveChild(moveItem,x,y); | 954 | moveChild(moveItem,x,y); |
955 | moveItem = moveItem->nextMultiItem(); | 955 | moveItem = moveItem->nextMultiItem(); |
956 | } | 956 | } |
957 | } else if (mActionType == RESIZETOP) { | 957 | } else if (mActionType == RESIZETOP) { |
958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
959 | mActionItem->expandTop(gy - mCurrentCellY); | 959 | mActionItem->expandTop(gy - mCurrentCellY); |
960 | mActionItem->resize(mActionItem->width(), | 960 | mActionItem->resize(mActionItem->width(), |
961 | mGridSpacingY * mActionItem->cellHeight()); | 961 | mGridSpacingY * mActionItem->cellHeight()); |
962 | int x,y; | 962 | int x,y; |
963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
964 | //moveChild(mActionItem,childX(mActionItem),y); | 964 | //moveChild(mActionItem,childX(mActionItem),y); |
965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
966 | } | 966 | } |
967 | } else if (mActionType == RESIZEBOTTOM) { | 967 | } else if (mActionType == RESIZEBOTTOM) { |
968 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 968 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
969 | mActionItem->expandBottom(gy - mCurrentCellY); | 969 | mActionItem->expandBottom(gy - mCurrentCellY); |
970 | mActionItem->resize(mActionItem->width(), | 970 | mActionItem->resize(mActionItem->width(), |
971 | mGridSpacingY * mActionItem->cellHeight()); | 971 | mGridSpacingY * mActionItem->cellHeight()); |
972 | } | 972 | } |
973 | } else if (mActionType == RESIZELEFT) { | 973 | } else if (mActionType == RESIZELEFT) { |
974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
975 | mActionItem->expandLeft(gx - mCurrentCellX); | 975 | mActionItem->expandLeft(gx - mCurrentCellX); |
976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
977 | mActionItem->height()); | 977 | mActionItem->height()); |
978 | int x,y; | 978 | int x,y; |
979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
980 | moveChild(mActionItem,x,childY(mActionItem)); | 980 | moveChild(mActionItem,x,childY(mActionItem)); |
981 | } | 981 | } |
982 | } else if (mActionType == RESIZERIGHT) { | 982 | } else if (mActionType == RESIZERIGHT) { |
983 | if (mCurrentCellX >= mActionItem->cellX()) { | 983 | if (mCurrentCellX >= mActionItem->cellX()) { |
984 | mActionItem->expandRight(gx - mCurrentCellX); | 984 | mActionItem->expandRight(gx - mCurrentCellX); |
985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
986 | mActionItem->height()); | 986 | mActionItem->height()); |
987 | } | 987 | } |
988 | } | 988 | } |
989 | mCurrentCellX = gx; | 989 | mCurrentCellX = gx; |
990 | mCurrentCellY = gy; | 990 | mCurrentCellY = gy; |
991 | } | 991 | } |
992 | } | 992 | } |
993 | 993 | ||
994 | void KOAgenda::endItemAction() | 994 | void KOAgenda::endItemAction() |
995 | { | 995 | { |
996 | 996 | ||
997 | if ( mItemMoved ) { | 997 | if ( mItemMoved ) { |
998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
999 | if ( !placeItem ) { | 999 | if ( !placeItem ) { |
1000 | placeItem = mActionItem; | 1000 | placeItem = mActionItem; |
1001 | } | 1001 | } |
1002 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 1002 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
1003 | Incidence* oldInc = placeItem->incidence(); | 1003 | Incidence* oldInc = placeItem->incidence(); |
1004 | placeItem->recreateIncidence(); | 1004 | placeItem->recreateIncidence(); |
1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1006 | } | 1006 | } |
1007 | int type = mActionType; | 1007 | int type = mActionType; |
1008 | if ( mAllDayMode ) | 1008 | if ( mAllDayMode ) |
1009 | type = -1; | 1009 | type = -1; |
1010 | KOAgendaItem *modifiedItem = placeItem; | 1010 | KOAgendaItem *modifiedItem = placeItem; |
1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1013 | KOAgendaItem *item; | 1013 | KOAgendaItem *item; |
1014 | 1014 | ||
1015 | if ( placeItem->incidence()->typeID() == todoID ) { | 1015 | if ( placeItem->incidence()->typeID() == todoID ) { |
1016 | mSelectedItem = 0; | 1016 | mSelectedItem = 0; |
1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1019 | emit itemModified( modifiedItem, mActionType ); | 1019 | emit itemModified( modifiedItem, mActionType ); |
1020 | } | 1020 | } |
1021 | else { | 1021 | else { |
1022 | 1022 | ||
1023 | 1023 | ||
1024 | globalFlagBlockAgendaItemPaint = 1; | 1024 | globalFlagBlockAgendaItemPaint = 1; |
1025 | for ( item=oldconflictItems.first(); item != 0; | 1025 | for ( item=oldconflictItems.first(); item != 0; |
1026 | item=oldconflictItems.next() ) { | 1026 | item=oldconflictItems.next() ) { |
1027 | placeSubCells(item); | 1027 | placeSubCells(item); |
1028 | } | 1028 | } |
1029 | while ( placeItem ) { | 1029 | while ( placeItem ) { |
1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1031 | oldconflictItems = placeItem->conflictItems(); | 1031 | oldconflictItems = placeItem->conflictItems(); |
1032 | for ( item=oldconflictItems.first(); item != 0; | 1032 | for ( item=oldconflictItems.first(); item != 0; |
1033 | item=oldconflictItems.next() ) { | 1033 | item=oldconflictItems.next() ) { |
1034 | placeSubCells(item); | 1034 | placeSubCells(item); |
1035 | } | 1035 | } |
1036 | placeSubCells( placeItem ); | 1036 | placeSubCells( placeItem ); |
1037 | placeItem = placeItem->nextMultiItem(); | 1037 | placeItem = placeItem->nextMultiItem(); |
1038 | } | 1038 | } |
1039 | globalFlagBlockAgendaItemPaint = 0; | 1039 | globalFlagBlockAgendaItemPaint = 0; |
1040 | for ( item=oldconflictItems.first(); item != 0; | 1040 | for ( item=oldconflictItems.first(); item != 0; |
1041 | item=oldconflictItems.next() ) { | 1041 | item=oldconflictItems.next() ) { |
1042 | globalFlagBlockAgendaItemUpdate = 0; | 1042 | globalFlagBlockAgendaItemUpdate = 0; |
1043 | item->repaintMe(); | 1043 | item->repaintMe(); |
1044 | globalFlagBlockAgendaItemUpdate = 1; | 1044 | globalFlagBlockAgendaItemUpdate = 1; |
1045 | item->repaint( false ); | 1045 | item->repaint( false ); |
1046 | } | 1046 | } |
1047 | placeItem = modifiedItem; | 1047 | placeItem = modifiedItem; |
1048 | 1048 | ||
1049 | while ( placeItem ) { | 1049 | while ( placeItem ) { |
1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1051 | globalFlagBlockAgendaItemUpdate = 0; | 1051 | globalFlagBlockAgendaItemUpdate = 0; |
1052 | placeItem->repaintMe(); | 1052 | placeItem->repaintMe(); |
1053 | globalFlagBlockAgendaItemUpdate = 1; | 1053 | globalFlagBlockAgendaItemUpdate = 1; |
1054 | placeItem->repaint(false); | 1054 | placeItem->repaint(false); |
1055 | placeItem = placeItem->nextMultiItem(); | 1055 | placeItem = placeItem->nextMultiItem(); |
1056 | } | 1056 | } |
1057 | emit itemModified( modifiedItem, mActionType ); | 1057 | emit itemModified( modifiedItem, mActionType ); |
1058 | 1058 | ||
1059 | 1059 | ||
1060 | placeItem = modifiedItem; | 1060 | placeItem = modifiedItem; |
1061 | while ( placeItem ) { | 1061 | while ( placeItem ) { |
1062 | oldconflictItems = placeItem->conflictItems(); | 1062 | oldconflictItems = placeItem->conflictItems(); |
1063 | for ( item=oldconflictItems.first(); item != 0; | 1063 | for ( item=oldconflictItems.first(); item != 0; |
1064 | item=oldconflictItems.next() ) { | 1064 | item=oldconflictItems.next() ) { |
1065 | placeSubCells(item); | 1065 | placeSubCells(item); |
1066 | } | 1066 | } |
1067 | placeSubCells( placeItem ); | 1067 | placeSubCells( placeItem ); |
1068 | placeItem = placeItem->nextMultiItem(); | 1068 | placeItem = placeItem->nextMultiItem(); |
1069 | 1069 | ||
1070 | } | 1070 | } |
1071 | placeItem = modifiedItem; | 1071 | placeItem = modifiedItem; |
1072 | while ( placeItem ) { | 1072 | while ( placeItem ) { |
1073 | oldconflictItems = placeItem->conflictItems(); | 1073 | oldconflictItems = placeItem->conflictItems(); |
1074 | for ( item=oldconflictItems.first(); item != 0; | 1074 | for ( item=oldconflictItems.first(); item != 0; |
1075 | item=oldconflictItems.next() ) { | 1075 | item=oldconflictItems.next() ) { |
1076 | globalFlagBlockAgendaItemUpdate = 0; | 1076 | globalFlagBlockAgendaItemUpdate = 0; |
1077 | item->repaintMe(); | 1077 | item->repaintMe(); |
1078 | globalFlagBlockAgendaItemUpdate = 1; | 1078 | globalFlagBlockAgendaItemUpdate = 1; |
1079 | item->repaint(false); | 1079 | item->repaint(false); |
1080 | } | 1080 | } |
1081 | placeItem = placeItem->nextMultiItem(); | 1081 | placeItem = placeItem->nextMultiItem(); |
1082 | } | 1082 | } |
1083 | /* | 1083 | /* |
1084 | 1084 | ||
1085 | oldconflictItems = modifiedItem->conflictItems(); | 1085 | oldconflictItems = modifiedItem->conflictItems(); |
1086 | for ( item=oldconflictItems.first(); item != 0; | 1086 | for ( item=oldconflictItems.first(); item != 0; |
1087 | item=oldconflictItems.next() ) { | 1087 | item=oldconflictItems.next() ) { |
1088 | globalFlagBlockAgendaItemUpdate = 0; | 1088 | globalFlagBlockAgendaItemUpdate = 0; |
1089 | item->paintMe(false); | 1089 | item->paintMe(false); |
1090 | globalFlagBlockAgendaItemUpdate = 1; | 1090 | globalFlagBlockAgendaItemUpdate = 1; |
1091 | item->repaint(false); | 1091 | item->repaint(false); |
1092 | } | 1092 | } |
1093 | */ | 1093 | */ |
1094 | 1094 | ||
1095 | 1095 | ||
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | } | 1098 | } |
1099 | 1099 | if ( mActionItem ) | |
1100 | emit incidenceSelected( mActionItem->incidence() ); | ||
1100 | mScrollUpTimer.stop(); | 1101 | mScrollUpTimer.stop(); |
1101 | mScrollDownTimer.stop(); | 1102 | mScrollDownTimer.stop(); |
1102 | setCursor( arrowCursor ); | 1103 | setCursor( arrowCursor ); |
1103 | mActionItem = 0; | 1104 | mActionItem = 0; |
1104 | mActionType = NOP; | 1105 | mActionType = NOP; |
1105 | mItemMoved = 0; | 1106 | mItemMoved = 0; |
1106 | 1107 | ||
1107 | } | 1108 | } |
1108 | 1109 | ||
1109 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1110 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1110 | { | 1111 | { |
1111 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1112 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1112 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1113 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1113 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1114 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1114 | // point = clipper()->mapFromGlobal(point); | 1115 | // point = clipper()->mapFromGlobal(point); |
1115 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1116 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1116 | 1117 | ||
1117 | int x,y; | 1118 | int x,y; |
1118 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1119 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1119 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1120 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1120 | int gx,gy; | 1121 | int gx,gy; |
1121 | contentsToGrid(x,y,gx,gy); | 1122 | contentsToGrid(x,y,gx,gy); |
1122 | 1123 | ||
1123 | // Change cursor to resize cursor if appropriate | 1124 | // Change cursor to resize cursor if appropriate |
1124 | if (mAllDayMode) { | 1125 | if (mAllDayMode) { |
1125 | int gridDistanceX = (x - gx * mGridSpacingX); | 1126 | int gridDistanceX = (x - gx * mGridSpacingX); |
1126 | if (gridDistanceX < mResizeBorderWidth && | 1127 | if (gridDistanceX < mResizeBorderWidth && |
1127 | moveItem->cellX() == gx) { | 1128 | moveItem->cellX() == gx) { |
1128 | setCursor(sizeHorCursor); | 1129 | setCursor(sizeHorCursor); |
1129 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1130 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1130 | moveItem->cellXWidth() == gx) { | 1131 | moveItem->cellXWidth() == gx) { |
1131 | setCursor(sizeHorCursor); | 1132 | setCursor(sizeHorCursor); |
1132 | } else { | 1133 | } else { |
1133 | setCursor(arrowCursor); | 1134 | setCursor(arrowCursor); |
1134 | } | 1135 | } |
1135 | } else { | 1136 | } else { |
1136 | int gridDistanceY = (y - gy * mGridSpacingY); | 1137 | int gridDistanceY = (y - gy * mGridSpacingY); |
1137 | if (gridDistanceY < mResizeBorderWidth && | 1138 | if (gridDistanceY < mResizeBorderWidth && |
1138 | moveItem->cellYTop() == gy && | 1139 | moveItem->cellYTop() == gy && |
1139 | !moveItem->firstMultiItem()) { | 1140 | !moveItem->firstMultiItem()) { |
1140 | setCursor(sizeVerCursor); | 1141 | setCursor(sizeVerCursor); |
1141 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1142 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1142 | moveItem->cellYBottom() == gy && | 1143 | moveItem->cellYBottom() == gy && |
1143 | !moveItem->lastMultiItem()) { | 1144 | !moveItem->lastMultiItem()) { |
1144 | setCursor(sizeVerCursor); | 1145 | setCursor(sizeVerCursor); |
1145 | } else { | 1146 | } else { |
1146 | setCursor(arrowCursor); | 1147 | setCursor(arrowCursor); |
1147 | } | 1148 | } |
1148 | } | 1149 | } |
1149 | } | 1150 | } |
1150 | 1151 | ||
1151 | 1152 | ||
1152 | /* | 1153 | /* |
1153 | Place item in cell and take care that multiple items using the same cell do | 1154 | Place item in cell and take care that multiple items using the same cell do |
1154 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1155 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1155 | it can get in all cases. | 1156 | it can get in all cases. |
1156 | At the moment the method has a bug: When an item is placed only the sub cell | 1157 | At the moment the method has a bug: When an item is placed only the sub cell |
1157 | widths of the items are changed, which are within the Y region the item to | 1158 | widths of the items are changed, which are within the Y region the item to |
1158 | place spans. When the sub cell width change of one of this items affects a | 1159 | place spans. When the sub cell width change of one of this items affects a |
1159 | cell, where other items are, which do not overlap in Y with the item to place, | 1160 | cell, where other items are, which do not overlap in Y with the item to place, |
1160 | the display gets corrupted, although the corruption looks quite nice. | 1161 | the display gets corrupted, although the corruption looks quite nice. |
1161 | */ | 1162 | */ |
1162 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1163 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1163 | { | 1164 | { |
1164 | 1165 | ||
1165 | QPtrList<KOAgendaItem> conflictItems; | 1166 | QPtrList<KOAgendaItem> conflictItems; |
1166 | int maxSubCells = 0; | 1167 | int maxSubCells = 0; |
1167 | QIntDict<KOAgendaItem> subCellDict(7); | 1168 | QIntDict<KOAgendaItem> subCellDict(7); |
1168 | 1169 | ||
1169 | KOAgendaItem *item; | 1170 | KOAgendaItem *item; |
1170 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1171 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1171 | if (item != placeItem) { | 1172 | if (item != placeItem) { |
1172 | if (placeItem->cellX() <= item->cellXWidth() && | 1173 | if (placeItem->cellX() <= item->cellXWidth() && |
1173 | placeItem->cellXWidth() >= item->cellX()) { | 1174 | placeItem->cellXWidth() >= item->cellX()) { |
1174 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1175 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1175 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1176 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1176 | conflictItems.append(item); | 1177 | conflictItems.append(item); |
1177 | if (item->subCells() > maxSubCells) | 1178 | if (item->subCells() > maxSubCells) |
1178 | maxSubCells = item->subCells(); | 1179 | maxSubCells = item->subCells(); |
1179 | subCellDict.insert(item->subCell(),item); | 1180 | subCellDict.insert(item->subCell(),item); |
1180 | } | 1181 | } |
1181 | } | 1182 | } |
1182 | } | 1183 | } |
1183 | } | 1184 | } |
1184 | 1185 | ||
1185 | if (conflictItems.count() > 0) { | 1186 | if (conflictItems.count() > 0) { |
1186 | // Look for unused sub cell and insert item | 1187 | // Look for unused sub cell and insert item |
1187 | int i; | 1188 | int i; |
1188 | for(i=0;i<maxSubCells;++i) { | 1189 | for(i=0;i<maxSubCells;++i) { |
1189 | if (!subCellDict.find(i)) { | 1190 | if (!subCellDict.find(i)) { |
1190 | placeItem->setSubCell(i); | 1191 | placeItem->setSubCell(i); |
1191 | break; | 1192 | break; |
1192 | } | 1193 | } |
1193 | } | 1194 | } |
1194 | if (i == maxSubCells) { | 1195 | if (i == maxSubCells) { |
1195 | placeItem->setSubCell(maxSubCells); | 1196 | placeItem->setSubCell(maxSubCells); |
1196 | maxSubCells++; // add new item to number of sub cells | 1197 | maxSubCells++; // add new item to number of sub cells |
1197 | } | 1198 | } |
1198 | 1199 | ||
1199 | // Prepare for sub cell geometry adjustment | 1200 | // Prepare for sub cell geometry adjustment |
1200 | int newSubCellWidth; | 1201 | int newSubCellWidth; |
1201 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1202 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1202 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1203 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1203 | conflictItems.append(placeItem); | 1204 | conflictItems.append(placeItem); |
1204 | 1205 | ||
1205 | 1206 | ||
1206 | // Adjust sub cell geometry of all direct conflict items | 1207 | // Adjust sub cell geometry of all direct conflict items |
1207 | for ( item=conflictItems.first(); item != 0; | 1208 | for ( item=conflictItems.first(); item != 0; |
1208 | item=conflictItems.next() ) { | 1209 | item=conflictItems.next() ) { |
1209 | item->setSubCells(maxSubCells); | 1210 | item->setSubCells(maxSubCells); |
1210 | if (mAllDayMode) { | 1211 | if (mAllDayMode) { |
1211 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1212 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1212 | } else { | 1213 | } else { |
1213 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1214 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1214 | } | 1215 | } |
1215 | int x,y; | 1216 | int x,y; |
1216 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1217 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1217 | if (mAllDayMode) { | 1218 | if (mAllDayMode) { |
1218 | y += item->subCell() * newSubCellWidth; | 1219 | y += item->subCell() * newSubCellWidth; |
1219 | } else { | 1220 | } else { |
1220 | x += item->subCell() * newSubCellWidth; | 1221 | x += item->subCell() * newSubCellWidth; |
1221 | } | 1222 | } |
1222 | moveChild(item,x,y); | 1223 | moveChild(item,x,y); |
1223 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1224 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1224 | //item->updateItem(); | 1225 | //item->updateItem(); |
1225 | } | 1226 | } |
1226 | // Adjust sub cell geometry of all conflict items of all conflict items | 1227 | // Adjust sub cell geometry of all conflict items of all conflict items |
1227 | for ( item=conflictItems.first(); item != 0; | 1228 | for ( item=conflictItems.first(); item != 0; |
1228 | item=conflictItems.next() ) { | 1229 | item=conflictItems.next() ) { |
1229 | if ( placeItem != item ) { | 1230 | if ( placeItem != item ) { |
1230 | KOAgendaItem *item2; | 1231 | KOAgendaItem *item2; |
1231 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1232 | for ( item2=conflictItems2.first(); item2 != 0; | 1233 | for ( item2=conflictItems2.first(); item2 != 0; |
1233 | item2=conflictItems2.next() ) { | 1234 | item2=conflictItems2.next() ) { |
1234 | if ( item2->subCells() != maxSubCells) { | 1235 | if ( item2->subCells() != maxSubCells) { |
1235 | item2->setSubCells(maxSubCells); | 1236 | item2->setSubCells(maxSubCells); |
1236 | if (mAllDayMode) { | 1237 | if (mAllDayMode) { |
1237 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1238 | } else { | 1239 | } else { |
1239 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1240 | } | 1241 | } |
1241 | int x,y; | 1242 | int x,y; |
1242 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1243 | if (mAllDayMode) { | 1244 | if (mAllDayMode) { |
1244 | y += item2->subCell() * newSubCellWidth; | 1245 | y += item2->subCell() * newSubCellWidth; |
1245 | } else { | 1246 | } else { |
1246 | x += item2->subCell() * newSubCellWidth; | 1247 | x += item2->subCell() * newSubCellWidth; |
1247 | } | 1248 | } |
1248 | moveChild(item2,x,y); | 1249 | moveChild(item2,x,y); |
1249 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1250 | } | 1251 | } |
1251 | } | 1252 | } |
1252 | } | 1253 | } |
1253 | } | 1254 | } |
1254 | } else { | 1255 | } else { |
1255 | placeItem->setSubCell(0); | 1256 | placeItem->setSubCell(0); |
1256 | placeItem->setSubCells(1); | 1257 | placeItem->setSubCells(1); |
1257 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1258 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1259 | int x,y; | 1260 | int x,y; |
1260 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1261 | moveChild(placeItem,x,y); | 1262 | moveChild(placeItem,x,y); |
1262 | } | 1263 | } |
1263 | placeItem->setConflictItems(conflictItems); | 1264 | placeItem->setConflictItems(conflictItems); |
1264 | // for ( item=conflictItems.first(); item != 0; | 1265 | // for ( item=conflictItems.first(); item != 0; |
1265 | // item=conflictItems.next() ) { | 1266 | // item=conflictItems.next() ) { |
1266 | // //item->updateItem(); | 1267 | // //item->updateItem(); |
1267 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1268 | // } | 1269 | // } |
1269 | // placeItem->updateItem(); | 1270 | // placeItem->updateItem(); |
1270 | } | 1271 | } |
1271 | 1272 | ||
1272 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1273 | { | 1274 | { |
1274 | if ( globalFlagBlockAgenda ) | 1275 | if ( globalFlagBlockAgenda ) |
1275 | return; | 1276 | return; |
1276 | 1277 | ||
1277 | if ( mInvalidPixmap ) { | 1278 | if ( mInvalidPixmap ) { |
1278 | mInvalidPixmap = false; | 1279 | mInvalidPixmap = false; |
1279 | qDebug("KO: Upsizing Pixmaps "); | 1280 | qDebug("KO: Upsizing Pixmaps "); |
1280 | computeSizes(); | 1281 | computeSizes(); |
1281 | emit updateViewSignal(); | 1282 | emit updateViewSignal(); |
1282 | return; | 1283 | return; |
1283 | } | 1284 | } |
1284 | if ( ! mAllDayMode ) { | 1285 | if ( ! mAllDayMode ) { |
1285 | // currently not working for | 1286 | // currently not working for |
1286 | 1287 | ||
1287 | //qDebug("KOAgenda::drawContents "); | 1288 | //qDebug("KOAgenda::drawContents "); |
1288 | #if 0 | 1289 | #if 0 |
1289 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1290 | qDebug("WAU "); | 1291 | qDebug("WAU "); |
1291 | drawContentsToPainter(); | 1292 | drawContentsToPainter(); |
1292 | } | 1293 | } |
1293 | #endif | 1294 | #endif |
1294 | QPaintDevice* pd = p->device(); | 1295 | QPaintDevice* pd = p->device(); |
1295 | p->end(); | 1296 | p->end(); |
1296 | int vx, vy; | 1297 | int vx, vy; |
1297 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1298 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1298 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1299 | mSelectionCellX * mGridSpacingX; | 1300 | mSelectionCellX * mGridSpacingX; |
1300 | contentsToViewport ( cx, cy, vx,vy); | 1301 | contentsToViewport ( cx, cy, vx,vy); |
1301 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1302 | 1303 | ||
1303 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1304 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1305 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1306 | 1307 | ||
1307 | int vxSel, vySel; | 1308 | int vxSel, vySel; |
1308 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1309 | int off = mSelectionHeight; | 1310 | int off = mSelectionHeight; |
1310 | if ( vySel < 0 ) | 1311 | if ( vySel < 0 ) |
1311 | off += vySel; | 1312 | off += vySel; |
1312 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1313 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1314 | } else { | 1315 | } else { |
1315 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1316 | } | 1317 | } |
1317 | } | 1318 | } |
1318 | if ( mSelectionHeight > 0 ) { | 1319 | if ( mSelectionHeight > 0 ) { |
1319 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1320 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1321 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1322 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1323 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1324 | int hei = mSelectionHeight; | 1325 | int hei = mSelectionHeight; |
1325 | int offset = 0; | 1326 | int offset = 0; |
1326 | while ( hei > 0 ) { | 1327 | while ( hei > 0 ) { |
1327 | int p_hei = 5; | 1328 | int p_hei = 5; |
1328 | if ( hei < 5 ) p_hei = hei; | 1329 | if ( hei < 5 ) p_hei = hei; |
1329 | hei -= 5; | 1330 | hei -= 5; |
1330 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1331 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1331 | offset += 5; | 1332 | offset += 5; |
1332 | } | 1333 | } |
1333 | } | 1334 | } |
1334 | } | 1335 | } |
1335 | p->begin( pd ); | 1336 | p->begin( pd ); |
1336 | } else { | 1337 | } else { |
1337 | #if 0 | 1338 | #if 0 |
1338 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1339 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1339 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1340 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1340 | qDebug("WAUWAU "); | 1341 | qDebug("WAUWAU "); |
1341 | drawContentsToPainter(); | 1342 | drawContentsToPainter(); |
1342 | } | 1343 | } |
1343 | #endif | 1344 | #endif |
1344 | QPaintDevice* pd = p->device(); | 1345 | QPaintDevice* pd = p->device(); |
1345 | p->end(); | 1346 | p->end(); |
1346 | int vx, vy; | 1347 | int vx, vy; |
1347 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1348 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1348 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1349 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1349 | mSelectionCellX * mGridSpacingX; | 1350 | mSelectionCellX * mGridSpacingX; |
1350 | contentsToViewport ( cx, cy, vx,vy); | 1351 | contentsToViewport ( cx, cy, vx,vy); |
1351 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1352 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1352 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1353 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1353 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1354 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1354 | 1355 | ||
1355 | if ( mSelectionHeight > 0 ) { | 1356 | if ( mSelectionHeight > 0 ) { |
1356 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1357 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1357 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1358 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1358 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1359 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1359 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1360 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1360 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1361 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1361 | int hei = mSelectionHeight; | 1362 | int hei = mSelectionHeight; |
1362 | int offset = 0; | 1363 | int offset = 0; |
1363 | while ( hei > 0 ) { | 1364 | while ( hei > 0 ) { |
1364 | int p_hei = 5; | 1365 | int p_hei = 5; |
1365 | if ( hei < 5 ) p_hei = hei; | 1366 | if ( hei < 5 ) p_hei = hei; |
1366 | hei -= 5; | 1367 | hei -= 5; |
1367 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1368 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1368 | offset += 5; | 1369 | offset += 5; |
1369 | } | 1370 | } |
1370 | } | 1371 | } |
1371 | } | 1372 | } |
1372 | p->begin( pd ); | 1373 | p->begin( pd ); |
1373 | } | 1374 | } |
1374 | 1375 | ||
1375 | } | 1376 | } |
1376 | 1377 | ||
1377 | void KOAgenda::finishUpdate() | 1378 | void KOAgenda::finishUpdate() |
1378 | { | 1379 | { |
1379 | 1380 | ||
1380 | KOAgendaItem *item; | 1381 | KOAgendaItem *item; |
1381 | globalFlagBlockAgendaItemPaint = 1; | 1382 | globalFlagBlockAgendaItemPaint = 1; |
1382 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1383 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1384 | if ( !item->checkLayout() ) { | 1385 | if ( !item->checkLayout() ) { |
1385 | //qDebug(" conflictitem found "); | 1386 | //qDebug(" conflictitem found "); |
1386 | int newSubCellWidth; | 1387 | int newSubCellWidth; |
1387 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1388 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1388 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1389 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1389 | 1390 | ||
1390 | if (mAllDayMode) { | 1391 | if (mAllDayMode) { |
1391 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1392 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1392 | } else { | 1393 | } else { |
1393 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1394 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1394 | } | 1395 | } |
1395 | int x,y; | 1396 | int x,y; |
1396 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1397 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1397 | if (mAllDayMode) { | 1398 | if (mAllDayMode) { |
1398 | y += item->subCell() * newSubCellWidth; | 1399 | y += item->subCell() * newSubCellWidth; |
1399 | } else { | 1400 | } else { |
1400 | x += item->subCell() * newSubCellWidth; | 1401 | x += item->subCell() * newSubCellWidth; |
1401 | } | 1402 | } |
1402 | moveChild(item,x,y); | 1403 | moveChild(item,x,y); |
1403 | } | 1404 | } |
1404 | } | 1405 | } |
1405 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1406 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1406 | if ( !item->isVisible() ) | 1407 | if ( !item->isVisible() ) |
1407 | item->show(); | 1408 | item->show(); |
1408 | 1409 | ||
1409 | } | 1410 | } |
1410 | globalFlagBlockAgendaItemUpdate = 0; | 1411 | globalFlagBlockAgendaItemUpdate = 0; |
1411 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1412 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1412 | item->repaintMe( ); | 1413 | item->repaintMe( ); |
1413 | } | 1414 | } |
1414 | globalFlagBlockAgendaItemUpdate = 1; | 1415 | globalFlagBlockAgendaItemUpdate = 1; |
1415 | qApp->processEvents(); | 1416 | qApp->processEvents(); |
1416 | globalFlagBlockAgendaItemPaint = 0; | 1417 | globalFlagBlockAgendaItemPaint = 0; |
1417 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1418 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1418 | item->repaint( false ); | 1419 | item->repaint( false ); |
1419 | } | 1420 | } |
1420 | marcus_bains(); | 1421 | marcus_bains(); |
1421 | } | 1422 | } |
1422 | 1423 | ||
1423 | /* | 1424 | /* |
1424 | Draw grid in the background of the agenda. | 1425 | Draw grid in the background of the agenda. |
1425 | */ | 1426 | */ |
1426 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1427 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1427 | { | 1428 | { |
1428 | 1429 | ||
1429 | 1430 | ||
1430 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1431 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1431 | return; | 1432 | return; |
1432 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1433 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1433 | return; | 1434 | return; |
1434 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1435 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1435 | if ( ch < 1 ) | 1436 | if ( ch < 1 ) |
1436 | ch = 1; | 1437 | ch = 1; |
1437 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1438 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1438 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1439 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1439 | } | 1440 | } |
1440 | mCurPixWid = contentsWidth(); | 1441 | mCurPixWid = contentsWidth(); |
1441 | mCurPixHei = ch; | 1442 | mCurPixHei = ch; |
1442 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1443 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1443 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1444 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1444 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1445 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1445 | } | 1446 | } |
1446 | mPixPainter.begin( &mPaintPixmap) ; | 1447 | mPixPainter.begin( &mPaintPixmap) ; |
1447 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1448 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1448 | QPainter * p ; | 1449 | QPainter * p ; |
1449 | if (paint == 0) { | 1450 | if (paint == 0) { |
1450 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1451 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1451 | p = &mPixPainter; | 1452 | p = &mPixPainter; |
1452 | } | 1453 | } |
1453 | else | 1454 | else |
1454 | p = paint ; | 1455 | p = paint ; |
1455 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1456 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1456 | 1457 | ||
1457 | //--cx;++cw; | 1458 | //--cx;++cw; |
1458 | int lGridSpacingY = mGridSpacingY*2; | 1459 | int lGridSpacingY = mGridSpacingY*2; |
1459 | int selDay; | 1460 | int selDay; |
1460 | QDate curDate = QDate::currentDate(); | 1461 | QDate curDate = QDate::currentDate(); |
1461 | if ( !backgroundOnly ) { | 1462 | if ( !backgroundOnly ) { |
1462 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1463 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1463 | { | 1464 | { |
1464 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1465 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1465 | int x1 = cx; | 1466 | int x1 = cx; |
1466 | int y1 = 0; | 1467 | int y1 = 0; |
1467 | if (y1 < cy) y1 = cy; | 1468 | if (y1 < cy) y1 = cy; |
1468 | int x2 = cx+cw-1; | 1469 | int x2 = cx+cw-1; |
1469 | int y2 = contentsHeight(); | 1470 | int y2 = contentsHeight(); |
1470 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1471 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1471 | if (x2 >= x1 && y2 >= y1) { | 1472 | if (x2 >= x1 && y2 >= y1) { |
1472 | int gxStart = selDay; | 1473 | int gxStart = selDay; |
1473 | int gxEnd = gxStart ; | 1474 | int gxEnd = gxStart ; |
1474 | int xStart = KOGlobals::self()->reverseLayout() ? | 1475 | int xStart = KOGlobals::self()->reverseLayout() ? |
1475 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1476 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1476 | gxStart*mGridSpacingX; | 1477 | gxStart*mGridSpacingX; |
1477 | if (xStart < x1) xStart = x1; | 1478 | if (xStart < x1) xStart = x1; |
1478 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1479 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1479 | (mColumns - gxStart)*mGridSpacingX-1 : | 1480 | (mColumns - gxStart)*mGridSpacingX-1 : |
1480 | (gxStart+1)*mGridSpacingX-1; | 1481 | (gxStart+1)*mGridSpacingX-1; |
1481 | if (xEnd > x2) xEnd = x2; | 1482 | if (xEnd > x2) xEnd = x2; |
1482 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1483 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1483 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1484 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1484 | KOPrefs::instance()->mAgendaBgColor.light()); | 1485 | KOPrefs::instance()->mAgendaBgColor.light()); |
1485 | else | 1486 | else |
1486 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1487 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1487 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1488 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1488 | 1489 | ||
1489 | } | 1490 | } |
1490 | } | 1491 | } |
1491 | } | 1492 | } |
1492 | } | 1493 | } |
1493 | // Highlight working hours | 1494 | // Highlight working hours |
1494 | 1495 | ||
1495 | if ( !backgroundOnly ) | 1496 | if ( !backgroundOnly ) |
1496 | if (mWorkingHoursEnable) { | 1497 | if (mWorkingHoursEnable) { |
1497 | int x1 = cx; | 1498 | int x1 = cx; |
1498 | int y1 = mWorkingHoursYTop; | 1499 | int y1 = mWorkingHoursYTop; |
1499 | if (y1 < cy) y1 = cy; | 1500 | if (y1 < cy) y1 = cy; |
1500 | int x2 = cx+cw-1; | 1501 | int x2 = cx+cw-1; |
1501 | // int x2 = mGridSpacingX * 5 - 1; | 1502 | // int x2 = mGridSpacingX * 5 - 1; |
1502 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1503 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1503 | int y2 = mWorkingHoursYBottom; | 1504 | int y2 = mWorkingHoursYBottom; |
1504 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1505 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1505 | 1506 | ||
1506 | if (x2 >= x1 && y2 >= y1) { | 1507 | if (x2 >= x1 && y2 >= y1) { |
1507 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1508 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1508 | int gxStart = x1/mGridSpacingX; | 1509 | int gxStart = x1/mGridSpacingX; |
1509 | int gxEnd = x2/mGridSpacingX; | 1510 | int gxEnd = x2/mGridSpacingX; |
1510 | while(gxStart <= gxEnd) { | 1511 | while(gxStart <= gxEnd) { |
1511 | if (gxStart < int(mHolidayMask->count()) && | 1512 | if (gxStart < int(mHolidayMask->count()) && |
1512 | !mHolidayMask->at(gxStart)) { | 1513 | !mHolidayMask->at(gxStart)) { |
1513 | int xStart = KOGlobals::self()->reverseLayout() ? | 1514 | int xStart = KOGlobals::self()->reverseLayout() ? |
1514 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1515 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1515 | gxStart*mGridSpacingX; | 1516 | gxStart*mGridSpacingX; |
1516 | if (xStart < x1) xStart = x1; | 1517 | if (xStart < x1) xStart = x1; |
1517 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1518 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1518 | (mColumns - gxStart)*mGridSpacingX-1 : | 1519 | (mColumns - gxStart)*mGridSpacingX-1 : |
1519 | (gxStart+1)*mGridSpacingX-1; | 1520 | (gxStart+1)*mGridSpacingX-1; |
1520 | if (xEnd > x2) xEnd = x2; | 1521 | if (xEnd > x2) xEnd = x2; |
1521 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { | 1522 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { |
1522 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1523 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1523 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1524 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1524 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1525 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1525 | else | 1526 | else |
1526 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1527 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1527 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1528 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1528 | } else { | 1529 | } else { |
1529 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1530 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1530 | KOPrefs::instance()->mWorkingHoursColor); | 1531 | KOPrefs::instance()->mWorkingHoursColor); |
1531 | } | 1532 | } |
1532 | } | 1533 | } |
1533 | ++gxStart; | 1534 | ++gxStart; |
1534 | } | 1535 | } |
1535 | } | 1536 | } |
1536 | } | 1537 | } |
1537 | /* | 1538 | /* |
1538 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1539 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1539 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1540 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1540 | mSelectionCellX * mGridSpacingX; | 1541 | mSelectionCellX * mGridSpacingX; |
1541 | 1542 | ||
1542 | // Draw selection | 1543 | // Draw selection |
1543 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1544 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1544 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1545 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1545 | // TODO: paint only part within cx,cy,cw,ch | 1546 | // TODO: paint only part within cx,cy,cw,ch |
1546 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1547 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1547 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1548 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1548 | } | 1549 | } |
1549 | */ | 1550 | */ |
1550 | // Draw vertical lines of grid | 1551 | // Draw vertical lines of grid |
1551 | 1552 | ||
1552 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1553 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1553 | if ( mGridSpacingX > 0 ) { | 1554 | if ( mGridSpacingX > 0 ) { |
1554 | while (x < cx + cw) { | 1555 | while (x < cx + cw) { |
1555 | p->drawLine(x,cy,x,cy+ch); | 1556 | p->drawLine(x,cy,x,cy+ch); |
1556 | x+=mGridSpacingX; | 1557 | x+=mGridSpacingX; |
1557 | } | 1558 | } |
1558 | } | 1559 | } |
1559 | // Draw horizontal lines of grid | 1560 | // Draw horizontal lines of grid |
1560 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1561 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1561 | if ( lGridSpacingY > 0 ) { | 1562 | if ( lGridSpacingY > 0 ) { |
1562 | while (y < cy + ch) { | 1563 | while (y < cy + ch) { |
1563 | p->setPen( SolidLine ); | 1564 | p->setPen( SolidLine ); |
1564 | p->drawLine(cx,y,cx+cw,y); | 1565 | p->drawLine(cx,y,cx+cw,y); |
1565 | y+=lGridSpacingY; | 1566 | y+=lGridSpacingY; |
1566 | p->setPen( DotLine ); | 1567 | p->setPen( DotLine ); |
1567 | p->drawLine(cx,y,cx+cw,y); | 1568 | p->drawLine(cx,y,cx+cw,y); |
1568 | y+=lGridSpacingY; | 1569 | y+=lGridSpacingY; |
1569 | } | 1570 | } |
1570 | p->setPen( SolidLine ); | 1571 | p->setPen( SolidLine ); |
1571 | } | 1572 | } |
1572 | mPixPainter.end() ; | 1573 | mPixPainter.end() ; |
1573 | } | 1574 | } |
1574 | 1575 | ||
1575 | /* | 1576 | /* |
1576 | Convert srcollview contents coordinates to agenda grid coordinates. | 1577 | Convert srcollview contents coordinates to agenda grid coordinates. |
1577 | */ | 1578 | */ |
1578 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1579 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1579 | { | 1580 | { |
1580 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1581 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1581 | x/mGridSpacingX; | 1582 | x/mGridSpacingX; |
1582 | gy = y/mGridSpacingY; | 1583 | gy = y/mGridSpacingY; |
1583 | } | 1584 | } |
1584 | 1585 | ||
1585 | /* | 1586 | /* |
1586 | Convert agenda grid coordinates to scrollview contents coordinates. | 1587 | Convert agenda grid coordinates to scrollview contents coordinates. |
1587 | */ | 1588 | */ |
1588 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1589 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1589 | { | 1590 | { |
1590 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1591 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1591 | gx*mGridSpacingX; | 1592 | gx*mGridSpacingX; |
1592 | y = gy*mGridSpacingY; | 1593 | y = gy*mGridSpacingY; |
1593 | } | 1594 | } |
1594 | 1595 | ||
1595 | 1596 | ||
1596 | /* | 1597 | /* |
1597 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1598 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1598 | the grid. | 1599 | the grid. |
1599 | */ | 1600 | */ |
1600 | int KOAgenda::timeToY(const QTime &time) | 1601 | int KOAgenda::timeToY(const QTime &time) |
1601 | { | 1602 | { |
1602 | int minutesPerCell = 24 * 60 / mRows; | 1603 | int minutesPerCell = 24 * 60 / mRows; |
1603 | int timeMinutes = time.hour() * 60 + time.minute(); | 1604 | int timeMinutes = time.hour() * 60 + time.minute(); |
1604 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1605 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1605 | return Y; | 1606 | return Y; |
1606 | } | 1607 | } |
1607 | 1608 | ||
1608 | 1609 | ||
1609 | /* | 1610 | /* |
1610 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1611 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1611 | fit into the grid. | 1612 | fit into the grid. |
1612 | */ | 1613 | */ |
1613 | QTime KOAgenda::gyToTime(int gy) | 1614 | QTime KOAgenda::gyToTime(int gy) |
1614 | { | 1615 | { |
1615 | 1616 | ||
1616 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1617 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1617 | 1618 | ||
1618 | int timeSeconds = secondsPerCell * gy; | 1619 | int timeSeconds = secondsPerCell * gy; |
1619 | 1620 | ||
1620 | QTime time( 0, 0, 0 ); | 1621 | QTime time( 0, 0, 0 ); |
1621 | if ( timeSeconds < 24 * 60 * 60 ) { | 1622 | if ( timeSeconds < 24 * 60 * 60 ) { |
1622 | time = time.addSecs(timeSeconds); | 1623 | time = time.addSecs(timeSeconds); |
1623 | } else { | 1624 | } else { |
1624 | time.setHMS( 23, 59, 59 ); | 1625 | time.setHMS( 23, 59, 59 ); |
1625 | } | 1626 | } |
1626 | 1627 | ||
1627 | return time; | 1628 | return time; |
1628 | } | 1629 | } |
1629 | 1630 | ||
1630 | void KOAgenda::setStartHour(int startHour) | 1631 | void KOAgenda::setStartHour(int startHour) |
1631 | { | 1632 | { |
1632 | int startCell = startHour * mRows / 24; | 1633 | int startCell = startHour * mRows / 24; |
1633 | setContentsPos(0,startCell * gridSpacingY()); | 1634 | setContentsPos(0,startCell * gridSpacingY()); |
1634 | } | 1635 | } |
1635 | void KOAgenda::hideUnused() | 1636 | void KOAgenda::hideUnused() |
1636 | { | 1637 | { |
1637 | // experimental only | 1638 | // experimental only |
1638 | // return; | 1639 | // return; |
1639 | KOAgendaItem *item; | 1640 | KOAgendaItem *item; |
1640 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1641 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1641 | item->hide(); | 1642 | item->hide(); |
1642 | } | 1643 | } |
1643 | } | 1644 | } |
1644 | 1645 | ||
1645 | 1646 | ||
1646 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1647 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1647 | { | 1648 | { |
1648 | 1649 | ||
1649 | KOAgendaItem *fi; | 1650 | KOAgendaItem *fi; |
1650 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1651 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1651 | if ( fi->incidence() == event ) { | 1652 | if ( fi->incidence() == event ) { |
1652 | mUnusedItems.remove(); | 1653 | mUnusedItems.remove(); |
1653 | fi->init( event, qd ); | 1654 | fi->init( event, qd ); |
1654 | return fi; | 1655 | return fi; |
1655 | } | 1656 | } |
1656 | } | 1657 | } |
1657 | fi=mUnusedItems.first(); | 1658 | fi=mUnusedItems.first(); |
1658 | if ( fi ) { | 1659 | if ( fi ) { |
1659 | mUnusedItems.remove(); | 1660 | mUnusedItems.remove(); |
1660 | fi->init( event, qd ); | 1661 | fi->init( event, qd ); |
1661 | return fi; | 1662 | return fi; |
1662 | } | 1663 | } |
1663 | // qDebug("new KOAgendaItem "); | 1664 | // qDebug("new KOAgendaItem "); |
1664 | 1665 | ||
1665 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1666 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1666 | agendaItem->installEventFilter(this); | 1667 | agendaItem->installEventFilter(this); |
1667 | addChild(agendaItem,0,0); | 1668 | addChild(agendaItem,0,0); |
1668 | return agendaItem; | 1669 | return agendaItem; |
1669 | } | 1670 | } |
1670 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1671 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1671 | { | 1672 | { |
1672 | KOAgendaItem *item; | 1673 | KOAgendaItem *item; |
1673 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1674 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1674 | if ( item->incidence() == todo ) { | 1675 | if ( item->incidence() == todo ) { |
1675 | mItems.remove(); | 1676 | mItems.remove(); |
1676 | return item; | 1677 | return item; |
1677 | } | 1678 | } |
1678 | } | 1679 | } |
1679 | return 0; | 1680 | return 0; |
1680 | } | 1681 | } |
1681 | 1682 | ||
1682 | 1683 | ||
1683 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1684 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1684 | { | 1685 | { |
1685 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1686 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1686 | KOAgendaItem *item; | 1687 | KOAgendaItem *item; |
1687 | item = getItemForTodo ( todo ); | 1688 | item = getItemForTodo ( todo ); |
1688 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1689 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1689 | if ( item ) { | 1690 | if ( item ) { |
1690 | blockSignals( true ); | 1691 | blockSignals( true ); |
1691 | //qDebug("item found "); | 1692 | //qDebug("item found "); |
1692 | item->hide(); | 1693 | item->hide(); |
1693 | item->setCellX(-2, -1 ); | 1694 | item->setCellX(-2, -1 ); |
1694 | item->select(false); | 1695 | item->select(false); |
1695 | mUnusedItems.append( item ); | 1696 | mUnusedItems.append( item ); |
1696 | mItems.remove( item ); | 1697 | mItems.remove( item ); |
1697 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1698 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1698 | KOAgendaItem *itemit; | 1699 | KOAgendaItem *itemit; |
1699 | //globalFlagBlockAgendaItemPaint = 1; | 1700 | //globalFlagBlockAgendaItemPaint = 1; |
1700 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1701 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1701 | itemit=oldconflictItems.next() ) { | 1702 | itemit=oldconflictItems.next() ) { |
1702 | if ( itemit != item ) | 1703 | if ( itemit != item ) |
1703 | placeSubCells(itemit); | 1704 | placeSubCells(itemit); |
1704 | } | 1705 | } |
1705 | qApp->processEvents(); | 1706 | qApp->processEvents(); |
1706 | //globalFlagBlockAgendaItemPaint = 0; | 1707 | //globalFlagBlockAgendaItemPaint = 0; |
1707 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1708 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1708 | itemit=oldconflictItems.next() ) { | 1709 | itemit=oldconflictItems.next() ) { |
1709 | globalFlagBlockAgendaItemUpdate = 0; | 1710 | globalFlagBlockAgendaItemUpdate = 0; |
1710 | if ( itemit != item ) | 1711 | if ( itemit != item ) |
1711 | itemit->repaintMe(); | 1712 | itemit->repaintMe(); |
1712 | globalFlagBlockAgendaItemUpdate = 1; | 1713 | globalFlagBlockAgendaItemUpdate = 1; |
1713 | //qDebug("sigleshot "); | 1714 | //qDebug("sigleshot "); |
1714 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); | 1715 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); |
1715 | //itemit->repaint( false ); repaintItem() | 1716 | //itemit->repaint( false ); repaintItem() |
1716 | } | 1717 | } |
1717 | blockSignals( false ); | 1718 | blockSignals( false ); |
1718 | } | 1719 | } |
1719 | if ( remove ) { | 1720 | if ( remove ) { |
1720 | //qDebug("remove****************************************** "); | 1721 | //qDebug("remove****************************************** "); |
1721 | return; | 1722 | return; |
1722 | } | 1723 | } |
1723 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) | 1724 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) |
1724 | return; | 1725 | return; |
1725 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1726 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1726 | QDate currentDate = QDate::currentDate(); | 1727 | QDate currentDate = QDate::currentDate(); |
1727 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1728 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1728 | QDateTime dt; | 1729 | QDateTime dt; |
1729 | if ( todo->hasCompletedDate() ) | 1730 | if ( todo->hasCompletedDate() ) |
1730 | dt = todo->completed(); | 1731 | dt = todo->completed(); |
1731 | else | 1732 | else |
1732 | dt = todo->dtDue(); | 1733 | dt = todo->dtDue(); |
1733 | if ( overdue ) { | 1734 | if ( overdue ) { |
1734 | days += todo->dtDue().date().daysTo( currentDate ); | 1735 | days += todo->dtDue().date().daysTo( currentDate ); |
1735 | } | 1736 | } |
1736 | else | 1737 | else |
1737 | currentDate = dt.date(); | 1738 | currentDate = dt.date(); |
1738 | 1739 | ||
1739 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1740 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1740 | if ( ! mAllDayMode ) return; | 1741 | if ( ! mAllDayMode ) return; |
1741 | // aldayagenda | 1742 | // aldayagenda |
1742 | globalFlagBlockAgendaItemPaint = 1; | 1743 | globalFlagBlockAgendaItemPaint = 1; |
1743 | item = insertAllDayItem(todo, currentDate,days, days); | 1744 | item = insertAllDayItem(todo, currentDate,days, days); |
1744 | item->show(); | 1745 | item->show(); |
1745 | 1746 | ||
1746 | } | 1747 | } |
1747 | else { | 1748 | else { |
1748 | if ( mAllDayMode ) return; | 1749 | if ( mAllDayMode ) return; |
1749 | // mAgenda | 1750 | // mAgenda |
1750 | globalFlagBlockAgendaItemPaint = 1; | 1751 | globalFlagBlockAgendaItemPaint = 1; |
1751 | int endY = timeToY(dt.time()) - 1; | 1752 | int endY = timeToY(dt.time()) - 1; |
1752 | int hi = 12/KOPrefs::instance()->mHourSize; | 1753 | int hi = 12/KOPrefs::instance()->mHourSize; |
1753 | int startY = endY - 1-hi; | 1754 | int startY = endY - 1-hi; |
1754 | item = insertItem(todo,currentDate,days,startY,endY); | 1755 | item = insertItem(todo,currentDate,days,startY,endY); |
1755 | item->show(); | 1756 | item->show(); |
1756 | } | 1757 | } |
1757 | qApp->processEvents(); | 1758 | qApp->processEvents(); |
1758 | globalFlagBlockAgendaItemPaint = 0; | 1759 | globalFlagBlockAgendaItemPaint = 0; |
1759 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1760 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1760 | KOAgendaItem *itemit; | 1761 | KOAgendaItem *itemit; |
1761 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1762 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1762 | itemit=oldconflictItems.next() ) { | 1763 | itemit=oldconflictItems.next() ) { |
1763 | globalFlagBlockAgendaItemUpdate = 0; | 1764 | globalFlagBlockAgendaItemUpdate = 0; |
1764 | itemit->repaintMe(); | 1765 | itemit->repaintMe(); |
1765 | globalFlagBlockAgendaItemUpdate = 1; | 1766 | globalFlagBlockAgendaItemUpdate = 1; |
1766 | itemit->repaint(); | 1767 | itemit->repaint(); |
1767 | } | 1768 | } |
1768 | globalFlagBlockAgendaItemUpdate = 0; | 1769 | globalFlagBlockAgendaItemUpdate = 0; |
1769 | item->repaintMe(); | 1770 | item->repaintMe(); |
1770 | globalFlagBlockAgendaItemUpdate = 1; | 1771 | globalFlagBlockAgendaItemUpdate = 1; |
1771 | item->repaint(); | 1772 | item->repaint(); |
1772 | } | 1773 | } |
1773 | /* | 1774 | /* |
1774 | Insert KOAgendaItem into agenda. | 1775 | Insert KOAgendaItem into agenda. |
1775 | */ | 1776 | */ |
1776 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1777 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1777 | { | 1778 | { |
1778 | if (mAllDayMode) { | 1779 | if (mAllDayMode) { |
1779 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1780 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1780 | return 0; | 1781 | return 0; |
1781 | } | 1782 | } |
1782 | 1783 | ||
1783 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1784 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1784 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1785 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1785 | 1786 | ||
1786 | int YSize = YBottom - YTop + 1; | 1787 | int YSize = YBottom - YTop + 1; |
1787 | if (YSize < 0) { | 1788 | if (YSize < 0) { |
1788 | YSize = 1; | 1789 | YSize = 1; |
1789 | } | 1790 | } |
1790 | int iheight = mGridSpacingY * YSize; | 1791 | int iheight = mGridSpacingY * YSize; |
1791 | 1792 | ||
1792 | agendaItem->resize(mGridSpacingX,iheight ); | 1793 | agendaItem->resize(mGridSpacingX,iheight ); |
1793 | agendaItem->setCellXY(X,YTop,YBottom); | 1794 | agendaItem->setCellXY(X,YTop,YBottom); |
1794 | agendaItem->setCellXWidth(X); | 1795 | agendaItem->setCellXWidth(X); |
1795 | 1796 | ||
1796 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1797 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1797 | mItems.append(agendaItem); | 1798 | mItems.append(agendaItem); |
1798 | 1799 | ||
1799 | placeSubCells(agendaItem); | 1800 | placeSubCells(agendaItem); |
1800 | 1801 | ||
1801 | //agendaItem->show(); | 1802 | //agendaItem->show(); |
1802 | 1803 | ||
1803 | 1804 | ||
1804 | return agendaItem; | 1805 | return agendaItem; |
1805 | } | 1806 | } |
1806 | 1807 | ||
1807 | 1808 | ||
1808 | /* | 1809 | /* |
1809 | Insert all-day KOAgendaItem into agenda. | 1810 | Insert all-day KOAgendaItem into agenda. |
1810 | */ | 1811 | */ |
1811 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1812 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1812 | { | 1813 | { |
1813 | if (!mAllDayMode) { | 1814 | if (!mAllDayMode) { |
1814 | return 0; | 1815 | return 0; |
1815 | } | 1816 | } |
1816 | 1817 | ||
1817 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1818 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1818 | 1819 | ||
1819 | agendaItem->setCellXY(XBegin,0,0); | 1820 | agendaItem->setCellXY(XBegin,0,0); |
1820 | agendaItem->setCellXWidth(XEnd); | 1821 | agendaItem->setCellXWidth(XEnd); |
1821 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1822 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1822 | 1823 | ||
1823 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1824 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1824 | mItems.append(agendaItem); | 1825 | mItems.append(agendaItem); |
1825 | 1826 | ||
1826 | placeSubCells(agendaItem); | 1827 | placeSubCells(agendaItem); |
1827 | 1828 | ||
1828 | //agendaItem->show(); | 1829 | //agendaItem->show(); |
1829 | 1830 | ||
1830 | return agendaItem; | 1831 | return agendaItem; |
1831 | } | 1832 | } |
1832 | 1833 | ||
1833 | 1834 | ||
1834 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1835 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1835 | int YTop,int YBottom) | 1836 | int YTop,int YBottom) |
1836 | { | 1837 | { |
1837 | if (mAllDayMode) { | 1838 | if (mAllDayMode) { |
1838 | ; | 1839 | ; |
1839 | return; | 1840 | return; |
1840 | } | 1841 | } |
1841 | 1842 | ||
1842 | int cellX,cellYTop,cellYBottom; | 1843 | int cellX,cellYTop,cellYBottom; |
1843 | QString newtext; | 1844 | QString newtext; |
1844 | int width = XEnd - XBegin + 1; | 1845 | int width = XEnd - XBegin + 1; |
1845 | int count = 0; | 1846 | int count = 0; |
1846 | KOAgendaItem *current = 0; | 1847 | KOAgendaItem *current = 0; |
1847 | QPtrList<KOAgendaItem> multiItems; | 1848 | QPtrList<KOAgendaItem> multiItems; |
1848 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1849 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1849 | if (cellX == XBegin) cellYTop = YTop; | 1850 | if (cellX == XBegin) cellYTop = YTop; |
1850 | else cellYTop = 0; | 1851 | else cellYTop = 0; |
1851 | if (cellX == XEnd) cellYBottom = YBottom; | 1852 | if (cellX == XEnd) cellYBottom = YBottom; |
1852 | else cellYBottom = rows() - 1; | 1853 | else cellYBottom = rows() - 1; |
1853 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1854 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1854 | newtext.append(event->summary()); | 1855 | newtext.append(event->summary()); |
1855 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1856 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1856 | current->setText(newtext); | 1857 | current->setText(newtext); |
1857 | multiItems.append(current); | 1858 | multiItems.append(current); |
1858 | } | 1859 | } |
1859 | 1860 | ||
1860 | KOAgendaItem *next = 0; | 1861 | KOAgendaItem *next = 0; |
1861 | KOAgendaItem *last = multiItems.last(); | 1862 | KOAgendaItem *last = multiItems.last(); |
1862 | KOAgendaItem *first = multiItems.first(); | 1863 | KOAgendaItem *first = multiItems.first(); |
1863 | KOAgendaItem *setFirst,*setLast; | 1864 | KOAgendaItem *setFirst,*setLast; |
1864 | current = first; | 1865 | current = first; |
1865 | while (current) { | 1866 | while (current) { |
1866 | next = multiItems.next(); | 1867 | next = multiItems.next(); |
1867 | if (current == first) setFirst = 0; | 1868 | if (current == first) setFirst = 0; |