summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-04 06:42:00 (UTC)
committer zautrix <zautrix>2005-07-04 06:42:00 (UTC)
commit068a89b64d8ef4cb49702ed53ab4e415a0b90a80 (patch) (unidiff)
tree9c2f4b77372cfbb2c1dab2717de027d8500a905a
parentad66f0fe56bb88104fb0065ccb599ab0edd35cf4 (diff)
downloadkdepimpi-068a89b64d8ef4cb49702ed53ab4e415a0b90a80.zip
kdepimpi-068a89b64d8ef4cb49702ed53ab4e415a0b90a80.tar.gz
kdepimpi-068a89b64d8ef4cb49702ed53ab4e415a0b90a80.tar.bz2
fixx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp2
-rw-r--r--korganizer/koagendaview.cpp31
2 files changed, 2 insertions, 31 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index f860f7d..94c3b22 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -370,1537 +370,1537 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
371 371
372 case (QEvent::Leave): 372 case (QEvent::Leave):
373 if (!mActionItem) 373 if (!mActionItem)
374 setCursor(arrowCursor); 374 setCursor(arrowCursor);
375 return true; 375 return true;
376 376
377 default: 377 default:
378 return QScrollView::eventFilter(object,event); 378 return QScrollView::eventFilter(object,event);
379 } 379 }
380} 380}
381void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
382{ 382{
383 mPopupTimer->stop(); 383 mPopupTimer->stop();
384 if ( mPopupKind == 1 || mPopupKind == 3 ) { 384 if ( mPopupKind == 1 || mPopupKind == 3 ) {
385 if (mActionItem ) { 385 if (mActionItem ) {
386 endItemAction(); 386 endItemAction();
387 } 387 }
388 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
389 if (mPopupItem) { 389 if (mPopupItem) {
390 //mClickedItem = mPopupItem; 390 //mClickedItem = mPopupItem;
391 selectItem(mPopupItem); 391 selectItem(mPopupItem);
392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
393 mAllAgendaPopup->installEventFilter( this ); 393 mAllAgendaPopup->installEventFilter( this );
394 emit showIncidencePopupSignal(mPopupItem->incidence()); 394 emit showIncidencePopupSignal(mPopupItem->incidence());
395 395
396 } 396 }
397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) { 397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
399 endSelectAction( false ); // do not emit new event signal 399 endSelectAction( false ); // do not emit new event signal
400 mLeftMouseDown = false; // no more leftMouse computation 400 mLeftMouseDown = false; // no more leftMouse computation
401 } 401 }
402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) 402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
403 mNewItemPopup->installEventFilter( this ); 403 mNewItemPopup->installEventFilter( this );
404 mNewItemPopup->popup( mPopupPos); 404 mNewItemPopup->popup( mPopupPos);
405 405
406 } 406 }
407 mLeftMouseDown = false; 407 mLeftMouseDown = false;
408 mPopupItem = 0; 408 mPopupItem = 0;
409 mPopupKind = 0; 409 mPopupKind = 0;
410} 410}
411void KOAgenda::categoryChanged(Incidence * inc) 411void KOAgenda::categoryChanged(Incidence * inc)
412{ 412{
413 KOAgendaItem *item; 413 KOAgendaItem *item;
414 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 414 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
415 if ( item->incidence() == inc ) { 415 if ( item->incidence() == inc ) {
416 item->initColor (); 416 item->initColor ();
417 item->updateItem(); 417 item->updateItem();
418 } 418 }
419 } 419 }
420} 420}
421bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 421bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
422{ 422{
423 static int startX = 0; 423 static int startX = 0;
424 static int startY = 0; 424 static int startY = 0;
425 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); 425 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
426 static bool blockMoving = true; 426 static bool blockMoving = true;
427 427
428 //qDebug("KOAgenda::eventFilter_mous "); 428 //qDebug("KOAgenda::eventFilter_mous ");
429 if ( object == mNewItemPopup ) { 429 if ( object == mNewItemPopup ) {
430 //qDebug("mNewItemPopup "); 430 //qDebug("mNewItemPopup ");
431 if ( me->type() == QEvent::MouseButtonRelease ) { 431 if ( me->type() == QEvent::MouseButtonRelease ) {
432 mNewItemPopup->removeEventFilter( this ); 432 mNewItemPopup->removeEventFilter( this );
433 int dX = me->globalPos().x() - mPopupPos.x();; 433 int dX = me->globalPos().x() - mPopupPos.x();;
434 if ( dX < 0 ) 434 if ( dX < 0 )
435 dX = -dX; 435 dX = -dX;
436 int dY = me->globalPos().y() - mPopupPos.y(); 436 int dY = me->globalPos().y() - mPopupPos.y();
437 if ( dY < 0 ) 437 if ( dY < 0 )
438 dY = -dY; 438 dY = -dY;
439 if ( dX > blockmoveDist || dY > blockmoveDist ) { 439 if ( dX > blockmoveDist || dY > blockmoveDist ) {
440 mNewItemPopup->hide(); 440 mNewItemPopup->hide();
441 } 441 }
442 } 442 }
443 return true; 443 return true;
444 } 444 }
445 if ( object == mAllAgendaPopup ) { 445 if ( object == mAllAgendaPopup ) {
446 //qDebug(" mAllAgendaPopup "); 446 //qDebug(" mAllAgendaPopup ");
447 if ( me->type() == QEvent::MouseButtonRelease ) { 447 if ( me->type() == QEvent::MouseButtonRelease ) {
448 mAllAgendaPopup->removeEventFilter( this ); 448 mAllAgendaPopup->removeEventFilter( this );
449 int dX = me->globalPos().x() - mPopupPos.x();; 449 int dX = me->globalPos().x() - mPopupPos.x();;
450 if ( dX < 0 ) 450 if ( dX < 0 )
451 dX = -dX; 451 dX = -dX;
452 int dY = me->globalPos().y() - mPopupPos.y(); 452 int dY = me->globalPos().y() - mPopupPos.y();
453 if ( dY < 0 ) 453 if ( dY < 0 )
454 dY = -dY; 454 dY = -dY;
455 if ( dX > blockmoveDist || dY > blockmoveDist ) { 455 if ( dX > blockmoveDist || dY > blockmoveDist ) {
456 mAllAgendaPopup->hide(); 456 mAllAgendaPopup->hide();
457 } 457 }
458 } 458 }
459 return true; 459 return true;
460 } 460 }
461 QPoint viewportPos; 461 QPoint viewportPos;
462 if (object != viewport()) { 462 if (object != viewport()) {
463 blockmoveDist = blockmoveDist*2; 463 blockmoveDist = blockmoveDist*2;
464 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 464 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
465 } else { 465 } else {
466 viewportPos = me->pos(); 466 viewportPos = me->pos();
467 } 467 }
468 bool objIsNotViewport = (object != viewport()); 468 bool objIsNotViewport = (object != viewport());
469 bool leftButt = false; 469 bool leftButt = false;
470#ifdef DESKTOP_VERSION 470#ifdef DESKTOP_VERSION
471 leftButt = (me->button() == LeftButton); 471 leftButt = (me->button() == LeftButton);
472#endif 472#endif
473 switch (me->type()) { 473 switch (me->type()) {
474 case QEvent::MouseButtonPress: 474 case QEvent::MouseButtonPress:
475 if (me->button() == LeftButton) { 475 if (me->button() == LeftButton) {
476 mPopupTimer->start( 600 ); 476 mPopupTimer->start( 600 );
477 mLeftMouseDown = true; 477 mLeftMouseDown = true;
478 } 478 }
479 blockMoving = true; 479 blockMoving = true;
480 startX = viewportPos.x(); 480 startX = viewportPos.x();
481 startY = viewportPos.y(); 481 startY = viewportPos.y();
482 mPopupPos = me->globalPos(); 482 mPopupPos = me->globalPos();
483 if ( objIsNotViewport && !leftButt ) { 483 if ( objIsNotViewport && !leftButt ) {
484 KOAgendaItem * tempItem = (KOAgendaItem *)object; 484 KOAgendaItem * tempItem = (KOAgendaItem *)object;
485 if (mAllDayMode) { 485 if (mAllDayMode) {
486 if ( tempItem->height() > 10 ) { 486 if ( tempItem->height() > 10 ) {
487 int minV = tempItem->height()/4; 487 int minV = tempItem->height()/4;
488 if ( minV > (blockmoveDist/2)-2 ) { 488 if ( minV > (blockmoveDist/2)-2 ) {
489 if ( minV > blockmoveDist ) 489 if ( minV > blockmoveDist )
490 minV = blockmoveDist; 490 minV = blockmoveDist;
491 else 491 else
492 minV = (blockmoveDist/2); 492 minV = (blockmoveDist/2);
493 } 493 }
494 bool border = false; 494 bool border = false;
495 int diff = tempItem->y() - viewportPos.y(); 495 int diff = tempItem->y() - viewportPos.y();
496 if ( diff < 0 ) 496 if ( diff < 0 )
497 diff *= -1; 497 diff *= -1;
498 if ( diff < minV ) { 498 if ( diff < minV ) {
499 border = true; 499 border = true;
500 objIsNotViewport = false; 500 objIsNotViewport = false;
501 } 501 }
502 if ( ! border ) { 502 if ( ! border ) {
503 diff = tempItem->y() + tempItem->height()- viewportPos.y(); 503 diff = tempItem->y() + tempItem->height()- viewportPos.y();
504 if ( diff < 0 ) 504 if ( diff < 0 )
505 diff *= -1; 505 diff *= -1;
506 if ( diff < minV ) { 506 if ( diff < minV ) {
507 border = true; 507 border = true;
508 objIsNotViewport = false; 508 objIsNotViewport = false;
509 } 509 }
510 } 510 }
511 } 511 }
512 } else { // not allday 512 } else { // not allday
513 if ( tempItem->width() > 10 ) { 513 if ( tempItem->width() > 10 ) {
514 int minH = tempItem->width()/4; 514 int minH = tempItem->width()/4;
515 if ( minH > (blockmoveDist/2)-2 ) { 515 if ( minH > (blockmoveDist/2)-2 ) {
516 if ( minH > blockmoveDist ) 516 if ( minH > blockmoveDist )
517 minH = blockmoveDist; 517 minH = blockmoveDist;
518 else 518 else
519 minH = (blockmoveDist/2); 519 minH = (blockmoveDist/2);
520 } 520 }
521 bool border = false; 521 bool border = false;
522 int diff = tempItem->x() - viewportPos.x(); 522 int diff = tempItem->x() - viewportPos.x();
523 if ( diff < 0 ) 523 if ( diff < 0 )
524 diff *= -1; 524 diff *= -1;
525 if ( diff < minH ) { 525 if ( diff < minH ) {
526 border = true; 526 border = true;
527 objIsNotViewport = false; 527 objIsNotViewport = false;
528 } 528 }
529 if ( ! border ) { 529 if ( ! border ) {
530 diff = tempItem->x() + tempItem->width() - viewportPos.x(); 530 diff = tempItem->x() + tempItem->width() - viewportPos.x();
531 if ( diff < 0 ) 531 if ( diff < 0 )
532 diff *= -1; 532 diff *= -1;
533 if ( diff < minH ) { 533 if ( diff < minH ) {
534 border = true; 534 border = true;
535 objIsNotViewport = false; 535 objIsNotViewport = false;
536 } 536 }
537 } 537 }
538 } 538 }
539 } 539 }
540 } 540 }
541 if ( objIsNotViewport ) { 541 if ( objIsNotViewport ) {
542 mPopupItem = (KOAgendaItem *)object; 542 mPopupItem = (KOAgendaItem *)object;
543 mPopupKind = 1; 543 mPopupKind = 1;
544 if (me->button() == RightButton) { 544 if (me->button() == RightButton) {
545 mPopupKind = 3; 545 mPopupKind = 3;
546 popupMenu(); 546 popupMenu();
547 } else if (me->button() == LeftButton) { 547 } else if (me->button() == LeftButton) {
548 mActionItem = (KOAgendaItem *)object; 548 mActionItem = (KOAgendaItem *)object;
549 if (mActionItem) { 549 if (mActionItem) {
550 emit signalClearSelection(); 550 emit signalClearSelection();
551 slotClearSelection(); 551 slotClearSelection();
552 selectItem(mActionItem); 552 selectItem(mActionItem);
553 Incidence *incidence = mActionItem->incidence(); 553 Incidence *incidence = mActionItem->incidence();
554 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 554 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
555 mActionItem = 0; 555 mActionItem = 0;
556 } else { 556 } else {
557 startItemAction(viewportPos); 557 startItemAction(viewportPos);
558 } 558 }
559 } 559 }
560 } 560 }
561 } else { // ---------- viewport() 561 } else { // ---------- viewport()
562 mPopupItem = 0; 562 mPopupItem = 0;
563 mPopupKind = 2; 563 mPopupKind = 2;
564 selectItem(0); 564 selectItem(0);
565 mActionItem = 0; 565 mActionItem = 0;
566 if (me->button() == RightButton) { 566 if (me->button() == RightButton) {
567 int x,y; 567 int x,y;
568 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 568 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
569 int gx,gy; 569 int gx,gy;
570 contentsToGrid(x,y,gx,gy); 570 contentsToGrid(x,y,gx,gy);
571 mCurrentCellX = gx; 571 mCurrentCellX = gx;
572 mCurrentCellY = gy; 572 mCurrentCellY = gy;
573 mStartCellX = gx; 573 mStartCellX = gx;
574 mStartCellY = gy; 574 mStartCellY = gy;
575 mPopupKind = 4; 575 mPopupKind = 4;
576 popupMenu(); 576 popupMenu();
577 } else if (me->button() == LeftButton) { 577 } else if (me->button() == LeftButton) {
578 setCursor(arrowCursor); 578 setCursor(arrowCursor);
579 startSelectAction(viewportPos); 579 startSelectAction(viewportPos);
580 } 580 }
581 } 581 }
582 break; 582 break;
583 583
584 case QEvent::MouseButtonRelease: 584 case QEvent::MouseButtonRelease:
585 if (me->button() == LeftButton ) { 585 if (me->button() == LeftButton ) {
586 mPopupTimer->stop(); 586 mPopupTimer->stop();
587 } 587 }
588 if (object != viewport()) { 588 if (object != viewport()) {
589 if (me->button() == LeftButton && mLeftMouseDown) { 589 if (me->button() == LeftButton && mLeftMouseDown) {
590 if (mActionItem) { 590 if (mActionItem) {
591 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 591 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
592 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 592 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
593 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 593 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
594 mScrollUpTimer.stop(); 594 mScrollUpTimer.stop();
595 mScrollDownTimer.stop(); 595 mScrollDownTimer.stop();
596 mActionItem->resetMove(); 596 mActionItem->resetMove();
597 placeSubCells( mActionItem ); 597 placeSubCells( mActionItem );
598 // emit startDragSignal( mActionItem->incidence() ); 598 // emit startDragSignal( mActionItem->incidence() );
599 setCursor( arrowCursor ); 599 setCursor( arrowCursor );
600 mActionItem = 0; 600 mActionItem = 0;
601 mActionType = NOP; 601 mActionType = NOP;
602 mItemMoved = 0; 602 mItemMoved = 0;
603 mLeftMouseDown = false; 603 mLeftMouseDown = false;
604 return true; 604 return true;
605 } 605 }
606 endItemAction(); 606 endItemAction();
607 } 607 }
608 } 608 }
609 609
610 } else { // ---------- viewport() 610 } else { // ---------- viewport()
611 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 611 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
612 endSelectAction( true ); // emit new event signal 612 endSelectAction( true ); // emit new event signal
613 } 613 }
614 } 614 }
615 if (me->button() == LeftButton) 615 if (me->button() == LeftButton)
616 mLeftMouseDown = false; 616 mLeftMouseDown = false;
617 617
618 break; 618 break;
619 619
620 case QEvent::MouseMove: 620 case QEvent::MouseMove:
621 //qDebug("mm "); 621 //qDebug("mm ");
622 if ( !mLeftMouseDown ) 622 if ( !mLeftMouseDown )
623 return false; 623 return false;
624 if ( blockMoving ) { 624 if ( blockMoving ) {
625 int dX, dY; 625 int dX, dY;
626 dX = startX - viewportPos.x(); 626 dX = startX - viewportPos.x();
627 if ( dX < 0 ) 627 if ( dX < 0 )
628 dX = -dX; 628 dX = -dX;
629 dY = viewportPos.y() - startY; 629 dY = viewportPos.y() - startY;
630 if ( dY < 0 ) 630 if ( dY < 0 )
631 dY = -dY; 631 dY = -dY;
632 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 632 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
633 if ( dX > blockmoveDist || dY > blockmoveDist ) { 633 if ( dX > blockmoveDist || dY > blockmoveDist ) {
634 blockMoving = false; 634 blockMoving = false;
635 } 635 }
636 } 636 }
637 if ( ! blockMoving ) 637 if ( ! blockMoving )
638 mPopupTimer->stop(); 638 mPopupTimer->stop();
639 if (object != viewport()) { 639 if (object != viewport()) {
640 KOAgendaItem *moveItem = (KOAgendaItem *)object; 640 KOAgendaItem *moveItem = (KOAgendaItem *)object;
641 if (!moveItem->incidence()->isReadOnly() ) { 641 if (!moveItem->incidence()->isReadOnly() ) {
642 if (!mActionItem) 642 if (!mActionItem)
643 setNoActionCursor(moveItem,viewportPos); 643 setNoActionCursor(moveItem,viewportPos);
644 else { 644 else {
645 if ( !blockMoving ) 645 if ( !blockMoving )
646 performItemAction(viewportPos); 646 performItemAction(viewportPos);
647 } 647 }
648 } 648 }
649 } else { // ---------- viewport() 649 } else { // ---------- viewport()
650 mPopupPos = viewport()->mapToGlobal( me->pos() ); 650 mPopupPos = viewport()->mapToGlobal( me->pos() );
651 if ( mActionType == SELECT ) { 651 if ( mActionType == SELECT ) {
652 performSelectAction( viewportPos ); 652 performSelectAction( viewportPos );
653 } 653 }
654 } 654 }
655 break; 655 break;
656 656
657 case QEvent::MouseButtonDblClick: 657 case QEvent::MouseButtonDblClick:
658 mPopupTimer->stop(); 658 mPopupTimer->stop();
659 if (object == viewport()) { 659 if (object == viewport()) {
660 selectItem(0); 660 selectItem(0);
661 int x,y; 661 int x,y;
662 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 662 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
663 int gx,gy; 663 int gx,gy;
664 contentsToGrid(x,y,gx,gy); 664 contentsToGrid(x,y,gx,gy);
665 emit newEventSignal(gx,gy); 665 emit newEventSignal(gx,gy);
666 } else { 666 } else {
667 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 667 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
668 selectItem(doubleClickedItem); 668 selectItem(doubleClickedItem);
669 if ( KOPrefs::instance()->mEditOnDoubleClick ) 669 if ( KOPrefs::instance()->mEditOnDoubleClick )
670 emit editIncidenceSignal(doubleClickedItem->incidence()); 670 emit editIncidenceSignal(doubleClickedItem->incidence());
671 else 671 else
672 emit showIncidenceSignal(doubleClickedItem->incidence()); 672 emit showIncidenceSignal(doubleClickedItem->incidence());
673 } 673 }
674 break; 674 break;
675 675
676 default: 676 default:
677 break; 677 break;
678 } 678 }
679 return true; 679 return true;
680 680
681} 681}
682 682
683void KOAgenda::newItem( int item ) 683void KOAgenda::newItem( int item )
684{ 684{
685 if ( item == 1 ) { //new event 685 if ( item == 1 ) { //new event
686 newEventSignal(mStartCellX ,mStartCellY ); 686 newEventSignal(mStartCellX ,mStartCellY );
687 } else 687 } else
688 if ( item == 2 ) { //new event 688 if ( item == 2 ) { //new event
689 newTodoSignal(mStartCellX ,mStartCellY ); 689 newTodoSignal(mStartCellX ,mStartCellY );
690 } else 690 } else
691 { 691 {
692 emit showDateView( item, mStartCellX ); 692 emit showDateView( item, mStartCellX );
693 // 3Day view 693 // 3Day view
694 // 4Week view 694 // 4Week view
695 // 5Month view 695 // 5Month view
696 // 6Journal view 696 // 6Journal view
697 } 697 }
698} 698}
699void KOAgenda::slotClearSelection() 699void KOAgenda::slotClearSelection()
700{ 700{
701 if (mSelectionHeight) { 701 if (mSelectionHeight) {
702 int selectionX = mSelectionCellX * mGridSpacingX; 702 int selectionX = mSelectionCellX * mGridSpacingX;
703 int top = mSelectionYTop - 2 *mGridSpacingY; 703 int top = mSelectionYTop - 2 *mGridSpacingY;
704 int hei = mSelectionHeight + 4 *mGridSpacingY; 704 int hei = mSelectionHeight + 4 *mGridSpacingY;
705 clearSelection(); 705 clearSelection();
706 repaintContents( selectionX, top, 706 repaintContents( selectionX, top,
707 mGridSpacingX, hei ,false ); 707 mGridSpacingX, hei ,false );
708 } 708 }
709 709
710} 710}
711void KOAgenda::startSelectAction(QPoint viewportPos) 711void KOAgenda::startSelectAction(QPoint viewportPos)
712{ 712{
713 713
714 emit signalClearSelection(); 714 emit signalClearSelection();
715 slotClearSelection(); 715 slotClearSelection();
716 716
717 mActionType = SELECT; 717 mActionType = SELECT;
718 718
719 int x,y; 719 int x,y;
720 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 720 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
721 int gx,gy; 721 int gx,gy;
722 contentsToGrid(x,y,gx,gy); 722 contentsToGrid(x,y,gx,gy);
723 723
724 mStartCellX = gx; 724 mStartCellX = gx;
725 mStartCellY = gy; 725 mStartCellY = gy;
726 mCurrentCellX = gx; 726 mCurrentCellX = gx;
727 mCurrentCellY = gy; 727 mCurrentCellY = gy;
728 728
729 // Store new selection 729 // Store new selection
730 mSelectionCellX = gx; 730 mSelectionCellX = gx;
731 mSelectionYTop = gy * mGridSpacingY; 731 mSelectionYTop = gy * mGridSpacingY;
732 mSelectionHeight = mGridSpacingY; 732 mSelectionHeight = mGridSpacingY;
733 733
734 // Paint new selection 734 // Paint new selection
735 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, 735 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
736 mGridSpacingX-1, mSelectionHeight ); 736 mGridSpacingX-1, mSelectionHeight );
737} 737}
738 738
739void KOAgenda::performSelectAction(QPoint viewportPos) 739void KOAgenda::performSelectAction(QPoint viewportPos)
740{ 740{
741 int x,y; 741 int x,y;
742 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 742 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
743 int gx,gy; 743 int gx,gy;
744 contentsToGrid(x,y,gx,gy); 744 contentsToGrid(x,y,gx,gy);
745 745
746 QPoint clipperPos = clipper()-> 746 QPoint clipperPos = clipper()->
747 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 747 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
748 748
749 // Scroll if cursor was moved to upper or lower end of agenda. 749 // Scroll if cursor was moved to upper or lower end of agenda.
750 if (clipperPos.y() < mScrollBorderWidth) { 750 if (clipperPos.y() < mScrollBorderWidth) {
751 mScrollUpTimer.start(mScrollDelay); 751 mScrollUpTimer.start(mScrollDelay);
752 } else if (visibleHeight() - clipperPos.y() < 752 } else if (visibleHeight() - clipperPos.y() <
753 mScrollBorderWidth) { 753 mScrollBorderWidth) {
754 mScrollDownTimer.start(mScrollDelay); 754 mScrollDownTimer.start(mScrollDelay);
755 } else { 755 } else {
756 mScrollUpTimer.stop(); 756 mScrollUpTimer.stop();
757 mScrollDownTimer.stop(); 757 mScrollDownTimer.stop();
758 } 758 }
759 759
760 if ( gy > mCurrentCellY ) { 760 if ( gy > mCurrentCellY ) {
761 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 761 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
762 762
763 763
764 repaintContents( (KOGlobals::self()->reverseLayout() ? 764 repaintContents( (KOGlobals::self()->reverseLayout() ?
765 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 765 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
766 mGridSpacingX, mSelectionYTop, 766 mGridSpacingX, mSelectionYTop,
767 mGridSpacingX, mSelectionHeight , false); 767 mGridSpacingX, mSelectionHeight , false);
768 768
769 mCurrentCellY = gy; 769 mCurrentCellY = gy;
770 } else if ( gy < mCurrentCellY ) { 770 } else if ( gy < mCurrentCellY ) {
771 if ( gy >= mStartCellY ) { 771 if ( gy >= mStartCellY ) {
772 int selectionHeight = mSelectionHeight; 772 int selectionHeight = mSelectionHeight;
773 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 773 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
774 774
775 repaintContents( (KOGlobals::self()->reverseLayout() ? 775 repaintContents( (KOGlobals::self()->reverseLayout() ?
776 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 776 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
777 mGridSpacingX, mSelectionYTop, 777 mGridSpacingX, mSelectionYTop,
778 mGridSpacingX, selectionHeight,false ); 778 mGridSpacingX, selectionHeight,false );
779 779
780 mCurrentCellY = gy; 780 mCurrentCellY = gy;
781 } else { 781 } else {
782 } 782 }
783 } 783 }
784} 784}
785 785
786void KOAgenda::endSelectAction( bool emitNewEvent ) 786void KOAgenda::endSelectAction( bool emitNewEvent )
787{ 787{
788 mActionType = NOP; 788 mActionType = NOP;
789 mScrollUpTimer.stop(); 789 mScrollUpTimer.stop();
790 mScrollDownTimer.stop(); 790 mScrollDownTimer.stop();
791 791
792 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 792 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
793 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 793 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
794 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 794 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
795 } 795 }
796} 796}
797 797
798void KOAgenda::startItemAction(QPoint viewportPos) 798void KOAgenda::startItemAction(QPoint viewportPos)
799{ 799{
800 int x,y; 800 int x,y;
801 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 801 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
802 int gx,gy; 802 int gx,gy;
803 contentsToGrid(x,y,gx,gy); 803 contentsToGrid(x,y,gx,gy);
804 804
805 mStartCellX = gx; 805 mStartCellX = gx;
806 mStartCellY = gy; 806 mStartCellY = gy;
807 mCurrentCellX = gx; 807 mCurrentCellX = gx;
808 mCurrentCellY = gy; 808 mCurrentCellY = gy;
809 809
810 if (mAllDayMode) { 810 if (mAllDayMode) {
811 int gridDistanceX = (x - gx * mGridSpacingX); 811 int gridDistanceX = (x - gx * mGridSpacingX);
812 if (gridDistanceX < mResizeBorderWidth && 812 if (gridDistanceX < mResizeBorderWidth &&
813 mActionItem->cellX() == mCurrentCellX) { 813 mActionItem->cellX() == mCurrentCellX) {
814 mActionType = RESIZELEFT; 814 mActionType = RESIZELEFT;
815 setCursor(sizeHorCursor); 815 setCursor(sizeHorCursor);
816 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 816 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
817 mActionItem->cellXWidth() == mCurrentCellX) { 817 mActionItem->cellXWidth() == mCurrentCellX) {
818 mActionType = RESIZERIGHT; 818 mActionType = RESIZERIGHT;
819 setCursor(sizeHorCursor); 819 setCursor(sizeHorCursor);
820 } else { 820 } else {
821 mActionType = MOVE; 821 mActionType = MOVE;
822 mActionItem->startMove(); 822 mActionItem->startMove();
823 setCursor(sizeAllCursor); 823 setCursor(sizeAllCursor);
824 } 824 }
825 } else { 825 } else {
826 int gridDistanceY = (y - gy * mGridSpacingY); 826 int gridDistanceY = (y - gy * mGridSpacingY);
827 bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); 827 bool allowResize = ( mActionItem->incidence()->typeID() != todoID );
828 if (allowResize && gridDistanceY < mResizeBorderWidth && 828 if (allowResize && gridDistanceY < mResizeBorderWidth &&
829 mActionItem->cellYTop() == mCurrentCellY && 829 mActionItem->cellYTop() == mCurrentCellY &&
830 !mActionItem->firstMultiItem()) { 830 !mActionItem->firstMultiItem()) {
831 mActionType = RESIZETOP; 831 mActionType = RESIZETOP;
832 setCursor(sizeVerCursor); 832 setCursor(sizeVerCursor);
833 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 833 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
834 mActionItem->cellYBottom() == mCurrentCellY && 834 mActionItem->cellYBottom() == mCurrentCellY &&
835 !mActionItem->lastMultiItem()) { 835 !mActionItem->lastMultiItem()) {
836 mActionType = RESIZEBOTTOM; 836 mActionType = RESIZEBOTTOM;
837 setCursor(sizeVerCursor); 837 setCursor(sizeVerCursor);
838 } else { 838 } else {
839 mActionType = MOVE; 839 mActionType = MOVE;
840 mActionItem->startMove(); 840 mActionItem->startMove();
841 setCursor(sizeAllCursor); 841 setCursor(sizeAllCursor);
842 } 842 }
843 } 843 }
844} 844}
845 845
846void KOAgenda::performItemAction(QPoint viewportPos) 846void KOAgenda::performItemAction(QPoint viewportPos)
847{ 847{
848// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 848// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
849// QPoint point = viewport()->mapToGlobal(viewportPos); 849// QPoint point = viewport()->mapToGlobal(viewportPos);
850// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 850// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
851// point = clipper()->mapFromGlobal(point); 851// point = clipper()->mapFromGlobal(point);
852// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 852// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
853// kdDebug() << "visible height: " << visibleHeight() << endl; 853// kdDebug() << "visible height: " << visibleHeight() << endl;
854 int x,y; 854 int x,y;
855 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 855 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
856// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 856// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
857 int gx,gy; 857 int gx,gy;
858 contentsToGrid(x,y,gx,gy); 858 contentsToGrid(x,y,gx,gy);
859 QPoint clipperPos = clipper()-> 859 QPoint clipperPos = clipper()->
860 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 860 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
861 861
862 // Cursor left active agenda area. 862 // Cursor left active agenda area.
863 // This starts a drag. 863 // This starts a drag.
864 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 864 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
865 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 865 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
866 if ( mActionType == MOVE ) { 866 if ( mActionType == MOVE ) {
867 mScrollUpTimer.stop(); 867 mScrollUpTimer.stop();
868 mScrollDownTimer.stop(); 868 mScrollDownTimer.stop();
869 mActionItem->resetMove(); 869 mActionItem->resetMove();
870 placeSubCells( mActionItem ); 870 placeSubCells( mActionItem );
871 // emit startDragSignal( mActionItem->incidence() ); 871 // emit startDragSignal( mActionItem->incidence() );
872 setCursor( arrowCursor ); 872 setCursor( arrowCursor );
873 mActionItem = 0; 873 mActionItem = 0;
874 mActionType = NOP; 874 mActionType = NOP;
875 mItemMoved = 0; 875 mItemMoved = 0;
876 return; 876 return;
877 } 877 }
878 } else { 878 } else {
879 switch ( mActionType ) { 879 switch ( mActionType ) {
880 case MOVE: 880 case MOVE:
881 setCursor( sizeAllCursor ); 881 setCursor( sizeAllCursor );
882 break; 882 break;
883 case RESIZETOP: 883 case RESIZETOP:
884 case RESIZEBOTTOM: 884 case RESIZEBOTTOM:
885 setCursor( sizeVerCursor ); 885 setCursor( sizeVerCursor );
886 break; 886 break;
887 case RESIZELEFT: 887 case RESIZELEFT:
888 case RESIZERIGHT: 888 case RESIZERIGHT:
889 setCursor( sizeHorCursor ); 889 setCursor( sizeHorCursor );
890 break; 890 break;
891 default: 891 default:
892 setCursor( arrowCursor ); 892 setCursor( arrowCursor );
893 } 893 }
894 } 894 }
895 895
896 // Scroll if item was moved to upper or lower end of agenda. 896 // Scroll if item was moved to upper or lower end of agenda.
897 if (clipperPos.y() < mScrollBorderWidth) { 897 if (clipperPos.y() < mScrollBorderWidth) {
898 mScrollUpTimer.start(mScrollDelay); 898 mScrollUpTimer.start(mScrollDelay);
899 } else if (visibleHeight() - clipperPos.y() < 899 } else if (visibleHeight() - clipperPos.y() <
900 mScrollBorderWidth) { 900 mScrollBorderWidth) {
901 mScrollDownTimer.start(mScrollDelay); 901 mScrollDownTimer.start(mScrollDelay);
902 } else { 902 } else {
903 mScrollUpTimer.stop(); 903 mScrollUpTimer.stop();
904 mScrollDownTimer.stop(); 904 mScrollDownTimer.stop();
905 } 905 }
906 906
907 // Move or resize item if necessary 907 // Move or resize item if necessary
908 if (mCurrentCellX != gx || mCurrentCellY != gy) { 908 if (mCurrentCellX != gx || mCurrentCellY != gy) {
909 mItemMoved = true; 909 mItemMoved = true;
910 mActionItem->raise(); 910 mActionItem->raise();
911 if (mActionType == MOVE) { 911 if (mActionType == MOVE) {
912 // Move all items belonging to a multi item 912 // Move all items belonging to a multi item
913 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 913 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
914 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 914 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
915 if (!moveItem) moveItem = mActionItem; 915 if (!moveItem) moveItem = mActionItem;
916 while (moveItem) { 916 while (moveItem) {
917 int dy; 917 int dy;
918 if (isMultiItem) dy = 0; 918 if (isMultiItem) dy = 0;
919 else dy = gy - mCurrentCellY; 919 else dy = gy - mCurrentCellY;
920 moveItem->moveRelative(gx - mCurrentCellX,dy); 920 moveItem->moveRelative(gx - mCurrentCellX,dy);
921 int x,y; 921 int x,y;
922 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 922 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
923 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 923 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
924 mGridSpacingY * moveItem->cellHeight()); 924 mGridSpacingY * moveItem->cellHeight());
925 moveChild(moveItem,x,y); 925 moveChild(moveItem,x,y);
926 moveItem = moveItem->nextMultiItem(); 926 moveItem = moveItem->nextMultiItem();
927 } 927 }
928 } else if (mActionType == RESIZETOP) { 928 } else if (mActionType == RESIZETOP) {
929 if (mCurrentCellY <= mActionItem->cellYBottom()) { 929 if (mCurrentCellY <= mActionItem->cellYBottom()) {
930 mActionItem->expandTop(gy - mCurrentCellY); 930 mActionItem->expandTop(gy - mCurrentCellY);
931 mActionItem->resize(mActionItem->width(), 931 mActionItem->resize(mActionItem->width(),
932 mGridSpacingY * mActionItem->cellHeight()); 932 mGridSpacingY * mActionItem->cellHeight());
933 int x,y; 933 int x,y;
934 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 934 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
935 //moveChild(mActionItem,childX(mActionItem),y); 935 //moveChild(mActionItem,childX(mActionItem),y);
936 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 936 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
937 } 937 }
938 } else if (mActionType == RESIZEBOTTOM) { 938 } else if (mActionType == RESIZEBOTTOM) {
939 if (mCurrentCellY >= mActionItem->cellYTop()) { 939 if (mCurrentCellY >= mActionItem->cellYTop()) {
940 mActionItem->expandBottom(gy - mCurrentCellY); 940 mActionItem->expandBottom(gy - mCurrentCellY);
941 mActionItem->resize(mActionItem->width(), 941 mActionItem->resize(mActionItem->width(),
942 mGridSpacingY * mActionItem->cellHeight()); 942 mGridSpacingY * mActionItem->cellHeight());
943 } 943 }
944 } else if (mActionType == RESIZELEFT) { 944 } else if (mActionType == RESIZELEFT) {
945 if (mCurrentCellX <= mActionItem->cellXWidth()) { 945 if (mCurrentCellX <= mActionItem->cellXWidth()) {
946 mActionItem->expandLeft(gx - mCurrentCellX); 946 mActionItem->expandLeft(gx - mCurrentCellX);
947 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 947 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
948 mActionItem->height()); 948 mActionItem->height());
949 int x,y; 949 int x,y;
950 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 950 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
951 moveChild(mActionItem,x,childY(mActionItem)); 951 moveChild(mActionItem,x,childY(mActionItem));
952 } 952 }
953 } else if (mActionType == RESIZERIGHT) { 953 } else if (mActionType == RESIZERIGHT) {
954 if (mCurrentCellX >= mActionItem->cellX()) { 954 if (mCurrentCellX >= mActionItem->cellX()) {
955 mActionItem->expandRight(gx - mCurrentCellX); 955 mActionItem->expandRight(gx - mCurrentCellX);
956 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 956 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
957 mActionItem->height()); 957 mActionItem->height());
958 } 958 }
959 } 959 }
960 mCurrentCellX = gx; 960 mCurrentCellX = gx;
961 mCurrentCellY = gy; 961 mCurrentCellY = gy;
962 } 962 }
963} 963}
964 964
965void KOAgenda::endItemAction() 965void KOAgenda::endItemAction()
966{ 966{
967 967
968 if ( mItemMoved ) { 968 if ( mItemMoved ) {
969 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 969 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
970 if ( !placeItem ) { 970 if ( !placeItem ) {
971 placeItem = mActionItem; 971 placeItem = mActionItem;
972 } 972 }
973 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 973 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
974 Incidence* oldInc = placeItem->incidence(); 974 Incidence* oldInc = placeItem->incidence();
975 placeItem->recreateIncidence(); 975 placeItem->recreateIncidence();
976 emit addToCalSignal(placeItem->incidence(), oldInc ); 976 emit addToCalSignal(placeItem->incidence(), oldInc );
977 } 977 }
978 int type = mActionType; 978 int type = mActionType;
979 if ( mAllDayMode ) 979 if ( mAllDayMode )
980 type = -1; 980 type = -1;
981 KOAgendaItem *modifiedItem = placeItem; 981 KOAgendaItem *modifiedItem = placeItem;
982 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 982 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
983 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 983 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
984 KOAgendaItem *item; 984 KOAgendaItem *item;
985 985
986 if ( placeItem->incidence()->typeID() == todoID ) { 986 if ( placeItem->incidence()->typeID() == todoID ) {
987 mSelectedItem = 0; 987 mSelectedItem = 0;
988 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 988 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
989 modifiedItem->mLastMoveXPos = mCurrentCellX; 989 modifiedItem->mLastMoveXPos = mCurrentCellX;
990 emit itemModified( modifiedItem, mActionType ); 990 emit itemModified( modifiedItem, mActionType );
991 } 991 }
992 else { 992 else {
993 993
994 994
995 globalFlagBlockAgendaItemPaint = 1; 995 globalFlagBlockAgendaItemPaint = 1;
996 for ( item=oldconflictItems.first(); item != 0; 996 for ( item=oldconflictItems.first(); item != 0;
997 item=oldconflictItems.next() ) { 997 item=oldconflictItems.next() ) {
998 placeSubCells(item); 998 placeSubCells(item);
999 } 999 }
1000 while ( placeItem ) { 1000 while ( placeItem ) {
1001 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1001 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1002 oldconflictItems = placeItem->conflictItems(); 1002 oldconflictItems = placeItem->conflictItems();
1003 for ( item=oldconflictItems.first(); item != 0; 1003 for ( item=oldconflictItems.first(); item != 0;
1004 item=oldconflictItems.next() ) { 1004 item=oldconflictItems.next() ) {
1005 placeSubCells(item); 1005 placeSubCells(item);
1006 } 1006 }
1007 placeSubCells( placeItem ); 1007 placeSubCells( placeItem );
1008 placeItem = placeItem->nextMultiItem(); 1008 placeItem = placeItem->nextMultiItem();
1009 } 1009 }
1010 globalFlagBlockAgendaItemPaint = 0; 1010 globalFlagBlockAgendaItemPaint = 0;
1011 for ( item=oldconflictItems.first(); item != 0; 1011 for ( item=oldconflictItems.first(); item != 0;
1012 item=oldconflictItems.next() ) { 1012 item=oldconflictItems.next() ) {
1013 globalFlagBlockAgendaItemUpdate = 0; 1013 globalFlagBlockAgendaItemUpdate = 0;
1014 item->repaintMe(); 1014 item->repaintMe();
1015 globalFlagBlockAgendaItemUpdate = 1; 1015 globalFlagBlockAgendaItemUpdate = 1;
1016 item->repaint( false ); 1016 item->repaint( false );
1017 } 1017 }
1018 placeItem = modifiedItem; 1018 placeItem = modifiedItem;
1019 1019
1020 while ( placeItem ) { 1020 while ( placeItem ) {
1021 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1021 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1022 globalFlagBlockAgendaItemUpdate = 0; 1022 globalFlagBlockAgendaItemUpdate = 0;
1023 placeItem->repaintMe(); 1023 placeItem->repaintMe();
1024 globalFlagBlockAgendaItemUpdate = 1; 1024 globalFlagBlockAgendaItemUpdate = 1;
1025 placeItem->repaint(false); 1025 placeItem->repaint(false);
1026 placeItem = placeItem->nextMultiItem(); 1026 placeItem = placeItem->nextMultiItem();
1027 } 1027 }
1028 emit itemModified( modifiedItem, mActionType ); 1028 emit itemModified( modifiedItem, mActionType );
1029 1029
1030 1030
1031 placeItem = modifiedItem; 1031 placeItem = modifiedItem;
1032 while ( placeItem ) { 1032 while ( placeItem ) {
1033 oldconflictItems = placeItem->conflictItems(); 1033 oldconflictItems = placeItem->conflictItems();
1034 for ( item=oldconflictItems.first(); item != 0; 1034 for ( item=oldconflictItems.first(); item != 0;
1035 item=oldconflictItems.next() ) { 1035 item=oldconflictItems.next() ) {
1036 placeSubCells(item); 1036 placeSubCells(item);
1037 } 1037 }
1038 placeSubCells( placeItem ); 1038 placeSubCells( placeItem );
1039 placeItem = placeItem->nextMultiItem(); 1039 placeItem = placeItem->nextMultiItem();
1040 1040
1041 } 1041 }
1042 placeItem = modifiedItem; 1042 placeItem = modifiedItem;
1043 while ( placeItem ) { 1043 while ( placeItem ) {
1044 oldconflictItems = placeItem->conflictItems(); 1044 oldconflictItems = placeItem->conflictItems();
1045 for ( item=oldconflictItems.first(); item != 0; 1045 for ( item=oldconflictItems.first(); item != 0;
1046 item=oldconflictItems.next() ) { 1046 item=oldconflictItems.next() ) {
1047 globalFlagBlockAgendaItemUpdate = 0; 1047 globalFlagBlockAgendaItemUpdate = 0;
1048 item->repaintMe(); 1048 item->repaintMe();
1049 globalFlagBlockAgendaItemUpdate = 1; 1049 globalFlagBlockAgendaItemUpdate = 1;
1050 item->repaint(false); 1050 item->repaint(false);
1051 } 1051 }
1052 placeItem = placeItem->nextMultiItem(); 1052 placeItem = placeItem->nextMultiItem();
1053 } 1053 }
1054 /* 1054 /*
1055 1055
1056 oldconflictItems = modifiedItem->conflictItems(); 1056 oldconflictItems = modifiedItem->conflictItems();
1057 for ( item=oldconflictItems.first(); item != 0; 1057 for ( item=oldconflictItems.first(); item != 0;
1058 item=oldconflictItems.next() ) { 1058 item=oldconflictItems.next() ) {
1059 globalFlagBlockAgendaItemUpdate = 0; 1059 globalFlagBlockAgendaItemUpdate = 0;
1060 item->paintMe(false); 1060 item->paintMe(false);
1061 globalFlagBlockAgendaItemUpdate = 1; 1061 globalFlagBlockAgendaItemUpdate = 1;
1062 item->repaint(false); 1062 item->repaint(false);
1063 } 1063 }
1064 */ 1064 */
1065 1065
1066 1066
1067 } 1067 }
1068 1068
1069 } 1069 }
1070 1070
1071 mScrollUpTimer.stop(); 1071 mScrollUpTimer.stop();
1072 mScrollDownTimer.stop(); 1072 mScrollDownTimer.stop();
1073 setCursor( arrowCursor ); 1073 setCursor( arrowCursor );
1074 mActionItem = 0; 1074 mActionItem = 0;
1075 mActionType = NOP; 1075 mActionType = NOP;
1076 mItemMoved = 0; 1076 mItemMoved = 0;
1077 1077
1078} 1078}
1079 1079
1080void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1080void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1081{ 1081{
1082// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1082// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1083// QPoint point = viewport()->mapToGlobal(viewportPos); 1083// QPoint point = viewport()->mapToGlobal(viewportPos);
1084// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1084// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1085// point = clipper()->mapFromGlobal(point); 1085// point = clipper()->mapFromGlobal(point);
1086// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1086// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1087 1087
1088 int x,y; 1088 int x,y;
1089 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1089 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1090// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1090// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1091 int gx,gy; 1091 int gx,gy;
1092 contentsToGrid(x,y,gx,gy); 1092 contentsToGrid(x,y,gx,gy);
1093 1093
1094 // Change cursor to resize cursor if appropriate 1094 // Change cursor to resize cursor if appropriate
1095 if (mAllDayMode) { 1095 if (mAllDayMode) {
1096 int gridDistanceX = (x - gx * mGridSpacingX); 1096 int gridDistanceX = (x - gx * mGridSpacingX);
1097 if (gridDistanceX < mResizeBorderWidth && 1097 if (gridDistanceX < mResizeBorderWidth &&
1098 moveItem->cellX() == gx) { 1098 moveItem->cellX() == gx) {
1099 setCursor(sizeHorCursor); 1099 setCursor(sizeHorCursor);
1100 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1100 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1101 moveItem->cellXWidth() == gx) { 1101 moveItem->cellXWidth() == gx) {
1102 setCursor(sizeHorCursor); 1102 setCursor(sizeHorCursor);
1103 } else { 1103 } else {
1104 setCursor(arrowCursor); 1104 setCursor(arrowCursor);
1105 } 1105 }
1106 } else { 1106 } else {
1107 int gridDistanceY = (y - gy * mGridSpacingY); 1107 int gridDistanceY = (y - gy * mGridSpacingY);
1108 if (gridDistanceY < mResizeBorderWidth && 1108 if (gridDistanceY < mResizeBorderWidth &&
1109 moveItem->cellYTop() == gy && 1109 moveItem->cellYTop() == gy &&
1110 !moveItem->firstMultiItem()) { 1110 !moveItem->firstMultiItem()) {
1111 setCursor(sizeVerCursor); 1111 setCursor(sizeVerCursor);
1112 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1112 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1113 moveItem->cellYBottom() == gy && 1113 moveItem->cellYBottom() == gy &&
1114 !moveItem->lastMultiItem()) { 1114 !moveItem->lastMultiItem()) {
1115 setCursor(sizeVerCursor); 1115 setCursor(sizeVerCursor);
1116 } else { 1116 } else {
1117 setCursor(arrowCursor); 1117 setCursor(arrowCursor);
1118 } 1118 }
1119 } 1119 }
1120} 1120}
1121 1121
1122 1122
1123/* 1123/*
1124 Place item in cell and take care that multiple items using the same cell do 1124 Place item in cell and take care that multiple items using the same cell do
1125 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1125 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1126 it can get in all cases. 1126 it can get in all cases.
1127 At the moment the method has a bug: When an item is placed only the sub cell 1127 At the moment the method has a bug: When an item is placed only the sub cell
1128 widths of the items are changed, which are within the Y region the item to 1128 widths of the items are changed, which are within the Y region the item to
1129 place spans. When the sub cell width change of one of this items affects a 1129 place spans. When the sub cell width change of one of this items affects a
1130 cell, where other items are, which do not overlap in Y with the item to place, 1130 cell, where other items are, which do not overlap in Y with the item to place,
1131 the display gets corrupted, although the corruption looks quite nice. 1131 the display gets corrupted, although the corruption looks quite nice.
1132*/ 1132*/
1133void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1133void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1134{ 1134{
1135 1135
1136 QPtrList<KOAgendaItem> conflictItems; 1136 QPtrList<KOAgendaItem> conflictItems;
1137 int maxSubCells = 0; 1137 int maxSubCells = 0;
1138 QIntDict<KOAgendaItem> subCellDict(5); 1138 QIntDict<KOAgendaItem> subCellDict(7);
1139 1139
1140 KOAgendaItem *item; 1140 KOAgendaItem *item;
1141 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1141 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1142 if (item != placeItem) { 1142 if (item != placeItem) {
1143 if (placeItem->cellX() <= item->cellXWidth() && 1143 if (placeItem->cellX() <= item->cellXWidth() &&
1144 placeItem->cellXWidth() >= item->cellX()) { 1144 placeItem->cellXWidth() >= item->cellX()) {
1145 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1145 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1146 (placeItem->cellYBottom() >= item->cellYTop())) { 1146 (placeItem->cellYBottom() >= item->cellYTop())) {
1147 conflictItems.append(item); 1147 conflictItems.append(item);
1148 if (item->subCells() > maxSubCells) 1148 if (item->subCells() > maxSubCells)
1149 maxSubCells = item->subCells(); 1149 maxSubCells = item->subCells();
1150 subCellDict.insert(item->subCell(),item); 1150 subCellDict.insert(item->subCell(),item);
1151 } 1151 }
1152 } 1152 }
1153 } 1153 }
1154 } 1154 }
1155 1155
1156 if (conflictItems.count() > 0) { 1156 if (conflictItems.count() > 0) {
1157 // Look for unused sub cell and insert item 1157 // Look for unused sub cell and insert item
1158 int i; 1158 int i;
1159 for(i=0;i<maxSubCells;++i) { 1159 for(i=0;i<maxSubCells;++i) {
1160 if (!subCellDict.find(i)) { 1160 if (!subCellDict.find(i)) {
1161 placeItem->setSubCell(i); 1161 placeItem->setSubCell(i);
1162 break; 1162 break;
1163 } 1163 }
1164 } 1164 }
1165 if (i == maxSubCells) { 1165 if (i == maxSubCells) {
1166 placeItem->setSubCell(maxSubCells); 1166 placeItem->setSubCell(maxSubCells);
1167 maxSubCells++; // add new item to number of sub cells 1167 maxSubCells++; // add new item to number of sub cells
1168 } 1168 }
1169 1169
1170 // Prepare for sub cell geometry adjustment 1170 // Prepare for sub cell geometry adjustment
1171 int newSubCellWidth; 1171 int newSubCellWidth;
1172 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1172 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1173 else newSubCellWidth = mGridSpacingX / maxSubCells; 1173 else newSubCellWidth = mGridSpacingX / maxSubCells;
1174 conflictItems.append(placeItem); 1174 conflictItems.append(placeItem);
1175 1175
1176 1176
1177 // Adjust sub cell geometry of all direct conflict items 1177 // Adjust sub cell geometry of all direct conflict items
1178 for ( item=conflictItems.first(); item != 0; 1178 for ( item=conflictItems.first(); item != 0;
1179 item=conflictItems.next() ) { 1179 item=conflictItems.next() ) {
1180 item->setSubCells(maxSubCells); 1180 item->setSubCells(maxSubCells);
1181 if (mAllDayMode) { 1181 if (mAllDayMode) {
1182 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1182 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1183 } else { 1183 } else {
1184 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1184 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1185 } 1185 }
1186 int x,y; 1186 int x,y;
1187 gridToContents(item->cellX(),item->cellYTop(),x,y); 1187 gridToContents(item->cellX(),item->cellYTop(),x,y);
1188 if (mAllDayMode) { 1188 if (mAllDayMode) {
1189 y += item->subCell() * newSubCellWidth; 1189 y += item->subCell() * newSubCellWidth;
1190 } else { 1190 } else {
1191 x += item->subCell() * newSubCellWidth; 1191 x += item->subCell() * newSubCellWidth;
1192 } 1192 }
1193 moveChild(item,x,y); 1193 moveChild(item,x,y);
1194 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1194 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1195 //item->updateItem(); 1195 //item->updateItem();
1196 } 1196 }
1197 // Adjust sub cell geometry of all conflict items of all conflict items 1197 // Adjust sub cell geometry of all conflict items of all conflict items
1198 for ( item=conflictItems.first(); item != 0; 1198 for ( item=conflictItems.first(); item != 0;
1199 item=conflictItems.next() ) { 1199 item=conflictItems.next() ) {
1200 if ( placeItem != item ) { 1200 if ( placeItem != item ) {
1201 KOAgendaItem *item2; 1201 KOAgendaItem *item2;
1202 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1202 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1203 for ( item2=conflictItems2.first(); item2 != 0; 1203 for ( item2=conflictItems2.first(); item2 != 0;
1204 item2=conflictItems2.next() ) { 1204 item2=conflictItems2.next() ) {
1205 if ( item2->subCells() != maxSubCells) { 1205 if ( item2->subCells() != maxSubCells) {
1206 item2->setSubCells(maxSubCells); 1206 item2->setSubCells(maxSubCells);
1207 if (mAllDayMode) { 1207 if (mAllDayMode) {
1208 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1208 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1209 } else { 1209 } else {
1210 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1210 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1211 } 1211 }
1212 int x,y; 1212 int x,y;
1213 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1213 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1214 if (mAllDayMode) { 1214 if (mAllDayMode) {
1215 y += item2->subCell() * newSubCellWidth; 1215 y += item2->subCell() * newSubCellWidth;
1216 } else { 1216 } else {
1217 x += item2->subCell() * newSubCellWidth; 1217 x += item2->subCell() * newSubCellWidth;
1218 } 1218 }
1219 moveChild(item2,x,y); 1219 moveChild(item2,x,y);
1220 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1220 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1221 } 1221 }
1222 } 1222 }
1223 } 1223 }
1224 } 1224 }
1225 } else { 1225 } else {
1226 placeItem->setSubCell(0); 1226 placeItem->setSubCell(0);
1227 placeItem->setSubCells(1); 1227 placeItem->setSubCells(1);
1228 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1228 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1229 else placeItem->resize(mGridSpacingX,placeItem->height()); 1229 else placeItem->resize(mGridSpacingX,placeItem->height());
1230 int x,y; 1230 int x,y;
1231 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1231 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1232 moveChild(placeItem,x,y); 1232 moveChild(placeItem,x,y);
1233 } 1233 }
1234 placeItem->setConflictItems(conflictItems); 1234 placeItem->setConflictItems(conflictItems);
1235 // for ( item=conflictItems.first(); item != 0; 1235 // for ( item=conflictItems.first(); item != 0;
1236// item=conflictItems.next() ) { 1236// item=conflictItems.next() ) {
1237// //item->updateItem(); 1237// //item->updateItem();
1238// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1238// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1239// } 1239// }
1240// placeItem->updateItem(); 1240// placeItem->updateItem();
1241} 1241}
1242 1242
1243void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1243void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1244{ 1244{
1245 if ( globalFlagBlockAgenda ) 1245 if ( globalFlagBlockAgenda )
1246 return; 1246 return;
1247 if ( ! mAllDayMode ) { 1247 if ( ! mAllDayMode ) {
1248 // currently not working for 1248 // currently not working for
1249 1249
1250 //qDebug("KOAgenda::drawContents "); 1250 //qDebug("KOAgenda::drawContents ");
1251 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1251 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1252 ;//drawContentsToPainter(); 1252 ;//drawContentsToPainter();
1253 1253
1254 QPaintDevice* pd = p->device(); 1254 QPaintDevice* pd = p->device();
1255 p->end(); 1255 p->end();
1256 int vx, vy; 1256 int vx, vy;
1257 int selectionX = KOGlobals::self()->reverseLayout() ? 1257 int selectionX = KOGlobals::self()->reverseLayout() ?
1258 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1258 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1259 mSelectionCellX * mGridSpacingX; 1259 mSelectionCellX * mGridSpacingX;
1260 contentsToViewport ( cx, cy, vx,vy); 1260 contentsToViewport ( cx, cy, vx,vy);
1261 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1261 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1262 1262
1263 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1263 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1264 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1264 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1265 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1265 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1266 1266
1267 int vxSel, vySel; 1267 int vxSel, vySel;
1268 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1268 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1269 int off = mSelectionHeight; 1269 int off = mSelectionHeight;
1270 if ( vySel < 0 ) 1270 if ( vySel < 0 )
1271 off += vySel; 1271 off += vySel;
1272 //qDebug("OFF %d %d %d", off,vySel, vy ); 1272 //qDebug("OFF %d %d %d", off,vySel, vy );
1273 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1273 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1274 } else { 1274 } else {
1275 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1275 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1276 } 1276 }
1277 } 1277 }
1278 if ( mSelectionHeight > 0 ) { 1278 if ( mSelectionHeight > 0 ) {
1279 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1279 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1280 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1280 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1281 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1281 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1282 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1282 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1283 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1283 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1284 } 1284 }
1285 } 1285 }
1286 p->begin( pd ); 1286 p->begin( pd );
1287 } else { 1287 } else {
1288 1288
1289 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1289 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1290 ;//drawContentsToPainter(); 1290 ;//drawContentsToPainter();
1291 1291
1292 QPaintDevice* pd = p->device(); 1292 QPaintDevice* pd = p->device();
1293 p->end(); 1293 p->end();
1294 int vx, vy; 1294 int vx, vy;
1295 int selectionX = KOGlobals::self()->reverseLayout() ? 1295 int selectionX = KOGlobals::self()->reverseLayout() ?
1296 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1296 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1297 mSelectionCellX * mGridSpacingX; 1297 mSelectionCellX * mGridSpacingX;
1298 contentsToViewport ( cx, cy, vx,vy); 1298 contentsToViewport ( cx, cy, vx,vy);
1299 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1299 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1300 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1300 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1301 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1301 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1302 1302
1303 if ( mSelectionHeight > 0 ) { 1303 if ( mSelectionHeight > 0 ) {
1304 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1304 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1305 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1305 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1306 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1306 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1307 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1307 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1308 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1308 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1309 } 1309 }
1310 } 1310 }
1311 p->begin( pd ); 1311 p->begin( pd );
1312 } 1312 }
1313 1313
1314} 1314}
1315 1315
1316void KOAgenda::finishUpdate() 1316void KOAgenda::finishUpdate()
1317{ 1317{
1318 1318
1319 KOAgendaItem *item; 1319 KOAgendaItem *item;
1320 globalFlagBlockAgendaItemPaint = 1; 1320 globalFlagBlockAgendaItemPaint = 1;
1321 // 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 1321 // 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
1322 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1322 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1323 if ( !item->checkLayout() ) { 1323 if ( !item->checkLayout() ) {
1324 //qDebug(" conflictitem found "); 1324 //qDebug(" conflictitem found ");
1325 int newSubCellWidth; 1325 int newSubCellWidth;
1326 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1326 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1327 else newSubCellWidth = mGridSpacingX / item->subCells(); 1327 else newSubCellWidth = mGridSpacingX / item->subCells();
1328 1328
1329 if (mAllDayMode) { 1329 if (mAllDayMode) {
1330 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1330 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1331 } else { 1331 } else {
1332 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1332 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1333 } 1333 }
1334 int x,y; 1334 int x,y;
1335 gridToContents(item->cellX(),item->cellYTop(),x,y); 1335 gridToContents(item->cellX(),item->cellYTop(),x,y);
1336 if (mAllDayMode) { 1336 if (mAllDayMode) {
1337 y += item->subCell() * newSubCellWidth; 1337 y += item->subCell() * newSubCellWidth;
1338 } else { 1338 } else {
1339 x += item->subCell() * newSubCellWidth; 1339 x += item->subCell() * newSubCellWidth;
1340 } 1340 }
1341 moveChild(item,x,y); 1341 moveChild(item,x,y);
1342 } 1342 }
1343 } 1343 }
1344 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1344 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1345 if ( !item->isVisible() ) 1345 if ( !item->isVisible() )
1346 item->show(); 1346 item->show();
1347 1347
1348 } 1348 }
1349 globalFlagBlockAgendaItemUpdate = 0; 1349 globalFlagBlockAgendaItemUpdate = 0;
1350 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1350 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1351 item->repaintMe( ); 1351 item->repaintMe( );
1352 } 1352 }
1353 globalFlagBlockAgendaItemUpdate = 1; 1353 globalFlagBlockAgendaItemUpdate = 1;
1354 qApp->processEvents(); 1354 qApp->processEvents();
1355 globalFlagBlockAgendaItemPaint = 0; 1355 globalFlagBlockAgendaItemPaint = 0;
1356 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1356 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1357 item->repaint( false ); 1357 item->repaint( false );
1358 } 1358 }
1359 1359
1360} 1360}
1361 1361
1362/* 1362/*
1363 Draw grid in the background of the agenda. 1363 Draw grid in the background of the agenda.
1364*/ 1364*/
1365void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1365void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1366{ 1366{
1367 1367
1368 1368
1369 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1369 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1370 return; 1370 return;
1371 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1371 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1372 return; 1372 return;
1373 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1373 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1374 if ( ch < 1 ) 1374 if ( ch < 1 )
1375 ch = 1; 1375 ch = 1;
1376 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1376 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1377 mPaintPixmap.resize( contentsWidth()+42, ch ); 1377 mPaintPixmap.resize( contentsWidth()+42, ch );
1378 } 1378 }
1379 mCurPixWid = contentsWidth(); 1379 mCurPixWid = contentsWidth();
1380 mCurPixHei = ch; 1380 mCurPixHei = ch;
1381 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { 1381 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) {
1382 mHighlightPixmap.resize( mGridSpacingX-1, ch ); 1382 mHighlightPixmap.resize( mGridSpacingX-1, ch );
1383 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1383 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1384 } 1384 }
1385 mPixPainter.begin( &mPaintPixmap) ; 1385 mPixPainter.begin( &mPaintPixmap) ;
1386 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1386 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1387 QPainter * p ; 1387 QPainter * p ;
1388 if (paint == 0) { 1388 if (paint == 0) {
1389 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1389 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1390 p = &mPixPainter; 1390 p = &mPixPainter;
1391 } 1391 }
1392 else 1392 else
1393 p = paint ; 1393 p = paint ;
1394 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1394 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1395 1395
1396 //--cx;++cw; 1396 //--cx;++cw;
1397 int lGridSpacingY = mGridSpacingY*2; 1397 int lGridSpacingY = mGridSpacingY*2;
1398 int selDay; 1398 int selDay;
1399 if ( !backgroundOnly ) 1399 if ( !backgroundOnly )
1400 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1400 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1401 { 1401 {
1402 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { 1402 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
1403 int x1 = cx; 1403 int x1 = cx;
1404 int y1 = 0; 1404 int y1 = 0;
1405 if (y1 < cy) y1 = cy; 1405 if (y1 < cy) y1 = cy;
1406 int x2 = cx+cw-1; 1406 int x2 = cx+cw-1;
1407 int y2 = contentsHeight(); 1407 int y2 = contentsHeight();
1408 if (y2 > cy+ch-1) y2=cy+ch-1; 1408 if (y2 > cy+ch-1) y2=cy+ch-1;
1409 if (x2 >= x1 && y2 >= y1) { 1409 if (x2 >= x1 && y2 >= y1) {
1410 int gxStart = selDay; 1410 int gxStart = selDay;
1411 int gxEnd = gxStart ; 1411 int gxEnd = gxStart ;
1412 int xStart = KOGlobals::self()->reverseLayout() ? 1412 int xStart = KOGlobals::self()->reverseLayout() ?
1413 (mColumns - 1 - gxStart)*mGridSpacingX : 1413 (mColumns - 1 - gxStart)*mGridSpacingX :
1414 gxStart*mGridSpacingX; 1414 gxStart*mGridSpacingX;
1415 if (xStart < x1) xStart = x1; 1415 if (xStart < x1) xStart = x1;
1416 int xEnd = KOGlobals::self()->reverseLayout() ? 1416 int xEnd = KOGlobals::self()->reverseLayout() ?
1417 (mColumns - gxStart)*mGridSpacingX-1 : 1417 (mColumns - gxStart)*mGridSpacingX-1 :
1418 (gxStart+1)*mGridSpacingX-1; 1418 (gxStart+1)*mGridSpacingX-1;
1419 if (xEnd > x2) xEnd = x2; 1419 if (xEnd > x2) xEnd = x2;
1420 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1420 if ( KOPrefs::instance()->mUseHighlightLightColor )
1421 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1421 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1422 KOPrefs::instance()->mAgendaBgColor.light()); 1422 KOPrefs::instance()->mAgendaBgColor.light());
1423 else 1423 else
1424 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1424 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1425 KOPrefs::instance()->mAgendaBgColor.dark()); 1425 KOPrefs::instance()->mAgendaBgColor.dark());
1426 1426
1427 } 1427 }
1428 } 1428 }
1429 } 1429 }
1430 // Highlight working hours 1430 // Highlight working hours
1431 1431
1432 if ( !backgroundOnly ) 1432 if ( !backgroundOnly )
1433 if (mWorkingHoursEnable) { 1433 if (mWorkingHoursEnable) {
1434 int x1 = cx; 1434 int x1 = cx;
1435 int y1 = mWorkingHoursYTop; 1435 int y1 = mWorkingHoursYTop;
1436 if (y1 < cy) y1 = cy; 1436 if (y1 < cy) y1 = cy;
1437 int x2 = cx+cw-1; 1437 int x2 = cx+cw-1;
1438 // int x2 = mGridSpacingX * 5 - 1; 1438 // int x2 = mGridSpacingX * 5 - 1;
1439 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1439 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1440 int y2 = mWorkingHoursYBottom; 1440 int y2 = mWorkingHoursYBottom;
1441 if (y2 > cy+ch-1) y2=cy+ch-1; 1441 if (y2 > cy+ch-1) y2=cy+ch-1;
1442 1442
1443 if (x2 >= x1 && y2 >= y1) { 1443 if (x2 >= x1 && y2 >= y1) {
1444 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1444 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1445 int gxStart = x1/mGridSpacingX; 1445 int gxStart = x1/mGridSpacingX;
1446 int gxEnd = x2/mGridSpacingX; 1446 int gxEnd = x2/mGridSpacingX;
1447 while(gxStart <= gxEnd) { 1447 while(gxStart <= gxEnd) {
1448 if (gxStart < int(mHolidayMask->count()) && 1448 if (gxStart < int(mHolidayMask->count()) &&
1449 !mHolidayMask->at(gxStart)) { 1449 !mHolidayMask->at(gxStart)) {
1450 int xStart = KOGlobals::self()->reverseLayout() ? 1450 int xStart = KOGlobals::self()->reverseLayout() ?
1451 (mColumns - 1 - gxStart)*mGridSpacingX : 1451 (mColumns - 1 - gxStart)*mGridSpacingX :
1452 gxStart*mGridSpacingX; 1452 gxStart*mGridSpacingX;
1453 if (xStart < x1) xStart = x1; 1453 if (xStart < x1) xStart = x1;
1454 int xEnd = KOGlobals::self()->reverseLayout() ? 1454 int xEnd = KOGlobals::self()->reverseLayout() ?
1455 (mColumns - gxStart)*mGridSpacingX-1 : 1455 (mColumns - gxStart)*mGridSpacingX-1 :
1456 (gxStart+1)*mGridSpacingX-1; 1456 (gxStart+1)*mGridSpacingX-1;
1457 if (xEnd > x2) xEnd = x2; 1457 if (xEnd > x2) xEnd = x2;
1458 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { 1458 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
1459 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1459 if ( KOPrefs::instance()->mUseHighlightLightColor )
1460 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1460 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1461 KOPrefs::instance()->mWorkingHoursColor.light()); 1461 KOPrefs::instance()->mWorkingHoursColor.light());
1462 else 1462 else
1463 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1463 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1464 KOPrefs::instance()->mWorkingHoursColor.dark()); 1464 KOPrefs::instance()->mWorkingHoursColor.dark());
1465 } else { 1465 } else {
1466 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1466 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1467 KOPrefs::instance()->mWorkingHoursColor); 1467 KOPrefs::instance()->mWorkingHoursColor);
1468 } 1468 }
1469 } 1469 }
1470 ++gxStart; 1470 ++gxStart;
1471 } 1471 }
1472 } 1472 }
1473 } 1473 }
1474 /* 1474 /*
1475 int selectionX = KOGlobals::self()->reverseLayout() ? 1475 int selectionX = KOGlobals::self()->reverseLayout() ?
1476 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1476 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1477 mSelectionCellX * mGridSpacingX; 1477 mSelectionCellX * mGridSpacingX;
1478 1478
1479 // Draw selection 1479 // Draw selection
1480 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1480 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1481 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1481 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1482 // TODO: paint only part within cx,cy,cw,ch 1482 // TODO: paint only part within cx,cy,cw,ch
1483 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1483 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1484 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1484 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1485 } 1485 }
1486 */ 1486 */
1487 // Draw vertical lines of grid 1487 // Draw vertical lines of grid
1488 1488
1489 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1489 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1490 if ( mGridSpacingX > 0 ) { 1490 if ( mGridSpacingX > 0 ) {
1491 while (x < cx + cw) { 1491 while (x < cx + cw) {
1492 p->drawLine(x,cy,x,cy+ch); 1492 p->drawLine(x,cy,x,cy+ch);
1493 x+=mGridSpacingX; 1493 x+=mGridSpacingX;
1494 } 1494 }
1495 } 1495 }
1496 // Draw horizontal lines of grid 1496 // Draw horizontal lines of grid
1497 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1497 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1498 if ( lGridSpacingY > 0 ) { 1498 if ( lGridSpacingY > 0 ) {
1499 while (y < cy + ch) { 1499 while (y < cy + ch) {
1500 p->setPen( SolidLine ); 1500 p->setPen( SolidLine );
1501 p->drawLine(cx,y,cx+cw,y); 1501 p->drawLine(cx,y,cx+cw,y);
1502 y+=lGridSpacingY; 1502 y+=lGridSpacingY;
1503 p->setPen( DotLine ); 1503 p->setPen( DotLine );
1504 p->drawLine(cx,y,cx+cw,y); 1504 p->drawLine(cx,y,cx+cw,y);
1505 y+=lGridSpacingY; 1505 y+=lGridSpacingY;
1506 } 1506 }
1507 p->setPen( SolidLine ); 1507 p->setPen( SolidLine );
1508 } 1508 }
1509 mPixPainter.end() ; 1509 mPixPainter.end() ;
1510} 1510}
1511 1511
1512/* 1512/*
1513 Convert srcollview contents coordinates to agenda grid coordinates. 1513 Convert srcollview contents coordinates to agenda grid coordinates.
1514*/ 1514*/
1515void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1515void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1516{ 1516{
1517 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1517 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1518 x/mGridSpacingX; 1518 x/mGridSpacingX;
1519 gy = y/mGridSpacingY; 1519 gy = y/mGridSpacingY;
1520} 1520}
1521 1521
1522/* 1522/*
1523 Convert agenda grid coordinates to scrollview contents coordinates. 1523 Convert agenda grid coordinates to scrollview contents coordinates.
1524*/ 1524*/
1525void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1525void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1526{ 1526{
1527 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1527 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1528 gx*mGridSpacingX; 1528 gx*mGridSpacingX;
1529 y = gy*mGridSpacingY; 1529 y = gy*mGridSpacingY;
1530} 1530}
1531 1531
1532 1532
1533/* 1533/*
1534 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1534 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1535 the grid. 1535 the grid.
1536*/ 1536*/
1537int KOAgenda::timeToY(const QTime &time) 1537int KOAgenda::timeToY(const QTime &time)
1538{ 1538{
1539 int minutesPerCell = 24 * 60 / mRows; 1539 int minutesPerCell = 24 * 60 / mRows;
1540 int timeMinutes = time.hour() * 60 + time.minute(); 1540 int timeMinutes = time.hour() * 60 + time.minute();
1541 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1541 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1542 return Y; 1542 return Y;
1543} 1543}
1544 1544
1545 1545
1546/* 1546/*
1547 Return time corresponding to cell y coordinate. Coordinates are rounded to 1547 Return time corresponding to cell y coordinate. Coordinates are rounded to
1548 fit into the grid. 1548 fit into the grid.
1549*/ 1549*/
1550QTime KOAgenda::gyToTime(int gy) 1550QTime KOAgenda::gyToTime(int gy)
1551{ 1551{
1552 1552
1553 int secondsPerCell = 24 * 60 * 60/ mRows; 1553 int secondsPerCell = 24 * 60 * 60/ mRows;
1554 1554
1555 int timeSeconds = secondsPerCell * gy; 1555 int timeSeconds = secondsPerCell * gy;
1556 1556
1557 QTime time( 0, 0, 0 ); 1557 QTime time( 0, 0, 0 );
1558 if ( timeSeconds < 24 * 60 * 60 ) { 1558 if ( timeSeconds < 24 * 60 * 60 ) {
1559 time = time.addSecs(timeSeconds); 1559 time = time.addSecs(timeSeconds);
1560 } else { 1560 } else {
1561 time.setHMS( 23, 59, 59 ); 1561 time.setHMS( 23, 59, 59 );
1562 } 1562 }
1563 1563
1564 return time; 1564 return time;
1565} 1565}
1566 1566
1567void KOAgenda::setStartHour(int startHour) 1567void KOAgenda::setStartHour(int startHour)
1568{ 1568{
1569 int startCell = startHour * mRows / 24; 1569 int startCell = startHour * mRows / 24;
1570 setContentsPos(0,startCell * gridSpacingY()); 1570 setContentsPos(0,startCell * gridSpacingY());
1571} 1571}
1572void KOAgenda::hideUnused() 1572void KOAgenda::hideUnused()
1573{ 1573{
1574 // experimental only 1574 // experimental only
1575 // return; 1575 // return;
1576 KOAgendaItem *item; 1576 KOAgendaItem *item;
1577 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1577 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1578 item->hide(); 1578 item->hide();
1579 } 1579 }
1580} 1580}
1581 1581
1582 1582
1583KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1583KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1584{ 1584{
1585 1585
1586 KOAgendaItem *fi; 1586 KOAgendaItem *fi;
1587 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1587 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1588 if ( fi->incidence() == event ) { 1588 if ( fi->incidence() == event ) {
1589 mUnusedItems.remove(); 1589 mUnusedItems.remove();
1590 fi->init( event, qd ); 1590 fi->init( event, qd );
1591 return fi; 1591 return fi;
1592 } 1592 }
1593 } 1593 }
1594 fi=mUnusedItems.first(); 1594 fi=mUnusedItems.first();
1595 if ( fi ) { 1595 if ( fi ) {
1596 mUnusedItems.remove(); 1596 mUnusedItems.remove();
1597 fi->init( event, qd ); 1597 fi->init( event, qd );
1598 return fi; 1598 return fi;
1599 } 1599 }
1600 // qDebug("new KOAgendaItem "); 1600 // qDebug("new KOAgendaItem ");
1601 1601
1602 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1602 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1603 agendaItem->installEventFilter(this); 1603 agendaItem->installEventFilter(this);
1604 addChild(agendaItem,0,0); 1604 addChild(agendaItem,0,0);
1605 return agendaItem; 1605 return agendaItem;
1606} 1606}
1607KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1607KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1608{ 1608{
1609 KOAgendaItem *item; 1609 KOAgendaItem *item;
1610 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1610 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1611 if ( item->incidence() == todo ) { 1611 if ( item->incidence() == todo ) {
1612 mItems.remove(); 1612 mItems.remove();
1613 return item; 1613 return item;
1614 } 1614 }
1615 } 1615 }
1616 return 0; 1616 return 0;
1617} 1617}
1618 1618
1619 1619
1620void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1620void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1621{ 1621{
1622 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1622 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1623 KOAgendaItem *item; 1623 KOAgendaItem *item;
1624 item = getItemForTodo ( todo ); 1624 item = getItemForTodo ( todo );
1625 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1625 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1626 if ( item ) { 1626 if ( item ) {
1627 blockSignals( true ); 1627 blockSignals( true );
1628 //qDebug("item found "); 1628 //qDebug("item found ");
1629 item->hide(); 1629 item->hide();
1630 item->setCellX(-2, -1 ); 1630 item->setCellX(-2, -1 );
1631 item->select(false); 1631 item->select(false);
1632 mUnusedItems.append( item ); 1632 mUnusedItems.append( item );
1633 mItems.remove( item ); 1633 mItems.remove( item );
1634 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1634 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1635 KOAgendaItem *itemit; 1635 KOAgendaItem *itemit;
1636 //globalFlagBlockAgendaItemPaint = 1; 1636 //globalFlagBlockAgendaItemPaint = 1;
1637 for ( itemit=oldconflictItems.first(); itemit != 0; 1637 for ( itemit=oldconflictItems.first(); itemit != 0;
1638 itemit=oldconflictItems.next() ) { 1638 itemit=oldconflictItems.next() ) {
1639 if ( itemit != item ) 1639 if ( itemit != item )
1640 placeSubCells(itemit); 1640 placeSubCells(itemit);
1641 } 1641 }
1642 qApp->processEvents(); 1642 qApp->processEvents();
1643 //globalFlagBlockAgendaItemPaint = 0; 1643 //globalFlagBlockAgendaItemPaint = 0;
1644 for ( itemit=oldconflictItems.first(); itemit != 0; 1644 for ( itemit=oldconflictItems.first(); itemit != 0;
1645 itemit=oldconflictItems.next() ) { 1645 itemit=oldconflictItems.next() ) {
1646 globalFlagBlockAgendaItemUpdate = 0; 1646 globalFlagBlockAgendaItemUpdate = 0;
1647 if ( itemit != item ) 1647 if ( itemit != item )
1648 itemit->repaintMe(); 1648 itemit->repaintMe();
1649 globalFlagBlockAgendaItemUpdate = 1; 1649 globalFlagBlockAgendaItemUpdate = 1;
1650 itemit->repaint(); 1650 itemit->repaint();
1651 } 1651 }
1652 blockSignals( false ); 1652 blockSignals( false );
1653 } 1653 }
1654 if ( remove ) { 1654 if ( remove ) {
1655 //qDebug("remove****************************************** "); 1655 //qDebug("remove****************************************** ");
1656 return; 1656 return;
1657 } 1657 }
1658 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) 1658 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
1659 return; 1659 return;
1660 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1660 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1661 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1661 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
1662 QDate currentDate; 1662 QDate currentDate;
1663 QDateTime dt; 1663 QDateTime dt;
1664 if ( todo->hasCompletedDate() ) 1664 if ( todo->hasCompletedDate() )
1665 dt = todo->completed(); 1665 dt = todo->completed();
1666 else 1666 else
1667 dt = todo->dtDue(); 1667 dt = todo->dtDue();
1668 if ( overdue ) { 1668 if ( overdue ) {
1669 currentDate = QDate::currentDate(); 1669 currentDate = QDate::currentDate();
1670 days += todo->dtDue().date().daysTo( currentDate ); 1670 days += todo->dtDue().date().daysTo( currentDate );
1671 } 1671 }
1672 else 1672 else
1673 currentDate = dt.date(); 1673 currentDate = dt.date();
1674 1674
1675 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1675 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1676 if ( ! mAllDayMode ) return; 1676 if ( ! mAllDayMode ) return;
1677 // aldayagenda 1677 // aldayagenda
1678 globalFlagBlockAgendaItemPaint = 1; 1678 globalFlagBlockAgendaItemPaint = 1;
1679 item = insertAllDayItem(todo, currentDate,days, days); 1679 item = insertAllDayItem(todo, currentDate,days, days);
1680 item->show(); 1680 item->show();
1681 1681
1682 } 1682 }
1683 else { 1683 else {
1684 if ( mAllDayMode ) return; 1684 if ( mAllDayMode ) return;
1685 // mAgenda 1685 // mAgenda
1686 globalFlagBlockAgendaItemPaint = 1; 1686 globalFlagBlockAgendaItemPaint = 1;
1687 int endY = timeToY(dt.time()) - 1; 1687 int endY = timeToY(dt.time()) - 1;
1688 int hi = 12/KOPrefs::instance()->mHourSize; 1688 int hi = 12/KOPrefs::instance()->mHourSize;
1689 int startY = endY - 1-hi; 1689 int startY = endY - 1-hi;
1690 item = insertItem(todo,currentDate,days,startY,endY); 1690 item = insertItem(todo,currentDate,days,startY,endY);
1691 item->show(); 1691 item->show();
1692 } 1692 }
1693 qApp->processEvents(); 1693 qApp->processEvents();
1694 globalFlagBlockAgendaItemPaint = 0; 1694 globalFlagBlockAgendaItemPaint = 0;
1695 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1695 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1696 KOAgendaItem *itemit; 1696 KOAgendaItem *itemit;
1697 for ( itemit=oldconflictItems.first(); itemit != 0; 1697 for ( itemit=oldconflictItems.first(); itemit != 0;
1698 itemit=oldconflictItems.next() ) { 1698 itemit=oldconflictItems.next() ) {
1699 globalFlagBlockAgendaItemUpdate = 0; 1699 globalFlagBlockAgendaItemUpdate = 0;
1700 itemit->repaintMe(); 1700 itemit->repaintMe();
1701 globalFlagBlockAgendaItemUpdate = 1; 1701 globalFlagBlockAgendaItemUpdate = 1;
1702 itemit->repaint(); 1702 itemit->repaint();
1703 } 1703 }
1704 globalFlagBlockAgendaItemUpdate = 0; 1704 globalFlagBlockAgendaItemUpdate = 0;
1705 item->repaintMe(); 1705 item->repaintMe();
1706 globalFlagBlockAgendaItemUpdate = 1; 1706 globalFlagBlockAgendaItemUpdate = 1;
1707 item->repaint(); 1707 item->repaint();
1708} 1708}
1709/* 1709/*
1710 Insert KOAgendaItem into agenda. 1710 Insert KOAgendaItem into agenda.
1711*/ 1711*/
1712KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1712KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1713{ 1713{
1714 if (mAllDayMode) { 1714 if (mAllDayMode) {
1715 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1715 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1716 return 0; 1716 return 0;
1717 } 1717 }
1718 1718
1719 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1719 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1720 //agendaItem->setFrameStyle(WinPanel|Raised); 1720 //agendaItem->setFrameStyle(WinPanel|Raised);
1721 1721
1722 int YSize = YBottom - YTop + 1; 1722 int YSize = YBottom - YTop + 1;
1723 if (YSize < 0) { 1723 if (YSize < 0) {
1724 YSize = 1; 1724 YSize = 1;
1725 } 1725 }
1726 int iheight = mGridSpacingY * YSize; 1726 int iheight = mGridSpacingY * YSize;
1727 1727
1728 agendaItem->resize(mGridSpacingX,iheight ); 1728 agendaItem->resize(mGridSpacingX,iheight );
1729 agendaItem->setCellXY(X,YTop,YBottom); 1729 agendaItem->setCellXY(X,YTop,YBottom);
1730 agendaItem->setCellXWidth(X); 1730 agendaItem->setCellXWidth(X);
1731 1731
1732 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1732 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1733 mItems.append(agendaItem); 1733 mItems.append(agendaItem);
1734 1734
1735 placeSubCells(agendaItem); 1735 placeSubCells(agendaItem);
1736 1736
1737 //agendaItem->show(); 1737 //agendaItem->show();
1738 1738
1739 marcus_bains(); 1739 marcus_bains();
1740 1740
1741 return agendaItem; 1741 return agendaItem;
1742} 1742}
1743 1743
1744 1744
1745/* 1745/*
1746 Insert all-day KOAgendaItem into agenda. 1746 Insert all-day KOAgendaItem into agenda.
1747*/ 1747*/
1748KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1748KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1749{ 1749{
1750 if (!mAllDayMode) { 1750 if (!mAllDayMode) {
1751 return 0; 1751 return 0;
1752 } 1752 }
1753 1753
1754 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1754 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1755 1755
1756 agendaItem->setCellXY(XBegin,0,0); 1756 agendaItem->setCellXY(XBegin,0,0);
1757 agendaItem->setCellXWidth(XEnd); 1757 agendaItem->setCellXWidth(XEnd);
1758 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1758 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1759 1759
1760 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1760 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1761 mItems.append(agendaItem); 1761 mItems.append(agendaItem);
1762 1762
1763 placeSubCells(agendaItem); 1763 placeSubCells(agendaItem);
1764 1764
1765 //agendaItem->show(); 1765 //agendaItem->show();
1766 1766
1767 return agendaItem; 1767 return agendaItem;
1768} 1768}
1769 1769
1770 1770
1771void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1771void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1772 int YTop,int YBottom) 1772 int YTop,int YBottom)
1773{ 1773{
1774 if (mAllDayMode) { 1774 if (mAllDayMode) {
1775 ; 1775 ;
1776 return; 1776 return;
1777 } 1777 }
1778 1778
1779 int cellX,cellYTop,cellYBottom; 1779 int cellX,cellYTop,cellYBottom;
1780 QString newtext; 1780 QString newtext;
1781 int width = XEnd - XBegin + 1; 1781 int width = XEnd - XBegin + 1;
1782 int count = 0; 1782 int count = 0;
1783 KOAgendaItem *current = 0; 1783 KOAgendaItem *current = 0;
1784 QPtrList<KOAgendaItem> multiItems; 1784 QPtrList<KOAgendaItem> multiItems;
1785 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1785 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1786 if (cellX == XBegin) cellYTop = YTop; 1786 if (cellX == XBegin) cellYTop = YTop;
1787 else cellYTop = 0; 1787 else cellYTop = 0;
1788 if (cellX == XEnd) cellYBottom = YBottom; 1788 if (cellX == XEnd) cellYBottom = YBottom;
1789 else cellYBottom = rows() - 1; 1789 else cellYBottom = rows() - 1;
1790 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1790 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1791 newtext.append(event->summary()); 1791 newtext.append(event->summary());
1792 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1792 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1793 current->setText(newtext); 1793 current->setText(newtext);
1794 multiItems.append(current); 1794 multiItems.append(current);
1795 } 1795 }
1796 1796
1797 KOAgendaItem *next = 0; 1797 KOAgendaItem *next = 0;
1798 KOAgendaItem *last = multiItems.last(); 1798 KOAgendaItem *last = multiItems.last();
1799 KOAgendaItem *first = multiItems.first(); 1799 KOAgendaItem *first = multiItems.first();
1800 KOAgendaItem *setFirst,*setLast; 1800 KOAgendaItem *setFirst,*setLast;
1801 current = first; 1801 current = first;
1802 while (current) { 1802 while (current) {
1803 next = multiItems.next(); 1803 next = multiItems.next();
1804 if (current == first) setFirst = 0; 1804 if (current == first) setFirst = 0;
1805 else setFirst = first; 1805 else setFirst = first;
1806 if (current == last) setLast = 0; 1806 if (current == last) setLast = 0;
1807 else setLast = last; 1807 else setLast = last;
1808 1808
1809 current->setMultiItem(setFirst,next,setLast); 1809 current->setMultiItem(setFirst,next,setLast);
1810 current = next; 1810 current = next;
1811 } 1811 }
1812 1812
1813 marcus_bains(); 1813 marcus_bains();
1814} 1814}
1815 1815
1816 1816
1817//QSizePolicy KOAgenda::sizePolicy() const 1817//QSizePolicy KOAgenda::sizePolicy() const
1818//{ 1818//{
1819 // Thought this would make the all-day event agenda minimum size and the 1819 // Thought this would make the all-day event agenda minimum size and the
1820 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1820 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1821 // don´t seem to think that an Expanding widget needs more space than a 1821 // don´t seem to think that an Expanding widget needs more space than a
1822 // Preferred one. 1822 // Preferred one.
1823 // But it doesn´t hurt, so it stays. 1823 // But it doesn´t hurt, so it stays.
1824// if (mAllDayMode) { 1824// if (mAllDayMode) {
1825// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1825// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1826// } else { 1826// } else {
1827// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1827// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1828// } 1828// }
1829//} 1829//}
1830void KOAgenda::finishResize ( ) 1830void KOAgenda::finishResize ( )
1831{ 1831{
1832 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1832 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1833 if ( globalFlagBlockAgenda == 0 ) { 1833 if ( globalFlagBlockAgenda == 0 ) {
1834 finishUpdate(); 1834 finishUpdate();
1835 //qDebug("finishUpdate() called "); 1835 //qDebug("finishUpdate() called ");
1836 } 1836 }
1837} 1837}
1838/* 1838/*
1839 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1839 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1840*/ 1840*/
1841void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1841void KOAgenda::resizeEvent ( QResizeEvent *ev )
1842{ 1842{
1843 mSelectionHeight = 0; 1843 mSelectionHeight = 0;
1844 mResizeTimer.start( 150 , true ); 1844 mResizeTimer.start( 150 , true );
1845 computeSizes(); 1845 computeSizes();
1846 return; 1846 return;
1847 1847
1848} 1848}
1849void KOAgenda::computeSizes() 1849void KOAgenda::computeSizes()
1850{ 1850{
1851 if ( globalFlagBlockStartup ) 1851 if ( globalFlagBlockStartup )
1852 return; 1852 return;
1853 int frameOffset = frameWidth() * 2 +1; 1853 int frameOffset = frameWidth() * 2 +1;
1854 if (mAllDayMode) { 1854 if (mAllDayMode) {
1855 mGridSpacingX = (width()-frameOffset) / mColumns; 1855 mGridSpacingX = (width()-frameOffset) / mColumns;
1856 mGridSpacingY = height() - 2 * frameWidth() - 1; 1856 mGridSpacingY = height() - 2 * frameWidth() - 1;
1857 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1857 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1858 // mGridSpacingY = height(); 1858 // mGridSpacingY = height();
1859 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1859 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1860 1860
1861 KOAgendaItem *item; 1861 KOAgendaItem *item;
1862 int subCellWidth; 1862 int subCellWidth;
1863 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1863 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1864 subCellWidth = mGridSpacingY / item->subCells(); 1864 subCellWidth = mGridSpacingY / item->subCells();
1865 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1865 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1866 moveChild(item,KOGlobals::self()->reverseLayout() ? 1866 moveChild(item,KOGlobals::self()->reverseLayout() ?
1867 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1867 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1868 item->cellX() * mGridSpacingX, 1868 item->cellX() * mGridSpacingX,
1869 item->subCell() * subCellWidth); 1869 item->subCell() * subCellWidth);
1870 } 1870 }
1871 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1871 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1872 } else { 1872 } else {
1873 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1873 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1874 if (height() > mGridSpacingY * mRows + 1 ) { 1874 if (height() > mGridSpacingY * mRows + 1 ) {
1875 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1875 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1876 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1876 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1877 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1877 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1878 emit resizedSignal(); 1878 emit resizedSignal();
1879 } else 1879 } else
1880 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1880 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1881 KOAgendaItem *item; 1881 KOAgendaItem *item;
1882 int subCellWidth; 1882 int subCellWidth;
1883 1883
1884 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1884 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1885 subCellWidth = mGridSpacingX / item->subCells(); 1885 subCellWidth = mGridSpacingX / item->subCells();
1886 item->resize(subCellWidth,item->height()); 1886 item->resize(subCellWidth,item->height());
1887 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1887 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1888 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1888 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1889 item->cellX() * mGridSpacingX) + 1889 item->cellX() * mGridSpacingX) +
1890 item->subCell() * subCellWidth,childY(item)); 1890 item->subCell() * subCellWidth,childY(item));
1891 } 1891 }
1892 } 1892 }
1893 int cw = contentsWidth(); 1893 int cw = contentsWidth();
1894 int ch = contentsHeight(); 1894 int ch = contentsHeight();
1895 if ( mAllDayMode ) { 1895 if ( mAllDayMode ) {
1896 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1896 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1897 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) 1897 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1898 paintPixAll->resize( cw, ch ); 1898 paintPixAll->resize( cw, ch );
1899 } else { 1899 } else {
1900 QPixmap* paintPix = KOAgendaItem::paintPix(); 1900 QPixmap* paintPix = KOAgendaItem::paintPix();
1901 if ( paintPix->width() < cw || paintPix->height() < ch ) 1901 if ( paintPix->width() < cw || paintPix->height() < ch )
1902 KOAgendaItem::resizePixmap( cw , ch ); 1902 KOAgendaItem::resizePixmap( cw , ch );
1903 } 1903 }
1904 1904
1905 checkScrollBoundaries(); 1905 checkScrollBoundaries();
1906 marcus_bains(); 1906 marcus_bains();
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index a42227c..5a63b35 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -356,1310 +356,1281 @@ void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 477
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), 478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *))); 479 this,SLOT(categoryChanged(Incidence *)));
480 480
481 481
482 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
483 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
484 // make connections between dependent widgets 484 // make connections between dependent widgets
485 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
486 486
487 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
488 // updateConfig(); 488 // updateConfig();
489 489
490 // createDayLabels(); 490 // createDayLabels();
491 491
492 // these blank widgets make the All Day Event box line up with the agenda 492 // these blank widgets make the All Day Event box line up with the agenda
493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
496 496
497 // Scrolling 497 // Scrolling
498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
499 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
501 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
502 502
503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
505 505
506 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
507 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
508 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
510 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
512 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
514 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
516 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
518 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
520 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
525 525
526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
527 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
529 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
531 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
533 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
535 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
537 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
538 538
539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
540 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
542 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
543 543
544 // event indicator update 544 // event indicator update
545 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
546 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
547 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
548 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
549 // drag signals 549 // drag signals
550 /* 550 /*
551 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
552 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
554 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
555 */ 555 */
556 // synchronize selections 556 // synchronize selections
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
562 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
564 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
565 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
566 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
570 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
573 573
574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
576 576
577} 577}
578 578
579void KOAgendaView::toggleAllDay() 579void KOAgendaView::toggleAllDay()
580{ 580{
581 if ( mSplitterAgenda->firstHandle() ) 581 if ( mSplitterAgenda->firstHandle() )
582 mSplitterAgenda->firstHandle()->toggle(); 582 mSplitterAgenda->firstHandle()->toggle();
583} 583}
584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
585{ 585{
586 calendar()->addIncidence( inc ); 586 calendar()->addIncidence( inc );
587 587
588 if ( incOld ) { 588 if ( incOld ) {
589 if ( incOld->typeID() == todoID ) 589 if ( incOld->typeID() == todoID )
590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
591 else 591 else
592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
593 } 593 }
594 594
595} 595}
596void KOAgendaView::categoryChanged(Incidence * inc) 596void KOAgendaView::categoryChanged(Incidence * inc)
597{ 597{
598 mAgenda->categoryChanged( inc ); 598 mAgenda->categoryChanged( inc );
599 mAllDayAgenda->categoryChanged( inc ); 599 mAllDayAgenda->categoryChanged( inc );
600} 600}
601KOAgendaView::~KOAgendaView() 601KOAgendaView::~KOAgendaView()
602{ 602{
603 delete mAllAgendaPopup; 603 delete mAllAgendaPopup;
604 //delete mAllDayAgendaPopup; 604 //delete mAllDayAgendaPopup;
605 delete KOAgendaItem::paintPix(); 605 delete KOAgendaItem::paintPix();
606 delete KOAgendaItem::paintPixSel(); 606 delete KOAgendaItem::paintPixSel();
607} 607}
608void KOAgendaView::resizeEvent( QResizeEvent* e ) 608void KOAgendaView::resizeEvent( QResizeEvent* e )
609{ 609{
610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
611 bool uc = false; 611 bool uc = false;
612 int ow = e->oldSize().width(); 612 int ow = e->oldSize().width();
613 int oh = e->oldSize().height(); 613 int oh = e->oldSize().height();
614 int w = e->size().width(); 614 int w = e->size().width();
615 int h = e->size().height(); 615 int h = e->size().height();
616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
618 uc = true; 618 uc = true;
619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
620 } 620 }
621 mUpcomingWidth = e->size().width() ; 621 mUpcomingWidth = e->size().width() ;
622 if ( mBlockUpdating || uc ) { 622 if ( mBlockUpdating || uc ) {
623 mBlockUpdating = false; 623 mBlockUpdating = false;
624 //mAgenda->setMinimumSize(800 , 600 ); 624 //mAgenda->setMinimumSize(800 , 600 );
625 //qDebug("mAgenda->resize+++++++++++++++ "); 625 //qDebug("mAgenda->resize+++++++++++++++ ");
626 updateConfig(); 626 updateConfig();
627 //qDebug("KOAgendaView::Updating now possible "); 627 //qDebug("KOAgendaView::Updating now possible ");
628 } else 628 } else
629 createDayLabels(); 629 createDayLabels();
630 //qDebug("resizeEvent end "); 630 //qDebug("resizeEvent end ");
631 631
632} 632}
633void KOAgendaView::slotDaylabelClicked( int num ) 633void KOAgendaView::slotDaylabelClicked( int num )
634{ 634{
635 635
636 QDate firstDate = mSelectedDates.first(); 636 QDate firstDate = mSelectedDates.first();
637 if ( num == -1 ) 637 if ( num == -1 )
638 emit showDateView( 6, firstDate ); 638 emit showDateView( 6, firstDate );
639 else if (num >= 0 ) { 639 else if (num >= 0 ) {
640 if ( mSelectedDates.count() == 1) 640 if ( mSelectedDates.count() == 1)
641 emit showDateView( 9, firstDate.addDays( num ) ); 641 emit showDateView( 9, firstDate.addDays( num ) );
642 else 642 else
643 emit showDateView( 3, firstDate.addDays( num ) ); 643 emit showDateView( 3, firstDate.addDays( num ) );
644 } 644 }
645 else 645 else
646 showDateView( 10, firstDate.addDays(1) ); 646 showDateView( 10, firstDate.addDays(1) );
647} 647}
648 648
649KOAgendaButton* KOAgendaView::getNewDaylabel() 649KOAgendaButton* KOAgendaView::getNewDaylabel()
650{ 650{
651 651
652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
654 mDayLabelsList.append( dayLabel ); 654 mDayLabelsList.append( dayLabel );
655 mLayoutDayLabels->addWidget(dayLabel); 655 mLayoutDayLabels->addWidget(dayLabel);
656 return dayLabel ; 656 return dayLabel ;
657} 657}
658 658
659void KOAgendaView::createDayLabels() 659void KOAgendaView::createDayLabels()
660{ 660{
661 661
662 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 662 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
663 // qDebug(" KOAgendaView::createDayLabels() blocked "); 663 // qDebug(" KOAgendaView::createDayLabels() blocked ");
664 return; 664 return;
665 665
666 } 666 }
667 int newHight; 667 int newHight;
668 if ( !mSelectedDates.count()) 668 if ( !mSelectedDates.count())
669 return; 669 return;
670 670
671 // ### Before deleting and recreating we could check if mSelectedDates changed... 671 // ### Before deleting and recreating we could check if mSelectedDates changed...
672 // It would remove some flickering and gain speed (since this is called by 672 // It would remove some flickering and gain speed (since this is called by
673 // each updateView() call) 673 // each updateView() call)
674 674
675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
677 if ( maxWid < 20 ) 677 if ( maxWid < 20 )
678 maxWid = 20; 678 maxWid = 20;
679 679
680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
681 QFontMetrics fm ( dlf ); 681 QFontMetrics fm ( dlf );
682 dlf.setBold( true ); 682 dlf.setBold( true );
683 int selCount = mSelectedDates.count(); 683 int selCount = mSelectedDates.count();
684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
685 QString dayTest = "Mon 20"; 685 QString dayTest = "Mon 20";
686 //QString dayTest = "Mon 20"; 686 //QString dayTest = "Mon 20";
687 int wid = fm.width( dayTest ); 687 int wid = fm.width( dayTest );
688 //maxWid -= ( selCount * 3 ); //working for QLabels 688 //maxWid -= ( selCount * 3 ); //working for QLabels
689 if ( QApplication::desktop()->width() <= 320 ) 689 if ( QApplication::desktop()->width() <= 320 )
690 maxWid -= ( selCount * 3 ); //working for QPushButton 690 maxWid -= ( selCount * 3 ); //working for QPushButton
691 else 691 else
692 maxWid -= ( selCount * 4 ); //working for QPushButton 692 maxWid -= ( selCount * 4 ); //working for QPushButton
693 if ( maxWid < 0 ) 693 if ( maxWid < 0 )
694 maxWid = 20; 694 maxWid = 20;
695 int needWid = wid * selCount; 695 int needWid = wid * selCount;
696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
697 //if ( needWid > maxWid ) 697 //if ( needWid > maxWid )
698 // qDebug("DAYLABELS TOOOOOOO BIG "); 698 // qDebug("DAYLABELS TOOOOOOO BIG ");
699 while ( needWid > maxWid ) { 699 while ( needWid > maxWid ) {
700 dayTest = dayTest.left( dayTest.length() - 1 ); 700 dayTest = dayTest.left( dayTest.length() - 1 );
701 wid = fm.width( dayTest ); 701 wid = fm.width( dayTest );
702 needWid = wid * selCount; 702 needWid = wid * selCount;
703 } 703 }
704 int maxLen = dayTest.length(); 704 int maxLen = dayTest.length();
705 int fontPoint = dlf.pointSize(); 705 int fontPoint = dlf.pointSize();
706 if ( maxLen < 2 ) { 706 if ( maxLen < 2 ) {
707 int fontPoint = dlf.pointSize(); 707 int fontPoint = dlf.pointSize();
708 while ( fontPoint > 4 ) { 708 while ( fontPoint > 4 ) {
709 --fontPoint; 709 --fontPoint;
710 dlf.setPointSize( fontPoint ); 710 dlf.setPointSize( fontPoint );
711 QFontMetrics f( dlf ); 711 QFontMetrics f( dlf );
712 wid = f.width( "30" ); 712 wid = f.width( "30" );
713 needWid = wid * selCount; 713 needWid = wid * selCount;
714 if ( needWid < maxWid ) 714 if ( needWid < maxWid )
715 break; 715 break;
716 } 716 }
717 maxLen = 2; 717 maxLen = 2;
718 } 718 }
719 //qDebug("Max len %d ", dayTest.length() ); 719 //qDebug("Max len %d ", dayTest.length() );
720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
721 dlf.setBold( false ); 721 dlf.setBold( false );
722 QFontMetrics tempF( dlf ); 722 QFontMetrics tempF( dlf );
723 newHight = tempF.height(); 723 newHight = tempF.height();
724 mDayLabels->setFont( dlf ); 724 mDayLabels->setFont( dlf );
725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
726 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 726 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
727 //mLayoutDayLabels->addSpacing( 2 ); 727 //mLayoutDayLabels->addSpacing( 2 );
728 // QFont lFont = dlf; 728 // QFont lFont = dlf;
729 bool appendLabels = false; 729 bool appendLabels = false;
730 KOAgendaButton *dayLabel; 730 KOAgendaButton *dayLabel;
731 dayLabel = mDayLabelsList.first(); 731 dayLabel = mDayLabelsList.first();
732 if ( !dayLabel ) { 732 if ( !dayLabel ) {
733 appendLabels = true; 733 appendLabels = true;
734 dayLabel = getNewDaylabel(); 734 dayLabel = getNewDaylabel();
735 } 735 }
736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
737 dayLabel->setFont( dlf ); 737 dayLabel->setFont( dlf );
738 dayLabel->setNum( -1 ); 738 dayLabel->setNum( -1 );
739 //dayLabel->setAlignment(QLabel::AlignHCenter); 739 //dayLabel->setAlignment(QLabel::AlignHCenter);
740 740
741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
742 dayLabel->show(); 742 dayLabel->show();
743 DateList::ConstIterator dit; 743 DateList::ConstIterator dit;
744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
745 int counter = -1; 745 int counter = -1;
746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
747 ++counter; 747 ++counter;
748 QDate date = *dit; 748 QDate date = *dit;
749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
750 if ( ! appendLabels ) { 750 if ( ! appendLabels ) {
751 dayLabel = mDayLabelsList.next(); 751 dayLabel = mDayLabelsList.next();
752 if ( !dayLabel ) 752 if ( !dayLabel )
753 appendLabels = true; 753 appendLabels = true;
754 } 754 }
755 if ( appendLabels ) { 755 if ( appendLabels ) {
756 dayLabel = getNewDaylabel(); 756 dayLabel = getNewDaylabel();
757 } 757 }
758 dayLabel->setMinimumWidth( 1 ); 758 dayLabel->setMinimumWidth( 1 );
759 dayLabel->setMaximumWidth( 10240 ); 759 dayLabel->setMaximumWidth( 10240 );
760 dayLabel->setFont( dlf ); 760 dayLabel->setFont( dlf );
761 dayLabel->show(); 761 dayLabel->show();
762 dayLabel->setAutoRepeat( false ); 762 dayLabel->setAutoRepeat( false );
763 dayLabel->setNum( counter ); 763 dayLabel->setNum( counter );
764 QString str; 764 QString str;
765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
767 switch ( maxLen ) { 767 switch ( maxLen ) {
768 case 2: 768 case 2:
769 str = QString::number( date.day() ); 769 str = QString::number( date.day() );
770 break; 770 break;
771 771
772 case 3: 772 case 3:
773 str = dayName.left( 1 ) +QString::number( date.day()); 773 str = dayName.left( 1 ) +QString::number( date.day());
774 774
775 break; 775 break;
776 case 4: 776 case 4:
777 str = dayName.left( 1 ) + " " +QString::number( date.day()); 777 str = dayName.left( 1 ) + " " +QString::number( date.day());
778 778
779 break; 779 break;
780 case 5: 780 case 5:
781 str = dayName.left( 2 ) + " " +QString::number( date.day()); 781 str = dayName.left( 2 ) + " " +QString::number( date.day());
782 782
783 break; 783 break;
784 case 6: 784 case 6:
785 str = dayName.left( 3 ) + " " +QString::number( date.day()); 785 str = dayName.left( 3 ) + " " +QString::number( date.day());
786 break; 786 break;
787 787
788 default: 788 default:
789 break; 789 break;
790 } 790 }
791 if ( oneday ) { 791 if ( oneday ) {
792 QString addString; 792 QString addString;
793 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 793 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
794 addString = i18n("Today"); 794 addString = i18n("Today");
795 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 795 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
796 addString = i18n("Tomorrow"); 796 addString = i18n("Tomorrow");
797 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 797 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
798 addString = i18n("Yesterday"); 798 addString = i18n("Yesterday");
799 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 799 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
800 addString = i18n("Day before yesterday"); 800 addString = i18n("Day before yesterday");
801 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 801 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
802 addString = i18n("Day after tomorrow"); 802 addString = i18n("Day after tomorrow");
803 if ( !addString.isEmpty() ) { 803 if ( !addString.isEmpty() ) {
804 str = addString+", " + str; 804 str = addString+", " + str;
805 } else { 805 } else {
806 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 806 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
807 } 807 }
808 } 808 }
809 dayLabel->setText(str); 809 dayLabel->setText(str);
810 //dayLabel->setAlignment(QLabel::AlignHCenter); 810 //dayLabel->setAlignment(QLabel::AlignHCenter);
811 if (date == QDate::currentDate()) { 811 if (date == QDate::currentDate()) {
812 QFont bFont = dlf; 812 QFont bFont = dlf;
813 bFont.setBold( true ); 813 bFont.setBold( true );
814 dayLabel->setFont(bFont); 814 dayLabel->setFont(bFont);
815 } 815 }
816 //dayLayout->addWidget(dayLabel); 816 //dayLayout->addWidget(dayLabel);
817 817
818#ifndef KORG_NOPLUGINS 818#ifndef KORG_NOPLUGINS
819 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 819 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
820 CalendarDecoration *it; 820 CalendarDecoration *it;
821 for(it = cds.first(); it; it = cds.next()) { 821 for(it = cds.first(); it; it = cds.next()) {
822 QString text = it->shortText( date ); 822 QString text = it->shortText( date );
823 if ( !text.isEmpty() ) { 823 if ( !text.isEmpty() ) {
824 QLabel *label = new QLabel(text,mDayLabels); 824 QLabel *label = new QLabel(text,mDayLabels);
825 label->setAlignment(AlignCenter); 825 label->setAlignment(AlignCenter);
826 dayLayout->addWidget(label); 826 dayLayout->addWidget(label);
827 } 827 }
828 } 828 }
829 829
830 for(it = cds.first(); it; it = cds.next()) { 830 for(it = cds.first(); it; it = cds.next()) {
831 QWidget *wid = it->smallWidget(mDayLabels,date); 831 QWidget *wid = it->smallWidget(mDayLabels,date);
832 if ( wid ) { 832 if ( wid ) {
833 // wid->setHeight(20); 833 // wid->setHeight(20);
834 dayLayout->addWidget(wid); 834 dayLayout->addWidget(wid);
835 } 835 }
836 } 836 }
837#endif 837#endif
838 } 838 }
839 if ( ! appendLabels ) { 839 if ( ! appendLabels ) {
840 dayLabel = mDayLabelsList.next(); 840 dayLabel = mDayLabelsList.next();
841 if ( !dayLabel ) 841 if ( !dayLabel )
842 appendLabels = true; 842 appendLabels = true;
843 } 843 }
844 if ( appendLabels ) { 844 if ( appendLabels ) {
845 dayLabel = getNewDaylabel(); 845 dayLabel = getNewDaylabel();
846 } 846 }
847 //dayLabel->hide();//test only 847 //dayLabel->hide();//test only
848 848
849 dayLabel->setText(">"); 849 dayLabel->setText(">");
850 dayLabel->setFont( dlf ); 850 dayLabel->setFont( dlf );
851 dayLabel->setAutoRepeat( true ); 851 dayLabel->setAutoRepeat( true );
852 dayLabel->show(); 852 dayLabel->show();
853 dayLabel->setNum( -2 ); 853 dayLabel->setNum( -2 );
854 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 854 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
855 855
856 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 856 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
857 if ( !appendLabels ) { 857 if ( !appendLabels ) {
858 dayLabel = mDayLabelsList.next(); 858 dayLabel = mDayLabelsList.next();
859 while ( dayLabel ) { 859 while ( dayLabel ) {
860 //qDebug("!dayLabel %d",dayLabel ); 860 //qDebug("!dayLabel %d",dayLabel );
861 dayLabel->hide(); 861 dayLabel->hide();
862 dayLabel = mDayLabelsList.next(); 862 dayLabel = mDayLabelsList.next();
863 } 863 }
864 } 864 }
865 865
866 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 866 mDayLabelsFrame->setFixedHeight( newHight + 4 );
867} 867}
868 868
869int KOAgendaView::maxDatesHint() 869int KOAgendaView::maxDatesHint()
870{ 870{
871 // Not sure about the max number of events, so return 0 for now. 871 // Not sure about the max number of events, so return 0 for now.
872 return 0; 872 return 0;
873} 873}
874 874
875int KOAgendaView::currentDateCount() 875int KOAgendaView::currentDateCount()
876{ 876{
877 return mSelectedDates.count(); 877 return mSelectedDates.count();
878} 878}
879 879
880QPtrList<Incidence> KOAgendaView::selectedIncidences() 880QPtrList<Incidence> KOAgendaView::selectedIncidences()
881{ 881{
882 QPtrList<Incidence> selected; 882 QPtrList<Incidence> selected;
883 Incidence *incidence; 883 Incidence *incidence;
884 884
885 incidence = mAgenda->selectedIncidence(); 885 incidence = mAgenda->selectedIncidence();
886 if (incidence) selected.append(incidence); 886 if (incidence) selected.append(incidence);
887 887
888 incidence = mAllDayAgenda->selectedIncidence(); 888 incidence = mAllDayAgenda->selectedIncidence();
889 if (incidence) selected.append(incidence); 889 if (incidence) selected.append(incidence);
890 890
891 return selected; 891 return selected;
892} 892}
893 893
894DateList KOAgendaView::selectedDates() 894DateList KOAgendaView::selectedDates()
895{ 895{
896 DateList selected; 896 DateList selected;
897 QDate qd; 897 QDate qd;
898 898
899 qd = mAgenda->selectedIncidenceDate(); 899 qd = mAgenda->selectedIncidenceDate();
900 if (qd.isValid()) selected.append(qd); 900 if (qd.isValid()) selected.append(qd);
901 901
902 qd = mAllDayAgenda->selectedIncidenceDate(); 902 qd = mAllDayAgenda->selectedIncidenceDate();
903 if (qd.isValid()) selected.append(qd); 903 if (qd.isValid()) selected.append(qd);
904 904
905 return selected; 905 return selected;
906} 906}
907 907
908 908
909void KOAgendaView::updateView() 909void KOAgendaView::updateView()
910{ 910{
911 if ( mBlockUpdating ) 911 if ( mBlockUpdating )
912 return; 912 return;
913 // kdDebug() << "KOAgendaView::updateView()" << endl; 913 // kdDebug() << "KOAgendaView::updateView()" << endl;
914 fillAgenda(); 914 fillAgenda();
915 915
916} 916}
917 917
918 918
919/* 919/*
920 Update configuration settings for the agenda view. This method is not 920 Update configuration settings for the agenda view. This method is not
921 complete. 921 complete.
922*/ 922*/
923void KOAgendaView::updateConfig() 923void KOAgendaView::updateConfig()
924{ 924{
925 if ( mBlockUpdating ) 925 if ( mBlockUpdating )
926 return; 926 return;
927 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 927 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
928 int old = KOPrefs::instance()->mHourSize; 928 int old = KOPrefs::instance()->mHourSize;
929 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 929 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
930 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 930 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
931 } 931 }
932 932
933 933
934 // update config for children 934 // update config for children
935 mTimeLabels->updateConfig(); 935 mTimeLabels->updateConfig();
936 mAgenda->storePosition(); 936 mAgenda->storePosition();
937 mAgenda->updateConfig(); 937 mAgenda->updateConfig();
938 mAllDayAgenda->updateConfig(); 938 mAllDayAgenda->updateConfig();
939 // widget synchronization 939 // widget synchronization
940 //TODO: find a better way, maybe signal/slot 940 //TODO: find a better way, maybe signal/slot
941 mTimeLabels->positionChanged(); 941 mTimeLabels->positionChanged();
942 942
943 // for some reason, this needs to be called explicitly 943 // for some reason, this needs to be called explicitly
944 mTimeLabels->repaint(); 944 mTimeLabels->repaint();
945 945
946 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 946 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
947 947
948 // ToolTips displaying summary of events 948 // ToolTips displaying summary of events
949 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 949 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
950 ->mEnableToolTips); 950 ->mEnableToolTips);
951 951
952 //setHolidayMasks(); 952 //setHolidayMasks();
953 953
954 //createDayLabels(); called by via updateView(); 954 //createDayLabels(); called by via updateView();
955 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 955 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
956 updateView(); 956 updateView();
957 mAgenda->restorePosition(); 957 mAgenda->restorePosition();
958} 958}
959 959
960 960
961void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 961void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
962{ 962{
963 963
964 964
965 int xxx = item->cellX(); 965 int xxx = item->cellX();
966 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); 966 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
967 if ( mMinY.at(xxx) > item->cellYTop() ) 967 if ( mMinY.at(xxx) > item->cellYTop() )
968 mMinY.at(xxx) = item->cellYTop(); 968 mMinY.at(xxx) = item->cellYTop();
969 if ( mMaxY.at(xxx) < item->cellYBottom() ) 969 if ( mMaxY.at(xxx) < item->cellYBottom() )
970 mMaxY.at(xxx) = item->cellYBottom(); 970 mMaxY.at(xxx) = item->cellYBottom();
971 971
972 QDateTime startDt,endDt; 972 QDateTime startDt,endDt;
973 QDate startDate; 973 QDate startDate;
974 int lenInSecs; 974 int lenInSecs;
975 // if ( type == KOAgenda::RESIZETOP ) 975 // if ( type == KOAgenda::RESIZETOP )
976 // qDebug("RESIZETOP "); 976 // qDebug("RESIZETOP ");
977 // if ( type == KOAgenda::RESIZEBOTTOM ) 977 // if ( type == KOAgenda::RESIZEBOTTOM )
978 // qDebug("RESIZEBOTTOM "); 978 // qDebug("RESIZEBOTTOM ");
979 // if ( type == KOAgenda::MOVE ) 979 // if ( type == KOAgenda::MOVE )
980 // qDebug("MOVE "); 980 // qDebug("MOVE ");
981 if ( item->incidence()->typeID() == eventID ) { 981 if ( item->incidence()->typeID() == eventID ) {
982 startDt =item->incidence()->dtStart(); 982 startDt =item->incidence()->dtStart();
983 endDt = item->incidence()->dtEnd(); 983 endDt = item->incidence()->dtEnd();
984 lenInSecs = startDt.secsTo( endDt ); 984 lenInSecs = startDt.secsTo( endDt );
985 } 985 }
986 986
987 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 987 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
988 988
989 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { 989 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) {
990 startDate = mSelectedDates[item->mLastMoveXPos]; 990 startDate = mSelectedDates[item->mLastMoveXPos];
991 } else { 991 } else {
992 if (item->cellX() < 0) { 992 if (item->cellX() < 0) {
993 startDate = (mSelectedDates.first()).addDays(item->cellX()); 993 startDate = (mSelectedDates.first()).addDays(item->cellX());
994 } else { 994 } else {
995 startDate = mSelectedDates[item->cellX()]; 995 startDate = mSelectedDates[item->cellX()];
996 } 996 }
997 } 997 }
998 startDt.setDate(startDate); 998 startDt.setDate(startDate);
999 999
1000 if (item->incidence()->doesFloat()) { 1000 if (item->incidence()->doesFloat()) {
1001 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 1001 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
1002 } else { 1002 } else {
1003 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 1003 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
1004 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 1004 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
1005 if ( item->incidence()->typeID() == eventID ) { 1005 if ( item->incidence()->typeID() == eventID ) {
1006 if ( type == KOAgenda::MOVE ) { 1006 if ( type == KOAgenda::MOVE ) {
1007 endDt = startDt.addSecs(lenInSecs); 1007 endDt = startDt.addSecs(lenInSecs);
1008 1008
1009 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 1009 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
1010 if (item->lastMultiItem()) { 1010 if (item->lastMultiItem()) {
1011 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1011 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1012 endDt.setDate(startDate. 1012 endDt.setDate(startDate.
1013 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1013 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1014 } else { 1014 } else {
1015 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1015 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1016 endDt.setDate(startDate); 1016 endDt.setDate(startDate);
1017 } 1017 }
1018 } 1018 }
1019 } else { 1019 } else {
1020 // todo 1020 // todo
1021 if (item->lastMultiItem()) { 1021 if (item->lastMultiItem()) {
1022 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1022 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1023 endDt.setDate(startDate. 1023 endDt.setDate(startDate.
1024 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1024 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1025 } else { 1025 } else {
1026 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1026 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1027 if ( item->cellYBottom() > 0 ) 1027 if ( item->cellYBottom() > 0 )
1028 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1028 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1029 else 1029 else
1030 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1030 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1031 endDt.setDate(startDate); 1031 endDt.setDate(startDate);
1032 } 1032 }
1033 } 1033 }
1034 } 1034 }
1035 if ( item->incidence()->typeID() == eventID ) { 1035 if ( item->incidence()->typeID() == eventID ) {
1036 item->incidence()->setDtStart(startDt); 1036 item->incidence()->setDtStart(startDt);
1037 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1037 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1038 } else if ( item->incidence()->typeID() == todoID ) { 1038 } else if ( item->incidence()->typeID() == todoID ) {
1039 Todo* to = static_cast<Todo*>(item->incidence()); 1039 Todo* to = static_cast<Todo*>(item->incidence());
1040 1040
1041 to->setDtDue(endDt); 1041 to->setDtDue(endDt);
1042 if ( to->hasStartDate() ) { 1042 if ( to->hasStartDate() ) {
1043 if (to->dtStart() >= to->dtDue() ) 1043 if (to->dtStart() >= to->dtDue() )
1044 to->setDtStart(to->dtDue().addDays( -2 )); 1044 to->setDtStart(to->dtDue().addDays( -2 ));
1045 } 1045 }
1046 1046
1047 } 1047 }
1048 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1048 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1049 item->incidence()->setRevision(item->incidence()->revision()+1); 1049 item->incidence()->setRevision(item->incidence()->revision()+1);
1050 item->setItemDate(startDt.date()); 1050 item->setItemDate(startDt.date());
1051 //item->updateItem(); 1051 //item->updateItem();
1052 if ( item->incidence()->typeID() == todoID ) { 1052 if ( item->incidence()->typeID() == todoID ) {
1053 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1053 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1054 1054
1055 } 1055 }
1056 else 1056 else
1057 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1057 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1058 item->updateItem(); 1058 item->updateItem();
1059} 1059}
1060 1060
1061void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1061void KOAgendaView::showDates( const QDate &start, const QDate &end )
1062{ 1062{
1063 // kdDebug() << "KOAgendaView::selectDates" << endl; 1063 // kdDebug() << "KOAgendaView::selectDates" << endl;
1064 1064
1065 mSelectedDates.clear(); 1065 mSelectedDates.clear();
1066 // qDebug("KOAgendaView::showDates "); 1066 // qDebug("KOAgendaView::showDates ");
1067 QDate d = start; 1067 QDate d = start;
1068 while (d <= end) { 1068 while (d <= end) {
1069 mSelectedDates.append(d); 1069 mSelectedDates.append(d);
1070 d = d.addDays( 1 ); 1070 d = d.addDays( 1 );
1071 } 1071 }
1072 1072
1073 // and update the view 1073 // and update the view
1074 fillAgenda(); 1074 fillAgenda();
1075} 1075}
1076 1076
1077 1077
1078void KOAgendaView::showEvents(QPtrList<Event>) 1078void KOAgendaView::showEvents(QPtrList<Event>)
1079{ 1079{
1080 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1080 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1081} 1081}
1082 1082
1083void KOAgendaView::changeEventDisplay(Event *, int) 1083void KOAgendaView::changeEventDisplay(Event *, int)
1084{ 1084{
1085 // qDebug("KOAgendaView::changeEventDisplay "); 1085 // qDebug("KOAgendaView::changeEventDisplay ");
1086 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1086 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1087 // this should be re-written to be MUCH smarter. Right now we 1087 // this should be re-written to be MUCH smarter. Right now we
1088 // are just playing dumb. 1088 // are just playing dumb.
1089 fillAgenda(); 1089 fillAgenda();
1090} 1090}
1091 1091
1092void KOAgendaView::fillAgenda(const QDate &) 1092void KOAgendaView::fillAgenda(const QDate &)
1093{ 1093{
1094 // qDebug("KOAgendaView::fillAgenda "); 1094 // qDebug("KOAgendaView::fillAgenda ");
1095 fillAgenda(); 1095 fillAgenda();
1096} 1096}
1097 1097
1098void KOAgendaView::fillAgenda() 1098void KOAgendaView::fillAgenda()
1099{ 1099{
1100 if ( globalFlagBlockStartup ) 1100 if ( globalFlagBlockStartup )
1101 return; 1101 return;
1102 if ( globalFlagBlockAgenda == 1 ) 1102 if ( globalFlagBlockAgenda == 1 )
1103 return; 1103 return;
1104 static bool onlyOne = false; 1104 static bool onlyOne = false;
1105 if ( onlyOne ) 1105 if ( onlyOne )
1106 return; 1106 return;
1107 onlyOne = true; 1107 onlyOne = true;
1108 //if ( globalFlagBlockAgenda == 2 ) 1108 //if ( globalFlagBlockAgenda == 2 )
1109 //globalFlagBlockAgenda = 0; 1109 //globalFlagBlockAgenda = 0;
1110 // globalFlagBlockPainting = false; 1110 // globalFlagBlockPainting = false;
1111 if ( globalFlagBlockAgenda == 0 ) 1111 if ( globalFlagBlockAgenda == 0 )
1112 globalFlagBlockAgenda = 1; 1112 globalFlagBlockAgenda = 1;
1113 // clearView(); 1113 // clearView();
1114 //qDebug("fillAgenda()++++ "); 1114 //qDebug("fillAgenda()++++ ");
1115 globalFlagBlockAgendaItemPaint = 1; 1115 globalFlagBlockAgendaItemPaint = 1;
1116 1116
1117 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1117 mAllDayAgenda->changeColumns(mSelectedDates.count());
1118 mAgenda->changeColumns(mSelectedDates.count()); 1118 mAgenda->changeColumns(mSelectedDates.count());
1119 qApp->processEvents(); 1119 qApp->processEvents();
1120 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1120 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1121 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1121 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1122 setHolidayMasks(); 1122 setHolidayMasks();
1123 1123
1124 //mAgenda->hideUnused();
1125 //mAllDayAgenda->hideUnused();
1126
1127 // mAgenda->blockNextRepaint( false );
1128 // mAgenda->viewport()->repaint();
1129 // mAgenda->blockNextRepaint( true );
1130 mMinY.resize(mSelectedDates.count()); 1124 mMinY.resize(mSelectedDates.count());
1131 mMaxY.resize(mSelectedDates.count()); 1125 mMaxY.resize(mSelectedDates.count());
1132 1126
1133 QPtrList<Event> dayEvents; 1127 QPtrList<Event> dayEvents;
1134 1128
1135 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1129 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1136 // Therefore, gtodoset all of them. 1130 // Therefore, gtodoset all of them.
1137 QPtrList<Todo> todos = calendar()->todos(); 1131 QPtrList<Todo> todos = calendar()->todos();
1138 1132
1139 mAgenda->setDateList(mSelectedDates); 1133 mAgenda->setDateList(mSelectedDates);
1140 1134
1141 QDate today = QDate::currentDate(); 1135 QDate today = QDate::currentDate();
1142 1136
1143 DateList::ConstIterator dit; 1137 DateList::ConstIterator dit;
1144 int curCol = 0; 1138 int curCol = 0;
1145 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1139 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1146 QDate currentDate = *dit; 1140 QDate currentDate = *dit;
1147 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1141 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1148 // << endl; 1142 // << endl;
1149 1143
1150 dayEvents = calendar()->events(currentDate,true); 1144 dayEvents = calendar()->events(currentDate,false);
1151 1145
1152 // Default values, which can never be reached 1146 // Default values, which can never be reached
1153 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1147 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1154 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1148 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1155 1149
1156 unsigned int numEvent; 1150 unsigned int numEvent;
1157 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1151 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1158 Event *event = dayEvents.at(numEvent); 1152 Event *event = dayEvents.at(numEvent);
1159 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1153 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1160 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1154 if ( event->uid().left(15) == QString("last-syncEvent-") )
1161 continue; 1155 continue;
1162 // kdDebug() << " Event: " << event->summary() << endl; 1156 // kdDebug() << " Event: " << event->summary() << endl;
1163 1157
1164 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1158 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1165 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1159 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1166 1160
1167 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1161 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1168 1162
1169 if (event->doesFloat()) { 1163 if (event->doesFloat()) {
1170 if (event->recurrence()->doesRecur()) { 1164 if (event->recurrence()->doesRecur()) {
1171 if (event->isMultiDay() ) { 1165 if (event->isMultiDay() ) {
1172 endX = endX - beginX;// endX is now number of days 1166 endX = endX - beginX;// endX is now number of days
1173 if ( event->recursOn( currentDate ) ) { 1167 if ( event->recursOn( currentDate ) ) {
1174 endX += curCol; 1168 endX += curCol;
1175 beginX = curCol; 1169 beginX = curCol;
1176 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1170 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1177 } else { 1171 } else {
1178 //qDebug("days %d %s",endX , currentDate.toString().latin1()); 1172 //qDebug("days %d %s",endX , currentDate.toString().latin1());
1179 QDate dateit = currentDate.addDays( -endX ); 1173 QDate dateit = currentDate.addDays( -endX );
1180 if ( event->recursOn( dateit ) ) { 1174 if ( event->recursOn( dateit ) ) {
1181 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1175 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1182 if ( curCol-endX < 0 ) { 1176 if ( curCol-endX < 0 ) {
1183 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1177 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1184 } 1178 }
1185 } 1179 }
1186 } 1180 }
1187 } else { 1181 } else {
1188 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1182 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1189 } 1183 }
1190 1184
1191 } else { 1185 } else {
1192 if (beginX <= 0 && curCol == 0) { 1186 if (beginX <= 0 && curCol == 0) {
1193 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1187 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1194 } else if (beginX == curCol) { 1188 } else if (beginX == curCol) {
1195 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1189 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1196 } 1190 }
1197 } 1191 }
1198 } else if (event->isMultiDay()) { 1192 } else if (event->isMultiDay()) {
1199 if ( event->doesRecur () ) { 1193 if ( event->doesRecur () ) {
1200 QDate dateit = currentDate; 1194 QDate dateit = currentDate;
1201 int count = 0; 1195 int count = 0;
1202 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1196 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1203 while (! event->recursOn( dateit ) && count <= max ) { 1197 while (! event->recursOn( dateit ) && count <= max ) {
1204 ++count; 1198 ++count;
1205 dateit = dateit.addDays( -1 ); 1199 dateit = dateit.addDays( -1 );
1206 } 1200 }
1207 bool ok; 1201 bool ok;
1208 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1202 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1209 if ( ok ) 1203 if ( ok )
1210 { 1204 {
1211 int secs = event->dtStart().secsTo( event->dtEnd() ); 1205 int secs = event->dtStart().secsTo( event->dtEnd() );
1212 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1206 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1213 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1207 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1214 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1208 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1215 1209
1216 } 1210 }
1217 } 1211 }
1218 int startY = mAgenda->timeToY(event->dtStart().time()); 1212 int startY = mAgenda->timeToY(event->dtStart().time());
1219 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1213 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1220 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1214 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1221 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1215 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1222 //qDebug("insert!!! "); 1216 //qDebug("insert!!! ");
1223 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1217 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1224 } 1218 }
1225 if (beginX == curCol) { 1219 if (beginX == curCol) {
1226 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1220 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1227 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1221 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1228 } else if (endX == curCol) { 1222 } else if (endX == curCol) {
1229 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1223 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1224 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1231 } else { 1225 } else {
1232 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1226 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1233 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1227 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1234 } 1228 }
1235 } else { 1229 } else {
1236 int startY = mAgenda->timeToY(event->dtStart().time()); 1230 int startY = mAgenda->timeToY(event->dtStart().time());
1237 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1231 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1238 if (endY < startY) endY = startY; 1232 if (endY < startY) endY = startY;
1239 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1233 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1240 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1234 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1241 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1235 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1242 } 1236 }
1243 } 1237 }
1244 // ---------- [display Todos -------------- 1238 // ---------- [display Todos --------------
1245 unsigned int numTodo; 1239 unsigned int numTodo;
1246 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1240 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1247 Todo *todo = todos.at(numTodo); 1241 Todo *todo = todos.at(numTodo);
1248 1242
1249 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1243 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1250 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1244 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1251 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1245 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1252 // Already completed items can be displayed on their original due date 1246 // Already completed items can be displayed on their original due date
1253 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1247 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1254 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1248 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1255 bool fillIn = false; 1249 bool fillIn = false;
1256 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1250 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1257 fillIn = true; 1251 fillIn = true;
1258 if ( ! fillIn && !todo->hasCompletedDate() ) 1252 if ( ! fillIn && !todo->hasCompletedDate() )
1259 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1253 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1260 if ( fillIn ) { 1254 if ( fillIn ) {
1261 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1255 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1262 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1256 if ( KOPrefs::instance()->mShowTodoInAgenda )
1263 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1257 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1264 } 1258 }
1265 else { 1259 else {
1266 QDateTime dt; 1260 QDateTime dt;
1267 if ( todo->hasCompletedDate() ) 1261 if ( todo->hasCompletedDate() )
1268 dt = todo->completed(); 1262 dt = todo->completed();
1269 else 1263 else
1270 dt = todo->dtDue();; 1264 dt = todo->dtDue();;
1271 1265
1272 1266
1273 int endY = mAgenda->timeToY(dt.time()) - 1; 1267 int endY = mAgenda->timeToY(dt.time()) - 1;
1274 int hi = (18/KOPrefs::instance()->mHourSize); 1268 int hi = (18/KOPrefs::instance()->mHourSize);
1275 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1269 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1276 int startY = endY -hi; 1270 int startY = endY -hi;
1277 1271
1278 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1272 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1279 1273
1280 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1274 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1281 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1275 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1282 } 1276 }
1283 } 1277 }
1284 } 1278 }
1285 // ---------- display Todos] -------------- 1279 // ---------- display Todos] --------------
1286 1280
1287 ++curCol; 1281 ++curCol;
1288 } 1282 }
1289 mAgenda->hideUnused(); 1283 mAgenda->hideUnused();
1290 mAllDayAgenda->hideUnused(); 1284 mAllDayAgenda->hideUnused();
1291 mAgenda->checkScrollBoundaries(); 1285 mAgenda->checkScrollBoundaries();
1292
1293 deleteSelectedDateTime(); 1286 deleteSelectedDateTime();
1294
1295 createDayLabels(); 1287 createDayLabels();
1296 emit incidenceSelected( 0 ); 1288 emit incidenceSelected( 0 );
1297 1289
1298 if ( globalFlagBlockAgenda == 2 ) { 1290 if ( globalFlagBlockAgenda == 2 ) {
1299 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1291 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1300 setStartHour( KOPrefs::instance()->mDayBegins ); 1292 setStartHour( KOPrefs::instance()->mDayBegins );
1301 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1293 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1302 setStartHour( QTime::currentTime ().hour() ); 1294 setStartHour( QTime::currentTime ().hour() );
1303 // qApp->processEvents();
1304 } 1295 }
1305 qApp->processEvents(); 1296 qApp->processEvents();
1306 //qDebug("qApp->processEvents(); END ");
1307 globalFlagBlockAgenda = 0; 1297 globalFlagBlockAgenda = 0;
1308
1309 // mAgenda->hideUnused();
1310 //mAllDayAgenda->hideUnused();
1311 mAllDayAgenda->drawContentsToPainter(); 1298 mAllDayAgenda->drawContentsToPainter();
1312 mAgenda->drawContentsToPainter(); 1299 mAgenda->drawContentsToPainter();
1313 repaintAgenda(); 1300 repaintAgenda();
1314 onlyOne = false; 1301 onlyOne = false;
1315 // mAgenda->finishUpdate();
1316 //mAllDayAgenda->finishUpdate();
1317
1318 // repaintAgenda();
1319 //qApp->processEvents();
1320 // globalFlagBlockAgenda = 0;
1321} 1302}
1322void KOAgendaView::repaintAgenda() 1303void KOAgendaView::repaintAgenda()
1323{ 1304{
1324 // mAllDayAgenda->drawContentsToPainter();
1325// mAllDayAgenda->viewport()->repaint( false );
1326// mAgenda->drawContentsToPainter();
1327// mAgenda->viewport()->repaint( false );
1328// qApp->processEvents();
1329
1330 //qDebug("KOAgendaView::repaintAgenda() ");
1331 //qApp->processEvents();
1332 mAgenda->viewport()->repaint( false ); 1305 mAgenda->viewport()->repaint( false );
1333 mAllDayAgenda->viewport()->repaint( false ); 1306 mAllDayAgenda->viewport()->repaint( false );
1334 mAgenda->finishUpdate(); 1307 mAgenda->finishUpdate();
1335 mAllDayAgenda->finishUpdate(); 1308 mAllDayAgenda->finishUpdate();
1336} 1309}
1337 1310
1338 1311
1339void KOAgendaView::clearView() 1312void KOAgendaView::clearView()
1340{ 1313{
1341 // kdDebug() << "ClearView" << endl;
1342 mAllDayAgenda->clear(); 1314 mAllDayAgenda->clear();
1343 mAgenda->clear(); 1315 mAgenda->clear();
1344} 1316}
1345void KOAgendaView::clearList() 1317void KOAgendaView::clearList()
1346{ 1318{
1347 // kdDebug() << "ClearView" << endl;
1348 clearView(); 1319 clearView();
1349 mAllDayAgenda->hideUnused(); 1320 mAllDayAgenda->hideUnused();
1350 mAgenda->hideUnused(); 1321 mAgenda->hideUnused();
1351} 1322}
1352 1323
1353void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1324void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1354 const QDate &td) 1325 const QDate &td)
1355{ 1326{
1356#ifndef KORG_NOPRINTER 1327#ifndef KORG_NOPRINTER
1357 if (fd == td) 1328 if (fd == td)
1358 calPrinter->preview(CalPrinter::Day, fd, td); 1329 calPrinter->preview(CalPrinter::Day, fd, td);
1359 else 1330 else
1360 calPrinter->preview(CalPrinter::Week, fd, td); 1331 calPrinter->preview(CalPrinter::Week, fd, td);
1361#endif 1332#endif
1362} 1333}
1363 1334
1364// void KOAgendaView::updateMovedTodo() 1335// void KOAgendaView::updateMovedTodo()
1365// { 1336// {
1366// // updateConfig(); 1337// // updateConfig();
1367// // emit updateTodoViews(); 1338// // emit updateTodoViews();
1368// } 1339// }
1369 1340
1370void KOAgendaView::slotShowDateView( int mode , int d ) 1341void KOAgendaView::slotShowDateView( int mode , int d )
1371{ 1342{
1372 if ( d >= mSelectedDates.count() ) { 1343 if ( d >= mSelectedDates.count() ) {
1373 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); 1344 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() );
1374 1345
1375 } else { 1346 } else {
1376 QDate day = mSelectedDates[d]; 1347 QDate day = mSelectedDates[d];
1377 emit showDateView(mode , day ); 1348 emit showDateView(mode , day );
1378 } 1349 }
1379 1350
1380} 1351}
1381void KOAgendaView::newEvent(int gx, int gy) 1352void KOAgendaView::newEvent(int gx, int gy)
1382{ 1353{
1383 if (!mSelectedDates.count()) return; 1354 if (!mSelectedDates.count()) return;
1384 1355
1385 QDate day = mSelectedDates[gx]; 1356 QDate day = mSelectedDates[gx];
1386 1357
1387 QTime time = mAgenda->gyToTime(gy); 1358 QTime time = mAgenda->gyToTime(gy);
1388 QDateTime dt(day,time); 1359 QDateTime dt(day,time);
1389 // if ( dt < QDateTime::currentDateTime () ) 1360 // if ( dt < QDateTime::currentDateTime () )
1390 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1361 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1391 emit newEventSignal(dt); 1362 emit newEventSignal(dt);
1392} 1363}
1393 1364
1394void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1365void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1395{ 1366{
1396 if (!mSelectedDates.count()) return; 1367 if (!mSelectedDates.count()) return;
1397 1368
1398 QDate dayStart = mSelectedDates[gxStart]; 1369 QDate dayStart = mSelectedDates[gxStart];
1399 QDate dayEnd = mSelectedDates[gxEnd]; 1370 QDate dayEnd = mSelectedDates[gxEnd];
1400 1371
1401 QTime timeStart = mAgenda->gyToTime(gyStart); 1372 QTime timeStart = mAgenda->gyToTime(gyStart);
1402 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1373 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1403 1374
1404 QDateTime dtStart(dayStart,timeStart); 1375 QDateTime dtStart(dayStart,timeStart);
1405 QDateTime dtEnd(dayEnd,timeEnd); 1376 QDateTime dtEnd(dayEnd,timeEnd);
1406 1377
1407 emit newEventSignal(dtStart,dtEnd); 1378 emit newEventSignal(dtStart,dtEnd);
1408} 1379}
1409 1380
1410void KOAgendaView::newEventAllDay(int gx, int ) 1381void KOAgendaView::newEventAllDay(int gx, int )
1411{ 1382{
1412 if (!mSelectedDates.count()) return; 1383 if (!mSelectedDates.count()) return;
1413 1384
1414 QDate day = mSelectedDates[gx]; 1385 QDate day = mSelectedDates[gx];
1415 1386
1416 emit newEventSignal(day); 1387 emit newEventSignal(day);
1417} 1388}
1418void KOAgendaView::newTodoAllDay(int gx, int ) 1389void KOAgendaView::newTodoAllDay(int gx, int )
1419{ 1390{
1420 if (!mSelectedDates.count()) return; 1391 if (!mSelectedDates.count()) return;
1421 1392
1422 QDateTime day (mSelectedDates[gx] ); 1393 QDateTime day (mSelectedDates[gx] );
1423 emit newTodoSignal(day, true); 1394 emit newTodoSignal(day, true);
1424} 1395}
1425void KOAgendaView::newTodo(int gx, int gy ) 1396void KOAgendaView::newTodo(int gx, int gy )
1426{ 1397{
1427 if (!mSelectedDates.count()) return; 1398 if (!mSelectedDates.count()) return;
1428 QDate dayStart = mSelectedDates[gx]; 1399 QDate dayStart = mSelectedDates[gx];
1429 QTime timeStart = mAgenda->gyToTime(gy); 1400 QTime timeStart = mAgenda->gyToTime(gy);
1430 QDateTime dt (dayStart,timeStart); 1401 QDateTime dt (dayStart,timeStart);
1431 emit newTodoSignal( dt, false ); 1402 emit newTodoSignal( dt, false );
1432} 1403}
1433 1404
1434void KOAgendaView::updateEventIndicatorTop(int newY) 1405void KOAgendaView::updateEventIndicatorTop(int newY)
1435{ 1406{
1436 uint i; 1407 uint i;
1437 for(i=0;i<mMinY.size();++i) { 1408 for(i=0;i<mMinY.size();++i) {
1438 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1409 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1439 else mEventIndicatorTop->enableColumn(i,false); 1410 else mEventIndicatorTop->enableColumn(i,false);
1440 } 1411 }
1441 1412
1442 mEventIndicatorTop->update(); 1413 mEventIndicatorTop->update();
1443} 1414}
1444 1415
1445void KOAgendaView::updateEventIndicatorBottom(int newY) 1416void KOAgendaView::updateEventIndicatorBottom(int newY)
1446{ 1417{
1447 uint i; 1418 uint i;
1448 for(i=0;i<mMaxY.size();++i) { 1419 for(i=0;i<mMaxY.size();++i) {
1449 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1420 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1450 else mEventIndicatorBottom->enableColumn(i,false); 1421 else mEventIndicatorBottom->enableColumn(i,false);
1451 } 1422 }
1452 1423
1453 mEventIndicatorBottom->update(); 1424 mEventIndicatorBottom->update();
1454} 1425}
1455 1426
1456void KOAgendaView::startDrag(Event *event) 1427void KOAgendaView::startDrag(Event *event)
1457{ 1428{
1458#ifndef KORG_NODND 1429#ifndef KORG_NODND
1459 DndFactory factory( calendar() ); 1430 DndFactory factory( calendar() );
1460 ICalDrag *vd = factory.createDrag(event,this); 1431 ICalDrag *vd = factory.createDrag(event,this);
1461 if (vd->drag()) { 1432 if (vd->drag()) {
1462 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1433 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1463 } 1434 }
1464#endif 1435#endif
1465} 1436}
1466 1437
1467void KOAgendaView::readSettings() 1438void KOAgendaView::readSettings()
1468{ 1439{
1469 readSettings(KOGlobals::config()); 1440 readSettings(KOGlobals::config());
1470} 1441}
1471 1442
1472void KOAgendaView::readSettings(KConfig *config) 1443void KOAgendaView::readSettings(KConfig *config)
1473{ 1444{
1474 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1445 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1475 1446
1476 config->setGroup("Views"); 1447 config->setGroup("Views");
1477 1448
1478 //#ifndef KORG_NOSPLITTER 1449 //#ifndef KORG_NOSPLITTER
1479 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1450 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1480 if (sizes.count() == 2) { 1451 if (sizes.count() == 2) {
1481 if ( sizes[0] < 20 ) { 1452 if ( sizes[0] < 20 ) {
1482 sizes[1] = sizes[1] +20 - sizes[0]; 1453 sizes[1] = sizes[1] +20 - sizes[0];
1483 sizes[0] = 20; 1454 sizes[0] = 20;
1484 } 1455 }
1485 mSplitterAgenda->setSizes(sizes); 1456 mSplitterAgenda->setSizes(sizes);
1486 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1457 // qDebug("read %d %d ",sizes[0],sizes[1] );
1487 } 1458 }
1488 //#endif 1459 //#endif
1489 1460
1490 // updateConfig(); 1461 // updateConfig();
1491} 1462}
1492 1463
1493void KOAgendaView::writeSettings(KConfig *config) 1464void KOAgendaView::writeSettings(KConfig *config)
1494{ 1465{
1495 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1466 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1496 1467
1497 config->setGroup("Views"); 1468 config->setGroup("Views");
1498 1469
1499 //#ifndef KORG_NOSPLITTER 1470 //#ifndef KORG_NOSPLITTER
1500 QValueList<int> list = mSplitterAgenda->sizes(); 1471 QValueList<int> list = mSplitterAgenda->sizes();
1501 config->writeEntry("Separator AgendaView",list); 1472 config->writeEntry("Separator AgendaView",list);
1502 //qDebug("write %d %d ", list[0],list[1] ); 1473 //qDebug("write %d %d ", list[0],list[1] );
1503 //#endif 1474 //#endif
1504} 1475}
1505 1476
1506void KOAgendaView::setHolidayMasks() 1477void KOAgendaView::setHolidayMasks()
1507{ 1478{
1508 mHolidayMask.resize(mSelectedDates.count()); 1479 mHolidayMask.resize(mSelectedDates.count());
1509 1480
1510 uint i; 1481 uint i;
1511 for(i=0;i<mSelectedDates.count();++i) { 1482 for(i=0;i<mSelectedDates.count();++i) {
1512 QDate date = mSelectedDates[i]; 1483 QDate date = mSelectedDates[i];
1513 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1484 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1514 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1485 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1515 bool showHoliday = false; 1486 bool showHoliday = false;
1516 if ( KOPrefs::instance()->mExcludeHolidays ) { 1487 if ( KOPrefs::instance()->mExcludeHolidays ) {
1517 QPtrList<Event> events = calendar()->events( date, true ); 1488 QPtrList<Event> events = calendar()->events( date, true );
1518 Event *event; 1489 Event *event;
1519 for( event = events.first(); event; event = events.next() ) { 1490 for( event = events.first(); event; event = events.next() ) {
1520 if ( event->isHoliday()) { 1491 if ( event->isHoliday()) {
1521 showHoliday = true; 1492 showHoliday = true;
1522 break; 1493 break;
1523 } 1494 }
1524 } 1495 }
1525 1496
1526 } 1497 }
1527 1498
1528#ifndef KORG_NOPLUGINS 1499#ifndef KORG_NOPLUGINS
1529 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1500 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1530 !KOCore::self()->holiday(date).isEmpty(); 1501 !KOCore::self()->holiday(date).isEmpty();
1531#endif 1502#endif
1532 bool showDay = showSaturday || showSunday || showHoliday; 1503 bool showDay = showSaturday || showSunday || showHoliday;
1533 1504
1534 if (showDay) { 1505 if (showDay) {
1535 mHolidayMask.at(i) = true; 1506 mHolidayMask.at(i) = true;
1536 } else { 1507 } else {
1537 mHolidayMask.at(i) = false; 1508 mHolidayMask.at(i) = false;
1538 } 1509 }
1539 } 1510 }
1540 1511
1541 mAgenda->setHolidayMask(&mHolidayMask); 1512 mAgenda->setHolidayMask(&mHolidayMask);
1542 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1513 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1543} 1514}
1544 1515
1545void KOAgendaView::setContentsPos(int y) 1516void KOAgendaView::setContentsPos(int y)
1546{ 1517{
1547 mAgenda->setContentsPos(0,y); 1518 mAgenda->setContentsPos(0,y);
1548} 1519}
1549 1520
1550void KOAgendaView::clearSelection() 1521void KOAgendaView::clearSelection()
1551{ 1522{
1552 mAgenda->deselectItem(); 1523 mAgenda->deselectItem();
1553 mAllDayAgenda->deselectItem(); 1524 mAllDayAgenda->deselectItem();
1554} 1525}
1555 1526
1556void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1527void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1557 int gxEnd, int gyEnd) 1528 int gxEnd, int gyEnd)
1558{ 1529{
1559 mTimeSpanInAllDay = true; 1530 mTimeSpanInAllDay = true;
1560 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1531 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1561} 1532}
1562 1533
1563 1534
1564 1535
1565 1536
1566void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1537void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1567 int gxEnd, int gyEnd) 1538 int gxEnd, int gyEnd)
1568{ 1539{
1569 if (!mSelectedDates.count()) return; 1540 if (!mSelectedDates.count()) return;
1570 1541
1571 QDate dayStart = mSelectedDates[gxStart]; 1542 QDate dayStart = mSelectedDates[gxStart];
1572 QDate dayEnd = mSelectedDates[gxEnd]; 1543 QDate dayEnd = mSelectedDates[gxEnd];
1573 1544
1574 QTime timeStart = mAgenda->gyToTime(gyStart); 1545 QTime timeStart = mAgenda->gyToTime(gyStart);
1575 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1546 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1576 1547
1577 QDateTime dtStart(dayStart,timeStart); 1548 QDateTime dtStart(dayStart,timeStart);
1578 QDateTime dtEnd(dayEnd,timeEnd); 1549 QDateTime dtEnd(dayEnd,timeEnd);
1579 1550
1580 mTimeSpanBegin = dtStart; 1551 mTimeSpanBegin = dtStart;
1581 mTimeSpanEnd = dtEnd; 1552 mTimeSpanEnd = dtEnd;
1582 1553
1583} 1554}
1584 1555
1585void KOAgendaView::deleteSelectedDateTime() 1556void KOAgendaView::deleteSelectedDateTime()
1586{ 1557{
1587 mTimeSpanBegin.setDate(QDate()); 1558 mTimeSpanBegin.setDate(QDate());
1588 mTimeSpanEnd.setDate(QDate()); 1559 mTimeSpanEnd.setDate(QDate());
1589 mTimeSpanInAllDay = false; 1560 mTimeSpanInAllDay = false;
1590} 1561}
1591 1562
1592void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1563void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1593{ 1564{
1594 e->ignore(); 1565 e->ignore();
1595} 1566}
1596 1567
1597void KOAgendaView::scrollOneHourUp() 1568void KOAgendaView::scrollOneHourUp()
1598{ 1569{
1599 1570
1600 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1571 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1601} 1572}
1602void KOAgendaView::scrollOneHourDown() 1573void KOAgendaView::scrollOneHourDown()
1603{ 1574{
1604 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1575 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1605} 1576}
1606 1577
1607void KOAgendaView::setStartHour( int h ) 1578void KOAgendaView::setStartHour( int h )
1608{ 1579{
1609 mAgenda->setStartHour( h ); 1580 mAgenda->setStartHour( h );
1610 1581
1611} 1582}
1612void KOAgendaView::setInitStartHour() 1583void KOAgendaView::setInitStartHour()
1613{ 1584{
1614 1585
1615 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1586 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1616 setStartHour( QTime::currentTime ().hour() ); 1587 setStartHour( QTime::currentTime ().hour() );
1617 else 1588 else
1618 setStartHour( KOPrefs::instance()->mDayBegins ); 1589 setStartHour( KOPrefs::instance()->mDayBegins );
1619 1590
1620} 1591}
1621 1592
1622 1593
1623void KOAgendaView::updateTodo( Todo * t, int ) 1594void KOAgendaView::updateTodo( Todo * t, int )
1624{ 1595{
1625 if ( !isVisible() ) 1596 if ( !isVisible() )
1626 return; 1597 return;
1627 bool remove = false; 1598 bool remove = false;
1628 bool removeAD = false; 1599 bool removeAD = false;
1629 QDate da; 1600 QDate da;
1630 if ( t->hasCompletedDate() ) 1601 if ( t->hasCompletedDate() )
1631 da = t->completed().date(); 1602 da = t->completed().date();
1632 else 1603 else
1633 da = t->dtDue().date(); 1604 da = t->dtDue().date();
1634 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1605 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1635 remove = true; 1606 remove = true;
1636 removeAD = true; 1607 removeAD = true;
1637 } 1608 }
1638 else { 1609 else {
1639 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1610 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1640 if ( overdue && 1611 if ( overdue &&
1641 QDate::currentDate() >= mSelectedDates.first() && 1612 QDate::currentDate() >= mSelectedDates.first() &&
1642 QDate::currentDate() <= mSelectedDates.last()) { 1613 QDate::currentDate() <= mSelectedDates.last()) {
1643 removeAD = false; 1614 removeAD = false;
1644 remove = true; 1615 remove = true;
1645 } 1616 }
1646 else { 1617 else {
1647 1618
1648 if ( da < mSelectedDates.first() || 1619 if ( da < mSelectedDates.first() ||
1649 da > mSelectedDates.last() ) { 1620 da > mSelectedDates.last() ) {
1650 remove = true; 1621 remove = true;
1651 removeAD = true; 1622 removeAD = true;
1652 } else { 1623 } else {
1653 remove = t->doesFloat() && !t->hasCompletedDate(); 1624 remove = t->doesFloat() && !t->hasCompletedDate();
1654 removeAD = !remove; 1625 removeAD = !remove;
1655 } 1626 }
1656 } 1627 }
1657 } 1628 }
1658 int days = mSelectedDates.first().daysTo( da ); 1629 int days = mSelectedDates.first().daysTo( da );
1659 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1630 //qDebug("daysto %d %d %d", days, remove,removeAD );
1660 mAgenda->updateTodo( t , days, remove); 1631 mAgenda->updateTodo( t , days, remove);
1661 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1632 if ( KOPrefs::instance()->mShowTodoInAgenda )
1662 mAllDayAgenda->updateTodo( t , days, removeAD); 1633 mAllDayAgenda->updateTodo( t , days, removeAD);
1663 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1634 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1664 1635
1665} 1636}