summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index acdf5a0..b290020 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -715,769 +715,770 @@ void KOAgenda::newItem( int item )
715 } else 715 } else
716 if ( item == 2 ) { //new event 716 if ( item == 2 ) { //new event
717 newTodoSignal(mStartCellX ,mStartCellY ); 717 newTodoSignal(mStartCellX ,mStartCellY );
718 } else 718 } else
719 { 719 {
720 emit showDateView( item, mStartCellX ); 720 emit showDateView( item, mStartCellX );
721 // 3Day view 721 // 3Day view
722 // 4Week view 722 // 4Week view
723 // 5Month view 723 // 5Month view
724 // 6Journal view 724 // 6Journal view
725 } 725 }
726} 726}
727void KOAgenda::slotClearSelection() 727void KOAgenda::slotClearSelection()
728{ 728{
729 if (mSelectionHeight) { 729 if (mSelectionHeight) {
730 int selectionX = mSelectionCellX * mGridSpacingX; 730 int selectionX = mSelectionCellX * mGridSpacingX;
731 int top = mSelectionYTop - 2 *mGridSpacingY; 731 int top = mSelectionYTop - 2 *mGridSpacingY;
732 int hei = mSelectionHeight + 4 *mGridSpacingY; 732 int hei = mSelectionHeight + 4 *mGridSpacingY;
733 clearSelection(); 733 clearSelection();
734 repaintContents( selectionX, top, 734 repaintContents( selectionX, top,
735 mGridSpacingX, hei ,false ); 735 mGridSpacingX, hei ,false );
736 } 736 }
737 737
738} 738}
739void KOAgenda::startSelectAction(QPoint viewportPos) 739void KOAgenda::startSelectAction(QPoint viewportPos)
740{ 740{
741 741
742 emit signalClearSelection(); 742 emit signalClearSelection();
743 slotClearSelection(); 743 slotClearSelection();
744 744
745 mActionType = SELECT; 745 mActionType = SELECT;
746 746
747 int x,y; 747 int x,y;
748 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 748 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
749 int gx,gy; 749 int gx,gy;
750 contentsToGrid(x,y,gx,gy); 750 contentsToGrid(x,y,gx,gy);
751 751
752 mStartCellX = gx; 752 mStartCellX = gx;
753 mStartCellY = gy; 753 mStartCellY = gy;
754 mCurrentCellX = gx; 754 mCurrentCellX = gx;
755 mCurrentCellY = gy; 755 mCurrentCellY = gy;
756 756
757 // Store new selection 757 // Store new selection
758 mSelectionCellX = gx; 758 mSelectionCellX = gx;
759 mSelectionYTop = gy * mGridSpacingY; 759 mSelectionYTop = gy * mGridSpacingY;
760 mSelectionHeight = mGridSpacingY; 760 mSelectionHeight = mGridSpacingY;
761 761
762 // Paint new selection 762 // Paint new selection
763 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, 763 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
764 mGridSpacingX-1, mSelectionHeight ); 764 mGridSpacingX-1, mSelectionHeight );
765} 765}
766 766
767void KOAgenda::performSelectAction(QPoint viewportPos) 767void KOAgenda::performSelectAction(QPoint viewportPos)
768{ 768{
769 int x,y; 769 int x,y;
770 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 770 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
771 int gx,gy; 771 int gx,gy;
772 contentsToGrid(x,y,gx,gy); 772 contentsToGrid(x,y,gx,gy);
773 773
774 QPoint clipperPos = clipper()-> 774 QPoint clipperPos = clipper()->
775 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 775 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
776 776
777 // Scroll if cursor was moved to upper or lower end of agenda. 777 // Scroll if cursor was moved to upper or lower end of agenda.
778 if (clipperPos.y() < mScrollBorderWidth) { 778 if (clipperPos.y() < mScrollBorderWidth) {
779 mScrollUpTimer.start(mScrollDelay); 779 mScrollUpTimer.start(mScrollDelay);
780 } else if (visibleHeight() - clipperPos.y() < 780 } else if (visibleHeight() - clipperPos.y() <
781 mScrollBorderWidth) { 781 mScrollBorderWidth) {
782 mScrollDownTimer.start(mScrollDelay); 782 mScrollDownTimer.start(mScrollDelay);
783 } else { 783 } else {
784 mScrollUpTimer.stop(); 784 mScrollUpTimer.stop();
785 mScrollDownTimer.stop(); 785 mScrollDownTimer.stop();
786 } 786 }
787 787
788 if ( gy > mCurrentCellY ) { 788 if ( gy > mCurrentCellY ) {
789 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 789 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
790 790
791 791
792 repaintContents( (KOGlobals::self()->reverseLayout() ? 792 repaintContents( (KOGlobals::self()->reverseLayout() ?
793 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 793 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
794 mGridSpacingX, mSelectionYTop, 794 mGridSpacingX, mSelectionYTop,
795 mGridSpacingX, mSelectionHeight , false); 795 mGridSpacingX, mSelectionHeight , false);
796 796
797 mCurrentCellY = gy; 797 mCurrentCellY = gy;
798 } else if ( gy < mCurrentCellY ) { 798 } else if ( gy < mCurrentCellY ) {
799 if ( gy >= mStartCellY ) { 799 if ( gy >= mStartCellY ) {
800 int selectionHeight = mSelectionHeight; 800 int selectionHeight = mSelectionHeight;
801 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 801 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
802 802
803 repaintContents( (KOGlobals::self()->reverseLayout() ? 803 repaintContents( (KOGlobals::self()->reverseLayout() ?
804 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 804 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
805 mGridSpacingX, mSelectionYTop, 805 mGridSpacingX, mSelectionYTop,
806 mGridSpacingX, selectionHeight,false ); 806 mGridSpacingX, selectionHeight,false );
807 807
808 mCurrentCellY = gy; 808 mCurrentCellY = gy;
809 } else { 809 } else {
810 } 810 }
811 } 811 }
812} 812}
813 813
814void KOAgenda::endSelectAction( bool emitNewEvent ) 814void KOAgenda::endSelectAction( bool emitNewEvent )
815{ 815{
816 mActionType = NOP; 816 mActionType = NOP;
817 mScrollUpTimer.stop(); 817 mScrollUpTimer.stop();
818 mScrollDownTimer.stop(); 818 mScrollDownTimer.stop();
819 819
820 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 820 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
821 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 821 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
822 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 822 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
823 } 823 }
824} 824}
825 825
826void KOAgenda::startItemAction(QPoint viewportPos) 826void KOAgenda::startItemAction(QPoint viewportPos)
827{ 827{
828 int x,y; 828 int x,y;
829 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 829 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
830 int gx,gy; 830 int gx,gy;
831 contentsToGrid(x,y,gx,gy); 831 contentsToGrid(x,y,gx,gy);
832 832
833 mStartCellX = gx; 833 mStartCellX = gx;
834 mStartCellY = gy; 834 mStartCellY = gy;
835 mCurrentCellX = gx; 835 mCurrentCellX = gx;
836 mCurrentCellY = gy; 836 mCurrentCellY = gy;
837 837
838 if (mAllDayMode) { 838 if (mAllDayMode) {
839 int gridDistanceX = (x - gx * mGridSpacingX); 839 int gridDistanceX = (x - gx * mGridSpacingX);
840 if (gridDistanceX < mResizeBorderWidth && 840 if (gridDistanceX < mResizeBorderWidth &&
841 mActionItem->cellX() == mCurrentCellX) { 841 mActionItem->cellX() == mCurrentCellX) {
842 mActionType = RESIZELEFT; 842 mActionType = RESIZELEFT;
843 setCursor(sizeHorCursor); 843 setCursor(sizeHorCursor);
844 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 844 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
845 mActionItem->cellXWidth() == mCurrentCellX) { 845 mActionItem->cellXWidth() == mCurrentCellX) {
846 mActionType = RESIZERIGHT; 846 mActionType = RESIZERIGHT;
847 setCursor(sizeHorCursor); 847 setCursor(sizeHorCursor);
848 } else { 848 } else {
849 mActionType = MOVE; 849 mActionType = MOVE;
850 mActionItem->startMove(); 850 mActionItem->startMove();
851 setCursor(sizeAllCursor); 851 setCursor(sizeAllCursor);
852 } 852 }
853 } else { 853 } else {
854 int gridDistanceY = (y - gy * mGridSpacingY); 854 int gridDistanceY = (y - gy * mGridSpacingY);
855 bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); 855 bool allowResize = ( mActionItem->incidence()->typeID() != todoID );
856 if (allowResize && gridDistanceY < mResizeBorderWidth && 856 if (allowResize && gridDistanceY < mResizeBorderWidth &&
857 mActionItem->cellYTop() == mCurrentCellY && 857 mActionItem->cellYTop() == mCurrentCellY &&
858 !mActionItem->firstMultiItem()) { 858 !mActionItem->firstMultiItem()) {
859 mActionType = RESIZETOP; 859 mActionType = RESIZETOP;
860 setCursor(sizeVerCursor); 860 setCursor(sizeVerCursor);
861 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 861 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
862 mActionItem->cellYBottom() == mCurrentCellY && 862 mActionItem->cellYBottom() == mCurrentCellY &&
863 !mActionItem->lastMultiItem()) { 863 !mActionItem->lastMultiItem()) {
864 mActionType = RESIZEBOTTOM; 864 mActionType = RESIZEBOTTOM;
865 setCursor(sizeVerCursor); 865 setCursor(sizeVerCursor);
866 } else { 866 } else {
867 mActionType = MOVE; 867 mActionType = MOVE;
868 mActionItem->startMove(); 868 mActionItem->startMove();
869 setCursor(sizeAllCursor); 869 setCursor(sizeAllCursor);
870 } 870 }
871 } 871 }
872} 872}
873 873
874void KOAgenda::performItemAction(QPoint viewportPos) 874void KOAgenda::performItemAction(QPoint viewportPos)
875{ 875{
876// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 876// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
877// QPoint point = viewport()->mapToGlobal(viewportPos); 877// QPoint point = viewport()->mapToGlobal(viewportPos);
878// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 878// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
879// point = clipper()->mapFromGlobal(point); 879// point = clipper()->mapFromGlobal(point);
880// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 880// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
881// kdDebug() << "visible height: " << visibleHeight() << endl; 881// kdDebug() << "visible height: " << visibleHeight() << endl;
882 int x,y; 882 int x,y;
883 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 883 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
884// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 884// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
885 int gx,gy; 885 int gx,gy;
886 contentsToGrid(x,y,gx,gy); 886 contentsToGrid(x,y,gx,gy);
887 QPoint clipperPos = clipper()-> 887 QPoint clipperPos = clipper()->
888 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 888 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
889 889
890 // Cursor left active agenda area. 890 // Cursor left active agenda area.
891 // This starts a drag. 891 // This starts a drag.
892 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 892 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
893 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 893 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
894 if ( mActionType == MOVE ) { 894 if ( mActionType == MOVE ) {
895 mScrollUpTimer.stop(); 895 mScrollUpTimer.stop();
896 mScrollDownTimer.stop(); 896 mScrollDownTimer.stop();
897 mActionItem->resetMove(); 897 mActionItem->resetMove();
898 placeSubCells( mActionItem ); 898 placeSubCells( mActionItem );
899 // emit startDragSignal( mActionItem->incidence() ); 899 // emit startDragSignal( mActionItem->incidence() );
900 setCursor( arrowCursor ); 900 setCursor( arrowCursor );
901 mActionItem = 0; 901 mActionItem = 0;
902 mActionType = NOP; 902 mActionType = NOP;
903 mItemMoved = 0; 903 mItemMoved = 0;
904 return; 904 return;
905 } 905 }
906 } else { 906 } else {
907 switch ( mActionType ) { 907 switch ( mActionType ) {
908 case MOVE: 908 case MOVE:
909 setCursor( sizeAllCursor ); 909 setCursor( sizeAllCursor );
910 break; 910 break;
911 case RESIZETOP: 911 case RESIZETOP:
912 case RESIZEBOTTOM: 912 case RESIZEBOTTOM:
913 setCursor( sizeVerCursor ); 913 setCursor( sizeVerCursor );
914 break; 914 break;
915 case RESIZELEFT: 915 case RESIZELEFT:
916 case RESIZERIGHT: 916 case RESIZERIGHT:
917 setCursor( sizeHorCursor ); 917 setCursor( sizeHorCursor );
918 break; 918 break;
919 default: 919 default:
920 setCursor( arrowCursor ); 920 setCursor( arrowCursor );
921 } 921 }
922 } 922 }
923 923
924 // Scroll if item was moved to upper or lower end of agenda. 924 // Scroll if item was moved to upper or lower end of agenda.
925 if (clipperPos.y() < mScrollBorderWidth) { 925 if (clipperPos.y() < mScrollBorderWidth) {
926 mScrollUpTimer.start(mScrollDelay); 926 mScrollUpTimer.start(mScrollDelay);
927 } else if (visibleHeight() - clipperPos.y() < 927 } else if (visibleHeight() - clipperPos.y() <
928 mScrollBorderWidth) { 928 mScrollBorderWidth) {
929 mScrollDownTimer.start(mScrollDelay); 929 mScrollDownTimer.start(mScrollDelay);
930 } else { 930 } else {
931 mScrollUpTimer.stop(); 931 mScrollUpTimer.stop();
932 mScrollDownTimer.stop(); 932 mScrollDownTimer.stop();
933 } 933 }
934 934
935 // Move or resize item if necessary 935 // Move or resize item if necessary
936 if (mCurrentCellX != gx || mCurrentCellY != gy) { 936 if (mCurrentCellX != gx || mCurrentCellY != gy) {
937 mItemMoved = true; 937 mItemMoved = true;
938 mActionItem->raise(); 938 mActionItem->raise();
939 if (mActionType == MOVE) { 939 if (mActionType == MOVE) {
940 // Move all items belonging to a multi item 940 // Move all items belonging to a multi item
941 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 941 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
942 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 942 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
943 if (!moveItem) moveItem = mActionItem; 943 if (!moveItem) moveItem = mActionItem;
944 while (moveItem) { 944 while (moveItem) {
945 int dy; 945 int dy;
946 if (isMultiItem) dy = 0; 946 if (isMultiItem) dy = 0;
947 else dy = gy - mCurrentCellY; 947 else dy = gy - mCurrentCellY;
948 moveItem->moveRelative(gx - mCurrentCellX,dy); 948 moveItem->moveRelative(gx - mCurrentCellX,dy);
949 int x,y; 949 int x,y;
950 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 950 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
951 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 951 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
952 mGridSpacingY * moveItem->cellHeight()); 952 mGridSpacingY * moveItem->cellHeight());
953 moveItem->raise(); 953 moveItem->raise();
954 moveChild(moveItem,x,y); 954 moveChild(moveItem,x,y);
955 moveItem = moveItem->nextMultiItem(); 955 moveItem = moveItem->nextMultiItem();
956 } 956 }
957 } else if (mActionType == RESIZETOP) { 957 } else if (mActionType == RESIZETOP) {
958 if (mCurrentCellY <= mActionItem->cellYBottom()) { 958 if (mCurrentCellY <= mActionItem->cellYBottom()) {
959 mActionItem->expandTop(gy - mCurrentCellY); 959 mActionItem->expandTop(gy - mCurrentCellY);
960 mActionItem->resize(mActionItem->width(), 960 mActionItem->resize(mActionItem->width(),
961 mGridSpacingY * mActionItem->cellHeight()); 961 mGridSpacingY * mActionItem->cellHeight());
962 int x,y; 962 int x,y;
963 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 963 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
964 //moveChild(mActionItem,childX(mActionItem),y); 964 //moveChild(mActionItem,childX(mActionItem),y);
965 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 965 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
966 } 966 }
967 } else if (mActionType == RESIZEBOTTOM) { 967 } else if (mActionType == RESIZEBOTTOM) {
968 if (mCurrentCellY >= mActionItem->cellYTop()) { 968 if (mCurrentCellY >= mActionItem->cellYTop()) {
969 mActionItem->expandBottom(gy - mCurrentCellY); 969 mActionItem->expandBottom(gy - mCurrentCellY);
970 mActionItem->resize(mActionItem->width(), 970 mActionItem->resize(mActionItem->width(),
971 mGridSpacingY * mActionItem->cellHeight()); 971 mGridSpacingY * mActionItem->cellHeight());
972 } 972 }
973 } else if (mActionType == RESIZELEFT) { 973 } else if (mActionType == RESIZELEFT) {
974 if (mCurrentCellX <= mActionItem->cellXWidth()) { 974 if (mCurrentCellX <= mActionItem->cellXWidth()) {
975 mActionItem->expandLeft(gx - mCurrentCellX); 975 mActionItem->expandLeft(gx - mCurrentCellX);
976 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 976 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
977 mActionItem->height()); 977 mActionItem->height());
978 int x,y; 978 int x,y;
979 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 979 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
980 moveChild(mActionItem,x,childY(mActionItem)); 980 moveChild(mActionItem,x,childY(mActionItem));
981 } 981 }
982 } else if (mActionType == RESIZERIGHT) { 982 } else if (mActionType == RESIZERIGHT) {
983 if (mCurrentCellX >= mActionItem->cellX()) { 983 if (mCurrentCellX >= mActionItem->cellX()) {
984 mActionItem->expandRight(gx - mCurrentCellX); 984 mActionItem->expandRight(gx - mCurrentCellX);
985 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 985 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
986 mActionItem->height()); 986 mActionItem->height());
987 } 987 }
988 } 988 }
989 mCurrentCellX = gx; 989 mCurrentCellX = gx;
990 mCurrentCellY = gy; 990 mCurrentCellY = gy;
991 } 991 }
992} 992}
993 993
994void KOAgenda::endItemAction() 994void KOAgenda::endItemAction()
995{ 995{
996 996
997 if ( mItemMoved ) { 997 if ( mItemMoved ) {
998 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 998 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
999 if ( !placeItem ) { 999 if ( !placeItem ) {
1000 placeItem = mActionItem; 1000 placeItem = mActionItem;
1001 } 1001 }
1002 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 1002 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
1003 Incidence* oldInc = placeItem->incidence(); 1003 Incidence* oldInc = placeItem->incidence();
1004 placeItem->recreateIncidence(); 1004 placeItem->recreateIncidence();
1005 emit addToCalSignal(placeItem->incidence(), oldInc ); 1005 emit addToCalSignal(placeItem->incidence(), oldInc );
1006 } 1006 }
1007 int type = mActionType; 1007 int type = mActionType;
1008 if ( mAllDayMode ) 1008 if ( mAllDayMode )
1009 type = -1; 1009 type = -1;
1010 KOAgendaItem *modifiedItem = placeItem; 1010 KOAgendaItem *modifiedItem = placeItem;
1011 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1011 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
1012 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1012 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
1013 KOAgendaItem *item; 1013 KOAgendaItem *item;
1014 1014
1015 if ( placeItem->incidence()->typeID() == todoID ) { 1015 if ( placeItem->incidence()->typeID() == todoID ) {
1016 mSelectedItem = 0; 1016 mSelectedItem = 0;
1017 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1017 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
1018 modifiedItem->mLastMoveXPos = mCurrentCellX; 1018 modifiedItem->mLastMoveXPos = mCurrentCellX;
1019 emit itemModified( modifiedItem, mActionType ); 1019 emit itemModified( modifiedItem, mActionType );
1020 } 1020 }
1021 else { 1021 else {
1022 1022
1023 1023
1024 globalFlagBlockAgendaItemPaint = 1; 1024 globalFlagBlockAgendaItemPaint = 1;
1025 for ( item=oldconflictItems.first(); item != 0; 1025 for ( item=oldconflictItems.first(); item != 0;
1026 item=oldconflictItems.next() ) { 1026 item=oldconflictItems.next() ) {
1027 placeSubCells(item); 1027 placeSubCells(item);
1028 } 1028 }
1029 while ( placeItem ) { 1029 while ( placeItem ) {
1030 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1030 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1031 oldconflictItems = placeItem->conflictItems(); 1031 oldconflictItems = placeItem->conflictItems();
1032 for ( item=oldconflictItems.first(); item != 0; 1032 for ( item=oldconflictItems.first(); item != 0;
1033 item=oldconflictItems.next() ) { 1033 item=oldconflictItems.next() ) {
1034 placeSubCells(item); 1034 placeSubCells(item);
1035 } 1035 }
1036 placeSubCells( placeItem ); 1036 placeSubCells( placeItem );
1037 placeItem = placeItem->nextMultiItem(); 1037 placeItem = placeItem->nextMultiItem();
1038 } 1038 }
1039 globalFlagBlockAgendaItemPaint = 0; 1039 globalFlagBlockAgendaItemPaint = 0;
1040 for ( item=oldconflictItems.first(); item != 0; 1040 for ( item=oldconflictItems.first(); item != 0;
1041 item=oldconflictItems.next() ) { 1041 item=oldconflictItems.next() ) {
1042 globalFlagBlockAgendaItemUpdate = 0; 1042 globalFlagBlockAgendaItemUpdate = 0;
1043 item->repaintMe(); 1043 item->repaintMe();
1044 globalFlagBlockAgendaItemUpdate = 1; 1044 globalFlagBlockAgendaItemUpdate = 1;
1045 item->repaint( false ); 1045 item->repaint( false );
1046 } 1046 }
1047 placeItem = modifiedItem; 1047 placeItem = modifiedItem;
1048 1048
1049 while ( placeItem ) { 1049 while ( placeItem ) {
1050 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1050 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1051 globalFlagBlockAgendaItemUpdate = 0; 1051 globalFlagBlockAgendaItemUpdate = 0;
1052 placeItem->repaintMe(); 1052 placeItem->repaintMe();
1053 globalFlagBlockAgendaItemUpdate = 1; 1053 globalFlagBlockAgendaItemUpdate = 1;
1054 placeItem->repaint(false); 1054 placeItem->repaint(false);
1055 placeItem = placeItem->nextMultiItem(); 1055 placeItem = placeItem->nextMultiItem();
1056 } 1056 }
1057 emit itemModified( modifiedItem, mActionType ); 1057 emit itemModified( modifiedItem, mActionType );
1058 1058
1059 1059
1060 placeItem = modifiedItem; 1060 placeItem = modifiedItem;
1061 while ( placeItem ) { 1061 while ( placeItem ) {
1062 oldconflictItems = placeItem->conflictItems(); 1062 oldconflictItems = placeItem->conflictItems();
1063 for ( item=oldconflictItems.first(); item != 0; 1063 for ( item=oldconflictItems.first(); item != 0;
1064 item=oldconflictItems.next() ) { 1064 item=oldconflictItems.next() ) {
1065 placeSubCells(item); 1065 placeSubCells(item);
1066 } 1066 }
1067 placeSubCells( placeItem ); 1067 placeSubCells( placeItem );
1068 placeItem = placeItem->nextMultiItem(); 1068 placeItem = placeItem->nextMultiItem();
1069 1069
1070 } 1070 }
1071 placeItem = modifiedItem; 1071 placeItem = modifiedItem;
1072 while ( placeItem ) { 1072 while ( placeItem ) {
1073 oldconflictItems = placeItem->conflictItems(); 1073 oldconflictItems = placeItem->conflictItems();
1074 for ( item=oldconflictItems.first(); item != 0; 1074 for ( item=oldconflictItems.first(); item != 0;
1075 item=oldconflictItems.next() ) { 1075 item=oldconflictItems.next() ) {
1076 globalFlagBlockAgendaItemUpdate = 0; 1076 globalFlagBlockAgendaItemUpdate = 0;
1077 item->repaintMe(); 1077 item->repaintMe();
1078 globalFlagBlockAgendaItemUpdate = 1; 1078 globalFlagBlockAgendaItemUpdate = 1;
1079 item->repaint(false); 1079 item->repaint(false);
1080 } 1080 }
1081 placeItem = placeItem->nextMultiItem(); 1081 placeItem = placeItem->nextMultiItem();
1082 } 1082 }
1083 /* 1083 /*
1084 1084
1085 oldconflictItems = modifiedItem->conflictItems(); 1085 oldconflictItems = modifiedItem->conflictItems();
1086 for ( item=oldconflictItems.first(); item != 0; 1086 for ( item=oldconflictItems.first(); item != 0;
1087 item=oldconflictItems.next() ) { 1087 item=oldconflictItems.next() ) {
1088 globalFlagBlockAgendaItemUpdate = 0; 1088 globalFlagBlockAgendaItemUpdate = 0;
1089 item->paintMe(false); 1089 item->paintMe(false);
1090 globalFlagBlockAgendaItemUpdate = 1; 1090 globalFlagBlockAgendaItemUpdate = 1;
1091 item->repaint(false); 1091 item->repaint(false);
1092 } 1092 }
1093 */ 1093 */
1094 1094
1095 1095
1096 } 1096 }
1097 1097
1098 } 1098 }
1099 1099 if ( mActionItem )
1100 emit incidenceSelected( mActionItem->incidence() );
1100 mScrollUpTimer.stop(); 1101 mScrollUpTimer.stop();
1101 mScrollDownTimer.stop(); 1102 mScrollDownTimer.stop();
1102 setCursor( arrowCursor ); 1103 setCursor( arrowCursor );
1103 mActionItem = 0; 1104 mActionItem = 0;
1104 mActionType = NOP; 1105 mActionType = NOP;
1105 mItemMoved = 0; 1106 mItemMoved = 0;
1106 1107
1107} 1108}
1108 1109
1109void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1110void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1110{ 1111{
1111// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1112// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1112// QPoint point = viewport()->mapToGlobal(viewportPos); 1113// QPoint point = viewport()->mapToGlobal(viewportPos);
1113// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1114// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1114// point = clipper()->mapFromGlobal(point); 1115// point = clipper()->mapFromGlobal(point);
1115// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1116// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1116 1117
1117 int x,y; 1118 int x,y;
1118 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1119 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1119// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1120// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1120 int gx,gy; 1121 int gx,gy;
1121 contentsToGrid(x,y,gx,gy); 1122 contentsToGrid(x,y,gx,gy);
1122 1123
1123 // Change cursor to resize cursor if appropriate 1124 // Change cursor to resize cursor if appropriate
1124 if (mAllDayMode) { 1125 if (mAllDayMode) {
1125 int gridDistanceX = (x - gx * mGridSpacingX); 1126 int gridDistanceX = (x - gx * mGridSpacingX);
1126 if (gridDistanceX < mResizeBorderWidth && 1127 if (gridDistanceX < mResizeBorderWidth &&
1127 moveItem->cellX() == gx) { 1128 moveItem->cellX() == gx) {
1128 setCursor(sizeHorCursor); 1129 setCursor(sizeHorCursor);
1129 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1130 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1130 moveItem->cellXWidth() == gx) { 1131 moveItem->cellXWidth() == gx) {
1131 setCursor(sizeHorCursor); 1132 setCursor(sizeHorCursor);
1132 } else { 1133 } else {
1133 setCursor(arrowCursor); 1134 setCursor(arrowCursor);
1134 } 1135 }
1135 } else { 1136 } else {
1136 int gridDistanceY = (y - gy * mGridSpacingY); 1137 int gridDistanceY = (y - gy * mGridSpacingY);
1137 if (gridDistanceY < mResizeBorderWidth && 1138 if (gridDistanceY < mResizeBorderWidth &&
1138 moveItem->cellYTop() == gy && 1139 moveItem->cellYTop() == gy &&
1139 !moveItem->firstMultiItem()) { 1140 !moveItem->firstMultiItem()) {
1140 setCursor(sizeVerCursor); 1141 setCursor(sizeVerCursor);
1141 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1142 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1142 moveItem->cellYBottom() == gy && 1143 moveItem->cellYBottom() == gy &&
1143 !moveItem->lastMultiItem()) { 1144 !moveItem->lastMultiItem()) {
1144 setCursor(sizeVerCursor); 1145 setCursor(sizeVerCursor);
1145 } else { 1146 } else {
1146 setCursor(arrowCursor); 1147 setCursor(arrowCursor);
1147 } 1148 }
1148 } 1149 }
1149} 1150}
1150 1151
1151 1152
1152/* 1153/*
1153 Place item in cell and take care that multiple items using the same cell do 1154 Place item in cell and take care that multiple items using the same cell do
1154 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1155 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1155 it can get in all cases. 1156 it can get in all cases.
1156 At the moment the method has a bug: When an item is placed only the sub cell 1157 At the moment the method has a bug: When an item is placed only the sub cell
1157 widths of the items are changed, which are within the Y region the item to 1158 widths of the items are changed, which are within the Y region the item to
1158 place spans. When the sub cell width change of one of this items affects a 1159 place spans. When the sub cell width change of one of this items affects a
1159 cell, where other items are, which do not overlap in Y with the item to place, 1160 cell, where other items are, which do not overlap in Y with the item to place,
1160 the display gets corrupted, although the corruption looks quite nice. 1161 the display gets corrupted, although the corruption looks quite nice.
1161*/ 1162*/
1162void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1163void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1163{ 1164{
1164 1165
1165 QPtrList<KOAgendaItem> conflictItems; 1166 QPtrList<KOAgendaItem> conflictItems;
1166 int maxSubCells = 0; 1167 int maxSubCells = 0;
1167 QIntDict<KOAgendaItem> subCellDict(7); 1168 QIntDict<KOAgendaItem> subCellDict(7);
1168 1169
1169 KOAgendaItem *item; 1170 KOAgendaItem *item;
1170 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1171 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1171 if (item != placeItem) { 1172 if (item != placeItem) {
1172 if (placeItem->cellX() <= item->cellXWidth() && 1173 if (placeItem->cellX() <= item->cellXWidth() &&
1173 placeItem->cellXWidth() >= item->cellX()) { 1174 placeItem->cellXWidth() >= item->cellX()) {
1174 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1175 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1175 (placeItem->cellYBottom() >= item->cellYTop())) { 1176 (placeItem->cellYBottom() >= item->cellYTop())) {
1176 conflictItems.append(item); 1177 conflictItems.append(item);
1177 if (item->subCells() > maxSubCells) 1178 if (item->subCells() > maxSubCells)
1178 maxSubCells = item->subCells(); 1179 maxSubCells = item->subCells();
1179 subCellDict.insert(item->subCell(),item); 1180 subCellDict.insert(item->subCell(),item);
1180 } 1181 }
1181 } 1182 }
1182 } 1183 }
1183 } 1184 }
1184 1185
1185 if (conflictItems.count() > 0) { 1186 if (conflictItems.count() > 0) {
1186 // Look for unused sub cell and insert item 1187 // Look for unused sub cell and insert item
1187 int i; 1188 int i;
1188 for(i=0;i<maxSubCells;++i) { 1189 for(i=0;i<maxSubCells;++i) {
1189 if (!subCellDict.find(i)) { 1190 if (!subCellDict.find(i)) {
1190 placeItem->setSubCell(i); 1191 placeItem->setSubCell(i);
1191 break; 1192 break;
1192 } 1193 }
1193 } 1194 }
1194 if (i == maxSubCells) { 1195 if (i == maxSubCells) {
1195 placeItem->setSubCell(maxSubCells); 1196 placeItem->setSubCell(maxSubCells);
1196 maxSubCells++; // add new item to number of sub cells 1197 maxSubCells++; // add new item to number of sub cells
1197 } 1198 }
1198 1199
1199 // Prepare for sub cell geometry adjustment 1200 // Prepare for sub cell geometry adjustment
1200 int newSubCellWidth; 1201 int newSubCellWidth;
1201 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1202 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1202 else newSubCellWidth = mGridSpacingX / maxSubCells; 1203 else newSubCellWidth = mGridSpacingX / maxSubCells;
1203 conflictItems.append(placeItem); 1204 conflictItems.append(placeItem);
1204 1205
1205 1206
1206 // Adjust sub cell geometry of all direct conflict items 1207 // Adjust sub cell geometry of all direct conflict items
1207 for ( item=conflictItems.first(); item != 0; 1208 for ( item=conflictItems.first(); item != 0;
1208 item=conflictItems.next() ) { 1209 item=conflictItems.next() ) {
1209 item->setSubCells(maxSubCells); 1210 item->setSubCells(maxSubCells);
1210 if (mAllDayMode) { 1211 if (mAllDayMode) {
1211 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1212 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1212 } else { 1213 } else {
1213 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1214 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1214 } 1215 }
1215 int x,y; 1216 int x,y;
1216 gridToContents(item->cellX(),item->cellYTop(),x,y); 1217 gridToContents(item->cellX(),item->cellYTop(),x,y);
1217 if (mAllDayMode) { 1218 if (mAllDayMode) {
1218 y += item->subCell() * newSubCellWidth; 1219 y += item->subCell() * newSubCellWidth;
1219 } else { 1220 } else {
1220 x += item->subCell() * newSubCellWidth; 1221 x += item->subCell() * newSubCellWidth;
1221 } 1222 }
1222 moveChild(item,x,y); 1223 moveChild(item,x,y);
1223 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1224 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1224 //item->updateItem(); 1225 //item->updateItem();
1225 } 1226 }
1226 // Adjust sub cell geometry of all conflict items of all conflict items 1227 // Adjust sub cell geometry of all conflict items of all conflict items
1227 for ( item=conflictItems.first(); item != 0; 1228 for ( item=conflictItems.first(); item != 0;
1228 item=conflictItems.next() ) { 1229 item=conflictItems.next() ) {
1229 if ( placeItem != item ) { 1230 if ( placeItem != item ) {
1230 KOAgendaItem *item2; 1231 KOAgendaItem *item2;
1231 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1232 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1232 for ( item2=conflictItems2.first(); item2 != 0; 1233 for ( item2=conflictItems2.first(); item2 != 0;
1233 item2=conflictItems2.next() ) { 1234 item2=conflictItems2.next() ) {
1234 if ( item2->subCells() != maxSubCells) { 1235 if ( item2->subCells() != maxSubCells) {
1235 item2->setSubCells(maxSubCells); 1236 item2->setSubCells(maxSubCells);
1236 if (mAllDayMode) { 1237 if (mAllDayMode) {
1237 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1238 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1238 } else { 1239 } else {
1239 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1240 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1240 } 1241 }
1241 int x,y; 1242 int x,y;
1242 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1243 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1243 if (mAllDayMode) { 1244 if (mAllDayMode) {
1244 y += item2->subCell() * newSubCellWidth; 1245 y += item2->subCell() * newSubCellWidth;
1245 } else { 1246 } else {
1246 x += item2->subCell() * newSubCellWidth; 1247 x += item2->subCell() * newSubCellWidth;
1247 } 1248 }
1248 moveChild(item2,x,y); 1249 moveChild(item2,x,y);
1249 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1250 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1250 } 1251 }
1251 } 1252 }
1252 } 1253 }
1253 } 1254 }
1254 } else { 1255 } else {
1255 placeItem->setSubCell(0); 1256 placeItem->setSubCell(0);
1256 placeItem->setSubCells(1); 1257 placeItem->setSubCells(1);
1257 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1258 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1258 else placeItem->resize(mGridSpacingX,placeItem->height()); 1259 else placeItem->resize(mGridSpacingX,placeItem->height());
1259 int x,y; 1260 int x,y;
1260 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1261 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1261 moveChild(placeItem,x,y); 1262 moveChild(placeItem,x,y);
1262 } 1263 }
1263 placeItem->setConflictItems(conflictItems); 1264 placeItem->setConflictItems(conflictItems);
1264 // for ( item=conflictItems.first(); item != 0; 1265 // for ( item=conflictItems.first(); item != 0;
1265// item=conflictItems.next() ) { 1266// item=conflictItems.next() ) {
1266// //item->updateItem(); 1267// //item->updateItem();
1267// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1268// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1268// } 1269// }
1269// placeItem->updateItem(); 1270// placeItem->updateItem();
1270} 1271}
1271 1272
1272void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1273void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1273{ 1274{
1274 if ( globalFlagBlockAgenda ) 1275 if ( globalFlagBlockAgenda )
1275 return; 1276 return;
1276 1277
1277 if ( mInvalidPixmap ) { 1278 if ( mInvalidPixmap ) {
1278 mInvalidPixmap = false; 1279 mInvalidPixmap = false;
1279 qDebug("KO: Upsizing Pixmaps "); 1280 qDebug("KO: Upsizing Pixmaps ");
1280 computeSizes(); 1281 computeSizes();
1281 emit updateViewSignal(); 1282 emit updateViewSignal();
1282 return; 1283 return;
1283 } 1284 }
1284 if ( ! mAllDayMode ) { 1285 if ( ! mAllDayMode ) {
1285 // currently not working for 1286 // currently not working for
1286 1287
1287 //qDebug("KOAgenda::drawContents "); 1288 //qDebug("KOAgenda::drawContents ");
1288#if 0 1289#if 0
1289 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1290 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1290 qDebug("WAU "); 1291 qDebug("WAU ");
1291 drawContentsToPainter(); 1292 drawContentsToPainter();
1292 } 1293 }
1293#endif 1294#endif
1294 QPaintDevice* pd = p->device(); 1295 QPaintDevice* pd = p->device();
1295 p->end(); 1296 p->end();
1296 int vx, vy; 1297 int vx, vy;
1297 int selectionX = KOGlobals::self()->reverseLayout() ? 1298 int selectionX = KOGlobals::self()->reverseLayout() ?
1298 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1299 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1299 mSelectionCellX * mGridSpacingX; 1300 mSelectionCellX * mGridSpacingX;
1300 contentsToViewport ( cx, cy, vx,vy); 1301 contentsToViewport ( cx, cy, vx,vy);
1301 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1302 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1302 1303
1303 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1304 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1304 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1305 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1305 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1306 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1306 1307
1307 int vxSel, vySel; 1308 int vxSel, vySel;
1308 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1309 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1309 int off = mSelectionHeight; 1310 int off = mSelectionHeight;
1310 if ( vySel < 0 ) 1311 if ( vySel < 0 )
1311 off += vySel; 1312 off += vySel;
1312 //qDebug("OFF %d %d %d", off,vySel, vy ); 1313 //qDebug("OFF %d %d %d", off,vySel, vy );
1313 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1314 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1314 } else { 1315 } else {
1315 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1316 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1316 } 1317 }
1317 } 1318 }
1318 if ( mSelectionHeight > 0 ) { 1319 if ( mSelectionHeight > 0 ) {
1319 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1320 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1320 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1321 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1321 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1322 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1322 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1323 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1323 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1324 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1324 int hei = mSelectionHeight; 1325 int hei = mSelectionHeight;
1325 int offset = 0; 1326 int offset = 0;
1326 while ( hei > 0 ) { 1327 while ( hei > 0 ) {
1327 int p_hei = 5; 1328 int p_hei = 5;
1328 if ( hei < 5 ) p_hei = hei; 1329 if ( hei < 5 ) p_hei = hei;
1329 hei -= 5; 1330 hei -= 5;
1330 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1331 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1331 offset += 5; 1332 offset += 5;
1332 } 1333 }
1333 } 1334 }
1334 } 1335 }
1335 p->begin( pd ); 1336 p->begin( pd );
1336 } else { 1337 } else {
1337#if 0 1338#if 0
1338 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); 1339 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() );
1339 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1340 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1340 qDebug("WAUWAU "); 1341 qDebug("WAUWAU ");
1341 drawContentsToPainter(); 1342 drawContentsToPainter();
1342 } 1343 }
1343#endif 1344#endif
1344 QPaintDevice* pd = p->device(); 1345 QPaintDevice* pd = p->device();
1345 p->end(); 1346 p->end();
1346 int vx, vy; 1347 int vx, vy;
1347 int selectionX = KOGlobals::self()->reverseLayout() ? 1348 int selectionX = KOGlobals::self()->reverseLayout() ?
1348 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1349 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1349 mSelectionCellX * mGridSpacingX; 1350 mSelectionCellX * mGridSpacingX;
1350 contentsToViewport ( cx, cy, vx,vy); 1351 contentsToViewport ( cx, cy, vx,vy);
1351 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1352 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1352 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1353 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1353 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1354 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1354 1355
1355 if ( mSelectionHeight > 0 ) { 1356 if ( mSelectionHeight > 0 ) {
1356 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1357 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1357 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1358 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1358 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1359 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1359 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1360 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1360 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1361 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1361 int hei = mSelectionHeight; 1362 int hei = mSelectionHeight;
1362 int offset = 0; 1363 int offset = 0;
1363 while ( hei > 0 ) { 1364 while ( hei > 0 ) {
1364 int p_hei = 5; 1365 int p_hei = 5;
1365 if ( hei < 5 ) p_hei = hei; 1366 if ( hei < 5 ) p_hei = hei;
1366 hei -= 5; 1367 hei -= 5;
1367 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1368 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1368 offset += 5; 1369 offset += 5;
1369 } 1370 }
1370 } 1371 }
1371 } 1372 }
1372 p->begin( pd ); 1373 p->begin( pd );
1373 } 1374 }
1374 1375
1375} 1376}
1376 1377
1377void KOAgenda::finishUpdate() 1378void KOAgenda::finishUpdate()
1378{ 1379{
1379 1380
1380 KOAgendaItem *item; 1381 KOAgendaItem *item;
1381 globalFlagBlockAgendaItemPaint = 1; 1382 globalFlagBlockAgendaItemPaint = 1;
1382 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1383 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1383 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1384 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1384 if ( !item->checkLayout() ) { 1385 if ( !item->checkLayout() ) {
1385 //qDebug(" conflictitem found "); 1386 //qDebug(" conflictitem found ");
1386 int newSubCellWidth; 1387 int newSubCellWidth;
1387 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1388 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1388 else newSubCellWidth = mGridSpacingX / item->subCells(); 1389 else newSubCellWidth = mGridSpacingX / item->subCells();
1389 1390
1390 if (mAllDayMode) { 1391 if (mAllDayMode) {
1391 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1392 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1392 } else { 1393 } else {
1393 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1394 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1394 } 1395 }
1395 int x,y; 1396 int x,y;
1396 gridToContents(item->cellX(),item->cellYTop(),x,y); 1397 gridToContents(item->cellX(),item->cellYTop(),x,y);
1397 if (mAllDayMode) { 1398 if (mAllDayMode) {
1398 y += item->subCell() * newSubCellWidth; 1399 y += item->subCell() * newSubCellWidth;
1399 } else { 1400 } else {
1400 x += item->subCell() * newSubCellWidth; 1401 x += item->subCell() * newSubCellWidth;
1401 } 1402 }
1402 moveChild(item,x,y); 1403 moveChild(item,x,y);
1403 } 1404 }
1404 } 1405 }
1405 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1406 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1406 if ( !item->isVisible() ) 1407 if ( !item->isVisible() )
1407 item->show(); 1408 item->show();
1408 1409
1409 } 1410 }
1410 globalFlagBlockAgendaItemUpdate = 0; 1411 globalFlagBlockAgendaItemUpdate = 0;
1411 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1412 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1412 item->repaintMe( ); 1413 item->repaintMe( );
1413 } 1414 }
1414 globalFlagBlockAgendaItemUpdate = 1; 1415 globalFlagBlockAgendaItemUpdate = 1;
1415 qApp->processEvents(); 1416 qApp->processEvents();
1416 globalFlagBlockAgendaItemPaint = 0; 1417 globalFlagBlockAgendaItemPaint = 0;
1417 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1418 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1418 item->repaint( false ); 1419 item->repaint( false );
1419 } 1420 }
1420 marcus_bains(); 1421 marcus_bains();
1421} 1422}
1422 1423
1423/* 1424/*
1424 Draw grid in the background of the agenda. 1425 Draw grid in the background of the agenda.
1425*/ 1426*/
1426void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1427void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1427{ 1428{
1428 1429
1429 1430
1430 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1431 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1431 return; 1432 return;
1432 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1433 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1433 return; 1434 return;
1434 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1435 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1435 if ( ch < 1 ) 1436 if ( ch < 1 )
1436 ch = 1; 1437 ch = 1;
1437 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1438 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1438 mPaintPixmap.resize( contentsWidth()+42, ch ); 1439 mPaintPixmap.resize( contentsWidth()+42, ch );
1439 } 1440 }
1440 mCurPixWid = contentsWidth(); 1441 mCurPixWid = contentsWidth();
1441 mCurPixHei = ch; 1442 mCurPixHei = ch;
1442 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { 1443 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
1443 mHighlightPixmap.resize( mGridSpacingX-1, 5 ); 1444 mHighlightPixmap.resize( mGridSpacingX-1, 5 );
1444 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1445 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1445 } 1446 }
1446 mPixPainter.begin( &mPaintPixmap) ; 1447 mPixPainter.begin( &mPaintPixmap) ;
1447 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1448 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1448 QPainter * p ; 1449 QPainter * p ;
1449 if (paint == 0) { 1450 if (paint == 0) {
1450 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1451 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1451 p = &mPixPainter; 1452 p = &mPixPainter;
1452 } 1453 }
1453 else 1454 else
1454 p = paint ; 1455 p = paint ;
1455 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1456 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1456 1457
1457 //--cx;++cw; 1458 //--cx;++cw;
1458 int lGridSpacingY = mGridSpacingY*2; 1459 int lGridSpacingY = mGridSpacingY*2;
1459 int selDay; 1460 int selDay;
1460 QDate curDate = QDate::currentDate(); 1461 QDate curDate = QDate::currentDate();
1461 if ( !backgroundOnly ) { 1462 if ( !backgroundOnly ) {
1462 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1463 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1463 { 1464 {
1464 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { 1465 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) {
1465 int x1 = cx; 1466 int x1 = cx;
1466 int y1 = 0; 1467 int y1 = 0;
1467 if (y1 < cy) y1 = cy; 1468 if (y1 < cy) y1 = cy;
1468 int x2 = cx+cw-1; 1469 int x2 = cx+cw-1;
1469 int y2 = contentsHeight(); 1470 int y2 = contentsHeight();
1470 if (y2 > cy+ch-1) y2=cy+ch-1; 1471 if (y2 > cy+ch-1) y2=cy+ch-1;
1471 if (x2 >= x1 && y2 >= y1) { 1472 if (x2 >= x1 && y2 >= y1) {
1472 int gxStart = selDay; 1473 int gxStart = selDay;
1473 int gxEnd = gxStart ; 1474 int gxEnd = gxStart ;
1474 int xStart = KOGlobals::self()->reverseLayout() ? 1475 int xStart = KOGlobals::self()->reverseLayout() ?
1475 (mColumns - 1 - gxStart)*mGridSpacingX : 1476 (mColumns - 1 - gxStart)*mGridSpacingX :
1476 gxStart*mGridSpacingX; 1477 gxStart*mGridSpacingX;
1477 if (xStart < x1) xStart = x1; 1478 if (xStart < x1) xStart = x1;
1478 int xEnd = KOGlobals::self()->reverseLayout() ? 1479 int xEnd = KOGlobals::self()->reverseLayout() ?
1479 (mColumns - gxStart)*mGridSpacingX-1 : 1480 (mColumns - gxStart)*mGridSpacingX-1 :
1480 (gxStart+1)*mGridSpacingX-1; 1481 (gxStart+1)*mGridSpacingX-1;
1481 if (xEnd > x2) xEnd = x2; 1482 if (xEnd > x2) xEnd = x2;
1482 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1483 if ( KOPrefs::instance()->mUseHighlightLightColor )
1483 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1484 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,