author | zautrix <zautrix> | 2005-08-17 13:06:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-17 13:06:53 (UTC) |
commit | 4b66565ed2db51bc636b7b4c12f19f036d9b80f3 (patch) (unidiff) | |
tree | 402372be9f52835e15757a51c18cfc46d47c8953 | |
parent | 31393a99cd2b190e62a7a09a7739a14af83936d1 (diff) | |
download | kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.zip kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.tar.gz kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.tar.bz2 |
allday agenda item fix
-rw-r--r-- | korganizer/koagenda.cpp | 42 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 20 | ||||
-rw-r--r-- | korganizer/koagendaitem.h | 1 |
3 files changed, 44 insertions, 19 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 88f5d99..796d633 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -704,1501 +704,1507 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | |||
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 | 846 | ||
847 | if (mAllDayMode) { | 847 | if (mAllDayMode) { |
848 | int gridDistanceX = (x - gx * mGridSpacingX); | 848 | int gridDistanceX = (x - gx * mGridSpacingX); |
849 | if (gridDistanceX < mResizeBorderWidth && | 849 | if (gridDistanceX < mResizeBorderWidth && |
850 | mActionItem->cellX() == mCurrentCellX) { | 850 | mActionItem->cellX() == mCurrentCellX) { |
851 | mActionType = RESIZELEFT; | 851 | mActionType = RESIZELEFT; |
852 | setCursor(sizeHorCursor); | 852 | setCursor(sizeHorCursor); |
853 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 853 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
854 | mActionItem->cellXWidth() == mCurrentCellX) { | 854 | mActionItem->cellXWidth() == mCurrentCellX) { |
855 | mActionType = RESIZERIGHT; | 855 | mActionType = RESIZERIGHT; |
856 | setCursor(sizeHorCursor); | 856 | setCursor(sizeHorCursor); |
857 | } else { | 857 | } else { |
858 | mActionType = MOVE; | 858 | mActionType = MOVE; |
859 | mActionItem->startMove(); | 859 | mActionItem->startMove(); |
860 | setCursor(sizeAllCursor); | 860 | setCursor(sizeAllCursor); |
861 | } | 861 | } |
862 | } else { | 862 | } else { |
863 | int gridDistanceY = (y - gy * mGridSpacingY); | 863 | int gridDistanceY = (y - gy * mGridSpacingY); |
864 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | 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 | moveItem->resize(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,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 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 985 | int diff = mActionItem->resizeMe(mGridSpacingX , |
986 | mActionItem->height()); | 986 | mGridSpacingX * mActionItem->cellWidth(), |
987 | mActionItem->height()); | ||
987 | int x,y; | 988 | int x,y; |
988 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 989 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
989 | moveChild(mActionItem,x,childY(mActionItem)); | 990 | moveChild(mActionItem,x+diff,childY(mActionItem)); |
990 | } | 991 | } |
991 | } else if (mActionType == RESIZERIGHT) { | 992 | } else if (mActionType == RESIZERIGHT) { |
992 | if (mCurrentCellX >= mActionItem->cellX()) { | 993 | if (mCurrentCellX >= mActionItem->cellX()) { |
993 | mActionItem->expandRight(gx - mCurrentCellX); | 994 | mActionItem->expandRight(gx - mCurrentCellX); |
994 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 995 | mActionItem->resizeMe(mGridSpacingX, mGridSpacingX * mActionItem->cellWidth(), |
995 | mActionItem->height()); | 996 | mActionItem->height()); |
996 | } | 997 | } |
997 | } | 998 | } |
998 | mCurrentCellX = gx; | 999 | mCurrentCellX = gx; |
999 | mCurrentCellY = gy; | 1000 | mCurrentCellY = gy; |
1000 | } | 1001 | } |
1001 | } | 1002 | } |
1002 | 1003 | ||
1003 | void KOAgenda::endItemAction() | 1004 | void KOAgenda::endItemAction() |
1004 | { | 1005 | { |
1005 | 1006 | ||
1006 | if ( mItemMoved ) { | 1007 | if ( mItemMoved ) { |
1007 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 1008 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
1008 | if ( !placeItem ) { | 1009 | if ( !placeItem ) { |
1009 | placeItem = mActionItem; | 1010 | placeItem = mActionItem; |
1010 | } | 1011 | } |
1011 | if ( placeItem->incidence()->doesRecur() ) { | 1012 | if ( placeItem->incidence()->doesRecur() ) { |
1012 | Incidence* oldInc = placeItem->incidence(); | 1013 | Incidence* oldInc = placeItem->incidence(); |
1013 | placeItem->recreateIncidence(); | 1014 | placeItem->recreateIncidence(); |
1014 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 1015 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1015 | } | 1016 | } |
1016 | int type = mActionType; | 1017 | int type = mActionType; |
1017 | if ( mAllDayMode ) | 1018 | if ( mAllDayMode ) |
1018 | type = -1; | 1019 | type = -1; |
1019 | KOAgendaItem *modifiedItem = placeItem; | 1020 | KOAgendaItem *modifiedItem = placeItem; |
1020 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1021 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1021 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1022 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1022 | KOAgendaItem *item; | 1023 | KOAgendaItem *item; |
1023 | 1024 | ||
1024 | if ( placeItem->incidence()->typeID() == todoID ) { | 1025 | if ( placeItem->incidence()->typeID() == todoID ) { |
1025 | mSelectedItem = 0; | 1026 | mSelectedItem = 0; |
1026 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1027 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1027 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1028 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1028 | emit itemModified( modifiedItem, mActionType ); | 1029 | emit itemModified( modifiedItem, mActionType ); |
1029 | } | 1030 | } |
1030 | else { | 1031 | else { |
1031 | 1032 | ||
1032 | 1033 | ||
1033 | globalFlagBlockAgendaItemPaint = 1; | 1034 | globalFlagBlockAgendaItemPaint = 1; |
1034 | for ( item=oldconflictItems.first(); item != 0; | 1035 | for ( item=oldconflictItems.first(); item != 0; |
1035 | item=oldconflictItems.next() ) { | 1036 | item=oldconflictItems.next() ) { |
1036 | placeSubCells(item); | 1037 | placeSubCells(item); |
1037 | } | 1038 | } |
1038 | while ( placeItem ) { | 1039 | while ( placeItem ) { |
1039 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1040 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1040 | oldconflictItems = placeItem->conflictItems(); | 1041 | oldconflictItems = placeItem->conflictItems(); |
1041 | for ( item=oldconflictItems.first(); item != 0; | 1042 | for ( item=oldconflictItems.first(); item != 0; |
1042 | item=oldconflictItems.next() ) { | 1043 | item=oldconflictItems.next() ) { |
1043 | placeSubCells(item); | 1044 | placeSubCells(item); |
1044 | } | 1045 | } |
1045 | placeSubCells( placeItem ); | 1046 | placeSubCells( placeItem ); |
1046 | placeItem = placeItem->nextMultiItem(); | 1047 | placeItem = placeItem->nextMultiItem(); |
1047 | } | 1048 | } |
1048 | globalFlagBlockAgendaItemPaint = 0; | 1049 | globalFlagBlockAgendaItemPaint = 0; |
1049 | for ( item=oldconflictItems.first(); item != 0; | 1050 | for ( item=oldconflictItems.first(); item != 0; |
1050 | item=oldconflictItems.next() ) { | 1051 | item=oldconflictItems.next() ) { |
1051 | globalFlagBlockAgendaItemUpdate = 0; | 1052 | globalFlagBlockAgendaItemUpdate = 0; |
1052 | item->repaintMe(); | 1053 | item->repaintMe(); |
1053 | globalFlagBlockAgendaItemUpdate = 1; | 1054 | globalFlagBlockAgendaItemUpdate = 1; |
1054 | item->repaint( false ); | 1055 | item->repaint( false ); |
1055 | } | 1056 | } |
1056 | placeItem = modifiedItem; | 1057 | placeItem = modifiedItem; |
1057 | 1058 | ||
1058 | while ( placeItem ) { | 1059 | while ( placeItem ) { |
1059 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1060 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1060 | globalFlagBlockAgendaItemUpdate = 0; | 1061 | globalFlagBlockAgendaItemUpdate = 0; |
1061 | placeItem->repaintMe(); | 1062 | placeItem->repaintMe(); |
1062 | globalFlagBlockAgendaItemUpdate = 1; | 1063 | globalFlagBlockAgendaItemUpdate = 1; |
1063 | placeItem->repaint(false); | 1064 | placeItem->repaint(false); |
1064 | placeItem = placeItem->nextMultiItem(); | 1065 | placeItem = placeItem->nextMultiItem(); |
1065 | } | 1066 | } |
1066 | emit itemModified( modifiedItem, mActionType ); | 1067 | emit itemModified( modifiedItem, mActionType ); |
1067 | 1068 | ||
1068 | 1069 | ||
1069 | placeItem = modifiedItem; | 1070 | placeItem = modifiedItem; |
1070 | while ( placeItem ) { | 1071 | while ( placeItem ) { |
1071 | oldconflictItems = placeItem->conflictItems(); | 1072 | oldconflictItems = placeItem->conflictItems(); |
1072 | for ( item=oldconflictItems.first(); item != 0; | 1073 | for ( item=oldconflictItems.first(); item != 0; |
1073 | item=oldconflictItems.next() ) { | 1074 | item=oldconflictItems.next() ) { |
1074 | placeSubCells(item); | 1075 | placeSubCells(item); |
1075 | } | 1076 | } |
1076 | placeSubCells( placeItem ); | 1077 | placeSubCells( placeItem ); |
1077 | placeItem = placeItem->nextMultiItem(); | 1078 | placeItem = placeItem->nextMultiItem(); |
1078 | 1079 | ||
1079 | } | 1080 | } |
1080 | placeItem = modifiedItem; | 1081 | placeItem = modifiedItem; |
1081 | while ( placeItem ) { | 1082 | while ( placeItem ) { |
1082 | oldconflictItems = placeItem->conflictItems(); | 1083 | oldconflictItems = placeItem->conflictItems(); |
1083 | for ( item=oldconflictItems.first(); item != 0; | 1084 | for ( item=oldconflictItems.first(); item != 0; |
1084 | item=oldconflictItems.next() ) { | 1085 | item=oldconflictItems.next() ) { |
1085 | globalFlagBlockAgendaItemUpdate = 0; | 1086 | globalFlagBlockAgendaItemUpdate = 0; |
1086 | item->repaintMe(); | 1087 | item->repaintMe(); |
1087 | globalFlagBlockAgendaItemUpdate = 1; | 1088 | globalFlagBlockAgendaItemUpdate = 1; |
1088 | item->repaint(false); | 1089 | item->repaint(false); |
1089 | } | 1090 | } |
1090 | placeItem = placeItem->nextMultiItem(); | 1091 | placeItem = placeItem->nextMultiItem(); |
1091 | } | 1092 | } |
1092 | /* | 1093 | /* |
1093 | 1094 | ||
1094 | oldconflictItems = modifiedItem->conflictItems(); | 1095 | oldconflictItems = modifiedItem->conflictItems(); |
1095 | for ( item=oldconflictItems.first(); item != 0; | 1096 | for ( item=oldconflictItems.first(); item != 0; |
1096 | item=oldconflictItems.next() ) { | 1097 | item=oldconflictItems.next() ) { |
1097 | globalFlagBlockAgendaItemUpdate = 0; | 1098 | globalFlagBlockAgendaItemUpdate = 0; |
1098 | item->paintMe(false); | 1099 | item->paintMe(false); |
1099 | globalFlagBlockAgendaItemUpdate = 1; | 1100 | globalFlagBlockAgendaItemUpdate = 1; |
1100 | item->repaint(false); | 1101 | item->repaint(false); |
1101 | } | 1102 | } |
1102 | */ | 1103 | */ |
1103 | 1104 | ||
1104 | 1105 | ||
1105 | } | 1106 | } |
1106 | 1107 | ||
1107 | } | 1108 | } |
1108 | if ( mActionItem ) | 1109 | if ( mActionItem ) |
1109 | emit incidenceSelected( mActionItem->incidence() ); | 1110 | emit incidenceSelected( mActionItem->incidence() ); |
1110 | mScrollUpTimer.stop(); | 1111 | mScrollUpTimer.stop(); |
1111 | mScrollDownTimer.stop(); | 1112 | mScrollDownTimer.stop(); |
1112 | setCursor( arrowCursor ); | 1113 | setCursor( arrowCursor ); |
1113 | mActionItem = 0; | 1114 | mActionItem = 0; |
1114 | mActionType = NOP; | 1115 | mActionType = NOP; |
1115 | mItemMoved = 0; | 1116 | mItemMoved = 0; |
1116 | 1117 | ||
1117 | } | 1118 | } |
1118 | 1119 | ||
1119 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1120 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1120 | { | 1121 | { |
1121 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1122 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1122 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1123 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1123 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1124 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1124 | // point = clipper()->mapFromGlobal(point); | 1125 | // point = clipper()->mapFromGlobal(point); |
1125 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1126 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1126 | 1127 | ||
1127 | int x,y; | 1128 | int x,y; |
1128 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1129 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1129 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1130 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1130 | int gx,gy; | 1131 | int gx,gy; |
1131 | contentsToGrid(x,y,gx,gy); | 1132 | contentsToGrid(x,y,gx,gy); |
1132 | 1133 | ||
1133 | // Change cursor to resize cursor if appropriate | 1134 | // Change cursor to resize cursor if appropriate |
1134 | if (mAllDayMode) { | 1135 | if (mAllDayMode) { |
1135 | int gridDistanceX = (x - gx * mGridSpacingX); | 1136 | int gridDistanceX = (x - gx * mGridSpacingX); |
1136 | if (gridDistanceX < mResizeBorderWidth && | 1137 | if (gridDistanceX < mResizeBorderWidth && |
1137 | moveItem->cellX() == gx) { | 1138 | moveItem->cellX() == gx) { |
1138 | setCursor(sizeHorCursor); | 1139 | setCursor(sizeHorCursor); |
1139 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1140 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1140 | moveItem->cellXWidth() == gx) { | 1141 | moveItem->cellXWidth() == gx) { |
1141 | setCursor(sizeHorCursor); | 1142 | setCursor(sizeHorCursor); |
1142 | } else { | 1143 | } else { |
1143 | setCursor(arrowCursor); | 1144 | setCursor(arrowCursor); |
1144 | } | 1145 | } |
1145 | } else { | 1146 | } else { |
1146 | int gridDistanceY = (y - gy * mGridSpacingY); | 1147 | int gridDistanceY = (y - gy * mGridSpacingY); |
1147 | if (gridDistanceY < mResizeBorderWidth && | 1148 | if (gridDistanceY < mResizeBorderWidth && |
1148 | moveItem->cellYTop() == gy && | 1149 | moveItem->cellYTop() == gy && |
1149 | !moveItem->firstMultiItem()) { | 1150 | !moveItem->firstMultiItem()) { |
1150 | setCursor(sizeVerCursor); | 1151 | setCursor(sizeVerCursor); |
1151 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1152 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1152 | moveItem->cellYBottom() == gy && | 1153 | moveItem->cellYBottom() == gy && |
1153 | !moveItem->lastMultiItem()) { | 1154 | !moveItem->lastMultiItem()) { |
1154 | setCursor(sizeVerCursor); | 1155 | setCursor(sizeVerCursor); |
1155 | } else { | 1156 | } else { |
1156 | setCursor(arrowCursor); | 1157 | setCursor(arrowCursor); |
1157 | } | 1158 | } |
1158 | } | 1159 | } |
1159 | } | 1160 | } |
1160 | 1161 | ||
1161 | 1162 | ||
1162 | /* | 1163 | /* |
1163 | Place item in cell and take care that multiple items using the same cell do | 1164 | Place item in cell and take care that multiple items using the same cell do |
1164 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1165 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1165 | it can get in all cases. | 1166 | it can get in all cases. |
1166 | At the moment the method has a bug: When an item is placed only the sub cell | 1167 | At the moment the method has a bug: When an item is placed only the sub cell |
1167 | widths of the items are changed, which are within the Y region the item to | 1168 | widths of the items are changed, which are within the Y region the item to |
1168 | place spans. When the sub cell width change of one of this items affects a | 1169 | place spans. When the sub cell width change of one of this items affects a |
1169 | cell, where other items are, which do not overlap in Y with the item to place, | 1170 | cell, where other items are, which do not overlap in Y with the item to place, |
1170 | the display gets corrupted, although the corruption looks quite nice. | 1171 | the display gets corrupted, although the corruption looks quite nice. |
1171 | */ | 1172 | */ |
1172 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1173 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1173 | { | 1174 | { |
1174 | 1175 | ||
1175 | QPtrList<KOAgendaItem> conflictItems; | 1176 | QPtrList<KOAgendaItem> conflictItems; |
1176 | int maxSubCells = 0; | 1177 | int maxSubCells = 0; |
1177 | QIntDict<KOAgendaItem> subCellDict(7); | 1178 | QIntDict<KOAgendaItem> subCellDict(7); |
1178 | 1179 | ||
1179 | KOAgendaItem *item; | 1180 | KOAgendaItem *item; |
1180 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1181 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1181 | if (item != placeItem) { | 1182 | if (item != placeItem) { |
1182 | if (placeItem->cellX() <= item->cellXWidth() && | 1183 | if (placeItem->cellX() <= item->cellXWidth() && |
1183 | placeItem->cellXWidth() >= item->cellX()) { | 1184 | placeItem->cellXWidth() >= item->cellX()) { |
1184 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1185 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1185 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1186 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1186 | conflictItems.append(item); | 1187 | conflictItems.append(item); |
1187 | if (item->subCells() > maxSubCells) | 1188 | if (item->subCells() > maxSubCells) |
1188 | maxSubCells = item->subCells(); | 1189 | maxSubCells = item->subCells(); |
1189 | subCellDict.insert(item->subCell(),item); | 1190 | subCellDict.insert(item->subCell(),item); |
1190 | } | 1191 | } |
1191 | } | 1192 | } |
1192 | } | 1193 | } |
1193 | } | 1194 | } |
1194 | 1195 | ||
1195 | if (conflictItems.count() > 0) { | 1196 | if (conflictItems.count() > 0) { |
1196 | // Look for unused sub cell and insert item | 1197 | // Look for unused sub cell and insert item |
1197 | int i; | 1198 | int i; |
1198 | for(i=0;i<maxSubCells;++i) { | 1199 | for(i=0;i<maxSubCells;++i) { |
1199 | if (!subCellDict.find(i)) { | 1200 | if (!subCellDict.find(i)) { |
1200 | placeItem->setSubCell(i); | 1201 | placeItem->setSubCell(i); |
1201 | break; | 1202 | break; |
1202 | } | 1203 | } |
1203 | } | 1204 | } |
1204 | if (i == maxSubCells) { | 1205 | if (i == maxSubCells) { |
1205 | placeItem->setSubCell(maxSubCells); | 1206 | placeItem->setSubCell(maxSubCells); |
1206 | maxSubCells++; // add new item to number of sub cells | 1207 | maxSubCells++; // add new item to number of sub cells |
1207 | } | 1208 | } |
1208 | 1209 | ||
1209 | // Prepare for sub cell geometry adjustment | 1210 | // Prepare for sub cell geometry adjustment |
1210 | int newSubCellWidth; | 1211 | int newSubCellWidth; |
1211 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1212 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1212 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1213 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1213 | conflictItems.append(placeItem); | 1214 | conflictItems.append(placeItem); |
1214 | 1215 | ||
1215 | 1216 | ||
1216 | // Adjust sub cell geometry of all direct conflict items | 1217 | // Adjust sub cell geometry of all direct conflict items |
1217 | for ( item=conflictItems.first(); item != 0; | 1218 | for ( item=conflictItems.first(); item != 0; |
1218 | item=conflictItems.next() ) { | 1219 | item=conflictItems.next() ) { |
1219 | item->setSubCells(maxSubCells); | 1220 | item->setSubCells(maxSubCells); |
1221 | int diff = 0; | ||
1220 | if (mAllDayMode) { | 1222 | if (mAllDayMode) { |
1221 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1223 | diff = item->resizeMe( mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1222 | } else { | 1224 | } else { |
1223 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1225 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1224 | } | 1226 | } |
1225 | int x,y; | 1227 | int x,y; |
1226 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1228 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1227 | if (mAllDayMode) { | 1229 | if (mAllDayMode) { |
1228 | y += item->subCell() * newSubCellWidth; | 1230 | y += item->subCell() * newSubCellWidth; |
1229 | } else { | 1231 | } else { |
1230 | x += item->subCell() * newSubCellWidth; | 1232 | x += item->subCell() * newSubCellWidth; |
1231 | } | 1233 | } |
1232 | moveChild(item,x,y); | 1234 | moveChild(item,x+diff,y); |
1233 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1235 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1234 | //item->updateItem(); | 1236 | //item->updateItem(); |
1235 | } | 1237 | } |
1236 | // Adjust sub cell geometry of all conflict items of all conflict items | 1238 | // Adjust sub cell geometry of all conflict items of all conflict items |
1237 | for ( item=conflictItems.first(); item != 0; | 1239 | for ( item=conflictItems.first(); item != 0; |
1238 | item=conflictItems.next() ) { | 1240 | item=conflictItems.next() ) { |
1239 | if ( placeItem != item ) { | 1241 | if ( placeItem != item ) { |
1240 | KOAgendaItem *item2; | 1242 | KOAgendaItem *item2; |
1241 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1243 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1242 | for ( item2=conflictItems2.first(); item2 != 0; | 1244 | for ( item2=conflictItems2.first(); item2 != 0; |
1243 | item2=conflictItems2.next() ) { | 1245 | item2=conflictItems2.next() ) { |
1244 | if ( item2->subCells() != maxSubCells) { | 1246 | if ( item2->subCells() != maxSubCells) { |
1245 | item2->setSubCells(maxSubCells); | 1247 | item2->setSubCells(maxSubCells); |
1248 | int diff = 0; | ||
1246 | if (mAllDayMode) { | 1249 | if (mAllDayMode) { |
1247 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1250 | diff = item2->resizeMe(mGridSpacingX, item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1248 | } else { | 1251 | } else { |
1249 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1252 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1250 | } | 1253 | } |
1251 | int x,y; | 1254 | int x,y; |
1252 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1255 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1253 | if (mAllDayMode) { | 1256 | if (mAllDayMode) { |
1254 | y += item2->subCell() * newSubCellWidth; | 1257 | y += item2->subCell() * newSubCellWidth; |
1255 | } else { | 1258 | } else { |
1256 | x += item2->subCell() * newSubCellWidth; | 1259 | x += item2->subCell() * newSubCellWidth; |
1257 | } | 1260 | } |
1258 | moveChild(item2,x,y); | 1261 | moveChild(item2,x+diff,y); |
1259 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1262 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1260 | } | 1263 | } |
1261 | } | 1264 | } |
1262 | } | 1265 | } |
1263 | } | 1266 | } |
1264 | } else { | 1267 | } else { |
1265 | placeItem->setSubCell(0); | 1268 | placeItem->setSubCell(0); |
1266 | placeItem->setSubCells(1); | 1269 | placeItem->setSubCells(1); |
1267 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1270 | int diff = 0; |
1271 | if (mAllDayMode) diff = placeItem->resizeMe( mGridSpacingX, placeItem->width(),mGridSpacingY); | ||
1268 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1272 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1269 | int x,y; | 1273 | int x,y; |
1270 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1274 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1271 | moveChild(placeItem,x,y); | 1275 | moveChild(placeItem,x+diff,y); |
1272 | } | 1276 | } |
1273 | placeItem->setConflictItems(conflictItems); | 1277 | placeItem->setConflictItems(conflictItems); |
1274 | // for ( item=conflictItems.first(); item != 0; | 1278 | // for ( item=conflictItems.first(); item != 0; |
1275 | // item=conflictItems.next() ) { | 1279 | // item=conflictItems.next() ) { |
1276 | // //item->updateItem(); | 1280 | // //item->updateItem(); |
1277 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1281 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1278 | // } | 1282 | // } |
1279 | // placeItem->updateItem(); | 1283 | // placeItem->updateItem(); |
1280 | } | 1284 | } |
1281 | 1285 | ||
1282 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1286 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1283 | { | 1287 | { |
1284 | if ( globalFlagBlockAgenda ) | 1288 | if ( globalFlagBlockAgenda ) |
1285 | return; | 1289 | return; |
1286 | 1290 | ||
1287 | if ( mInvalidPixmap ) { | 1291 | if ( mInvalidPixmap ) { |
1288 | mInvalidPixmap = false; | 1292 | mInvalidPixmap = false; |
1289 | qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); | 1293 | qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); |
1290 | computeSizes(); | 1294 | computeSizes(); |
1291 | emit updateViewSignal(); | 1295 | emit updateViewSignal(); |
1292 | return; | 1296 | return; |
1293 | } | 1297 | } |
1294 | //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1()); | 1298 | //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1()); |
1295 | if ( ! mAllDayMode ) { | 1299 | if ( ! mAllDayMode ) { |
1296 | // currently not working for | 1300 | // currently not working for |
1297 | 1301 | ||
1298 | //qDebug("KOAgenda::drawContents "); | 1302 | //qDebug("KOAgenda::drawContents "); |
1299 | #if 0 | 1303 | #if 0 |
1300 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1304 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1301 | qDebug("WAU "); | 1305 | qDebug("WAU "); |
1302 | drawContentsToPainter(); | 1306 | drawContentsToPainter(); |
1303 | } | 1307 | } |
1304 | #endif | 1308 | #endif |
1305 | QPaintDevice* pd = p->device(); | 1309 | QPaintDevice* pd = p->device(); |
1306 | p->end(); | 1310 | p->end(); |
1307 | int vx, vy; | 1311 | int vx, vy; |
1308 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1312 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1309 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1313 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1310 | mSelectionCellX * mGridSpacingX; | 1314 | mSelectionCellX * mGridSpacingX; |
1311 | contentsToViewport ( cx, cy, vx,vy); | 1315 | contentsToViewport ( cx, cy, vx,vy); |
1312 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1316 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1313 | 1317 | ||
1314 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1318 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1315 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1319 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1316 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1320 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1317 | 1321 | ||
1318 | int vxSel, vySel; | 1322 | int vxSel, vySel; |
1319 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1323 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1320 | int off = mSelectionHeight; | 1324 | int off = mSelectionHeight; |
1321 | if ( vySel < 0 ) | 1325 | if ( vySel < 0 ) |
1322 | off += vySel; | 1326 | off += vySel; |
1323 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1327 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1324 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1328 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1325 | } else { | 1329 | } else { |
1326 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1330 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1327 | } | 1331 | } |
1328 | } | 1332 | } |
1329 | if ( mSelectionHeight > 0 ) { | 1333 | if ( mSelectionHeight > 0 ) { |
1330 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1334 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1331 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1335 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1332 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1336 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1333 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1337 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1334 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1338 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1335 | int hei = mSelectionHeight; | 1339 | int hei = mSelectionHeight; |
1336 | int offset = 0; | 1340 | int offset = 0; |
1337 | while ( hei > 0 ) { | 1341 | while ( hei > 0 ) { |
1338 | int p_hei = 5; | 1342 | int p_hei = 5; |
1339 | if ( hei < 5 ) p_hei = hei; | 1343 | if ( hei < 5 ) p_hei = hei; |
1340 | hei -= 5; | 1344 | hei -= 5; |
1341 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1345 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1342 | offset += 5; | 1346 | offset += 5; |
1343 | } | 1347 | } |
1344 | } | 1348 | } |
1345 | } | 1349 | } |
1346 | p->begin( pd ); | 1350 | p->begin( pd ); |
1347 | } else { | 1351 | } else { |
1348 | #if 0 | 1352 | #if 0 |
1349 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1353 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1350 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1354 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1351 | qDebug("WAUWAU "); | 1355 | qDebug("WAUWAU "); |
1352 | drawContentsToPainter(); | 1356 | drawContentsToPainter(); |
1353 | } | 1357 | } |
1354 | #endif | 1358 | #endif |
1355 | QPaintDevice* pd = p->device(); | 1359 | QPaintDevice* pd = p->device(); |
1356 | p->end(); | 1360 | p->end(); |
1357 | int vx, vy; | 1361 | int vx, vy; |
1358 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1362 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1359 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1363 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1360 | mSelectionCellX * mGridSpacingX; | 1364 | mSelectionCellX * mGridSpacingX; |
1361 | contentsToViewport ( cx, cy, vx,vy); | 1365 | contentsToViewport ( cx, cy, vx,vy); |
1362 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1366 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1363 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1367 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1364 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1368 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1365 | 1369 | ||
1366 | if ( mSelectionHeight > 0 ) { | 1370 | if ( mSelectionHeight > 0 ) { |
1367 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1371 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1368 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1372 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1369 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1373 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1370 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1374 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1371 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1375 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1372 | int hei = mSelectionHeight; | 1376 | int hei = mSelectionHeight; |
1373 | int offset = 0; | 1377 | int offset = 0; |
1374 | while ( hei > 0 ) { | 1378 | while ( hei > 0 ) { |
1375 | int p_hei = 5; | 1379 | int p_hei = 5; |
1376 | if ( hei < 5 ) p_hei = hei; | 1380 | if ( hei < 5 ) p_hei = hei; |
1377 | hei -= 5; | 1381 | hei -= 5; |
1378 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1382 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1379 | offset += 5; | 1383 | offset += 5; |
1380 | } | 1384 | } |
1381 | } | 1385 | } |
1382 | } | 1386 | } |
1383 | p->begin( pd ); | 1387 | p->begin( pd ); |
1384 | } | 1388 | } |
1385 | 1389 | ||
1386 | } | 1390 | } |
1387 | 1391 | ||
1388 | void KOAgenda::finishUpdate() | 1392 | void KOAgenda::finishUpdate() |
1389 | { | 1393 | { |
1390 | 1394 | ||
1391 | KOAgendaItem *item; | 1395 | KOAgendaItem *item; |
1392 | globalFlagBlockAgendaItemPaint = 1; | 1396 | globalFlagBlockAgendaItemPaint = 1; |
1393 | // 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 | 1397 | // 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 |
1394 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1398 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1395 | if ( !item->checkLayout() ) { | 1399 | if ( !item->checkLayout() ) { |
1396 | //qDebug(" conflictitem found "); | 1400 | //qDebug(" conflictitem found "); |
1397 | int newSubCellWidth; | 1401 | int newSubCellWidth; |
1402 | int diff = 0; | ||
1398 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1403 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1399 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1404 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1400 | 1405 | ||
1401 | if (mAllDayMode) { | 1406 | if (mAllDayMode) { |
1402 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1407 | diff = item->resizeMe(mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1403 | } else { | 1408 | } else { |
1404 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1409 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1405 | } | 1410 | } |
1406 | int x,y; | 1411 | int x,y; |
1407 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1412 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1408 | if (mAllDayMode) { | 1413 | if (mAllDayMode) { |
1409 | y += item->subCell() * newSubCellWidth; | 1414 | y += item->subCell() * newSubCellWidth; |
1410 | } else { | 1415 | } else { |
1411 | x += item->subCell() * newSubCellWidth; | 1416 | x += item->subCell() * newSubCellWidth; |
1412 | } | 1417 | } |
1413 | moveChild(item,x,y); | 1418 | moveChild(item,x+diff,y); |
1414 | } | 1419 | } |
1415 | } | 1420 | } |
1416 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1421 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1417 | if ( !item->isVisible() ) | 1422 | if ( !item->isVisible() ) |
1418 | item->show(); | 1423 | item->show(); |
1419 | 1424 | ||
1420 | } | 1425 | } |
1421 | globalFlagBlockAgendaItemUpdate = 0; | 1426 | globalFlagBlockAgendaItemUpdate = 0; |
1422 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1427 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1423 | item->repaintMe( ); | 1428 | item->repaintMe( ); |
1424 | } | 1429 | } |
1425 | globalFlagBlockAgendaItemUpdate = 1; | 1430 | globalFlagBlockAgendaItemUpdate = 1; |
1426 | qApp->processEvents(); | 1431 | qApp->processEvents(); |
1427 | globalFlagBlockAgendaItemPaint = 0; | 1432 | globalFlagBlockAgendaItemPaint = 0; |
1428 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1429 | item->repaint( false ); | 1434 | item->repaint( false ); |
1430 | } | 1435 | } |
1431 | marcus_bains(); | 1436 | marcus_bains(); |
1432 | } | 1437 | } |
1433 | 1438 | ||
1434 | /* | 1439 | /* |
1435 | Draw grid in the background of the agenda. | 1440 | Draw grid in the background of the agenda. |
1436 | */ | 1441 | */ |
1437 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1442 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1438 | { | 1443 | { |
1439 | 1444 | ||
1440 | 1445 | ||
1441 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1446 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1442 | return; | 1447 | return; |
1443 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1448 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1444 | return; | 1449 | return; |
1445 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1450 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1446 | if ( ch < 1 ) | 1451 | if ( ch < 1 ) |
1447 | ch = 1; | 1452 | ch = 1; |
1448 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1453 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1449 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1454 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1450 | } | 1455 | } |
1451 | mCurPixWid = contentsWidth(); | 1456 | mCurPixWid = contentsWidth(); |
1452 | mCurPixHei = ch; | 1457 | mCurPixHei = ch; |
1453 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1458 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1454 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1459 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1455 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1460 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1456 | } | 1461 | } |
1457 | mPixPainter.begin( &mPaintPixmap) ; | 1462 | mPixPainter.begin( &mPaintPixmap) ; |
1458 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1463 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1459 | QPainter * p ; | 1464 | QPainter * p ; |
1460 | if (paint == 0) { | 1465 | if (paint == 0) { |
1461 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1466 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1462 | p = &mPixPainter; | 1467 | p = &mPixPainter; |
1463 | } | 1468 | } |
1464 | else | 1469 | else |
1465 | p = paint ; | 1470 | p = paint ; |
1466 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1471 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1467 | 1472 | ||
1468 | //--cx;++cw; | 1473 | //--cx;++cw; |
1469 | int lGridSpacingY = mGridSpacingY*2; | 1474 | int lGridSpacingY = mGridSpacingY*2; |
1470 | uint selDay; | 1475 | uint selDay; |
1471 | QDate curDate = QDate::currentDate(); | 1476 | QDate curDate = QDate::currentDate(); |
1472 | if ( !backgroundOnly ) { | 1477 | if ( !backgroundOnly ) { |
1473 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1478 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1474 | { | 1479 | { |
1475 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1480 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1476 | int x1 = cx; | 1481 | int x1 = cx; |
1477 | int y1 = 0; | 1482 | int y1 = 0; |
1478 | if (y1 < cy) y1 = cy; | 1483 | if (y1 < cy) y1 = cy; |
1479 | int x2 = cx+cw-1; | 1484 | int x2 = cx+cw-1; |
1480 | int y2 = contentsHeight(); | 1485 | int y2 = contentsHeight(); |
1481 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1486 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1482 | if (x2 >= x1 && y2 >= y1) { | 1487 | if (x2 >= x1 && y2 >= y1) { |
1483 | int gxStart = selDay; | 1488 | int gxStart = selDay; |
1484 | //int gxEnd = gxStart ; | 1489 | //int gxEnd = gxStart ; |
1485 | int xStart = KOGlobals::self()->reverseLayout() ? | 1490 | int xStart = KOGlobals::self()->reverseLayout() ? |
1486 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1491 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1487 | gxStart*mGridSpacingX; | 1492 | gxStart*mGridSpacingX; |
1488 | if (xStart < x1) xStart = x1; | 1493 | if (xStart < x1) xStart = x1; |
1489 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1494 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1490 | (mColumns - gxStart)*mGridSpacingX-1 : | 1495 | (mColumns - gxStart)*mGridSpacingX-1 : |
1491 | (gxStart+1)*mGridSpacingX-1; | 1496 | (gxStart+1)*mGridSpacingX-1; |
1492 | if (xEnd > x2) xEnd = x2; | 1497 | if (xEnd > x2) xEnd = x2; |
1493 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1498 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1494 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1499 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1495 | KOPrefs::instance()->mAgendaBgColor.light()); | 1500 | KOPrefs::instance()->mAgendaBgColor.light()); |
1496 | else | 1501 | else |
1497 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1502 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1498 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1503 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1499 | 1504 | ||
1500 | } | 1505 | } |
1501 | } | 1506 | } |
1502 | } | 1507 | } |
1503 | } | 1508 | } |
1504 | // Highlight working hours | 1509 | // Highlight working hours |
1505 | 1510 | ||
1506 | if ( !backgroundOnly ) | 1511 | if ( !backgroundOnly ) |
1507 | if (mWorkingHoursEnable) { | 1512 | if (mWorkingHoursEnable) { |
1508 | int x1 = cx; | 1513 | int x1 = cx; |
1509 | int y1 = mWorkingHoursYTop; | 1514 | int y1 = mWorkingHoursYTop; |
1510 | if (y1 < cy) y1 = cy; | 1515 | if (y1 < cy) y1 = cy; |
1511 | int x2 = cx+cw-1; | 1516 | int x2 = cx+cw-1; |
1512 | // int x2 = mGridSpacingX * 5 - 1; | 1517 | // int x2 = mGridSpacingX * 5 - 1; |
1513 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1518 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1514 | int y2 = mWorkingHoursYBottom; | 1519 | int y2 = mWorkingHoursYBottom; |
1515 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1520 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1516 | 1521 | ||
1517 | if (x2 >= x1 && y2 >= y1) { | 1522 | if (x2 >= x1 && y2 >= y1) { |
1518 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1523 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1519 | int gxStart = x1/mGridSpacingX; | 1524 | int gxStart = x1/mGridSpacingX; |
1520 | int gxEnd = x2/mGridSpacingX; | 1525 | int gxEnd = x2/mGridSpacingX; |
1521 | while(gxStart <= gxEnd) { | 1526 | while(gxStart <= gxEnd) { |
1522 | if (gxStart < int(mHolidayMask->count()) && | 1527 | if (gxStart < int(mHolidayMask->count()) && |
1523 | !mHolidayMask->at(gxStart)) { | 1528 | !mHolidayMask->at(gxStart)) { |
1524 | int xStart = KOGlobals::self()->reverseLayout() ? | 1529 | int xStart = KOGlobals::self()->reverseLayout() ? |
1525 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1530 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1526 | gxStart*mGridSpacingX; | 1531 | gxStart*mGridSpacingX; |
1527 | if (xStart < x1) xStart = x1; | 1532 | if (xStart < x1) xStart = x1; |
1528 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1533 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1529 | (mColumns - gxStart)*mGridSpacingX-1 : | 1534 | (mColumns - gxStart)*mGridSpacingX-1 : |
1530 | (gxStart+1)*mGridSpacingX-1; | 1535 | (gxStart+1)*mGridSpacingX-1; |
1531 | if (xEnd > x2) xEnd = x2; | 1536 | if (xEnd > x2) xEnd = x2; |
1532 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { | 1537 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { |
1533 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1538 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1534 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1539 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1535 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1540 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1536 | else | 1541 | else |
1537 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1542 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1538 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1543 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1539 | } else { | 1544 | } else { |
1540 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1545 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1541 | KOPrefs::instance()->mWorkingHoursColor); | 1546 | KOPrefs::instance()->mWorkingHoursColor); |
1542 | } | 1547 | } |
1543 | } | 1548 | } |
1544 | ++gxStart; | 1549 | ++gxStart; |
1545 | } | 1550 | } |
1546 | } | 1551 | } |
1547 | } | 1552 | } |
1548 | /* | 1553 | /* |
1549 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1554 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1550 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1555 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1551 | mSelectionCellX * mGridSpacingX; | 1556 | mSelectionCellX * mGridSpacingX; |
1552 | 1557 | ||
1553 | // Draw selection | 1558 | // Draw selection |
1554 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1559 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1555 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1560 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1556 | // TODO: paint only part within cx,cy,cw,ch | 1561 | // TODO: paint only part within cx,cy,cw,ch |
1557 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1562 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1558 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1563 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1559 | } | 1564 | } |
1560 | */ | 1565 | */ |
1561 | // Draw vertical lines of grid | 1566 | // Draw vertical lines of grid |
1562 | 1567 | ||
1563 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1568 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1564 | if ( mGridSpacingX > 0 ) { | 1569 | if ( mGridSpacingX > 0 ) { |
1565 | while (x < cx + cw) { | 1570 | while (x < cx + cw) { |
1566 | p->drawLine(x,cy,x,cy+ch); | 1571 | p->drawLine(x,cy,x,cy+ch); |
1567 | x+=mGridSpacingX; | 1572 | x+=mGridSpacingX; |
1568 | } | 1573 | } |
1569 | } | 1574 | } |
1570 | // Draw horizontal lines of grid | 1575 | // Draw horizontal lines of grid |
1571 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1576 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1572 | if ( lGridSpacingY > 0 ) { | 1577 | if ( lGridSpacingY > 0 ) { |
1573 | while (y < cy + ch) { | 1578 | while (y < cy + ch) { |
1574 | p->setPen( SolidLine ); | 1579 | p->setPen( SolidLine ); |
1575 | p->drawLine(cx,y,cx+cw,y); | 1580 | p->drawLine(cx,y,cx+cw,y); |
1576 | y+=lGridSpacingY; | 1581 | y+=lGridSpacingY; |
1577 | p->setPen( DotLine ); | 1582 | p->setPen( DotLine ); |
1578 | p->drawLine(cx,y,cx+cw,y); | 1583 | p->drawLine(cx,y,cx+cw,y); |
1579 | y+=lGridSpacingY; | 1584 | y+=lGridSpacingY; |
1580 | } | 1585 | } |
1581 | p->setPen( SolidLine ); | 1586 | p->setPen( SolidLine ); |
1582 | } | 1587 | } |
1583 | mPixPainter.end() ; | 1588 | mPixPainter.end() ; |
1584 | } | 1589 | } |
1585 | 1590 | ||
1586 | /* | 1591 | /* |
1587 | Convert srcollview contents coordinates to agenda grid coordinates. | 1592 | Convert srcollview contents coordinates to agenda grid coordinates. |
1588 | */ | 1593 | */ |
1589 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1594 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1590 | { | 1595 | { |
1591 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1596 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1592 | x/mGridSpacingX; | 1597 | x/mGridSpacingX; |
1593 | gy = y/mGridSpacingY; | 1598 | gy = y/mGridSpacingY; |
1594 | } | 1599 | } |
1595 | 1600 | ||
1596 | /* | 1601 | /* |
1597 | Convert agenda grid coordinates to scrollview contents coordinates. | 1602 | Convert agenda grid coordinates to scrollview contents coordinates. |
1598 | */ | 1603 | */ |
1599 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1604 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1600 | { | 1605 | { |
1601 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1606 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1602 | gx*mGridSpacingX; | 1607 | gx*mGridSpacingX; |
1603 | y = gy*mGridSpacingY; | 1608 | y = gy*mGridSpacingY; |
1604 | } | 1609 | } |
1605 | 1610 | ||
1606 | 1611 | ||
1607 | /* | 1612 | /* |
1608 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1613 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1609 | the grid. | 1614 | the grid. |
1610 | */ | 1615 | */ |
1611 | int KOAgenda::timeToY(const QTime &time) | 1616 | int KOAgenda::timeToY(const QTime &time) |
1612 | { | 1617 | { |
1613 | int minutesPerCell = 24 * 60 / mRows; | 1618 | int minutesPerCell = 24 * 60 / mRows; |
1614 | int timeMinutes = time.hour() * 60 + time.minute(); | 1619 | int timeMinutes = time.hour() * 60 + time.minute(); |
1615 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1620 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1616 | return Y; | 1621 | return Y; |
1617 | } | 1622 | } |
1618 | 1623 | ||
1619 | 1624 | ||
1620 | /* | 1625 | /* |
1621 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1626 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1622 | fit into the grid. | 1627 | fit into the grid. |
1623 | */ | 1628 | */ |
1624 | QTime KOAgenda::gyToTime(int gy) | 1629 | QTime KOAgenda::gyToTime(int gy) |
1625 | { | 1630 | { |
1626 | 1631 | ||
1627 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1632 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1628 | 1633 | ||
1629 | int timeSeconds = secondsPerCell * gy; | 1634 | int timeSeconds = secondsPerCell * gy; |
1630 | 1635 | ||
1631 | QTime time( 0, 0, 0 ); | 1636 | QTime time( 0, 0, 0 ); |
1632 | if ( timeSeconds < 24 * 60 * 60 ) { | 1637 | if ( timeSeconds < 24 * 60 * 60 ) { |
1633 | time = time.addSecs(timeSeconds); | 1638 | time = time.addSecs(timeSeconds); |
1634 | } else { | 1639 | } else { |
1635 | time.setHMS( 23, 59, 59 ); | 1640 | time.setHMS( 23, 59, 59 ); |
1636 | } | 1641 | } |
1637 | 1642 | ||
1638 | return time; | 1643 | return time; |
1639 | } | 1644 | } |
1640 | 1645 | ||
1641 | void KOAgenda::setStartHour(int startHour) | 1646 | void KOAgenda::setStartHour(int startHour) |
1642 | { | 1647 | { |
1643 | int startCell = startHour * mRows / 24; | 1648 | int startCell = startHour * mRows / 24; |
1644 | setContentsPos(0,startCell * gridSpacingY()); | 1649 | setContentsPos(0,startCell * gridSpacingY()); |
1645 | } | 1650 | } |
1646 | QTime KOAgenda::getEndTime() | 1651 | QTime KOAgenda::getEndTime() |
1647 | { | 1652 | { |
1648 | int tim = (contentsY ()+viewport()->height())*24/contentsHeight (); | 1653 | int tim = (contentsY ()+viewport()->height())*24/contentsHeight (); |
1649 | if ( tim > 23 ) | 1654 | if ( tim > 23 ) |
1650 | return QTime ( 23,59,59); | 1655 | return QTime ( 23,59,59); |
1651 | return QTime ( tim,0,0); | 1656 | return QTime ( tim,0,0); |
1652 | } | 1657 | } |
1653 | void KOAgenda::hideUnused() | 1658 | void KOAgenda::hideUnused() |
1654 | { | 1659 | { |
1655 | // experimental only | 1660 | // experimental only |
1656 | // return; | 1661 | // return; |
1657 | KOAgendaItem *item; | 1662 | KOAgendaItem *item; |
1658 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1663 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1659 | item->hide(); | 1664 | item->hide(); |
1660 | } | 1665 | } |
1661 | } | 1666 | } |
1662 | 1667 | ||
1663 | 1668 | ||
1664 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1669 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1665 | { | 1670 | { |
1666 | 1671 | ||
1667 | KOAgendaItem *fi; | 1672 | KOAgendaItem *fi; |
1668 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1673 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1669 | if ( fi->incidence() == event ) { | 1674 | if ( fi->incidence() == event ) { |
1670 | mUnusedItems.remove(); | 1675 | mUnusedItems.remove(); |
1671 | fi->init( event, qd ); | 1676 | fi->init( event, qd ); |
1672 | return fi; | 1677 | return fi; |
1673 | } | 1678 | } |
1674 | } | 1679 | } |
1675 | fi=mUnusedItems.first(); | 1680 | fi=mUnusedItems.first(); |
1676 | if ( fi ) { | 1681 | if ( fi ) { |
1677 | mUnusedItems.remove(); | 1682 | mUnusedItems.remove(); |
1678 | fi->init( event, qd ); | 1683 | fi->init( event, qd ); |
1679 | return fi; | 1684 | return fi; |
1680 | } | 1685 | } |
1681 | // qDebug("new KOAgendaItem "); | 1686 | // qDebug("new KOAgendaItem "); |
1682 | 1687 | ||
1683 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1688 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1684 | agendaItem->installEventFilter(this); | 1689 | agendaItem->installEventFilter(this); |
1685 | addChild(agendaItem,0,0); | 1690 | addChild(agendaItem,0,0); |
1686 | return agendaItem; | 1691 | return agendaItem; |
1687 | } | 1692 | } |
1688 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1693 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1689 | { | 1694 | { |
1690 | KOAgendaItem *item; | 1695 | KOAgendaItem *item; |
1691 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1696 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1692 | if ( item->incidence() == todo ) { | 1697 | if ( item->incidence() == todo ) { |
1693 | mItems.remove(); | 1698 | mItems.remove(); |
1694 | return item; | 1699 | return item; |
1695 | } | 1700 | } |
1696 | } | 1701 | } |
1697 | return 0; | 1702 | return 0; |
1698 | } | 1703 | } |
1699 | 1704 | ||
1700 | 1705 | ||
1701 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1706 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1702 | { | 1707 | { |
1703 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1708 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1704 | KOAgendaItem *item; | 1709 | KOAgendaItem *item; |
1705 | item = getItemForTodo ( todo ); | 1710 | item = getItemForTodo ( todo ); |
1706 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1711 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1707 | if ( item ) { | 1712 | if ( item ) { |
1708 | blockSignals( true ); | 1713 | blockSignals( true ); |
1709 | //qDebug("item found "); | 1714 | //qDebug("item found "); |
1710 | item->hide(); | 1715 | item->hide(); |
1711 | item->setCellX(-2, -1 ); | 1716 | item->setCellX(-2, -1 ); |
1712 | item->select(false); | 1717 | item->select(false); |
1713 | mUnusedItems.append( item ); | 1718 | mUnusedItems.append( item ); |
1714 | mItems.remove( item ); | 1719 | mItems.remove( item ); |
1715 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1720 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1716 | KOAgendaItem *itemit; | 1721 | KOAgendaItem *itemit; |
1717 | //globalFlagBlockAgendaItemPaint = 1; | 1722 | //globalFlagBlockAgendaItemPaint = 1; |
1718 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1723 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1719 | itemit=oldconflictItems.next() ) { | 1724 | itemit=oldconflictItems.next() ) { |
1720 | if ( itemit != item ) | 1725 | if ( itemit != item ) |
1721 | placeSubCells(itemit); | 1726 | placeSubCells(itemit); |
1722 | } | 1727 | } |
1723 | qApp->processEvents(); | 1728 | qApp->processEvents(); |
1724 | //globalFlagBlockAgendaItemPaint = 0; | 1729 | //globalFlagBlockAgendaItemPaint = 0; |
1725 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1730 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1726 | itemit=oldconflictItems.next() ) { | 1731 | itemit=oldconflictItems.next() ) { |
1727 | globalFlagBlockAgendaItemUpdate = 0; | 1732 | globalFlagBlockAgendaItemUpdate = 0; |
1728 | if ( itemit != item ) | 1733 | if ( itemit != item ) |
1729 | itemit->repaintMe(); | 1734 | itemit->repaintMe(); |
1730 | globalFlagBlockAgendaItemUpdate = 1; | 1735 | globalFlagBlockAgendaItemUpdate = 1; |
1731 | //qDebug("sigleshot "); | 1736 | //qDebug("sigleshot "); |
1732 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); | 1737 | QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); |
1733 | //itemit->repaint( false ); repaintItem() | 1738 | //itemit->repaint( false ); repaintItem() |
1734 | } | 1739 | } |
1735 | blockSignals( false ); | 1740 | blockSignals( false ); |
1736 | } | 1741 | } |
1737 | if ( remove ) { | 1742 | if ( remove ) { |
1738 | //qDebug("remove****************************************** "); | 1743 | //qDebug("remove****************************************** "); |
1739 | return; | 1744 | return; |
1740 | } | 1745 | } |
1741 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) | 1746 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) |
1742 | return; | 1747 | return; |
1743 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1748 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1744 | QDate currentDate = QDate::currentDate(); | 1749 | QDate currentDate = QDate::currentDate(); |
1745 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1750 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1746 | QDateTime dt; | 1751 | QDateTime dt; |
1747 | if ( todo->hasCompletedDate() ) | 1752 | if ( todo->hasCompletedDate() ) |
1748 | dt = todo->completed(); | 1753 | dt = todo->completed(); |
1749 | else | 1754 | else |
1750 | dt = todo->dtDue(); | 1755 | dt = todo->dtDue(); |
1751 | if ( overdue ) { | 1756 | if ( overdue ) { |
1752 | days += todo->dtDue().date().daysTo( currentDate ); | 1757 | days += todo->dtDue().date().daysTo( currentDate ); |
1753 | } | 1758 | } |
1754 | else | 1759 | else |
1755 | currentDate = dt.date(); | 1760 | currentDate = dt.date(); |
1756 | 1761 | ||
1757 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1762 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1758 | if ( ! mAllDayMode ) return; | 1763 | if ( ! mAllDayMode ) return; |
1759 | // aldayagenda | 1764 | // aldayagenda |
1760 | globalFlagBlockAgendaItemPaint = 1; | 1765 | globalFlagBlockAgendaItemPaint = 1; |
1761 | item = insertAllDayItem(todo, currentDate,days, days); | 1766 | item = insertAllDayItem(todo, currentDate,days, days); |
1762 | item->show(); | 1767 | item->show(); |
1763 | 1768 | ||
1764 | } | 1769 | } |
1765 | else { | 1770 | else { |
1766 | if ( mAllDayMode ) return; | 1771 | if ( mAllDayMode ) return; |
1767 | // mAgenda | 1772 | // mAgenda |
1768 | globalFlagBlockAgendaItemPaint = 1; | 1773 | globalFlagBlockAgendaItemPaint = 1; |
1769 | int endY = timeToY(dt.time()) - 1; | 1774 | int endY = timeToY(dt.time()) - 1; |
1770 | int hi = 12/KOPrefs::instance()->mHourSize; | 1775 | int hi = 12/KOPrefs::instance()->mHourSize; |
1771 | int startY = endY - 1-hi; | 1776 | int startY = endY - 1-hi; |
1772 | item = insertItem(todo,currentDate,days,startY,endY); | 1777 | item = insertItem(todo,currentDate,days,startY,endY); |
1773 | item->show(); | 1778 | item->show(); |
1774 | } | 1779 | } |
1775 | qApp->processEvents(); | 1780 | qApp->processEvents(); |
1776 | globalFlagBlockAgendaItemPaint = 0; | 1781 | globalFlagBlockAgendaItemPaint = 0; |
1777 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1782 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1778 | KOAgendaItem *itemit; | 1783 | KOAgendaItem *itemit; |
1779 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1784 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1780 | itemit=oldconflictItems.next() ) { | 1785 | itemit=oldconflictItems.next() ) { |
1781 | globalFlagBlockAgendaItemUpdate = 0; | 1786 | globalFlagBlockAgendaItemUpdate = 0; |
1782 | itemit->repaintMe(); | 1787 | itemit->repaintMe(); |
1783 | globalFlagBlockAgendaItemUpdate = 1; | 1788 | globalFlagBlockAgendaItemUpdate = 1; |
1784 | itemit->repaint(); | 1789 | itemit->repaint(); |
1785 | } | 1790 | } |
1786 | globalFlagBlockAgendaItemUpdate = 0; | 1791 | globalFlagBlockAgendaItemUpdate = 0; |
1787 | item->repaintMe(); | 1792 | item->repaintMe(); |
1788 | globalFlagBlockAgendaItemUpdate = 1; | 1793 | globalFlagBlockAgendaItemUpdate = 1; |
1789 | item->repaint(); | 1794 | item->repaint(); |
1790 | } | 1795 | } |
1791 | /* | 1796 | /* |
1792 | Insert KOAgendaItem into agenda. | 1797 | Insert KOAgendaItem into agenda. |
1793 | */ | 1798 | */ |
1794 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1799 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1795 | { | 1800 | { |
1796 | if (mAllDayMode) { | 1801 | if (mAllDayMode) { |
1797 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1802 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1798 | return 0; | 1803 | return 0; |
1799 | } | 1804 | } |
1800 | 1805 | ||
1801 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1806 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1802 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1807 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1803 | 1808 | ||
1804 | int YSize = YBottom - YTop + 1; | 1809 | int YSize = YBottom - YTop + 1; |
1805 | if (YSize < 0) { | 1810 | if (YSize < 0) { |
1806 | YSize = 1; | 1811 | YSize = 1; |
1807 | } | 1812 | } |
1808 | int iheight = mGridSpacingY * YSize; | 1813 | int iheight = mGridSpacingY * YSize; |
1809 | 1814 | ||
1810 | agendaItem->resize(mGridSpacingX,iheight ); | 1815 | agendaItem->resize(mGridSpacingX,iheight ); |
1811 | agendaItem->setCellXY(X,YTop,YBottom); | 1816 | agendaItem->setCellXY(X,YTop,YBottom); |
1812 | agendaItem->setCellXWidth(X); | 1817 | agendaItem->setCellXWidth(X); |
1813 | 1818 | ||
1814 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1819 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1815 | mItems.append(agendaItem); | 1820 | mItems.append(agendaItem); |
1816 | 1821 | ||
1817 | placeSubCells(agendaItem); | 1822 | placeSubCells(agendaItem); |
1818 | 1823 | ||
1819 | //agendaItem->show(); | 1824 | //agendaItem->show(); |
1820 | 1825 | ||
1821 | 1826 | ||
1822 | return agendaItem; | 1827 | return agendaItem; |
1823 | } | 1828 | } |
1824 | 1829 | ||
1825 | 1830 | ||
1826 | /* | 1831 | /* |
1827 | Insert all-day KOAgendaItem into agenda. | 1832 | Insert all-day KOAgendaItem into agenda. |
1828 | */ | 1833 | */ |
1829 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1834 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1830 | { | 1835 | { |
1831 | if (!mAllDayMode) { | 1836 | if (!mAllDayMode) { |
1832 | return 0; | 1837 | return 0; |
1833 | } | 1838 | } |
1834 | 1839 | ||
1835 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1840 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1836 | 1841 | ||
1837 | agendaItem->setCellXY(XBegin,0,0); | 1842 | agendaItem->setCellXY(XBegin,0,0); |
1838 | agendaItem->setCellXWidth(XEnd); | 1843 | agendaItem->setCellXWidth(XEnd); |
1839 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1844 | agendaItem->resizeMe(mGridSpacingX, mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1840 | 1845 | ||
1841 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1846 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1842 | mItems.append(agendaItem); | 1847 | mItems.append(agendaItem); |
1843 | 1848 | ||
1844 | placeSubCells(agendaItem); | 1849 | placeSubCells(agendaItem); |
1845 | 1850 | ||
1846 | //agendaItem->show(); | 1851 | //agendaItem->show(); |
1847 | 1852 | ||
1848 | return agendaItem; | 1853 | return agendaItem; |
1849 | } | 1854 | } |
1850 | 1855 | ||
1851 | 1856 | ||
1852 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1857 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1853 | int YTop,int YBottom) | 1858 | int YTop,int YBottom) |
1854 | { | 1859 | { |
1855 | if (mAllDayMode) { | 1860 | if (mAllDayMode) { |
1856 | ; | 1861 | ; |
1857 | return; | 1862 | return; |
1858 | } | 1863 | } |
1859 | 1864 | ||
1860 | int cellX,cellYTop,cellYBottom; | 1865 | int cellX,cellYTop,cellYBottom; |
1861 | QString newtext; | 1866 | QString newtext; |
1862 | int width = XEnd - XBegin + 1; | 1867 | int width = XEnd - XBegin + 1; |
1863 | int count = 0; | 1868 | int count = 0; |
1864 | KOAgendaItem *current = 0; | 1869 | KOAgendaItem *current = 0; |
1865 | QPtrList<KOAgendaItem> multiItems; | 1870 | QPtrList<KOAgendaItem> multiItems; |
1866 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1871 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1867 | if (cellX == XBegin) cellYTop = YTop; | 1872 | if (cellX == XBegin) cellYTop = YTop; |
1868 | else cellYTop = 0; | 1873 | else cellYTop = 0; |
1869 | if (cellX == XEnd) cellYBottom = YBottom; | 1874 | if (cellX == XEnd) cellYBottom = YBottom; |
1870 | else cellYBottom = rows() - 1; | 1875 | else cellYBottom = rows() - 1; |
1871 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1876 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1872 | newtext.append(event->summary()); | 1877 | newtext.append(event->summary()); |
1873 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1878 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1874 | current->setText(newtext); | 1879 | current->setText(newtext); |
1875 | multiItems.append(current); | 1880 | multiItems.append(current); |
1876 | } | 1881 | } |
1877 | 1882 | ||
1878 | KOAgendaItem *next = 0; | 1883 | KOAgendaItem *next = 0; |
1879 | KOAgendaItem *last = multiItems.last(); | 1884 | KOAgendaItem *last = multiItems.last(); |
1880 | KOAgendaItem *first = multiItems.first(); | 1885 | KOAgendaItem *first = multiItems.first(); |
1881 | KOAgendaItem *setFirst,*setLast; | 1886 | KOAgendaItem *setFirst,*setLast; |
1882 | current = first; | 1887 | current = first; |
1883 | while (current) { | 1888 | while (current) { |
1884 | next = multiItems.next(); | 1889 | next = multiItems.next(); |
1885 | if (current == first) setFirst = 0; | 1890 | if (current == first) setFirst = 0; |
1886 | else setFirst = first; | 1891 | else setFirst = first; |
1887 | if (current == last) setLast = 0; | 1892 | if (current == last) setLast = 0; |
1888 | else setLast = last; | 1893 | else setLast = last; |
1889 | 1894 | ||
1890 | current->setMultiItem(setFirst,next,setLast); | 1895 | current->setMultiItem(setFirst,next,setLast); |
1891 | current = next; | 1896 | current = next; |
1892 | } | 1897 | } |
1893 | } | 1898 | } |
1894 | 1899 | ||
1895 | 1900 | ||
1896 | //QSizePolicy KOAgenda::sizePolicy() const | 1901 | //QSizePolicy KOAgenda::sizePolicy() const |
1897 | //{ | 1902 | //{ |
1898 | // Thought this would make the all-day event agenda minimum size and the | 1903 | // Thought this would make the all-day event agenda minimum size and the |
1899 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1904 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1900 | // don´t seem to think that an Expanding widget needs more space than a | 1905 | // don´t seem to think that an Expanding widget needs more space than a |
1901 | // Preferred one. | 1906 | // Preferred one. |
1902 | // But it doesn´t hurt, so it stays. | 1907 | // But it doesn´t hurt, so it stays. |
1903 | // if (mAllDayMode) { | 1908 | // if (mAllDayMode) { |
1904 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1909 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1905 | // } else { | 1910 | // } else { |
1906 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1911 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1907 | // } | 1912 | // } |
1908 | //} | 1913 | //} |
1909 | void KOAgenda::finishResize ( ) | 1914 | void KOAgenda::finishResize ( ) |
1910 | { | 1915 | { |
1911 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1916 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1912 | if ( globalFlagBlockAgenda == 0 ) { | 1917 | if ( globalFlagBlockAgenda == 0 ) { |
1913 | finishUpdate(); | 1918 | finishUpdate(); |
1914 | //qDebug("finishUpdate() called "); | 1919 | //qDebug("finishUpdate() called "); |
1915 | } | 1920 | } |
1916 | } | 1921 | } |
1917 | /* | 1922 | /* |
1918 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1923 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1919 | */ | 1924 | */ |
1920 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1925 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1921 | { | 1926 | { |
1922 | mSelectionHeight = 0; | 1927 | mSelectionHeight = 0; |
1923 | mResizeTimer.start( 150 , true ); | 1928 | mResizeTimer.start( 150 , true ); |
1924 | computeSizes(); | 1929 | computeSizes(); |
1925 | QScrollView::resizeEvent( ev ); | 1930 | QScrollView::resizeEvent( ev ); |
1926 | return; | 1931 | return; |
1927 | 1932 | ||
1928 | } | 1933 | } |
1929 | void KOAgenda::computeSizes() | 1934 | void KOAgenda::computeSizes() |
1930 | { | 1935 | { |
1931 | if ( globalFlagBlockStartup ) | 1936 | if ( globalFlagBlockStartup ) |
1932 | return; | 1937 | return; |
1933 | int frameOffset = frameWidth() * 2 +1; | 1938 | int frameOffset = frameWidth() * 2 +1; |
1934 | if (mAllDayMode) { | 1939 | if (mAllDayMode) { |
1935 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1940 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1936 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1941 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1937 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1942 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1938 | // mGridSpacingY = height(); | 1943 | // mGridSpacingY = height(); |
1939 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1944 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1940 | 1945 | ||
1941 | KOAgendaItem *item; | 1946 | KOAgendaItem *item; |
1942 | int subCellWidth; | 1947 | int subCellWidth; |
1943 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1948 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1944 | subCellWidth = mGridSpacingY / item->subCells(); | 1949 | subCellWidth = mGridSpacingY / item->subCells(); |
1945 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1950 | int diff = 0; |
1946 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1951 | diff = item->resizeMe(mGridSpacingX ,mGridSpacingX * item->cellWidth(),subCellWidth); |
1952 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | ||
1947 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1953 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1948 | item->cellX() * mGridSpacingX, | 1954 | item->cellX() * mGridSpacingX) + diff, |
1949 | item->subCell() * subCellWidth); | 1955 | item->subCell() * subCellWidth); |
1950 | } | 1956 | } |
1951 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1957 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1952 | } else { | 1958 | } else { |
1953 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1959 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1954 | if (height() > mGridSpacingY * mRows + 1 ) { | 1960 | if (height() > mGridSpacingY * mRows + 1 ) { |
1955 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1961 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1956 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1962 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1957 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1963 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1958 | emit resizedSignal(); | 1964 | emit resizedSignal(); |
1959 | } else | 1965 | } else |
1960 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1966 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1961 | KOAgendaItem *item; | 1967 | KOAgendaItem *item; |
1962 | int subCellWidth; | 1968 | int subCellWidth; |
1963 | 1969 | ||
1964 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1970 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1965 | subCellWidth = mGridSpacingX / item->subCells(); | 1971 | subCellWidth = mGridSpacingX / item->subCells(); |
1966 | item->resize(subCellWidth,item->height()); | 1972 | item->resize(subCellWidth,item->height()); |
1967 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1973 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1968 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1974 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1969 | item->cellX() * mGridSpacingX) + | 1975 | item->cellX() * mGridSpacingX) + |
1970 | item->subCell() * subCellWidth,childY(item)); | 1976 | item->subCell() * subCellWidth,childY(item)); |
1971 | } | 1977 | } |
1972 | } | 1978 | } |
1973 | int cw = contentsWidth(); | 1979 | int cw = contentsWidth(); |
1974 | int ch = contentsHeight(); | 1980 | int ch = contentsHeight(); |
1975 | if ( mAllDayMode ) { | 1981 | if ( mAllDayMode ) { |
1976 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1982 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1977 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1983 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1978 | //qDebug("paintPixAll->resize "); | 1984 | //qDebug("paintPixAll->resize "); |
1979 | paintPixAll->resize( cw, ch ); | 1985 | paintPixAll->resize( cw, ch ); |
1980 | } | 1986 | } |
1981 | } else { | 1987 | } else { |
1982 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1988 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1983 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1989 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1984 | //qDebug("paintPix->resize "); | 1990 | //qDebug("paintPix->resize "); |
1985 | paintPix->resize( cw , ch ); | 1991 | paintPix->resize( cw , ch ); |
1986 | } | 1992 | } |
1987 | } | 1993 | } |
1988 | 1994 | ||
1989 | checkScrollBoundaries(); | 1995 | checkScrollBoundaries(); |
1990 | drawContentsToPainter(); | 1996 | drawContentsToPainter(); |
1991 | viewport()->repaint(false); | 1997 | viewport()->repaint(false); |
1992 | } | 1998 | } |
1993 | 1999 | ||
1994 | void KOAgenda::scrollUp() | 2000 | void KOAgenda::scrollUp() |
1995 | { | 2001 | { |
1996 | scrollBy(0,-mScrollOffset); | 2002 | scrollBy(0,-mScrollOffset); |
1997 | } | 2003 | } |
1998 | 2004 | ||
1999 | 2005 | ||
2000 | void KOAgenda::scrollDown() | 2006 | void KOAgenda::scrollDown() |
2001 | { | 2007 | { |
2002 | scrollBy(0,mScrollOffset); | 2008 | scrollBy(0,mScrollOffset); |
2003 | } | 2009 | } |
2004 | 2010 | ||
2005 | void KOAgenda::popupAlarm() | 2011 | void KOAgenda::popupAlarm() |
2006 | { | 2012 | { |
2007 | if (!mClickedItem) { | 2013 | if (!mClickedItem) { |
2008 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 2014 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
2009 | return; | 2015 | return; |
2010 | } | 2016 | } |
2011 | // TODO: deal correctly with multiple alarms | 2017 | // TODO: deal correctly with multiple alarms |
2012 | Alarm* alarm; | 2018 | Alarm* alarm; |
2013 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 2019 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
2014 | for(alarm=list.first();alarm;alarm=list.next()) { | 2020 | for(alarm=list.first();alarm;alarm=list.next()) { |
2015 | alarm->toggleAlarm(); | 2021 | alarm->toggleAlarm(); |
2016 | } | 2022 | } |
2017 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 2023 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
2018 | mClickedItem->paintMe( true ); | 2024 | mClickedItem->paintMe( true ); |
2019 | mClickedItem->repaint( false ); | 2025 | mClickedItem->repaint( false ); |
2020 | } | 2026 | } |
2021 | 2027 | ||
2022 | /* | 2028 | /* |
2023 | Calculates the minimum width | 2029 | Calculates the minimum width |
2024 | */ | 2030 | */ |
2025 | int KOAgenda::minimumWidth() const | 2031 | int KOAgenda::minimumWidth() const |
2026 | { | 2032 | { |
2027 | // TODO:: develop a way to dynamically determine the minimum width | 2033 | // TODO:: develop a way to dynamically determine the minimum width |
2028 | int min = 100; | 2034 | int min = 100; |
2029 | 2035 | ||
2030 | return min; | 2036 | return min; |
2031 | } | 2037 | } |
2032 | 2038 | ||
2033 | void KOAgenda::updateConfig() | 2039 | void KOAgenda::updateConfig() |
2034 | { | 2040 | { |
2035 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 2041 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
2036 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 2042 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
2037 | if ( mAllDayMode ) { | 2043 | if ( mAllDayMode ) { |
2038 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 2044 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
2039 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 2045 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
2040 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 2046 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
2041 | // setMaximumHeight( mGridSpacingY+1 ); | 2047 | // setMaximumHeight( mGridSpacingY+1 ); |
2042 | viewport()->repaint( false ); | 2048 | viewport()->repaint( false ); |
2043 | //setFixedHeight( mGridSpacingY+1 ); | 2049 | //setFixedHeight( mGridSpacingY+1 ); |
2044 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2050 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2045 | } | 2051 | } |
2046 | else { | 2052 | else { |
2047 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2053 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2048 | calculateWorkingHours(); | 2054 | calculateWorkingHours(); |
2049 | } | 2055 | } |
2050 | } | 2056 | } |
2051 | 2057 | ||
2052 | void KOAgenda::checkScrollBoundaries() | 2058 | void KOAgenda::checkScrollBoundaries() |
2053 | { | 2059 | { |
2054 | // Invalidate old values to force update | 2060 | // Invalidate old values to force update |
2055 | mOldLowerScrollValue = -1; | 2061 | mOldLowerScrollValue = -1; |
2056 | mOldUpperScrollValue = -1; | 2062 | mOldUpperScrollValue = -1; |
2057 | 2063 | ||
2058 | checkScrollBoundaries(verticalScrollBar()->value()); | 2064 | checkScrollBoundaries(verticalScrollBar()->value()); |
2059 | } | 2065 | } |
2060 | 2066 | ||
2061 | void KOAgenda::checkScrollBoundaries(int v) | 2067 | void KOAgenda::checkScrollBoundaries(int v) |
2062 | { | 2068 | { |
2063 | if ( mGridSpacingY == 0 ) | 2069 | if ( mGridSpacingY == 0 ) |
2064 | return; | 2070 | return; |
2065 | int yMin = v/mGridSpacingY; | 2071 | int yMin = v/mGridSpacingY; |
2066 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2072 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2067 | 2073 | ||
2068 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2074 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2069 | 2075 | ||
2070 | if (yMin != mOldLowerScrollValue) { | 2076 | if (yMin != mOldLowerScrollValue) { |
2071 | mOldLowerScrollValue = yMin; | 2077 | mOldLowerScrollValue = yMin; |
2072 | emit lowerYChanged(yMin); | 2078 | emit lowerYChanged(yMin); |
2073 | } | 2079 | } |
2074 | if (yMax != mOldUpperScrollValue) { | 2080 | if (yMax != mOldUpperScrollValue) { |
2075 | mOldUpperScrollValue = yMax; | 2081 | mOldUpperScrollValue = yMax; |
2076 | emit upperYChanged(yMax); | 2082 | emit upperYChanged(yMax); |
2077 | } | 2083 | } |
2078 | } | 2084 | } |
2079 | 2085 | ||
2080 | void KOAgenda::deselectItem() | 2086 | void KOAgenda::deselectItem() |
2081 | { | 2087 | { |
2082 | if (mSelectedItem.isNull()) return; | 2088 | if (mSelectedItem.isNull()) return; |
2083 | mSelectedItem->select(false); | 2089 | mSelectedItem->select(false); |
2084 | mSelectedItem = 0; | 2090 | mSelectedItem = 0; |
2085 | } | 2091 | } |
2086 | 2092 | ||
2087 | void KOAgenda::selectItem(KOAgendaItem *item) | 2093 | void KOAgenda::selectItem(KOAgendaItem *item) |
2088 | { | 2094 | { |
2089 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2095 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2090 | deselectItem(); | 2096 | deselectItem(); |
2091 | if (item == 0) { | 2097 | if (item == 0) { |
2092 | emit incidenceSelected( 0 ); | 2098 | emit incidenceSelected( 0 ); |
2093 | return; | 2099 | return; |
2094 | } | 2100 | } |
2095 | mSelectedItem = item; | 2101 | mSelectedItem = item; |
2096 | mSelectedItem->select(); | 2102 | mSelectedItem->select(); |
2097 | emit incidenceSelected( mSelectedItem->incidence() ); | 2103 | emit incidenceSelected( mSelectedItem->incidence() ); |
2098 | } | 2104 | } |
2099 | 2105 | ||
2100 | // This function seems never be called. | 2106 | // This function seems never be called. |
2101 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2107 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2102 | { | 2108 | { |
2103 | switch(kev->key()) { | 2109 | switch(kev->key()) { |
2104 | case Key_PageDown: | 2110 | case Key_PageDown: |
2105 | verticalScrollBar()->addPage(); | 2111 | verticalScrollBar()->addPage(); |
2106 | break; | 2112 | break; |
2107 | case Key_PageUp: | 2113 | case Key_PageUp: |
2108 | verticalScrollBar()->subtractPage(); | 2114 | verticalScrollBar()->subtractPage(); |
2109 | break; | 2115 | break; |
2110 | case Key_Down: | 2116 | case Key_Down: |
2111 | verticalScrollBar()->addLine(); | 2117 | verticalScrollBar()->addLine(); |
2112 | break; | 2118 | break; |
2113 | case Key_Up: | 2119 | case Key_Up: |
2114 | verticalScrollBar()->subtractLine(); | 2120 | verticalScrollBar()->subtractLine(); |
2115 | break; | 2121 | break; |
2116 | default: | 2122 | default: |
2117 | ; | 2123 | ; |
2118 | } | 2124 | } |
2119 | } | 2125 | } |
2120 | 2126 | ||
2121 | void KOAgenda::calculateWorkingHours() | 2127 | void KOAgenda::calculateWorkingHours() |
2122 | { | 2128 | { |
2123 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2129 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2124 | mWorkingHoursEnable = !mAllDayMode; | 2130 | mWorkingHoursEnable = !mAllDayMode; |
2125 | 2131 | ||
2126 | mWorkingHoursYTop = mGridSpacingY * | 2132 | mWorkingHoursYTop = mGridSpacingY * |
2127 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2133 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2128 | mWorkingHoursYBottom = mGridSpacingY * | 2134 | mWorkingHoursYBottom = mGridSpacingY * |
2129 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2135 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2130 | } | 2136 | } |
2131 | 2137 | ||
2132 | 2138 | ||
2133 | DateList KOAgenda::dateList() const | 2139 | DateList KOAgenda::dateList() const |
2134 | { | 2140 | { |
2135 | return mSelectedDates; | 2141 | return mSelectedDates; |
2136 | } | 2142 | } |
2137 | 2143 | ||
2138 | void KOAgenda::setDateList(const DateList &selectedDates) | 2144 | void KOAgenda::setDateList(const DateList &selectedDates) |
2139 | { | 2145 | { |
2140 | mSelectedDates = selectedDates; | 2146 | mSelectedDates = selectedDates; |
2141 | } | 2147 | } |
2142 | 2148 | ||
2143 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2149 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2144 | { | 2150 | { |
2145 | mHolidayMask = mask; | 2151 | mHolidayMask = mask; |
2146 | 2152 | ||
2147 | /* | 2153 | /* |
2148 | kdDebug() << "HolidayMask: "; | 2154 | kdDebug() << "HolidayMask: "; |
2149 | for(uint i=0;i<mask->count();++i) { | 2155 | for(uint i=0;i<mask->count();++i) { |
2150 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2156 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2151 | } | 2157 | } |
2152 | kdDebug() << endl; | 2158 | kdDebug() << endl; |
2153 | */ | 2159 | */ |
2154 | } | 2160 | } |
2155 | 2161 | ||
2156 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2162 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2157 | { | 2163 | { |
2158 | 2164 | ||
2159 | QScrollView::contentsMousePressEvent(event); | 2165 | QScrollView::contentsMousePressEvent(event); |
2160 | } | 2166 | } |
2161 | 2167 | ||
2162 | void KOAgenda::storePosition() | 2168 | void KOAgenda::storePosition() |
2163 | { | 2169 | { |
2164 | //mContentPosition | 2170 | //mContentPosition |
2165 | int max = mGridSpacingY*4*24; | 2171 | int max = mGridSpacingY*4*24; |
2166 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2172 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2167 | mContentPosition = 0; | 2173 | mContentPosition = 0; |
2168 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2174 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2169 | mContentPosition = -1.0; | 2175 | mContentPosition = -1.0; |
2170 | else | 2176 | else |
2171 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2177 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2172 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2178 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2173 | 2179 | ||
2174 | } | 2180 | } |
2175 | void KOAgenda::restorePosition() | 2181 | void KOAgenda::restorePosition() |
2176 | { | 2182 | { |
2177 | int posY; | 2183 | int posY; |
2178 | int max = mGridSpacingY*4*24; | 2184 | int max = mGridSpacingY*4*24; |
2179 | if ( mContentPosition < 0 ) | 2185 | if ( mContentPosition < 0 ) |
2180 | posY = max-viewport()->height(); | 2186 | posY = max-viewport()->height(); |
2181 | else | 2187 | else |
2182 | if ( mContentPosition == 0 ) | 2188 | if ( mContentPosition == 0 ) |
2183 | posY = 0; | 2189 | posY = 0; |
2184 | else | 2190 | else |
2185 | posY = (int) ((max/mContentPosition)-(viewport()->height()/2)); | 2191 | posY = (int) ((max/mContentPosition)-(viewport()->height()/2)); |
2186 | setContentsPos (0, posY ); | 2192 | setContentsPos (0, posY ); |
2187 | //qDebug("posY %d hei %d", posY, max); | 2193 | //qDebug("posY %d hei %d", posY, max); |
2188 | 2194 | ||
2189 | } | 2195 | } |
2190 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 2196 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
2191 | { | 2197 | { |
2192 | ++x; | 2198 | ++x; |
2193 | QScrollView::moveChild( w, x , y ); | 2199 | QScrollView::moveChild( w, x , y ); |
2194 | } | 2200 | } |
2195 | #include <qmessagebox.h> | 2201 | #include <qmessagebox.h> |
2196 | #ifdef DESKTOP_VERSION | 2202 | #ifdef DESKTOP_VERSION |
2197 | #include <qprinter.h> | 2203 | #include <qprinter.h> |
2198 | #include <qpainter.h> | 2204 | #include <qpainter.h> |
2199 | #include <qpaintdevicemetrics.h> | 2205 | #include <qpaintdevicemetrics.h> |
2200 | 2206 | ||
2201 | #endif | 2207 | #endif |
2202 | void KOAgenda::printSelection() | 2208 | void KOAgenda::printSelection() |
2203 | { | 2209 | { |
2204 | #ifdef DESKTOP_VERSION | 2210 | #ifdef DESKTOP_VERSION |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 49ad9b8..7a685d8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -403,448 +403,466 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | |||
403 | if ( ! small || w > 3 * h || h > 3* w ) | 403 | if ( ! small || w > 3 * h || h > 3* w ) |
404 | addIcon = updateIcons( paint, horLayout ); | 404 | addIcon = updateIcons( paint, horLayout ); |
405 | 405 | ||
406 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 406 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
407 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); | 407 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); |
408 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 408 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
409 | if ( ! small ) { | 409 | if ( ! small ) { |
410 | x += 3; yy += 3;w -= 6; h-= 5; | 410 | x += 3; yy += 3;w -= 6; h-= 5; |
411 | } else { | 411 | } else { |
412 | x += 2; yy += 1;w -= 4; h-= 4; | 412 | x += 2; yy += 1;w -= 4; h-= 4; |
413 | if ( nfh < 6.01 ) { | 413 | if ( nfh < 6.01 ) { |
414 | yy -= 2; | 414 | yy -= 2; |
415 | h += 4; | 415 | h += 4; |
416 | } | 416 | } |
417 | else | 417 | else |
418 | if ( nfh < h -2 ) | 418 | if ( nfh < h -2 ) |
419 | ++yy; | 419 | ++yy; |
420 | } | 420 | } |
421 | int align; | 421 | int align; |
422 | #ifndef DESKTOP_VERSION | 422 | #ifndef DESKTOP_VERSION |
423 | align = ( AlignLeft|WordBreak|AlignTop); | 423 | align = ( AlignLeft|WordBreak|AlignTop); |
424 | #else | 424 | #else |
425 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 425 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
426 | #endif | 426 | #endif |
427 | if ( addIcon ) { | 427 | if ( addIcon ) { |
428 | if ( ! horLayout ) { | 428 | if ( ! horLayout ) { |
429 | x += AGENDA_ICON_SIZE+3; | 429 | x += AGENDA_ICON_SIZE+3; |
430 | w -= (AGENDA_ICON_SIZE+3); | 430 | w -= (AGENDA_ICON_SIZE+3); |
431 | } | 431 | } |
432 | else { | 432 | else { |
433 | yy+= AGENDA_ICON_SIZE+2; | 433 | yy+= AGENDA_ICON_SIZE+2; |
434 | h -=(AGENDA_ICON_SIZE+3); | 434 | h -=(AGENDA_ICON_SIZE+3); |
435 | } | 435 | } |
436 | } | 436 | } |
437 | if ( mWhiteText ) | 437 | if ( mWhiteText ) |
438 | paint->setPen ( white); | 438 | paint->setPen ( white); |
439 | if ( x < 0 ) { | 439 | if ( x < 0 ) { |
440 | w = w+x-3; | 440 | w = w+x-3; |
441 | x = 3; | 441 | x = 3; |
442 | if ( !horLayout && addIcon ) | 442 | if ( !horLayout && addIcon ) |
443 | x += AGENDA_ICON_SIZE+3; | 443 | x += AGENDA_ICON_SIZE+3; |
444 | if ( w > parentWidget()->width() ){ | 444 | if ( w > parentWidget()->width() ){ |
445 | w = parentWidget()->width() - 6; | 445 | w = parentWidget()->width() - 6; |
446 | #ifndef DESKTOP_VERSION | 446 | #ifndef DESKTOP_VERSION |
447 | align = ( AlignHCenter|WordBreak|AlignTop); | 447 | align = ( AlignHCenter|WordBreak|AlignTop); |
448 | #else | 448 | #else |
449 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 449 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
450 | #endif | 450 | #endif |
451 | 451 | ||
452 | } | 452 | } |
453 | } | 453 | } |
454 | QRect dr; | 454 | QRect dr; |
455 | if ( w + x > parentWidget()->width() ) | 455 | if ( w + x > parentWidget()->width() ) |
456 | w = parentWidget()->width()-x; | 456 | w = parentWidget()->width()-x; |
457 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 457 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
458 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 458 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
459 | if ( mIncidence->cancelled() ){ | 459 | if ( mIncidence->cancelled() ){ |
460 | 460 | ||
461 | 461 | ||
462 | small = ( height() < 20 ); | 462 | small = ( height() < 20 ); |
463 | 463 | ||
464 | if ( ! small ) { | 464 | if ( ! small ) { |
465 | QFontMetrics fm ( paint->font() ); | 465 | QFontMetrics fm ( paint->font() ); |
466 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 466 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
467 | } | 467 | } |
468 | 468 | ||
469 | } | 469 | } |
470 | pa.end(); | 470 | pa.end(); |
471 | 471 | ||
472 | } | 472 | } |
473 | 473 | ||
474 | QPixmap * KOAgendaItem::paintPix() | 474 | QPixmap * KOAgendaItem::paintPix() |
475 | { | 475 | { |
476 | static QPixmap* mPaintPix = 0; | 476 | static QPixmap* mPaintPix = 0; |
477 | if ( ! mPaintPix ) { | 477 | if ( ! mPaintPix ) { |
478 | int w = QApplication::desktop()->width(); | 478 | int w = QApplication::desktop()->width(); |
479 | int h = QApplication::desktop()->height(); | 479 | int h = QApplication::desktop()->height(); |
480 | mPaintPix = new QPixmap(w,h); | 480 | mPaintPix = new QPixmap(w,h); |
481 | } | 481 | } |
482 | return mPaintPix ; | 482 | return mPaintPix ; |
483 | } | 483 | } |
484 | QPixmap * KOAgendaItem::paintPixAllday() | 484 | QPixmap * KOAgendaItem::paintPixAllday() |
485 | { | 485 | { |
486 | static QPixmap* mPaintPixA = 0; | 486 | static QPixmap* mPaintPixA = 0; |
487 | if ( ! mPaintPixA ) { | 487 | if ( ! mPaintPixA ) { |
488 | int w = QApplication::desktop()->width(); | 488 | int w = QApplication::desktop()->width(); |
489 | int h = QApplication::desktop()->height()/5; | 489 | int h = QApplication::desktop()->height()/5; |
490 | mPaintPixA = new QPixmap(w,h); | 490 | mPaintPixA = new QPixmap(w,h); |
491 | } | 491 | } |
492 | return mPaintPixA ; | 492 | return mPaintPixA ; |
493 | } | 493 | } |
494 | 494 | ||
495 | void KOAgendaItem::repaintItem() | 495 | void KOAgendaItem::repaintItem() |
496 | { | 496 | { |
497 | globalFlagBlockAgendaItemPaint = 0; | 497 | globalFlagBlockAgendaItemPaint = 0; |
498 | globalFlagBlockAgenda = 0; | 498 | globalFlagBlockAgenda = 0; |
499 | repaint( false ); | 499 | repaint( false ); |
500 | } | 500 | } |
501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
502 | { | 502 | { |
503 | 503 | ||
504 | if ( globalFlagBlockAgendaItemPaint ) | 504 | if ( globalFlagBlockAgendaItemPaint ) |
505 | return; | 505 | return; |
506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
507 | return; | 507 | return; |
508 | int yy; | 508 | int yy; |
509 | if ( mAllDay ) | 509 | if ( mAllDay ) |
510 | yy = y(); | 510 | yy = y(); |
511 | else | 511 | else |
512 | yy = mCellYTop * ( height() / cellHeight() ); | 512 | yy = mCellYTop * ( height() / cellHeight() ); |
513 | int xx = x(); | 513 | int xx = x(); |
514 | 514 | ||
515 | if ( xPaintCoord != xx || yPaintCoord != yy || | 515 | if ( xPaintCoord != xx || yPaintCoord != yy || |
516 | wPaintCoord != width() || hPaintCoord != height()) { | 516 | wPaintCoord != width() || hPaintCoord != height()) { |
517 | xPaintCoord= xx; | 517 | xPaintCoord= xx; |
518 | yPaintCoord = yy; | 518 | yPaintCoord = yy; |
519 | wPaintCoord = width(); | 519 | wPaintCoord = width(); |
520 | hPaintCoord = height(); | 520 | hPaintCoord = height(); |
521 | globalFlagBlockAgendaItemUpdate = 0; | 521 | globalFlagBlockAgendaItemUpdate = 0; |
522 | paintMe( mSelected ); | 522 | paintMe( mSelected ); |
523 | //qDebug("calling paintMe "); | 523 | //qDebug("calling paintMe "); |
524 | globalFlagBlockAgendaItemUpdate = 1; | 524 | globalFlagBlockAgendaItemUpdate = 1; |
525 | if ( mSelected ) | 525 | if ( mSelected ) |
526 | return; | 526 | return; |
527 | } | 527 | } |
528 | int rx, ry, rw, rh; | 528 | int rx, ry, rw, rh; |
529 | rx = e->rect().x(); | 529 | rx = e->rect().x(); |
530 | ry = e->rect().y(); | 530 | ry = e->rect().y(); |
531 | rw = e->rect().width(); | 531 | rw = e->rect().width(); |
532 | rh = e->rect().height(); | 532 | rh = e->rect().height(); |
533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
534 | 534 | ||
535 | QPixmap* paintFrom ; | 535 | QPixmap* paintFrom ; |
536 | if ( mSelected ) { | 536 | if ( mSelected ) { |
537 | paintMe( mSelected ); | 537 | paintMe( mSelected ); |
538 | return; | 538 | return; |
539 | } else { | 539 | } else { |
540 | if ( mAllDay ) | 540 | if ( mAllDay ) |
541 | paintFrom = paintPixAllday(); | 541 | paintFrom = paintPixAllday(); |
542 | else | 542 | else |
543 | paintFrom = paintPix(); | 543 | paintFrom = paintPix(); |
544 | } | 544 | } |
545 | xx += rx; | 545 | xx += rx; |
546 | 546 | ||
547 | if ( xx < 0 ) { | 547 | if ( xx < 0 ) { |
548 | rw = rw + xx; | 548 | rw = rw + xx; |
549 | rx -= xx; | 549 | rx -= xx; |
550 | xx = 0; | 550 | xx = 0; |
551 | if ( rw <= 1 ) { | 551 | if ( rw <= 1 ) { |
552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | if ( paintFrom->width() < xx+rw ) { | 556 | if ( paintFrom->width() < xx+rw ) { |
557 | rw = paintFrom->width() - xx; | 557 | rw = paintFrom->width() - xx; |
558 | if ( rw <= 1 ) { | 558 | if ( rw <= 1 ) { |
559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
560 | return; | 560 | return; |
561 | } | 561 | } |
562 | } | 562 | } |
563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
565 | } | 565 | } |
566 | void KOAgendaItem::computeText() | 566 | void KOAgendaItem::computeText() |
567 | { | 567 | { |
568 | mDisplayedText = mIncidence->summary(); | 568 | mDisplayedText = mIncidence->summary(); |
569 | if ( (mIncidence->typeID() == todoID ) ) { | 569 | if ( (mIncidence->typeID() == todoID ) ) { |
570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
573 | else if ( !(mIncidence->doesFloat())) | 573 | else if ( !(mIncidence->doesFloat())) |
574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
579 | 579 | ||
580 | if ( mAllDay ) { | 580 | if ( mAllDay ) { |
581 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 581 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
582 | if ( mIncidence->doesRecur() ) { | 582 | if ( mIncidence->doesRecur() ) { |
583 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; | 583 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; |
584 | } else { | 584 | } else { |
585 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 585 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | if ( !mIncidence->location().isEmpty() ) { | 591 | if ( !mIncidence->location().isEmpty() ) { |
592 | if ( mAllDay ) | 592 | if ( mAllDay ) |
593 | mDisplayedText += " ("; | 593 | mDisplayedText += " ("; |
594 | else | 594 | else |
595 | mDisplayedText += "\n("; | 595 | mDisplayedText += "\n("; |
596 | mDisplayedText += mIncidence->location() +")"; | 596 | mDisplayedText += mIncidence->location() +")"; |
597 | } | 597 | } |
598 | #ifdef DESKTOP_VERSION | 598 | #ifdef DESKTOP_VERSION |
599 | QString tipText = mIncidence->summary(); | 599 | QString tipText = mIncidence->summary(); |
600 | if ( !mIncidence->doesFloat() ) { | 600 | if ( !mIncidence->doesFloat() ) { |
601 | if ( mIncidence->typeID() == eventID ) { | 601 | if ( mIncidence->typeID() == eventID ) { |
602 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 602 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
603 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 603 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
604 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 604 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
605 | } | 605 | } |
606 | else { | 606 | else { |
607 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 607 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
608 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 608 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
609 | } | 609 | } |
610 | } | 610 | } |
611 | else if ( mIncidence->typeID() == todoID ) { | 611 | else if ( mIncidence->typeID() == todoID ) { |
612 | if (mIncidence->hasStartDate()) | 612 | if (mIncidence->hasStartDate()) |
613 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 613 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
614 | if (((Todo*)mIncidence)->hasDueDate()) | 614 | if (((Todo*)mIncidence)->hasDueDate()) |
615 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 615 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
616 | } | 616 | } |
617 | } else if ( mIncidence->typeID() == todoID ) { | 617 | } else if ( mIncidence->typeID() == todoID ) { |
618 | if (mIncidence->hasStartDate()) | 618 | if (mIncidence->hasStartDate()) |
619 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 619 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
620 | if (((Todo*)mIncidence)->hasDueDate()) | 620 | if (((Todo*)mIncidence)->hasDueDate()) |
621 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 621 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
622 | } | 622 | } |
623 | 623 | ||
624 | if (!mIncidence->location().isEmpty()) { | 624 | if (!mIncidence->location().isEmpty()) { |
625 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 625 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
626 | } | 626 | } |
627 | QToolTip::add(this,tipText,toolTipGroup(),""); | 627 | QToolTip::add(this,tipText,toolTipGroup(),""); |
628 | #endif | 628 | #endif |
629 | } | 629 | } |
630 | void KOAgendaItem::updateItem() | 630 | void KOAgendaItem::updateItem() |
631 | { | 631 | { |
632 | computeText(); | 632 | computeText(); |
633 | 633 | ||
634 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 634 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
635 | paintMe( mSelected ); | 635 | paintMe( mSelected ); |
636 | repaint( false); | 636 | repaint( false); |
637 | } | 637 | } |
638 | 638 | ||
639 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 639 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
640 | { | 640 | { |
641 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 641 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
642 | paintMe( mSelected ); | 642 | paintMe( mSelected ); |
643 | repaint( false ); | 643 | repaint( false ); |
644 | } | 644 | } |
645 | 645 | ||
646 | /* | 646 | /* |
647 | Return height of item in units of agenda cells | 647 | Return height of item in units of agenda cells |
648 | */ | 648 | */ |
649 | int KOAgendaItem::cellHeight() | 649 | int KOAgendaItem::cellHeight() |
650 | { | 650 | { |
651 | int ret = mCellYBottom - mCellYTop + 1; | 651 | int ret = mCellYBottom - mCellYTop + 1; |
652 | if ( ret <= 0 ) { | 652 | if ( ret <= 0 ) { |
653 | ret = 1; | 653 | ret = 1; |
654 | mCellYBottom = 0; | 654 | mCellYBottom = 0; |
655 | mCellYTop = 0; | 655 | mCellYTop = 0; |
656 | } | 656 | } |
657 | return ret; | 657 | return ret; |
658 | } | 658 | } |
659 | 659 | // it may be that allday agenda items have a needed width > 32000 | |
660 | // this code is to fix this problem | ||
661 | int KOAgendaItem::resizeMe( int grid, int wid, int hei ) | ||
662 | { | ||
663 | int diff = 0; | ||
664 | if ( mCellX < -3 && mAllDay ) { | ||
665 | diff = (mCellX + 3) * -grid; | ||
666 | //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); | ||
667 | if ( diff >= wid ) { | ||
668 | // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); | ||
669 | //diff = 0; | ||
670 | } | ||
671 | } | ||
672 | if ( wid == width() || diff >= wid ) | ||
673 | resize( wid, hei ); | ||
674 | else | ||
675 | resize( wid - diff, hei ); | ||
676 | return diff; | ||
677 | } | ||
660 | /* | 678 | /* |
661 | Return height of item in units of agenda cells | 679 | Return height of item in units of agenda cells |
662 | */ | 680 | */ |
663 | int KOAgendaItem::cellWidth() | 681 | int KOAgendaItem::cellWidth() |
664 | { | 682 | { |
665 | return mCellXWidth - mCellX + 1; | 683 | return mCellXWidth - mCellX + 1; |
666 | } | 684 | } |
667 | 685 | ||
668 | void KOAgendaItem::setItemDate(QDate qd) | 686 | void KOAgendaItem::setItemDate(QDate qd) |
669 | { | 687 | { |
670 | mDate = qd; | 688 | mDate = qd; |
671 | } | 689 | } |
672 | 690 | ||
673 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 691 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
674 | { | 692 | { |
675 | mCellX = X; | 693 | mCellX = X; |
676 | mCellYTop = YTop; | 694 | mCellYTop = YTop; |
677 | mCellYBottom = YBottom; | 695 | mCellYBottom = YBottom; |
678 | } | 696 | } |
679 | 697 | ||
680 | void KOAgendaItem::setCellXWidth(int xwidth) | 698 | void KOAgendaItem::setCellXWidth(int xwidth) |
681 | { | 699 | { |
682 | mCellXWidth = xwidth; | 700 | mCellXWidth = xwidth; |
683 | } | 701 | } |
684 | 702 | ||
685 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 703 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
686 | { | 704 | { |
687 | mCellX = XLeft; | 705 | mCellX = XLeft; |
688 | mCellXWidth = XRight; | 706 | mCellXWidth = XRight; |
689 | } | 707 | } |
690 | 708 | ||
691 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 709 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
692 | { | 710 | { |
693 | mCellYTop = YTop; | 711 | mCellYTop = YTop; |
694 | mCellYBottom = YBottom; | 712 | mCellYBottom = YBottom; |
695 | } | 713 | } |
696 | 714 | ||
697 | void KOAgendaItem::setSubCell(int subCell) | 715 | void KOAgendaItem::setSubCell(int subCell) |
698 | { | 716 | { |
699 | mSubCell = subCell; | 717 | mSubCell = subCell; |
700 | } | 718 | } |
701 | 719 | ||
702 | void KOAgendaItem::setSubCells(int subCells) | 720 | void KOAgendaItem::setSubCells(int subCells) |
703 | { | 721 | { |
704 | mSubCells = subCells; | 722 | mSubCells = subCells; |
705 | } | 723 | } |
706 | 724 | ||
707 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 725 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
708 | KOAgendaItem *last) | 726 | KOAgendaItem *last) |
709 | { | 727 | { |
710 | mFirstMultiItem = first; | 728 | mFirstMultiItem = first; |
711 | mNextMultiItem = next; | 729 | mNextMultiItem = next; |
712 | mLastMultiItem = last; | 730 | mLastMultiItem = last; |
713 | } | 731 | } |
714 | 732 | ||
715 | void KOAgendaItem::startMove() | 733 | void KOAgendaItem::startMove() |
716 | { | 734 | { |
717 | mStartCellX = mCellX; | 735 | mStartCellX = mCellX; |
718 | mStartCellXWidth = mCellXWidth; | 736 | mStartCellXWidth = mCellXWidth; |
719 | mStartCellYTop = mCellYTop; | 737 | mStartCellYTop = mCellYTop; |
720 | mStartCellYBottom = mCellYBottom; | 738 | mStartCellYBottom = mCellYBottom; |
721 | } | 739 | } |
722 | 740 | ||
723 | void KOAgendaItem::resetMove() | 741 | void KOAgendaItem::resetMove() |
724 | { | 742 | { |
725 | mCellX = mStartCellX; | 743 | mCellX = mStartCellX; |
726 | mCellXWidth = mStartCellXWidth; | 744 | mCellXWidth = mStartCellXWidth; |
727 | mCellYTop = mStartCellYTop; | 745 | mCellYTop = mStartCellYTop; |
728 | mCellYBottom = mStartCellYBottom; | 746 | mCellYBottom = mStartCellYBottom; |
729 | } | 747 | } |
730 | 748 | ||
731 | void KOAgendaItem::moveRelative(int dx, int dy) | 749 | void KOAgendaItem::moveRelative(int dx, int dy) |
732 | { | 750 | { |
733 | int newX = cellX() + dx; | 751 | int newX = cellX() + dx; |
734 | int newXWidth = cellXWidth() + dx; | 752 | int newXWidth = cellXWidth() + dx; |
735 | int newYTop = cellYTop() + dy; | 753 | int newYTop = cellYTop() + dy; |
736 | int newYBottom = cellYBottom() + dy; | 754 | int newYBottom = cellYBottom() + dy; |
737 | setCellXY(newX,newYTop,newYBottom); | 755 | setCellXY(newX,newYTop,newYBottom); |
738 | setCellXWidth(newXWidth); | 756 | setCellXWidth(newXWidth); |
739 | } | 757 | } |
740 | 758 | ||
741 | void KOAgendaItem::expandTop(int dy) | 759 | void KOAgendaItem::expandTop(int dy) |
742 | { | 760 | { |
743 | int newYTop = cellYTop() + dy; | 761 | int newYTop = cellYTop() + dy; |
744 | int newYBottom = cellYBottom(); | 762 | int newYBottom = cellYBottom(); |
745 | if (newYTop > newYBottom) newYTop = newYBottom; | 763 | if (newYTop > newYBottom) newYTop = newYBottom; |
746 | setCellY(newYTop, newYBottom); | 764 | setCellY(newYTop, newYBottom); |
747 | } | 765 | } |
748 | 766 | ||
749 | void KOAgendaItem::expandBottom(int dy) | 767 | void KOAgendaItem::expandBottom(int dy) |
750 | { | 768 | { |
751 | int newYTop = cellYTop(); | 769 | int newYTop = cellYTop(); |
752 | int newYBottom = cellYBottom() + dy; | 770 | int newYBottom = cellYBottom() + dy; |
753 | if (newYBottom < newYTop) newYBottom = newYTop; | 771 | if (newYBottom < newYTop) newYBottom = newYTop; |
754 | setCellY(newYTop, newYBottom); | 772 | setCellY(newYTop, newYBottom); |
755 | } | 773 | } |
756 | 774 | ||
757 | void KOAgendaItem::expandLeft(int dx) | 775 | void KOAgendaItem::expandLeft(int dx) |
758 | { | 776 | { |
759 | int newX = cellX() + dx; | 777 | int newX = cellX() + dx; |
760 | int newXWidth = cellXWidth(); | 778 | int newXWidth = cellXWidth(); |
761 | if (newX > newXWidth) newX = newXWidth; | 779 | if (newX > newXWidth) newX = newXWidth; |
762 | setCellX(newX,newXWidth); | 780 | setCellX(newX,newXWidth); |
763 | } | 781 | } |
764 | 782 | ||
765 | void KOAgendaItem::expandRight(int dx) | 783 | void KOAgendaItem::expandRight(int dx) |
766 | { | 784 | { |
767 | int newX = cellX(); | 785 | int newX = cellX(); |
768 | int newXWidth = cellXWidth() + dx; | 786 | int newXWidth = cellXWidth() + dx; |
769 | if (newXWidth < newX) newXWidth = newX; | 787 | if (newXWidth < newX) newXWidth = newX; |
770 | setCellX(newX,newXWidth); | 788 | setCellX(newX,newXWidth); |
771 | } | 789 | } |
772 | 790 | ||
773 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 791 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
774 | { | 792 | { |
775 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 793 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
776 | return mToolTipGroup; | 794 | return mToolTipGroup; |
777 | } | 795 | } |
778 | 796 | ||
779 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 797 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
780 | { | 798 | { |
781 | #ifndef KORG_NODND | 799 | #ifndef KORG_NODND |
782 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 800 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
783 | !QTextDrag::canDecode( e ) ) { | 801 | !QTextDrag::canDecode( e ) ) { |
784 | e->ignore(); | 802 | e->ignore(); |
785 | return; | 803 | return; |
786 | } | 804 | } |
787 | e->accept(); | 805 | e->accept(); |
788 | #endif | 806 | #endif |
789 | } | 807 | } |
790 | 808 | ||
791 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 809 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
792 | { | 810 | { |
793 | #ifndef KORG_NODND | 811 | #ifndef KORG_NODND |
794 | QString text; | 812 | QString text; |
795 | if(QTextDrag::decode(e,text)) | 813 | if(QTextDrag::decode(e,text)) |
796 | { | 814 | { |
797 | kdDebug() << "Dropped : " << text << endl; | 815 | kdDebug() << "Dropped : " << text << endl; |
798 | QStringList emails = QStringList::split(",",text); | 816 | QStringList emails = QStringList::split(",",text); |
799 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 817 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
800 | kdDebug() << " Email: " << (*it) << endl; | 818 | kdDebug() << " Email: " << (*it) << endl; |
801 | int pos = (*it).find("<"); | 819 | int pos = (*it).find("<"); |
802 | QString name = (*it).left(pos); | 820 | QString name = (*it).left(pos); |
803 | QString email = (*it).mid(pos); | 821 | QString email = (*it).mid(pos); |
804 | if (!email.isEmpty()) { | 822 | if (!email.isEmpty()) { |
805 | mIncidence->addAttendee(new Attendee(name,email)); | 823 | mIncidence->addAttendee(new Attendee(name,email)); |
806 | } | 824 | } |
807 | } | 825 | } |
808 | } | 826 | } |
809 | #endif | 827 | #endif |
810 | } | 828 | } |
811 | 829 | ||
812 | 830 | ||
813 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 831 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
814 | { | 832 | { |
815 | return mConflictItems; | 833 | return mConflictItems; |
816 | } | 834 | } |
817 | 835 | ||
818 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 836 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
819 | { | 837 | { |
820 | mConflictItems = ci; | 838 | mConflictItems = ci; |
821 | KOAgendaItem *item; | 839 | KOAgendaItem *item; |
822 | for ( item=mConflictItems.first(); item != 0; | 840 | for ( item=mConflictItems.first(); item != 0; |
823 | item=mConflictItems.next() ) { | 841 | item=mConflictItems.next() ) { |
824 | item->addConflictItem(this); | 842 | item->addConflictItem(this); |
825 | } | 843 | } |
826 | } | 844 | } |
827 | 845 | ||
828 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 846 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
829 | { | 847 | { |
830 | if (mConflictItems.find(ci)<0) | 848 | if (mConflictItems.find(ci)<0) |
831 | mConflictItems.append(ci); | 849 | mConflictItems.append(ci); |
832 | } | 850 | } |
833 | 851 | ||
834 | bool KOAgendaItem::checkLayout() | 852 | bool KOAgendaItem::checkLayout() |
835 | { | 853 | { |
836 | if ( !mConflictItems.count() ) | 854 | if ( !mConflictItems.count() ) |
837 | return true; | 855 | return true; |
838 | int max = 0; | 856 | int max = 0; |
839 | KOAgendaItem *item; | 857 | KOAgendaItem *item; |
840 | for ( item=mConflictItems.first(); item != 0; | 858 | for ( item=mConflictItems.first(); item != 0; |
841 | item=mConflictItems.next() ) { | 859 | item=mConflictItems.next() ) { |
842 | if ( item->subCells() > max ) | 860 | if ( item->subCells() > max ) |
843 | max = item->subCells(); | 861 | max = item->subCells(); |
844 | } | 862 | } |
845 | if ( max > subCells() ) { | 863 | if ( max > subCells() ) { |
846 | setSubCells( max ); | 864 | setSubCells( max ); |
847 | return false; | 865 | return false; |
848 | } | 866 | } |
849 | return true; | 867 | return true; |
850 | } | 868 | } |
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index 2b26e95..97acd4c 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h | |||
@@ -1,166 +1,167 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | #ifndef KOAGENDAITEM_H | 19 | #ifndef KOAGENDAITEM_H |
20 | #define KOAGENDAITEM_H | 20 | #define KOAGENDAITEM_H |
21 | 21 | ||
22 | #include <qframe.h> | 22 | #include <qframe.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qpalette.h> | 26 | #include <qpalette.h> |
27 | 27 | ||
28 | #include <libkcal/incidence.h> | 28 | #include <libkcal/incidence.h> |
29 | 29 | ||
30 | class KOAgendaItemWhatsThis; | 30 | class KOAgendaItemWhatsThis; |
31 | class QToolTipGroup; | 31 | class QToolTipGroup; |
32 | class QDragEnterEvent; | 32 | class QDragEnterEvent; |
33 | class QDropEvent; | 33 | class QDropEvent; |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | /* | 37 | /* |
38 | The KOAgendaItem has to make sure that it receives all mouse events, which are | 38 | The KOAgendaItem has to make sure that it receives all mouse events, which are |
39 | to be used for dragging and resizing. That means it has to be installed as | 39 | to be used for dragging and resizing. That means it has to be installed as |
40 | eventfiler for its children, if it has children, and it has to pass mouse | 40 | eventfiler for its children, if it has children, and it has to pass mouse |
41 | events from the cildren to itself. See eventFilter(). | 41 | events from the cildren to itself. See eventFilter(). |
42 | */ | 42 | */ |
43 | class KOAgendaItem : public QWidget | 43 | class KOAgendaItem : public QWidget |
44 | { | 44 | { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | public: | 46 | public: |
47 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, | 47 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, |
48 | WFlags f=0 ); | 48 | WFlags f=0 ); |
49 | ~KOAgendaItem(); | 49 | ~KOAgendaItem(); |
50 | QString getWhatsThisText(); | 50 | QString getWhatsThisText(); |
51 | void init ( Incidence *incidence, QDate qd ); | 51 | void init ( Incidence *incidence, QDate qd ); |
52 | int cellX() { return mCellX; } | 52 | int cellX() { return mCellX; } |
53 | int cellXWidth() { return mCellXWidth; } | 53 | int cellXWidth() { return mCellXWidth; } |
54 | int cellYTop() { return mCellYTop; } | 54 | int cellYTop() { return mCellYTop; } |
55 | int cellYBottom() { return mCellYBottom; } | 55 | int cellYBottom() { return mCellYBottom; } |
56 | int cellHeight(); | 56 | int cellHeight(); |
57 | int cellWidth(); | 57 | int cellWidth(); |
58 | int subCell() { return mSubCell; } | 58 | int subCell() { return mSubCell; } |
59 | int subCells() { return mSubCells; } | 59 | int subCells() { return mSubCells; } |
60 | 60 | ||
61 | void setCellXY(int X, int YTop, int YBottom); | 61 | void setCellXY(int X, int YTop, int YBottom); |
62 | void setCellY(int YTop, int YBottom); | 62 | void setCellY(int YTop, int YBottom); |
63 | void setCellX(int XLeft, int XRight); | 63 | void setCellX(int XLeft, int XRight); |
64 | void setCellXWidth(int xwidth); | 64 | void setCellXWidth(int xwidth); |
65 | void setSubCell(int subCell); | 65 | void setSubCell(int subCell); |
66 | void setSubCells(int subCells); | 66 | void setSubCells(int subCells); |
67 | 67 | ||
68 | /** Start movement */ | 68 | /** Start movement */ |
69 | void startMove(); | 69 | void startMove(); |
70 | /** Reset to original values */ | 70 | /** Reset to original values */ |
71 | void resetMove(); | 71 | void resetMove(); |
72 | 72 | ||
73 | void moveRelative(int dx,int dy); | 73 | void moveRelative(int dx,int dy); |
74 | void expandTop(int dy); | 74 | void expandTop(int dy); |
75 | void expandBottom(int dy); | 75 | void expandBottom(int dy); |
76 | void expandLeft(int dx); | 76 | void expandLeft(int dx); |
77 | void expandRight(int dx); | 77 | void expandRight(int dx); |
78 | int mLastMoveXPos; | 78 | int mLastMoveXPos; |
79 | 79 | ||
80 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 80 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
81 | KOAgendaItem *last); | 81 | KOAgendaItem *last); |
82 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } | 82 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } |
83 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } | 83 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } |
84 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } | 84 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } |
85 | 85 | ||
86 | Incidence *incidence() const { return mIncidence; } | 86 | Incidence *incidence() const { return mIncidence; } |
87 | QDate itemDate() { return mDate; } | 87 | QDate itemDate() { return mDate; } |
88 | 88 | ||
89 | /** Update the date of this item's occurence (not in the event) */ | 89 | /** Update the date of this item's occurence (not in the event) */ |
90 | void setItemDate(QDate qd); | 90 | void setItemDate(QDate qd); |
91 | 91 | ||
92 | void setText ( const QString & text ) { mDisplayedText = text; } | 92 | void setText ( const QString & text ) { mDisplayedText = text; } |
93 | QString text () { return mDisplayedText; } | 93 | QString text () { return mDisplayedText; } |
94 | 94 | ||
95 | virtual bool eventFilter ( QObject *, QEvent * ); | 95 | virtual bool eventFilter ( QObject *, QEvent * ); |
96 | 96 | ||
97 | static QToolTipGroup *toolTipGroup(); | 97 | static QToolTipGroup *toolTipGroup(); |
98 | 98 | ||
99 | QPtrList<KOAgendaItem> conflictItems(); | 99 | QPtrList<KOAgendaItem> conflictItems(); |
100 | void setConflictItems(QPtrList<KOAgendaItem>); | 100 | void setConflictItems(QPtrList<KOAgendaItem>); |
101 | void addConflictItem(KOAgendaItem *ci); | 101 | void addConflictItem(KOAgendaItem *ci); |
102 | void paintMe( bool, QPainter* painter = 0 ); | 102 | void paintMe( bool, QPainter* painter = 0 ); |
103 | void repaintMe(); | 103 | void repaintMe(); |
104 | static QPixmap * paintPix(); | 104 | static QPixmap * paintPix(); |
105 | static QPixmap * paintPixAllday(); | 105 | static QPixmap * paintPixAllday(); |
106 | void updateItem(); | 106 | void updateItem(); |
107 | void computeText(); | 107 | void computeText(); |
108 | void recreateIncidence(); | 108 | void recreateIncidence(); |
109 | bool checkLayout(); | 109 | bool checkLayout(); |
110 | void initColor (); | 110 | void initColor (); |
111 | bool isAllDay() { return mAllDay; } | 111 | bool isAllDay() { return mAllDay; } |
112 | int resizeMe( int grid, int wid, int hei ); | ||
112 | public slots: | 113 | public slots: |
113 | bool updateIcons( QPainter *, bool ); | 114 | bool updateIcons( QPainter *, bool ); |
114 | void select(bool=true); | 115 | void select(bool=true); |
115 | void repaintItem(); | 116 | void repaintItem(); |
116 | 117 | ||
117 | protected: | 118 | protected: |
118 | void dragEnterEvent(QDragEnterEvent *e); | 119 | void dragEnterEvent(QDragEnterEvent *e); |
119 | void dropEvent(QDropEvent *e); | 120 | void dropEvent(QDropEvent *e); |
120 | void paintEvent ( QPaintEvent * ); | 121 | void paintEvent ( QPaintEvent * ); |
121 | void resizeEvent ( QResizeEvent *ev ); | 122 | void resizeEvent ( QResizeEvent *ev ); |
122 | 123 | ||
123 | private: | 124 | private: |
124 | KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; | 125 | KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; |
125 | bool mAllDay; | 126 | bool mAllDay; |
126 | bool mWhiteText; | 127 | bool mWhiteText; |
127 | int mCellX; | 128 | int mCellX; |
128 | int mCellXWidth; | 129 | int mCellXWidth; |
129 | int mCellYTop,mCellYBottom; | 130 | int mCellYTop,mCellYBottom; |
130 | int mSubCell; // subcell number of this item | 131 | int mSubCell; // subcell number of this item |
131 | int mSubCells; // Total number of subcells in cell of this item | 132 | int mSubCells; // Total number of subcells in cell of this item |
132 | int xPaintCoord; | 133 | int xPaintCoord; |
133 | int yPaintCoord; | 134 | int yPaintCoord; |
134 | int wPaintCoord; | 135 | int wPaintCoord; |
135 | int hPaintCoord; | 136 | int hPaintCoord; |
136 | // Variables to remember start position | 137 | // Variables to remember start position |
137 | int mStartCellX; | 138 | int mStartCellX; |
138 | int mStartCellXWidth; | 139 | int mStartCellXWidth; |
139 | int mStartCellYTop,mStartCellYBottom; | 140 | int mStartCellYTop,mStartCellYBottom; |
140 | int mLastMovePos; | 141 | int mLastMovePos; |
141 | 142 | ||
142 | // Multi item pointers | 143 | // Multi item pointers |
143 | KOAgendaItem *mFirstMultiItem; | 144 | KOAgendaItem *mFirstMultiItem; |
144 | KOAgendaItem *mNextMultiItem; | 145 | KOAgendaItem *mNextMultiItem; |
145 | KOAgendaItem *mLastMultiItem; | 146 | KOAgendaItem *mLastMultiItem; |
146 | 147 | ||
147 | int mFontPixelSize; | 148 | int mFontPixelSize; |
148 | Incidence *mIncidence; // corresponding event or todo | 149 | Incidence *mIncidence; // corresponding event or todo |
149 | QDate mDate; //date this events occurs (for recurrence) | 150 | QDate mDate; //date this events occurs (for recurrence) |
150 | //void showIcon( QLabel*, int ); | 151 | //void showIcon( QLabel*, int ); |
151 | //QLabel *mTodoIconLabel; | 152 | //QLabel *mTodoIconLabel; |
152 | //QLabel *mItemLabel; | 153 | //QLabel *mItemLabel; |
153 | //QWidget *mIconBox; | 154 | //QWidget *mIconBox; |
154 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; | 155 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; |
155 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; | 156 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; |
156 | //QLabel *mIconMoreInfo; | 157 | //QLabel *mIconMoreInfo; |
157 | static QToolTipGroup *mToolTipGroup; | 158 | static QToolTipGroup *mToolTipGroup; |
158 | 159 | ||
159 | QColor mBackgroundColor; | 160 | QColor mBackgroundColor; |
160 | QColorGroup mColorGroup; | 161 | QColorGroup mColorGroup; |
161 | QString mDisplayedText; | 162 | QString mDisplayedText; |
162 | bool mSelected; | 163 | bool mSelected; |
163 | QPtrList<KOAgendaItem> mConflictItems; | 164 | QPtrList<KOAgendaItem> mConflictItems; |
164 | }; | 165 | }; |
165 | 166 | ||
166 | #endif // KOAGENDAITEM_H | 167 | #endif // KOAGENDAITEM_H |