-rw-r--r-- | korganizer/koagenda.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 2a2acb1..fc213d8 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -564,544 +564,544 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | |||
564 | } | 564 | } |
565 | } | 565 | } |
566 | if ( ! blockMoving ) | 566 | if ( ! blockMoving ) |
567 | mPopupTimer->stop(); | 567 | mPopupTimer->stop(); |
568 | if (object != viewport()) { | 568 | if (object != viewport()) { |
569 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 569 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
570 | if (!moveItem->incidence()->isReadOnly() ) { | 570 | if (!moveItem->incidence()->isReadOnly() ) { |
571 | if (!mActionItem) | 571 | if (!mActionItem) |
572 | setNoActionCursor(moveItem,viewportPos); | 572 | setNoActionCursor(moveItem,viewportPos); |
573 | else { | 573 | else { |
574 | if ( !blockMoving ) | 574 | if ( !blockMoving ) |
575 | performItemAction(viewportPos); | 575 | performItemAction(viewportPos); |
576 | } | 576 | } |
577 | } | 577 | } |
578 | } else { // ---------- viewport() | 578 | } else { // ---------- viewport() |
579 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 579 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
580 | if ( mActionType == SELECT ) { | 580 | if ( mActionType == SELECT ) { |
581 | performSelectAction( viewportPos ); | 581 | performSelectAction( viewportPos ); |
582 | } | 582 | } |
583 | } | 583 | } |
584 | break; | 584 | break; |
585 | 585 | ||
586 | case QEvent::MouseButtonDblClick: | 586 | case QEvent::MouseButtonDblClick: |
587 | mPopupTimer->stop(); | 587 | mPopupTimer->stop(); |
588 | if (object == viewport()) { | 588 | if (object == viewport()) { |
589 | selectItem(0); | 589 | selectItem(0); |
590 | int x,y; | 590 | int x,y; |
591 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 591 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
592 | int gx,gy; | 592 | int gx,gy; |
593 | contentsToGrid(x,y,gx,gy); | 593 | contentsToGrid(x,y,gx,gy); |
594 | emit newEventSignal(gx,gy); | 594 | emit newEventSignal(gx,gy); |
595 | } else { | 595 | } else { |
596 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 596 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
597 | selectItem(doubleClickedItem); | 597 | selectItem(doubleClickedItem); |
598 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 598 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
599 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 599 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
600 | else | 600 | else |
601 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 601 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
602 | } | 602 | } |
603 | break; | 603 | break; |
604 | 604 | ||
605 | default: | 605 | default: |
606 | break; | 606 | break; |
607 | } | 607 | } |
608 | return true; | 608 | return true; |
609 | 609 | ||
610 | } | 610 | } |
611 | 611 | ||
612 | void KOAgenda::newItem( int item ) | 612 | void KOAgenda::newItem( int item ) |
613 | { | 613 | { |
614 | if ( item == 1 ) { //new event | 614 | if ( item == 1 ) { //new event |
615 | newEventSignal(mStartCellX ,mStartCellY ); | 615 | newEventSignal(mStartCellX ,mStartCellY ); |
616 | } else | 616 | } else |
617 | if ( item == 2 ) { //new event | 617 | if ( item == 2 ) { //new event |
618 | newTodoSignal(mStartCellX ,mStartCellY ); | 618 | newTodoSignal(mStartCellX ,mStartCellY ); |
619 | } else | 619 | } else |
620 | { | 620 | { |
621 | emit showDateView( item, mStartCellX ); | 621 | emit showDateView( item, mStartCellX ); |
622 | // 3Day view | 622 | // 3Day view |
623 | // 4Week view | 623 | // 4Week view |
624 | // 5Month view | 624 | // 5Month view |
625 | // 6Journal view | 625 | // 6Journal view |
626 | } | 626 | } |
627 | } | 627 | } |
628 | void KOAgenda::slotClearSelection() | 628 | void KOAgenda::slotClearSelection() |
629 | { | 629 | { |
630 | if (mSelectionHeight) { | 630 | if (mSelectionHeight) { |
631 | int selectionX = mSelectionCellX * mGridSpacingX; | 631 | int selectionX = mSelectionCellX * mGridSpacingX; |
632 | int top = mSelectionYTop - 2 *mGridSpacingY; | 632 | int top = mSelectionYTop - 2 *mGridSpacingY; |
633 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 633 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
634 | clearSelection(); | 634 | clearSelection(); |
635 | repaintContents( selectionX, top, | 635 | repaintContents( selectionX, top, |
636 | mGridSpacingX, hei ,false ); | 636 | mGridSpacingX, hei ,false ); |
637 | } | 637 | } |
638 | 638 | ||
639 | } | 639 | } |
640 | void KOAgenda::startSelectAction(QPoint viewportPos) | 640 | void KOAgenda::startSelectAction(QPoint viewportPos) |
641 | { | 641 | { |
642 | 642 | ||
643 | emit signalClearSelection(); | 643 | emit signalClearSelection(); |
644 | slotClearSelection(); | 644 | slotClearSelection(); |
645 | 645 | ||
646 | mActionType = SELECT; | 646 | mActionType = SELECT; |
647 | 647 | ||
648 | int x,y; | 648 | int x,y; |
649 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 649 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
650 | int gx,gy; | 650 | int gx,gy; |
651 | contentsToGrid(x,y,gx,gy); | 651 | contentsToGrid(x,y,gx,gy); |
652 | 652 | ||
653 | mStartCellX = gx; | 653 | mStartCellX = gx; |
654 | mStartCellY = gy; | 654 | mStartCellY = gy; |
655 | mCurrentCellX = gx; | 655 | mCurrentCellX = gx; |
656 | mCurrentCellY = gy; | 656 | mCurrentCellY = gy; |
657 | 657 | ||
658 | // Store new selection | 658 | // Store new selection |
659 | mSelectionCellX = gx; | 659 | mSelectionCellX = gx; |
660 | mSelectionYTop = gy * mGridSpacingY; | 660 | mSelectionYTop = gy * mGridSpacingY; |
661 | mSelectionHeight = mGridSpacingY; | 661 | mSelectionHeight = mGridSpacingY; |
662 | 662 | ||
663 | // Paint new selection | 663 | // Paint new selection |
664 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 664 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
665 | mGridSpacingX-1, mSelectionHeight ); | 665 | mGridSpacingX-1, mSelectionHeight ); |
666 | } | 666 | } |
667 | 667 | ||
668 | void KOAgenda::performSelectAction(QPoint viewportPos) | 668 | void KOAgenda::performSelectAction(QPoint viewportPos) |
669 | { | 669 | { |
670 | int x,y; | 670 | int x,y; |
671 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 671 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
672 | int gx,gy; | 672 | int gx,gy; |
673 | contentsToGrid(x,y,gx,gy); | 673 | contentsToGrid(x,y,gx,gy); |
674 | 674 | ||
675 | QPoint clipperPos = clipper()-> | 675 | QPoint clipperPos = clipper()-> |
676 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 676 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
677 | 677 | ||
678 | // Scroll if cursor was moved to upper or lower end of agenda. | 678 | // Scroll if cursor was moved to upper or lower end of agenda. |
679 | if (clipperPos.y() < mScrollBorderWidth) { | 679 | if (clipperPos.y() < mScrollBorderWidth) { |
680 | mScrollUpTimer.start(mScrollDelay); | 680 | mScrollUpTimer.start(mScrollDelay); |
681 | } else if (visibleHeight() - clipperPos.y() < | 681 | } else if (visibleHeight() - clipperPos.y() < |
682 | mScrollBorderWidth) { | 682 | mScrollBorderWidth) { |
683 | mScrollDownTimer.start(mScrollDelay); | 683 | mScrollDownTimer.start(mScrollDelay); |
684 | } else { | 684 | } else { |
685 | mScrollUpTimer.stop(); | 685 | mScrollUpTimer.stop(); |
686 | mScrollDownTimer.stop(); | 686 | mScrollDownTimer.stop(); |
687 | } | 687 | } |
688 | 688 | ||
689 | if ( gy > mCurrentCellY ) { | 689 | if ( gy > mCurrentCellY ) { |
690 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 690 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
691 | 691 | ||
692 | 692 | ||
693 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 693 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
694 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 694 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
695 | mGridSpacingX, mSelectionYTop, | 695 | mGridSpacingX, mSelectionYTop, |
696 | mGridSpacingX, mSelectionHeight , false); | 696 | mGridSpacingX, mSelectionHeight , false); |
697 | 697 | ||
698 | mCurrentCellY = gy; | 698 | mCurrentCellY = gy; |
699 | } else if ( gy < mCurrentCellY ) { | 699 | } else if ( gy < mCurrentCellY ) { |
700 | if ( gy >= mStartCellY ) { | 700 | if ( gy >= mStartCellY ) { |
701 | int selectionHeight = mSelectionHeight; | 701 | int selectionHeight = mSelectionHeight; |
702 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 702 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
703 | 703 | ||
704 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 704 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
705 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 705 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
706 | mGridSpacingX, mSelectionYTop, | 706 | mGridSpacingX, mSelectionYTop, |
707 | mGridSpacingX, selectionHeight,false ); | 707 | mGridSpacingX, selectionHeight,false ); |
708 | 708 | ||
709 | mCurrentCellY = gy; | 709 | mCurrentCellY = gy; |
710 | } else { | 710 | } else { |
711 | } | 711 | } |
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 715 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
716 | { | 716 | { |
717 | mActionType = NOP; | 717 | mActionType = NOP; |
718 | mScrollUpTimer.stop(); | 718 | mScrollUpTimer.stop(); |
719 | mScrollDownTimer.stop(); | 719 | mScrollDownTimer.stop(); |
720 | 720 | ||
721 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 721 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
722 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 722 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
723 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 723 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
724 | } | 724 | } |
725 | } | 725 | } |
726 | 726 | ||
727 | void KOAgenda::startItemAction(QPoint viewportPos) | 727 | void KOAgenda::startItemAction(QPoint viewportPos) |
728 | { | 728 | { |
729 | int x,y; | 729 | int x,y; |
730 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 730 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
731 | int gx,gy; | 731 | int gx,gy; |
732 | contentsToGrid(x,y,gx,gy); | 732 | contentsToGrid(x,y,gx,gy); |
733 | 733 | ||
734 | mStartCellX = gx; | 734 | mStartCellX = gx; |
735 | mStartCellY = gy; | 735 | mStartCellY = gy; |
736 | mCurrentCellX = gx; | 736 | mCurrentCellX = gx; |
737 | mCurrentCellY = gy; | 737 | mCurrentCellY = gy; |
738 | 738 | ||
739 | if (mAllDayMode) { | 739 | if (mAllDayMode) { |
740 | int gridDistanceX = (x - gx * mGridSpacingX); | 740 | int gridDistanceX = (x - gx * mGridSpacingX); |
741 | if (gridDistanceX < mResizeBorderWidth && | 741 | if (gridDistanceX < mResizeBorderWidth && |
742 | mActionItem->cellX() == mCurrentCellX) { | 742 | mActionItem->cellX() == mCurrentCellX) { |
743 | mActionType = RESIZELEFT; | 743 | mActionType = RESIZELEFT; |
744 | setCursor(sizeHorCursor); | 744 | setCursor(sizeHorCursor); |
745 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 745 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
746 | mActionItem->cellXWidth() == mCurrentCellX) { | 746 | mActionItem->cellXWidth() == mCurrentCellX) { |
747 | mActionType = RESIZERIGHT; | 747 | mActionType = RESIZERIGHT; |
748 | setCursor(sizeHorCursor); | 748 | setCursor(sizeHorCursor); |
749 | } else { | 749 | } else { |
750 | mActionType = MOVE; | 750 | mActionType = MOVE; |
751 | mActionItem->startMove(); | 751 | mActionItem->startMove(); |
752 | setCursor(sizeAllCursor); | 752 | setCursor(sizeAllCursor); |
753 | } | 753 | } |
754 | } else { | 754 | } else { |
755 | int gridDistanceY = (y - gy * mGridSpacingY); | 755 | int gridDistanceY = (y - gy * mGridSpacingY); |
756 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 756 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); |
757 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 757 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
758 | mActionItem->cellYTop() == mCurrentCellY && | 758 | mActionItem->cellYTop() == mCurrentCellY && |
759 | !mActionItem->firstMultiItem()) { | 759 | !mActionItem->firstMultiItem()) { |
760 | mActionType = RESIZETOP; | 760 | mActionType = RESIZETOP; |
761 | setCursor(sizeVerCursor); | 761 | setCursor(sizeVerCursor); |
762 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 762 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
763 | mActionItem->cellYBottom() == mCurrentCellY && | 763 | mActionItem->cellYBottom() == mCurrentCellY && |
764 | !mActionItem->lastMultiItem()) { | 764 | !mActionItem->lastMultiItem()) { |
765 | mActionType = RESIZEBOTTOM; | 765 | mActionType = RESIZEBOTTOM; |
766 | setCursor(sizeVerCursor); | 766 | setCursor(sizeVerCursor); |
767 | } else { | 767 | } else { |
768 | mActionType = MOVE; | 768 | mActionType = MOVE; |
769 | mActionItem->startMove(); | 769 | mActionItem->startMove(); |
770 | setCursor(sizeAllCursor); | 770 | setCursor(sizeAllCursor); |
771 | } | 771 | } |
772 | } | 772 | } |
773 | } | 773 | } |
774 | 774 | ||
775 | void KOAgenda::performItemAction(QPoint viewportPos) | 775 | void KOAgenda::performItemAction(QPoint viewportPos) |
776 | { | 776 | { |
777 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 777 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
778 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 778 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
779 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 779 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
780 | // point = clipper()->mapFromGlobal(point); | 780 | // point = clipper()->mapFromGlobal(point); |
781 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 781 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
782 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 782 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
783 | int x,y; | 783 | int x,y; |
784 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 784 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
785 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 785 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
786 | int gx,gy; | 786 | int gx,gy; |
787 | contentsToGrid(x,y,gx,gy); | 787 | contentsToGrid(x,y,gx,gy); |
788 | QPoint clipperPos = clipper()-> | 788 | QPoint clipperPos = clipper()-> |
789 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 789 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
790 | 790 | ||
791 | // Cursor left active agenda area. | 791 | // Cursor left active agenda area. |
792 | // This starts a drag. | 792 | // This starts a drag. |
793 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 793 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
794 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 794 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
795 | if ( mActionType == MOVE ) { | 795 | if ( mActionType == MOVE ) { |
796 | mScrollUpTimer.stop(); | 796 | mScrollUpTimer.stop(); |
797 | mScrollDownTimer.stop(); | 797 | mScrollDownTimer.stop(); |
798 | mActionItem->resetMove(); | 798 | mActionItem->resetMove(); |
799 | placeSubCells( mActionItem ); | 799 | placeSubCells( mActionItem ); |
800 | // emit startDragSignal( mActionItem->incidence() ); | 800 | // emit startDragSignal( mActionItem->incidence() ); |
801 | setCursor( arrowCursor ); | 801 | setCursor( arrowCursor ); |
802 | mActionItem = 0; | 802 | mActionItem = 0; |
803 | mActionType = NOP; | 803 | mActionType = NOP; |
804 | mItemMoved = 0; | 804 | mItemMoved = 0; |
805 | return; | 805 | return; |
806 | } | 806 | } |
807 | } else { | 807 | } else { |
808 | switch ( mActionType ) { | 808 | switch ( mActionType ) { |
809 | case MOVE: | 809 | case MOVE: |
810 | setCursor( sizeAllCursor ); | 810 | setCursor( sizeAllCursor ); |
811 | break; | 811 | break; |
812 | case RESIZETOP: | 812 | case RESIZETOP: |
813 | case RESIZEBOTTOM: | 813 | case RESIZEBOTTOM: |
814 | setCursor( sizeVerCursor ); | 814 | setCursor( sizeVerCursor ); |
815 | break; | 815 | break; |
816 | case RESIZELEFT: | 816 | case RESIZELEFT: |
817 | case RESIZERIGHT: | 817 | case RESIZERIGHT: |
818 | setCursor( sizeHorCursor ); | 818 | setCursor( sizeHorCursor ); |
819 | break; | 819 | break; |
820 | default: | 820 | default: |
821 | setCursor( arrowCursor ); | 821 | setCursor( arrowCursor ); |
822 | } | 822 | } |
823 | } | 823 | } |
824 | 824 | ||
825 | // Scroll if item was moved to upper or lower end of agenda. | 825 | // Scroll if item was moved to upper or lower end of agenda. |
826 | if (clipperPos.y() < mScrollBorderWidth) { | 826 | if (clipperPos.y() < mScrollBorderWidth) { |
827 | mScrollUpTimer.start(mScrollDelay); | 827 | mScrollUpTimer.start(mScrollDelay); |
828 | } else if (visibleHeight() - clipperPos.y() < | 828 | } else if (visibleHeight() - clipperPos.y() < |
829 | mScrollBorderWidth) { | 829 | mScrollBorderWidth) { |
830 | mScrollDownTimer.start(mScrollDelay); | 830 | mScrollDownTimer.start(mScrollDelay); |
831 | } else { | 831 | } else { |
832 | mScrollUpTimer.stop(); | 832 | mScrollUpTimer.stop(); |
833 | mScrollDownTimer.stop(); | 833 | mScrollDownTimer.stop(); |
834 | } | 834 | } |
835 | 835 | ||
836 | // Move or resize item if necessary | 836 | // Move or resize item if necessary |
837 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 837 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
838 | mItemMoved = true; | 838 | mItemMoved = true; |
839 | mActionItem->raise(); | 839 | mActionItem->raise(); |
840 | if (mActionType == MOVE) { | 840 | if (mActionType == MOVE) { |
841 | // Move all items belonging to a multi item | 841 | // Move all items belonging to a multi item |
842 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 842 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
843 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 843 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
844 | if (!moveItem) moveItem = mActionItem; | 844 | if (!moveItem) moveItem = mActionItem; |
845 | while (moveItem) { | 845 | while (moveItem) { |
846 | int dy; | 846 | int dy; |
847 | if (isMultiItem) dy = 0; | 847 | if (isMultiItem) dy = 0; |
848 | else dy = gy - mCurrentCellY; | 848 | else dy = gy - mCurrentCellY; |
849 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 849 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
850 | int x,y; | 850 | int x,y; |
851 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 851 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
852 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 852 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
853 | mGridSpacingY * moveItem->cellHeight()); | 853 | mGridSpacingY * moveItem->cellHeight()); |
854 | moveChild(moveItem,x,y); | 854 | moveChild(moveItem,x,y); |
855 | moveItem = moveItem->nextMultiItem(); | 855 | moveItem = moveItem->nextMultiItem(); |
856 | } | 856 | } |
857 | } else if (mActionType == RESIZETOP) { | 857 | } else if (mActionType == RESIZETOP) { |
858 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 858 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
859 | mActionItem->expandTop(gy - mCurrentCellY); | 859 | mActionItem->expandTop(gy - mCurrentCellY); |
860 | mActionItem->resize(mActionItem->width(), | 860 | mActionItem->resize(mActionItem->width(), |
861 | mGridSpacingY * mActionItem->cellHeight()); | 861 | mGridSpacingY * mActionItem->cellHeight()); |
862 | int x,y; | 862 | int x,y; |
863 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 863 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
864 | //moveChild(mActionItem,childX(mActionItem),y); | 864 | //moveChild(mActionItem,childX(mActionItem),y); |
865 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 865 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
866 | } | 866 | } |
867 | } else if (mActionType == RESIZEBOTTOM) { | 867 | } else if (mActionType == RESIZEBOTTOM) { |
868 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 868 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
869 | mActionItem->expandBottom(gy - mCurrentCellY); | 869 | mActionItem->expandBottom(gy - mCurrentCellY); |
870 | mActionItem->resize(mActionItem->width(), | 870 | mActionItem->resize(mActionItem->width(), |
871 | mGridSpacingY * mActionItem->cellHeight()); | 871 | mGridSpacingY * mActionItem->cellHeight()); |
872 | } | 872 | } |
873 | } else if (mActionType == RESIZELEFT) { | 873 | } else if (mActionType == RESIZELEFT) { |
874 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 874 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
875 | mActionItem->expandLeft(gx - mCurrentCellX); | 875 | mActionItem->expandLeft(gx - mCurrentCellX); |
876 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 876 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
877 | mActionItem->height()); | 877 | mActionItem->height()); |
878 | int x,y; | 878 | int x,y; |
879 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 879 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
880 | moveChild(mActionItem,x,childY(mActionItem)); | 880 | moveChild(mActionItem,x,childY(mActionItem)); |
881 | } | 881 | } |
882 | } else if (mActionType == RESIZERIGHT) { | 882 | } else if (mActionType == RESIZERIGHT) { |
883 | if (mCurrentCellX >= mActionItem->cellX()) { | 883 | if (mCurrentCellX >= mActionItem->cellX()) { |
884 | mActionItem->expandRight(gx - mCurrentCellX); | 884 | mActionItem->expandRight(gx - mCurrentCellX); |
885 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 885 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
886 | mActionItem->height()); | 886 | mActionItem->height()); |
887 | } | 887 | } |
888 | } | 888 | } |
889 | mCurrentCellX = gx; | 889 | mCurrentCellX = gx; |
890 | mCurrentCellY = gy; | 890 | mCurrentCellY = gy; |
891 | } | 891 | } |
892 | } | 892 | } |
893 | 893 | ||
894 | void KOAgenda::endItemAction() | 894 | void KOAgenda::endItemAction() |
895 | { | 895 | { |
896 | 896 | ||
897 | if ( mItemMoved ) { | 897 | if ( mItemMoved ) { |
898 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 898 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
899 | if ( !placeItem ) { | 899 | if ( !placeItem ) { |
900 | placeItem = mActionItem; | 900 | placeItem = mActionItem; |
901 | } | 901 | } |
902 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 902 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
903 | Incidence* oldInc = placeItem->incidence(); | 903 | Incidence* oldInc = placeItem->incidence(); |
904 | placeItem->recreateIncidence(); | 904 | placeItem->recreateIncidence(); |
905 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 905 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
906 | } | 906 | } |
907 | int type = mActionType; | 907 | int type = mActionType; |
908 | if ( mAllDayMode ) | 908 | if ( mAllDayMode ) |
909 | type = -1; | 909 | type = -1; |
910 | KOAgendaItem *modifiedItem = placeItem; | 910 | KOAgendaItem *modifiedItem = placeItem; |
911 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 911 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
912 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 912 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
913 | KOAgendaItem *item; | 913 | KOAgendaItem *item; |
914 | 914 | ||
915 | if ( placeItem->incidence()->type() == "Todo" ) { | 915 | if ( placeItem->incidence()->typeID() == todoID ) { |
916 | mSelectedItem = 0; | 916 | mSelectedItem = 0; |
917 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 917 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
918 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 918 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
919 | emit itemModified( modifiedItem, mActionType ); | 919 | emit itemModified( modifiedItem, mActionType ); |
920 | } | 920 | } |
921 | else { | 921 | else { |
922 | 922 | ||
923 | 923 | ||
924 | globalFlagBlockAgendaItemPaint = 1; | 924 | globalFlagBlockAgendaItemPaint = 1; |
925 | for ( item=oldconflictItems.first(); item != 0; | 925 | for ( item=oldconflictItems.first(); item != 0; |
926 | item=oldconflictItems.next() ) { | 926 | item=oldconflictItems.next() ) { |
927 | placeSubCells(item); | 927 | placeSubCells(item); |
928 | } | 928 | } |
929 | while ( placeItem ) { | 929 | while ( placeItem ) { |
930 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 930 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
931 | oldconflictItems = placeItem->conflictItems(); | 931 | oldconflictItems = placeItem->conflictItems(); |
932 | for ( item=oldconflictItems.first(); item != 0; | 932 | for ( item=oldconflictItems.first(); item != 0; |
933 | item=oldconflictItems.next() ) { | 933 | item=oldconflictItems.next() ) { |
934 | placeSubCells(item); | 934 | placeSubCells(item); |
935 | } | 935 | } |
936 | placeSubCells( placeItem ); | 936 | placeSubCells( placeItem ); |
937 | placeItem = placeItem->nextMultiItem(); | 937 | placeItem = placeItem->nextMultiItem(); |
938 | } | 938 | } |
939 | globalFlagBlockAgendaItemPaint = 0; | 939 | globalFlagBlockAgendaItemPaint = 0; |
940 | for ( item=oldconflictItems.first(); item != 0; | 940 | for ( item=oldconflictItems.first(); item != 0; |
941 | item=oldconflictItems.next() ) { | 941 | item=oldconflictItems.next() ) { |
942 | globalFlagBlockAgendaItemUpdate = 0; | 942 | globalFlagBlockAgendaItemUpdate = 0; |
943 | item->repaintMe(); | 943 | item->repaintMe(); |
944 | globalFlagBlockAgendaItemUpdate = 1; | 944 | globalFlagBlockAgendaItemUpdate = 1; |
945 | item->repaint( false ); | 945 | item->repaint( false ); |
946 | } | 946 | } |
947 | placeItem = modifiedItem; | 947 | placeItem = modifiedItem; |
948 | 948 | ||
949 | while ( placeItem ) { | 949 | while ( placeItem ) { |
950 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 950 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
951 | globalFlagBlockAgendaItemUpdate = 0; | 951 | globalFlagBlockAgendaItemUpdate = 0; |
952 | placeItem->repaintMe(); | 952 | placeItem->repaintMe(); |
953 | globalFlagBlockAgendaItemUpdate = 1; | 953 | globalFlagBlockAgendaItemUpdate = 1; |
954 | placeItem->repaint(false); | 954 | placeItem->repaint(false); |
955 | placeItem = placeItem->nextMultiItem(); | 955 | placeItem = placeItem->nextMultiItem(); |
956 | } | 956 | } |
957 | emit itemModified( modifiedItem, mActionType ); | 957 | emit itemModified( modifiedItem, mActionType ); |
958 | 958 | ||
959 | 959 | ||
960 | placeItem = modifiedItem; | 960 | placeItem = modifiedItem; |
961 | while ( placeItem ) { | 961 | while ( placeItem ) { |
962 | oldconflictItems = placeItem->conflictItems(); | 962 | oldconflictItems = placeItem->conflictItems(); |
963 | for ( item=oldconflictItems.first(); item != 0; | 963 | for ( item=oldconflictItems.first(); item != 0; |
964 | item=oldconflictItems.next() ) { | 964 | item=oldconflictItems.next() ) { |
965 | placeSubCells(item); | 965 | placeSubCells(item); |
966 | } | 966 | } |
967 | placeSubCells( placeItem ); | 967 | placeSubCells( placeItem ); |
968 | placeItem = placeItem->nextMultiItem(); | 968 | placeItem = placeItem->nextMultiItem(); |
969 | 969 | ||
970 | } | 970 | } |
971 | placeItem = modifiedItem; | 971 | placeItem = modifiedItem; |
972 | while ( placeItem ) { | 972 | while ( placeItem ) { |
973 | oldconflictItems = placeItem->conflictItems(); | 973 | oldconflictItems = placeItem->conflictItems(); |
974 | for ( item=oldconflictItems.first(); item != 0; | 974 | for ( item=oldconflictItems.first(); item != 0; |
975 | item=oldconflictItems.next() ) { | 975 | item=oldconflictItems.next() ) { |
976 | globalFlagBlockAgendaItemUpdate = 0; | 976 | globalFlagBlockAgendaItemUpdate = 0; |
977 | item->repaintMe(); | 977 | item->repaintMe(); |
978 | globalFlagBlockAgendaItemUpdate = 1; | 978 | globalFlagBlockAgendaItemUpdate = 1; |
979 | item->repaint(false); | 979 | item->repaint(false); |
980 | } | 980 | } |
981 | placeItem = placeItem->nextMultiItem(); | 981 | placeItem = placeItem->nextMultiItem(); |
982 | } | 982 | } |
983 | /* | 983 | /* |
984 | 984 | ||
985 | oldconflictItems = modifiedItem->conflictItems(); | 985 | oldconflictItems = modifiedItem->conflictItems(); |
986 | for ( item=oldconflictItems.first(); item != 0; | 986 | for ( item=oldconflictItems.first(); item != 0; |
987 | item=oldconflictItems.next() ) { | 987 | item=oldconflictItems.next() ) { |
988 | globalFlagBlockAgendaItemUpdate = 0; | 988 | globalFlagBlockAgendaItemUpdate = 0; |
989 | item->paintMe(false); | 989 | item->paintMe(false); |
990 | globalFlagBlockAgendaItemUpdate = 1; | 990 | globalFlagBlockAgendaItemUpdate = 1; |
991 | item->repaint(false); | 991 | item->repaint(false); |
992 | } | 992 | } |
993 | */ | 993 | */ |
994 | 994 | ||
995 | 995 | ||
996 | } | 996 | } |
997 | 997 | ||
998 | } | 998 | } |
999 | 999 | ||
1000 | mScrollUpTimer.stop(); | 1000 | mScrollUpTimer.stop(); |
1001 | mScrollDownTimer.stop(); | 1001 | mScrollDownTimer.stop(); |
1002 | setCursor( arrowCursor ); | 1002 | setCursor( arrowCursor ); |
1003 | mActionItem = 0; | 1003 | mActionItem = 0; |
1004 | mActionType = NOP; | 1004 | mActionType = NOP; |
1005 | mItemMoved = 0; | 1005 | mItemMoved = 0; |
1006 | 1006 | ||
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1009 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1010 | { | 1010 | { |
1011 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1011 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1012 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1012 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1013 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1013 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1014 | // point = clipper()->mapFromGlobal(point); | 1014 | // point = clipper()->mapFromGlobal(point); |
1015 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1015 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1016 | 1016 | ||
1017 | int x,y; | 1017 | int x,y; |
1018 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1018 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1019 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1019 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1020 | int gx,gy; | 1020 | int gx,gy; |
1021 | contentsToGrid(x,y,gx,gy); | 1021 | contentsToGrid(x,y,gx,gy); |
1022 | 1022 | ||
1023 | // Change cursor to resize cursor if appropriate | 1023 | // Change cursor to resize cursor if appropriate |
1024 | if (mAllDayMode) { | 1024 | if (mAllDayMode) { |
1025 | int gridDistanceX = (x - gx * mGridSpacingX); | 1025 | int gridDistanceX = (x - gx * mGridSpacingX); |
1026 | if (gridDistanceX < mResizeBorderWidth && | 1026 | if (gridDistanceX < mResizeBorderWidth && |
1027 | moveItem->cellX() == gx) { | 1027 | moveItem->cellX() == gx) { |
1028 | setCursor(sizeHorCursor); | 1028 | setCursor(sizeHorCursor); |
1029 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1029 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1030 | moveItem->cellXWidth() == gx) { | 1030 | moveItem->cellXWidth() == gx) { |
1031 | setCursor(sizeHorCursor); | 1031 | setCursor(sizeHorCursor); |
1032 | } else { | 1032 | } else { |
1033 | setCursor(arrowCursor); | 1033 | setCursor(arrowCursor); |
1034 | } | 1034 | } |
1035 | } else { | 1035 | } else { |
1036 | int gridDistanceY = (y - gy * mGridSpacingY); | 1036 | int gridDistanceY = (y - gy * mGridSpacingY); |
1037 | if (gridDistanceY < mResizeBorderWidth && | 1037 | if (gridDistanceY < mResizeBorderWidth && |
1038 | moveItem->cellYTop() == gy && | 1038 | moveItem->cellYTop() == gy && |
1039 | !moveItem->firstMultiItem()) { | 1039 | !moveItem->firstMultiItem()) { |
1040 | setCursor(sizeVerCursor); | 1040 | setCursor(sizeVerCursor); |
1041 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1041 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1042 | moveItem->cellYBottom() == gy && | 1042 | moveItem->cellYBottom() == gy && |
1043 | !moveItem->lastMultiItem()) { | 1043 | !moveItem->lastMultiItem()) { |
1044 | setCursor(sizeVerCursor); | 1044 | setCursor(sizeVerCursor); |
1045 | } else { | 1045 | } else { |
1046 | setCursor(arrowCursor); | 1046 | setCursor(arrowCursor); |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } | 1049 | } |
1050 | 1050 | ||
1051 | 1051 | ||
1052 | /* | 1052 | /* |
1053 | Place item in cell and take care that multiple items using the same cell do | 1053 | Place item in cell and take care that multiple items using the same cell do |
1054 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1054 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1055 | it can get in all cases. | 1055 | it can get in all cases. |
1056 | At the moment the method has a bug: When an item is placed only the sub cell | 1056 | At the moment the method has a bug: When an item is placed only the sub cell |
1057 | widths of the items are changed, which are within the Y region the item to | 1057 | widths of the items are changed, which are within the Y region the item to |
1058 | place spans. When the sub cell width change of one of this items affects a | 1058 | place spans. When the sub cell width change of one of this items affects a |
1059 | cell, where other items are, which do not overlap in Y with the item to place, | 1059 | cell, where other items are, which do not overlap in Y with the item to place, |
1060 | the display gets corrupted, although the corruption looks quite nice. | 1060 | the display gets corrupted, although the corruption looks quite nice. |
1061 | */ | 1061 | */ |
1062 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1062 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1063 | { | 1063 | { |
1064 | 1064 | ||
1065 | QPtrList<KOAgendaItem> conflictItems; | 1065 | QPtrList<KOAgendaItem> conflictItems; |
1066 | int maxSubCells = 0; | 1066 | int maxSubCells = 0; |
1067 | QIntDict<KOAgendaItem> subCellDict(5); | 1067 | QIntDict<KOAgendaItem> subCellDict(5); |
1068 | 1068 | ||
1069 | KOAgendaItem *item; | 1069 | KOAgendaItem *item; |
1070 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1070 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1071 | if (item != placeItem) { | 1071 | if (item != placeItem) { |
1072 | if (placeItem->cellX() <= item->cellXWidth() && | 1072 | if (placeItem->cellX() <= item->cellXWidth() && |
1073 | placeItem->cellXWidth() >= item->cellX()) { | 1073 | placeItem->cellXWidth() >= item->cellX()) { |
1074 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1074 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1075 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1075 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1076 | conflictItems.append(item); | 1076 | conflictItems.append(item); |
1077 | if (item->subCells() > maxSubCells) | 1077 | if (item->subCells() > maxSubCells) |
1078 | maxSubCells = item->subCells(); | 1078 | maxSubCells = item->subCells(); |
1079 | subCellDict.insert(item->subCell(),item); | 1079 | subCellDict.insert(item->subCell(),item); |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | if (conflictItems.count() > 0) { | 1085 | if (conflictItems.count() > 0) { |
1086 | // Look for unused sub cell and insert item | 1086 | // Look for unused sub cell and insert item |
1087 | int i; | 1087 | int i; |
1088 | for(i=0;i<maxSubCells;++i) { | 1088 | for(i=0;i<maxSubCells;++i) { |
1089 | if (!subCellDict.find(i)) { | 1089 | if (!subCellDict.find(i)) { |
1090 | placeItem->setSubCell(i); | 1090 | placeItem->setSubCell(i); |
1091 | break; | 1091 | break; |
1092 | } | 1092 | } |
1093 | } | 1093 | } |
1094 | if (i == maxSubCells) { | 1094 | if (i == maxSubCells) { |
1095 | placeItem->setSubCell(maxSubCells); | 1095 | placeItem->setSubCell(maxSubCells); |
1096 | maxSubCells++; // add new item to number of sub cells | 1096 | maxSubCells++; // add new item to number of sub cells |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | // Prepare for sub cell geometry adjustment | 1099 | // Prepare for sub cell geometry adjustment |
1100 | int newSubCellWidth; | 1100 | int newSubCellWidth; |
1101 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1101 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1102 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1102 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1103 | conflictItems.append(placeItem); | 1103 | conflictItems.append(placeItem); |
1104 | 1104 | ||
1105 | 1105 | ||
1106 | // Adjust sub cell geometry of all direct conflict items | 1106 | // Adjust sub cell geometry of all direct conflict items |
1107 | for ( item=conflictItems.first(); item != 0; | 1107 | for ( item=conflictItems.first(); item != 0; |