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