author | zautrix <zautrix> | 2005-01-30 16:38:38 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-30 16:38:38 (UTC) |
commit | 23d345c877ae9de6a077af3705026d15bb04d1e3 (patch) (unidiff) | |
tree | 1c90eaf14b5fe5daf97645bebed2eabbe66b8a89 | |
parent | a34c528fdd8d2cdec14bae9ccb0eee54c8e4e374 (diff) | |
download | kdepimpi-23d345c877ae9de6a077af3705026d15bb04d1e3.zip kdepimpi-23d345c877ae9de6a077af3705026d15bb04d1e3.tar.gz kdepimpi-23d345c877ae9de6a077af3705026d15bb04d1e3.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagenda.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 3 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.h | 1 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 12 |
4 files changed, 13 insertions, 5 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 7c41cab..0aef929 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -704,1295 +704,1295 @@ void KOAgenda::startItemAction(QPoint viewportPos) | |||
704 | } | 704 | } |
705 | } else { | 705 | } else { |
706 | int gridDistanceY = (y - gy * mGridSpacingY); | 706 | int gridDistanceY = (y - gy * mGridSpacingY); |
707 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 707 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
708 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 708 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
709 | mActionItem->cellYTop() == mCurrentCellY && | 709 | mActionItem->cellYTop() == mCurrentCellY && |
710 | !mActionItem->firstMultiItem()) { | 710 | !mActionItem->firstMultiItem()) { |
711 | mActionType = RESIZETOP; | 711 | mActionType = RESIZETOP; |
712 | setCursor(sizeVerCursor); | 712 | setCursor(sizeVerCursor); |
713 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 713 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
714 | mActionItem->cellYBottom() == mCurrentCellY && | 714 | mActionItem->cellYBottom() == mCurrentCellY && |
715 | !mActionItem->lastMultiItem()) { | 715 | !mActionItem->lastMultiItem()) { |
716 | mActionType = RESIZEBOTTOM; | 716 | mActionType = RESIZEBOTTOM; |
717 | setCursor(sizeVerCursor); | 717 | setCursor(sizeVerCursor); |
718 | } else { | 718 | } else { |
719 | mActionType = MOVE; | 719 | mActionType = MOVE; |
720 | mActionItem->startMove(); | 720 | mActionItem->startMove(); |
721 | setCursor(sizeAllCursor); | 721 | setCursor(sizeAllCursor); |
722 | } | 722 | } |
723 | } | 723 | } |
724 | } | 724 | } |
725 | 725 | ||
726 | void KOAgenda::performItemAction(QPoint viewportPos) | 726 | void KOAgenda::performItemAction(QPoint viewportPos) |
727 | { | 727 | { |
728 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 728 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
729 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 729 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
730 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 730 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
731 | // point = clipper()->mapFromGlobal(point); | 731 | // point = clipper()->mapFromGlobal(point); |
732 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 732 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
733 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 733 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
734 | int x,y; | 734 | int x,y; |
735 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 735 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
736 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 736 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
737 | int gx,gy; | 737 | int gx,gy; |
738 | contentsToGrid(x,y,gx,gy); | 738 | contentsToGrid(x,y,gx,gy); |
739 | QPoint clipperPos = clipper()-> | 739 | QPoint clipperPos = clipper()-> |
740 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 740 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
741 | 741 | ||
742 | // Cursor left active agenda area. | 742 | // Cursor left active agenda area. |
743 | // This starts a drag. | 743 | // This starts a drag. |
744 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 744 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
745 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 745 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
746 | if ( mActionType == MOVE ) { | 746 | if ( mActionType == MOVE ) { |
747 | mScrollUpTimer.stop(); | 747 | mScrollUpTimer.stop(); |
748 | mScrollDownTimer.stop(); | 748 | mScrollDownTimer.stop(); |
749 | mActionItem->resetMove(); | 749 | mActionItem->resetMove(); |
750 | placeSubCells( mActionItem ); | 750 | placeSubCells( mActionItem ); |
751 | // emit startDragSignal( mActionItem->incidence() ); | 751 | // emit startDragSignal( mActionItem->incidence() ); |
752 | setCursor( arrowCursor ); | 752 | setCursor( arrowCursor ); |
753 | mActionItem = 0; | 753 | mActionItem = 0; |
754 | mActionType = NOP; | 754 | mActionType = NOP; |
755 | mItemMoved = 0; | 755 | mItemMoved = 0; |
756 | return; | 756 | return; |
757 | } | 757 | } |
758 | } else { | 758 | } else { |
759 | switch ( mActionType ) { | 759 | switch ( mActionType ) { |
760 | case MOVE: | 760 | case MOVE: |
761 | setCursor( sizeAllCursor ); | 761 | setCursor( sizeAllCursor ); |
762 | break; | 762 | break; |
763 | case RESIZETOP: | 763 | case RESIZETOP: |
764 | case RESIZEBOTTOM: | 764 | case RESIZEBOTTOM: |
765 | setCursor( sizeVerCursor ); | 765 | setCursor( sizeVerCursor ); |
766 | break; | 766 | break; |
767 | case RESIZELEFT: | 767 | case RESIZELEFT: |
768 | case RESIZERIGHT: | 768 | case RESIZERIGHT: |
769 | setCursor( sizeHorCursor ); | 769 | setCursor( sizeHorCursor ); |
770 | break; | 770 | break; |
771 | default: | 771 | default: |
772 | setCursor( arrowCursor ); | 772 | setCursor( arrowCursor ); |
773 | } | 773 | } |
774 | } | 774 | } |
775 | 775 | ||
776 | // Scroll if item was moved to upper or lower end of agenda. | 776 | // Scroll if item was moved to upper or lower end of agenda. |
777 | if (clipperPos.y() < mScrollBorderWidth) { | 777 | if (clipperPos.y() < mScrollBorderWidth) { |
778 | mScrollUpTimer.start(mScrollDelay); | 778 | mScrollUpTimer.start(mScrollDelay); |
779 | } else if (visibleHeight() - clipperPos.y() < | 779 | } else if (visibleHeight() - clipperPos.y() < |
780 | mScrollBorderWidth) { | 780 | mScrollBorderWidth) { |
781 | mScrollDownTimer.start(mScrollDelay); | 781 | mScrollDownTimer.start(mScrollDelay); |
782 | } else { | 782 | } else { |
783 | mScrollUpTimer.stop(); | 783 | mScrollUpTimer.stop(); |
784 | mScrollDownTimer.stop(); | 784 | mScrollDownTimer.stop(); |
785 | } | 785 | } |
786 | 786 | ||
787 | // Move or resize item if necessary | 787 | // Move or resize item if necessary |
788 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 788 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
789 | mItemMoved = true; | 789 | mItemMoved = true; |
790 | mActionItem->raise(); | 790 | mActionItem->raise(); |
791 | if (mActionType == MOVE) { | 791 | if (mActionType == MOVE) { |
792 | // Move all items belonging to a multi item | 792 | // Move all items belonging to a multi item |
793 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 793 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
794 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 794 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
795 | if (!moveItem) moveItem = mActionItem; | 795 | if (!moveItem) moveItem = mActionItem; |
796 | while (moveItem) { | 796 | while (moveItem) { |
797 | int dy; | 797 | int dy; |
798 | if (isMultiItem) dy = 0; | 798 | if (isMultiItem) dy = 0; |
799 | else dy = gy - mCurrentCellY; | 799 | else dy = gy - mCurrentCellY; |
800 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 800 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
801 | int x,y; | 801 | int x,y; |
802 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 802 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
803 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 803 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
804 | mGridSpacingY * moveItem->cellHeight()); | 804 | mGridSpacingY * moveItem->cellHeight()); |
805 | moveChild(moveItem,x,y); | 805 | moveChild(moveItem,x,y); |
806 | moveItem = moveItem->nextMultiItem(); | 806 | moveItem = moveItem->nextMultiItem(); |
807 | } | 807 | } |
808 | } else if (mActionType == RESIZETOP) { | 808 | } else if (mActionType == RESIZETOP) { |
809 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 809 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
810 | mActionItem->expandTop(gy - mCurrentCellY); | 810 | mActionItem->expandTop(gy - mCurrentCellY); |
811 | mActionItem->resize(mActionItem->width(), | 811 | mActionItem->resize(mActionItem->width(), |
812 | mGridSpacingY * mActionItem->cellHeight()); | 812 | mGridSpacingY * mActionItem->cellHeight()); |
813 | int x,y; | 813 | int x,y; |
814 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 814 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
815 | //moveChild(mActionItem,childX(mActionItem),y); | 815 | //moveChild(mActionItem,childX(mActionItem),y); |
816 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 816 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
817 | } | 817 | } |
818 | } else if (mActionType == RESIZEBOTTOM) { | 818 | } else if (mActionType == RESIZEBOTTOM) { |
819 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 819 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
820 | mActionItem->expandBottom(gy - mCurrentCellY); | 820 | mActionItem->expandBottom(gy - mCurrentCellY); |
821 | mActionItem->resize(mActionItem->width(), | 821 | mActionItem->resize(mActionItem->width(), |
822 | mGridSpacingY * mActionItem->cellHeight()); | 822 | mGridSpacingY * mActionItem->cellHeight()); |
823 | } | 823 | } |
824 | } else if (mActionType == RESIZELEFT) { | 824 | } else if (mActionType == RESIZELEFT) { |
825 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 825 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
826 | mActionItem->expandLeft(gx - mCurrentCellX); | 826 | mActionItem->expandLeft(gx - mCurrentCellX); |
827 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 827 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
828 | mActionItem->height()); | 828 | mActionItem->height()); |
829 | int x,y; | 829 | int x,y; |
830 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 830 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
831 | moveChild(mActionItem,x,childY(mActionItem)); | 831 | moveChild(mActionItem,x,childY(mActionItem)); |
832 | } | 832 | } |
833 | } else if (mActionType == RESIZERIGHT) { | 833 | } else if (mActionType == RESIZERIGHT) { |
834 | if (mCurrentCellX >= mActionItem->cellX()) { | 834 | if (mCurrentCellX >= mActionItem->cellX()) { |
835 | mActionItem->expandRight(gx - mCurrentCellX); | 835 | mActionItem->expandRight(gx - mCurrentCellX); |
836 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 836 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
837 | mActionItem->height()); | 837 | mActionItem->height()); |
838 | } | 838 | } |
839 | } | 839 | } |
840 | mCurrentCellX = gx; | 840 | mCurrentCellX = gx; |
841 | mCurrentCellY = gy; | 841 | mCurrentCellY = gy; |
842 | } | 842 | } |
843 | } | 843 | } |
844 | 844 | ||
845 | void KOAgenda::endItemAction() | 845 | void KOAgenda::endItemAction() |
846 | { | 846 | { |
847 | 847 | ||
848 | if ( mItemMoved ) { | 848 | if ( mItemMoved ) { |
849 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 849 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
850 | if ( !placeItem ) { | 850 | if ( !placeItem ) { |
851 | placeItem = mActionItem; | 851 | placeItem = mActionItem; |
852 | } | 852 | } |
853 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 853 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
854 | Incidence* oldInc = placeItem->incidence(); | 854 | Incidence* oldInc = placeItem->incidence(); |
855 | placeItem->recreateIncidence(); | 855 | placeItem->recreateIncidence(); |
856 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 856 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
857 | } | 857 | } |
858 | int type = mActionType; | 858 | int type = mActionType; |
859 | if ( mAllDayMode ) | 859 | if ( mAllDayMode ) |
860 | type = -1; | 860 | type = -1; |
861 | KOAgendaItem *modifiedItem = placeItem; | 861 | KOAgendaItem *modifiedItem = placeItem; |
862 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 862 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
863 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 863 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
864 | KOAgendaItem *item; | 864 | KOAgendaItem *item; |
865 | 865 | ||
866 | if ( placeItem->incidence()->type() == "Todo" ) { | 866 | if ( placeItem->incidence()->type() == "Todo" ) { |
867 | mSelectedItem = 0; | 867 | mSelectedItem = 0; |
868 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 868 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
869 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 869 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
870 | emit itemModified( modifiedItem, mActionType ); | 870 | emit itemModified( modifiedItem, mActionType ); |
871 | } | 871 | } |
872 | else { | 872 | else { |
873 | #if 0 | 873 | #if 0 |
874 | for ( item=oldconflictItems.first(); item != 0; | 874 | for ( item=oldconflictItems.first(); item != 0; |
875 | item=oldconflictItems.next() ) { | 875 | item=oldconflictItems.next() ) { |
876 | placeSubCells(item); | 876 | placeSubCells(item); |
877 | } | 877 | } |
878 | while ( placeItem ) { | 878 | while ( placeItem ) { |
879 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 879 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
880 | placeSubCells( placeItem ); | 880 | placeSubCells( placeItem ); |
881 | placeItem = placeItem->nextMultiItem(); | 881 | placeItem = placeItem->nextMultiItem(); |
882 | } | 882 | } |
883 | #endif | 883 | #endif |
884 | 884 | ||
885 | globalFlagBlockAgendaItemPaint = 1; | 885 | globalFlagBlockAgendaItemPaint = 1; |
886 | for ( item=oldconflictItems.first(); item != 0; | 886 | for ( item=oldconflictItems.first(); item != 0; |
887 | item=oldconflictItems.next() ) { | 887 | item=oldconflictItems.next() ) { |
888 | placeSubCells(item); | 888 | placeSubCells(item); |
889 | } | 889 | } |
890 | while ( placeItem ) { | 890 | while ( placeItem ) { |
891 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 891 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
892 | oldconflictItems = placeItem->conflictItems(); | 892 | oldconflictItems = placeItem->conflictItems(); |
893 | for ( item=oldconflictItems.first(); item != 0; | 893 | for ( item=oldconflictItems.first(); item != 0; |
894 | item=oldconflictItems.next() ) { | 894 | item=oldconflictItems.next() ) { |
895 | placeSubCells(item); | 895 | placeSubCells(item); |
896 | } | 896 | } |
897 | placeSubCells( placeItem ); | 897 | placeSubCells( placeItem ); |
898 | placeItem = placeItem->nextMultiItem(); | 898 | placeItem = placeItem->nextMultiItem(); |
899 | } | 899 | } |
900 | globalFlagBlockAgendaItemPaint = 0; | 900 | globalFlagBlockAgendaItemPaint = 0; |
901 | for ( item=oldconflictItems.first(); item != 0; | 901 | for ( item=oldconflictItems.first(); item != 0; |
902 | item=oldconflictItems.next() ) { | 902 | item=oldconflictItems.next() ) { |
903 | globalFlagBlockAgendaItemUpdate = 0; | 903 | globalFlagBlockAgendaItemUpdate = 0; |
904 | item->repaintMe(); | 904 | item->repaintMe(); |
905 | globalFlagBlockAgendaItemUpdate = 1; | 905 | globalFlagBlockAgendaItemUpdate = 1; |
906 | item->repaint( false ); | 906 | item->repaint( false ); |
907 | } | 907 | } |
908 | placeItem = modifiedItem; | 908 | placeItem = modifiedItem; |
909 | 909 | ||
910 | while ( placeItem ) { | 910 | while ( placeItem ) { |
911 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 911 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
912 | globalFlagBlockAgendaItemUpdate = 0; | 912 | globalFlagBlockAgendaItemUpdate = 0; |
913 | placeItem->repaintMe(); | 913 | placeItem->repaintMe(); |
914 | globalFlagBlockAgendaItemUpdate = 1; | 914 | globalFlagBlockAgendaItemUpdate = 1; |
915 | placeItem->repaint(false); | 915 | placeItem->repaint(false); |
916 | placeItem = placeItem->nextMultiItem(); | 916 | placeItem = placeItem->nextMultiItem(); |
917 | } | 917 | } |
918 | emit itemModified( modifiedItem, mActionType ); | 918 | emit itemModified( modifiedItem, mActionType ); |
919 | 919 | ||
920 | 920 | ||
921 | placeItem = modifiedItem; | 921 | placeItem = modifiedItem; |
922 | while ( placeItem ) { | 922 | while ( placeItem ) { |
923 | oldconflictItems = placeItem->conflictItems(); | 923 | oldconflictItems = placeItem->conflictItems(); |
924 | for ( item=oldconflictItems.first(); item != 0; | 924 | for ( item=oldconflictItems.first(); item != 0; |
925 | item=oldconflictItems.next() ) { | 925 | item=oldconflictItems.next() ) { |
926 | placeSubCells(item); | 926 | placeSubCells(item); |
927 | } | 927 | } |
928 | placeSubCells( placeItem ); | 928 | placeSubCells( placeItem ); |
929 | placeItem = placeItem->nextMultiItem(); | 929 | placeItem = placeItem->nextMultiItem(); |
930 | 930 | ||
931 | } | 931 | } |
932 | placeItem = modifiedItem; | 932 | placeItem = modifiedItem; |
933 | while ( placeItem ) { | 933 | while ( placeItem ) { |
934 | oldconflictItems = placeItem->conflictItems(); | 934 | oldconflictItems = placeItem->conflictItems(); |
935 | for ( item=oldconflictItems.first(); item != 0; | 935 | for ( item=oldconflictItems.first(); item != 0; |
936 | item=oldconflictItems.next() ) { | 936 | item=oldconflictItems.next() ) { |
937 | globalFlagBlockAgendaItemUpdate = 0; | 937 | globalFlagBlockAgendaItemUpdate = 0; |
938 | item->repaintMe(); | 938 | item->repaintMe(); |
939 | globalFlagBlockAgendaItemUpdate = 1; | 939 | globalFlagBlockAgendaItemUpdate = 1; |
940 | item->repaint(false); | 940 | item->repaint(false); |
941 | } | 941 | } |
942 | placeItem = placeItem->nextMultiItem(); | 942 | placeItem = placeItem->nextMultiItem(); |
943 | } | 943 | } |
944 | /* | 944 | /* |
945 | 945 | ||
946 | oldconflictItems = modifiedItem->conflictItems(); | 946 | oldconflictItems = modifiedItem->conflictItems(); |
947 | for ( item=oldconflictItems.first(); item != 0; | 947 | for ( item=oldconflictItems.first(); item != 0; |
948 | item=oldconflictItems.next() ) { | 948 | item=oldconflictItems.next() ) { |
949 | globalFlagBlockAgendaItemUpdate = 0; | 949 | globalFlagBlockAgendaItemUpdate = 0; |
950 | item->paintMe(false); | 950 | item->paintMe(false); |
951 | globalFlagBlockAgendaItemUpdate = 1; | 951 | globalFlagBlockAgendaItemUpdate = 1; |
952 | item->repaint(false); | 952 | item->repaint(false); |
953 | } | 953 | } |
954 | */ | 954 | */ |
955 | 955 | ||
956 | 956 | ||
957 | } | 957 | } |
958 | 958 | ||
959 | } | 959 | } |
960 | 960 | ||
961 | mScrollUpTimer.stop(); | 961 | mScrollUpTimer.stop(); |
962 | mScrollDownTimer.stop(); | 962 | mScrollDownTimer.stop(); |
963 | setCursor( arrowCursor ); | 963 | setCursor( arrowCursor ); |
964 | mActionItem = 0; | 964 | mActionItem = 0; |
965 | mActionType = NOP; | 965 | mActionType = NOP; |
966 | mItemMoved = 0; | 966 | mItemMoved = 0; |
967 | 967 | ||
968 | } | 968 | } |
969 | 969 | ||
970 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 970 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
971 | { | 971 | { |
972 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 972 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
973 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 973 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
974 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 974 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
975 | // point = clipper()->mapFromGlobal(point); | 975 | // point = clipper()->mapFromGlobal(point); |
976 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 976 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
977 | 977 | ||
978 | int x,y; | 978 | int x,y; |
979 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 979 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
980 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 980 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
981 | int gx,gy; | 981 | int gx,gy; |
982 | contentsToGrid(x,y,gx,gy); | 982 | contentsToGrid(x,y,gx,gy); |
983 | 983 | ||
984 | // Change cursor to resize cursor if appropriate | 984 | // Change cursor to resize cursor if appropriate |
985 | if (mAllDayMode) { | 985 | if (mAllDayMode) { |
986 | int gridDistanceX = (x - gx * mGridSpacingX); | 986 | int gridDistanceX = (x - gx * mGridSpacingX); |
987 | if (gridDistanceX < mResizeBorderWidth && | 987 | if (gridDistanceX < mResizeBorderWidth && |
988 | moveItem->cellX() == gx) { | 988 | moveItem->cellX() == gx) { |
989 | setCursor(sizeHorCursor); | 989 | setCursor(sizeHorCursor); |
990 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 990 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
991 | moveItem->cellXWidth() == gx) { | 991 | moveItem->cellXWidth() == gx) { |
992 | setCursor(sizeHorCursor); | 992 | setCursor(sizeHorCursor); |
993 | } else { | 993 | } else { |
994 | setCursor(arrowCursor); | 994 | setCursor(arrowCursor); |
995 | } | 995 | } |
996 | } else { | 996 | } else { |
997 | int gridDistanceY = (y - gy * mGridSpacingY); | 997 | int gridDistanceY = (y - gy * mGridSpacingY); |
998 | if (gridDistanceY < mResizeBorderWidth && | 998 | if (gridDistanceY < mResizeBorderWidth && |
999 | moveItem->cellYTop() == gy && | 999 | moveItem->cellYTop() == gy && |
1000 | !moveItem->firstMultiItem()) { | 1000 | !moveItem->firstMultiItem()) { |
1001 | setCursor(sizeVerCursor); | 1001 | setCursor(sizeVerCursor); |
1002 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1002 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1003 | moveItem->cellYBottom() == gy && | 1003 | moveItem->cellYBottom() == gy && |
1004 | !moveItem->lastMultiItem()) { | 1004 | !moveItem->lastMultiItem()) { |
1005 | setCursor(sizeVerCursor); | 1005 | setCursor(sizeVerCursor); |
1006 | } else { | 1006 | } else { |
1007 | setCursor(arrowCursor); | 1007 | setCursor(arrowCursor); |
1008 | } | 1008 | } |
1009 | } | 1009 | } |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | 1012 | ||
1013 | /* | 1013 | /* |
1014 | Place item in cell and take care that multiple items using the same cell do | 1014 | Place item in cell and take care that multiple items using the same cell do |
1015 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1015 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1016 | it can get in all cases. | 1016 | it can get in all cases. |
1017 | At the moment the method has a bug: When an item is placed only the sub cell | 1017 | At the moment the method has a bug: When an item is placed only the sub cell |
1018 | widths of the items are changed, which are within the Y region the item to | 1018 | widths of the items are changed, which are within the Y region the item to |
1019 | place spans. When the sub cell width change of one of this items affects a | 1019 | place spans. When the sub cell width change of one of this items affects a |
1020 | cell, where other items are, which do not overlap in Y with the item to place, | 1020 | cell, where other items are, which do not overlap in Y with the item to place, |
1021 | the display gets corrupted, although the corruption looks quite nice. | 1021 | the display gets corrupted, although the corruption looks quite nice. |
1022 | */ | 1022 | */ |
1023 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1023 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1024 | { | 1024 | { |
1025 | 1025 | ||
1026 | QPtrList<KOAgendaItem> conflictItems; | 1026 | QPtrList<KOAgendaItem> conflictItems; |
1027 | int maxSubCells = 0; | 1027 | int maxSubCells = 0; |
1028 | QIntDict<KOAgendaItem> subCellDict(5); | 1028 | QIntDict<KOAgendaItem> subCellDict(5); |
1029 | 1029 | ||
1030 | KOAgendaItem *item; | 1030 | KOAgendaItem *item; |
1031 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1031 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1032 | if (item != placeItem) { | 1032 | if (item != placeItem) { |
1033 | if (placeItem->cellX() <= item->cellXWidth() && | 1033 | if (placeItem->cellX() <= item->cellXWidth() && |
1034 | placeItem->cellXWidth() >= item->cellX()) { | 1034 | placeItem->cellXWidth() >= item->cellX()) { |
1035 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1035 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1036 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1036 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1037 | conflictItems.append(item); | 1037 | conflictItems.append(item); |
1038 | if (item->subCells() > maxSubCells) | 1038 | if (item->subCells() > maxSubCells) |
1039 | maxSubCells = item->subCells(); | 1039 | maxSubCells = item->subCells(); |
1040 | subCellDict.insert(item->subCell(),item); | 1040 | subCellDict.insert(item->subCell(),item); |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | if (conflictItems.count() > 0) { | 1046 | if (conflictItems.count() > 0) { |
1047 | // Look for unused sub cell and insert item | 1047 | // Look for unused sub cell and insert item |
1048 | int i; | 1048 | int i; |
1049 | for(i=0;i<maxSubCells;++i) { | 1049 | for(i=0;i<maxSubCells;++i) { |
1050 | if (!subCellDict.find(i)) { | 1050 | if (!subCellDict.find(i)) { |
1051 | placeItem->setSubCell(i); | 1051 | placeItem->setSubCell(i); |
1052 | break; | 1052 | break; |
1053 | } | 1053 | } |
1054 | } | 1054 | } |
1055 | if (i == maxSubCells) { | 1055 | if (i == maxSubCells) { |
1056 | placeItem->setSubCell(maxSubCells); | 1056 | placeItem->setSubCell(maxSubCells); |
1057 | maxSubCells++; // add new item to number of sub cells | 1057 | maxSubCells++; // add new item to number of sub cells |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | // Prepare for sub cell geometry adjustment | 1060 | // Prepare for sub cell geometry adjustment |
1061 | int newSubCellWidth; | 1061 | int newSubCellWidth; |
1062 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1062 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1063 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1063 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1064 | conflictItems.append(placeItem); | 1064 | conflictItems.append(placeItem); |
1065 | 1065 | ||
1066 | 1066 | ||
1067 | // Adjust sub cell geometry of all items | 1067 | // Adjust sub cell geometry of all items |
1068 | for ( item=conflictItems.first(); item != 0; | 1068 | for ( item=conflictItems.first(); item != 0; |
1069 | item=conflictItems.next() ) { | 1069 | item=conflictItems.next() ) { |
1070 | item->setSubCells(maxSubCells); | 1070 | item->setSubCells(maxSubCells); |
1071 | if (mAllDayMode) { | 1071 | if (mAllDayMode) { |
1072 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1072 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1073 | } else { | 1073 | } else { |
1074 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1074 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1075 | } | 1075 | } |
1076 | int x,y; | 1076 | int x,y; |
1077 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1077 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1078 | if (mAllDayMode) { | 1078 | if (mAllDayMode) { |
1079 | y += item->subCell() * newSubCellWidth; | 1079 | y += item->subCell() * newSubCellWidth; |
1080 | } else { | 1080 | } else { |
1081 | x += item->subCell() * newSubCellWidth; | 1081 | x += item->subCell() * newSubCellWidth; |
1082 | } | 1082 | } |
1083 | moveChild(item,x,y); | 1083 | moveChild(item,x,y); |
1084 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1084 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1085 | //item->updateItem(); | 1085 | //item->updateItem(); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | } else { | 1088 | } else { |
1089 | placeItem->setSubCell(0); | 1089 | placeItem->setSubCell(0); |
1090 | placeItem->setSubCells(1); | 1090 | placeItem->setSubCells(1); |
1091 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1091 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1092 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1092 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1093 | int x,y; | 1093 | int x,y; |
1094 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1094 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1095 | moveChild(placeItem,x,y); | 1095 | moveChild(placeItem,x,y); |
1096 | } | 1096 | } |
1097 | placeItem->setConflictItems(conflictItems); | 1097 | placeItem->setConflictItems(conflictItems); |
1098 | // for ( item=conflictItems.first(); item != 0; | 1098 | // for ( item=conflictItems.first(); item != 0; |
1099 | // item=conflictItems.next() ) { | 1099 | // item=conflictItems.next() ) { |
1100 | // //item->updateItem(); | 1100 | // //item->updateItem(); |
1101 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1101 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1102 | // } | 1102 | // } |
1103 | // placeItem->updateItem(); | 1103 | // placeItem->updateItem(); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1106 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1107 | { | 1107 | { |
1108 | if ( globalFlagBlockAgenda ) | 1108 | if ( globalFlagBlockAgenda ) |
1109 | return; | 1109 | return; |
1110 | //qDebug("KOAgenda::drawContents "); | 1110 | //qDebug("KOAgenda::drawContents "); |
1111 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1111 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1112 | ;//drawContentsToPainter(); | 1112 | ;//drawContentsToPainter(); |
1113 | 1113 | ||
1114 | QPaintDevice* pd = p->device(); | 1114 | QPaintDevice* pd = p->device(); |
1115 | p->end(); | 1115 | p->end(); |
1116 | int vx, vy; | 1116 | int vx, vy; |
1117 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1117 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1118 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1118 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1119 | mSelectionCellX * mGridSpacingX; | 1119 | mSelectionCellX * mGridSpacingX; |
1120 | contentsToViewport ( cx, cy, vx,vy); | 1120 | contentsToViewport ( cx, cy, vx,vy); |
1121 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1121 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1122 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1122 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1123 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1123 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1124 | 1124 | ||
1125 | if ( mSelectionHeight > 0 ) { | 1125 | if ( mSelectionHeight > 0 ) { |
1126 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1126 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1127 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1127 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1128 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1128 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1129 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1129 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1130 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1130 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | //qDebug("btbl "); | 1133 | //qDebug("btbl "); |
1134 | p->begin( pd ); | 1134 | p->begin( pd ); |
1135 | //qDebug("end "); | 1135 | //qDebug("end "); |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | void KOAgenda::finishUpdate() | 1138 | void KOAgenda::finishUpdate() |
1139 | { | 1139 | { |
1140 | 1140 | ||
1141 | KOAgendaItem *item; | 1141 | KOAgendaItem *item; |
1142 | globalFlagBlockAgendaItemPaint = 1; | 1142 | globalFlagBlockAgendaItemPaint = 1; |
1143 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1143 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1144 | if ( !item->isVisible() ) | 1144 | if ( !item->isVisible() ) |
1145 | item->show(); | 1145 | item->show(); |
1146 | 1146 | ||
1147 | } | 1147 | } |
1148 | globalFlagBlockAgendaItemUpdate = 0; | 1148 | globalFlagBlockAgendaItemUpdate = 0; |
1149 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1149 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1150 | item->repaintMe( ); | 1150 | item->repaintMe( ); |
1151 | } | 1151 | } |
1152 | globalFlagBlockAgendaItemUpdate = 1; | 1152 | globalFlagBlockAgendaItemUpdate = 1; |
1153 | qApp->processEvents(); | 1153 | qApp->processEvents(); |
1154 | globalFlagBlockAgendaItemPaint = 0; | 1154 | globalFlagBlockAgendaItemPaint = 0; |
1155 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1155 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1156 | item->repaint( false ); | 1156 | item->repaint( false ); |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | /* | 1161 | /* |
1162 | Draw grid in the background of the agenda. | 1162 | Draw grid in the background of the agenda. |
1163 | */ | 1163 | */ |
1164 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1164 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1165 | { | 1165 | { |
1166 | 1166 | ||
1167 | 1167 | ||
1168 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1168 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1169 | return; | 1169 | return; |
1170 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1170 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1171 | return; | 1171 | return; |
1172 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1172 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1173 | if ( ch < 1 ) | 1173 | if ( ch < 1 ) |
1174 | ch = 1; | 1174 | ch = 1; |
1175 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1175 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1176 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1176 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1177 | } | 1177 | } |
1178 | mCurPixWid = contentsWidth(); | 1178 | mCurPixWid = contentsWidth(); |
1179 | mCurPixHei = ch; | 1179 | mCurPixHei = ch; |
1180 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1180 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1181 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1181 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1182 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1182 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1183 | } | 1183 | } |
1184 | mPixPainter.begin( &mPaintPixmap) ; | 1184 | mPixPainter.begin( &mPaintPixmap) ; |
1185 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1185 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1186 | QPainter * p ; | 1186 | QPainter * p ; |
1187 | if (paint == 0) { | 1187 | if (paint == 0) { |
1188 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1188 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1189 | p = &mPixPainter; | 1189 | p = &mPixPainter; |
1190 | } | 1190 | } |
1191 | else | 1191 | else |
1192 | p = paint ; | 1192 | p = paint ; |
1193 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1193 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1194 | 1194 | ||
1195 | //--cx;++cw; | 1195 | //--cx;++cw; |
1196 | int lGridSpacingY = mGridSpacingY*2; | 1196 | int lGridSpacingY = mGridSpacingY*2; |
1197 | int selDay; | 1197 | int selDay; |
1198 | if ( !backgroundOnly ) | 1198 | if ( !backgroundOnly ) |
1199 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1199 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1200 | { | 1200 | { |
1201 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1201 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1202 | int x1 = cx; | 1202 | int x1 = cx; |
1203 | int y1 = 0; | 1203 | int y1 = 0; |
1204 | if (y1 < cy) y1 = cy; | 1204 | if (y1 < cy) y1 = cy; |
1205 | int x2 = cx+cw-1; | 1205 | int x2 = cx+cw-1; |
1206 | int y2 = contentsHeight(); | 1206 | int y2 = contentsHeight(); |
1207 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1207 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1208 | if (x2 >= x1 && y2 >= y1) { | 1208 | if (x2 >= x1 && y2 >= y1) { |
1209 | int gxStart = selDay; | 1209 | int gxStart = selDay; |
1210 | int gxEnd = gxStart ; | 1210 | int gxEnd = gxStart ; |
1211 | int xStart = KOGlobals::self()->reverseLayout() ? | 1211 | int xStart = KOGlobals::self()->reverseLayout() ? |
1212 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1212 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1213 | gxStart*mGridSpacingX; | 1213 | gxStart*mGridSpacingX; |
1214 | if (xStart < x1) xStart = x1; | 1214 | if (xStart < x1) xStart = x1; |
1215 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1215 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1216 | (mColumns - gxStart)*mGridSpacingX-1 : | 1216 | (mColumns - gxStart)*mGridSpacingX-1 : |
1217 | (gxStart+1)*mGridSpacingX-1; | 1217 | (gxStart+1)*mGridSpacingX-1; |
1218 | if (xEnd > x2) xEnd = x2; | 1218 | if (xEnd > x2) xEnd = x2; |
1219 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1219 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1220 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1220 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1221 | KOPrefs::instance()->mAgendaBgColor.light()); | 1221 | KOPrefs::instance()->mAgendaBgColor.light()); |
1222 | else | 1222 | else |
1223 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1223 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1224 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1224 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1225 | 1225 | ||
1226 | } | 1226 | } |
1227 | } | 1227 | } |
1228 | } | 1228 | } |
1229 | // Highlight working hours | 1229 | // Highlight working hours |
1230 | 1230 | ||
1231 | if ( !backgroundOnly ) | 1231 | if ( !backgroundOnly ) |
1232 | if (mWorkingHoursEnable) { | 1232 | if (mWorkingHoursEnable) { |
1233 | int x1 = cx; | 1233 | int x1 = cx; |
1234 | int y1 = mWorkingHoursYTop; | 1234 | int y1 = mWorkingHoursYTop; |
1235 | if (y1 < cy) y1 = cy; | 1235 | if (y1 < cy) y1 = cy; |
1236 | int x2 = cx+cw-1; | 1236 | int x2 = cx+cw-1; |
1237 | // int x2 = mGridSpacingX * 5 - 1; | 1237 | // int x2 = mGridSpacingX * 5 - 1; |
1238 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1238 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1239 | int y2 = mWorkingHoursYBottom; | 1239 | int y2 = mWorkingHoursYBottom; |
1240 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1240 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1241 | 1241 | ||
1242 | if (x2 >= x1 && y2 >= y1) { | 1242 | if (x2 >= x1 && y2 >= y1) { |
1243 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1243 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1244 | int gxStart = x1/mGridSpacingX; | 1244 | int gxStart = x1/mGridSpacingX; |
1245 | int gxEnd = x2/mGridSpacingX; | 1245 | int gxEnd = x2/mGridSpacingX; |
1246 | while(gxStart <= gxEnd) { | 1246 | while(gxStart <= gxEnd) { |
1247 | if (gxStart < int(mHolidayMask->count()) && | 1247 | if (gxStart < int(mHolidayMask->count()) && |
1248 | !mHolidayMask->at(gxStart)) { | 1248 | !mHolidayMask->at(gxStart)) { |
1249 | int xStart = KOGlobals::self()->reverseLayout() ? | 1249 | int xStart = KOGlobals::self()->reverseLayout() ? |
1250 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1250 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1251 | gxStart*mGridSpacingX; | 1251 | gxStart*mGridSpacingX; |
1252 | if (xStart < x1) xStart = x1; | 1252 | if (xStart < x1) xStart = x1; |
1253 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1253 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1254 | (mColumns - gxStart)*mGridSpacingX-1 : | 1254 | (mColumns - gxStart)*mGridSpacingX-1 : |
1255 | (gxStart+1)*mGridSpacingX-1; | 1255 | (gxStart+1)*mGridSpacingX-1; |
1256 | if (xEnd > x2) xEnd = x2; | 1256 | if (xEnd > x2) xEnd = x2; |
1257 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1257 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1258 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1258 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1259 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1259 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1260 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1260 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1261 | else | 1261 | else |
1262 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1262 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1263 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1263 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1264 | } else { | 1264 | } else { |
1265 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1265 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1266 | KOPrefs::instance()->mWorkingHoursColor); | 1266 | KOPrefs::instance()->mWorkingHoursColor); |
1267 | } | 1267 | } |
1268 | } | 1268 | } |
1269 | ++gxStart; | 1269 | ++gxStart; |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | /* | 1273 | /* |
1274 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1274 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1275 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1275 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1276 | mSelectionCellX * mGridSpacingX; | 1276 | mSelectionCellX * mGridSpacingX; |
1277 | 1277 | ||
1278 | // Draw selection | 1278 | // Draw selection |
1279 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1279 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1280 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1280 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1281 | // TODO: paint only part within cx,cy,cw,ch | 1281 | // TODO: paint only part within cx,cy,cw,ch |
1282 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1282 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1283 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1283 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1284 | } | 1284 | } |
1285 | */ | 1285 | */ |
1286 | // Draw vertical lines of grid | 1286 | // Draw vertical lines of grid |
1287 | 1287 | ||
1288 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1288 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1289 | if ( mGridSpacingX > 0 ) { | 1289 | if ( mGridSpacingX > 0 ) { |
1290 | while (x < cx + cw) { | 1290 | while (x < cx + cw) { |
1291 | p->drawLine(x,cy,x,cy+ch); | 1291 | p->drawLine(x,cy,x,cy+ch); |
1292 | x+=mGridSpacingX; | 1292 | x+=mGridSpacingX; |
1293 | } | 1293 | } |
1294 | } | 1294 | } |
1295 | // Draw horizontal lines of grid | 1295 | // Draw horizontal lines of grid |
1296 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1296 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1297 | if ( lGridSpacingY > 0 ) { | 1297 | if ( lGridSpacingY > 0 ) { |
1298 | while (y < cy + ch) { | 1298 | while (y < cy + ch) { |
1299 | p->setPen( SolidLine ); | 1299 | p->setPen( SolidLine ); |
1300 | p->drawLine(cx,y,cx+cw,y); | 1300 | p->drawLine(cx,y,cx+cw,y); |
1301 | y+=lGridSpacingY; | 1301 | y+=lGridSpacingY; |
1302 | p->setPen( DotLine ); | 1302 | p->setPen( DotLine ); |
1303 | p->drawLine(cx,y,cx+cw,y); | 1303 | p->drawLine(cx,y,cx+cw,y); |
1304 | y+=lGridSpacingY; | 1304 | y+=lGridSpacingY; |
1305 | } | 1305 | } |
1306 | p->setPen( SolidLine ); | 1306 | p->setPen( SolidLine ); |
1307 | } | 1307 | } |
1308 | mPixPainter.end() ; | 1308 | mPixPainter.end() ; |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | /* | 1311 | /* |
1312 | Convert srcollview contents coordinates to agenda grid coordinates. | 1312 | Convert srcollview contents coordinates to agenda grid coordinates. |
1313 | */ | 1313 | */ |
1314 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1314 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1315 | { | 1315 | { |
1316 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1316 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1317 | x/mGridSpacingX; | 1317 | x/mGridSpacingX; |
1318 | gy = y/mGridSpacingY; | 1318 | gy = y/mGridSpacingY; |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | /* | 1321 | /* |
1322 | Convert agenda grid coordinates to scrollview contents coordinates. | 1322 | Convert agenda grid coordinates to scrollview contents coordinates. |
1323 | */ | 1323 | */ |
1324 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1324 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1325 | { | 1325 | { |
1326 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1326 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1327 | gx*mGridSpacingX; | 1327 | gx*mGridSpacingX; |
1328 | y = gy*mGridSpacingY; | 1328 | y = gy*mGridSpacingY; |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | 1331 | ||
1332 | /* | 1332 | /* |
1333 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1333 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1334 | the grid. | 1334 | the grid. |
1335 | */ | 1335 | */ |
1336 | int KOAgenda::timeToY(const QTime &time) | 1336 | int KOAgenda::timeToY(const QTime &time) |
1337 | { | 1337 | { |
1338 | int minutesPerCell = 24 * 60 / mRows; | 1338 | int minutesPerCell = 24 * 60 / mRows; |
1339 | int timeMinutes = time.hour() * 60 + time.minute(); | 1339 | int timeMinutes = time.hour() * 60 + time.minute(); |
1340 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1340 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1341 | return Y; | 1341 | return Y; |
1342 | } | 1342 | } |
1343 | 1343 | ||
1344 | 1344 | ||
1345 | /* | 1345 | /* |
1346 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1346 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1347 | fit into the grid. | 1347 | fit into the grid. |
1348 | */ | 1348 | */ |
1349 | QTime KOAgenda::gyToTime(int gy) | 1349 | QTime KOAgenda::gyToTime(int gy) |
1350 | { | 1350 | { |
1351 | 1351 | ||
1352 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1352 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1353 | 1353 | ||
1354 | int timeSeconds = secondsPerCell * gy; | 1354 | int timeSeconds = secondsPerCell * gy; |
1355 | 1355 | ||
1356 | QTime time( 0, 0, 0 ); | 1356 | QTime time( 0, 0, 0 ); |
1357 | if ( timeSeconds < 24 * 60 * 60 ) { | 1357 | if ( timeSeconds < 24 * 60 * 60 ) { |
1358 | time = time.addSecs(timeSeconds); | 1358 | time = time.addSecs(timeSeconds); |
1359 | } else { | 1359 | } else { |
1360 | time.setHMS( 23, 59, 59 ); | 1360 | time.setHMS( 23, 59, 59 ); |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | return time; | 1363 | return time; |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | void KOAgenda::setStartHour(int startHour) | 1366 | void KOAgenda::setStartHour(int startHour) |
1367 | { | 1367 | { |
1368 | int startCell = startHour * mRows / 24; | 1368 | int startCell = startHour * mRows / 24; |
1369 | setContentsPos(0,startCell * gridSpacingY()); | 1369 | setContentsPos(0,startCell * gridSpacingY()); |
1370 | } | 1370 | } |
1371 | void KOAgenda::hideUnused() | 1371 | void KOAgenda::hideUnused() |
1372 | { | 1372 | { |
1373 | // experimental only | 1373 | // experimental only |
1374 | // return; | 1374 | // return; |
1375 | KOAgendaItem *item; | 1375 | KOAgendaItem *item; |
1376 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1376 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1377 | item->hide(); | 1377 | item->hide(); |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | 1380 | ||
1381 | 1381 | ||
1382 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1382 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1383 | { | 1383 | { |
1384 | 1384 | ||
1385 | KOAgendaItem *fi; | 1385 | KOAgendaItem *fi; |
1386 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1386 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1387 | if ( fi->incidence() == event ) { | 1387 | if ( fi->incidence() == event ) { |
1388 | mUnusedItems.remove(); | 1388 | mUnusedItems.remove(); |
1389 | fi->init( event, qd ); | 1389 | fi->init( event, qd ); |
1390 | return fi; | 1390 | return fi; |
1391 | } | 1391 | } |
1392 | } | 1392 | } |
1393 | fi=mUnusedItems.first(); | 1393 | fi=mUnusedItems.first(); |
1394 | if ( fi ) { | 1394 | if ( fi ) { |
1395 | mUnusedItems.remove(); | 1395 | mUnusedItems.remove(); |
1396 | fi->init( event, qd ); | 1396 | fi->init( event, qd ); |
1397 | return fi; | 1397 | return fi; |
1398 | } | 1398 | } |
1399 | // qDebug("new KOAgendaItem "); | 1399 | // qDebug("new KOAgendaItem "); |
1400 | 1400 | ||
1401 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1401 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1402 | agendaItem->installEventFilter(this); | 1402 | agendaItem->installEventFilter(this); |
1403 | addChild(agendaItem,0,0); | 1403 | addChild(agendaItem,0,0); |
1404 | return agendaItem; | 1404 | return agendaItem; |
1405 | } | 1405 | } |
1406 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1406 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1407 | { | 1407 | { |
1408 | KOAgendaItem *item; | 1408 | KOAgendaItem *item; |
1409 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1409 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1410 | if ( item->incidence() == todo ) { | 1410 | if ( item->incidence() == todo ) { |
1411 | mItems.remove(); | 1411 | mItems.remove(); |
1412 | return item; | 1412 | return item; |
1413 | } | 1413 | } |
1414 | } | 1414 | } |
1415 | return 0; | 1415 | return 0; |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | 1418 | ||
1419 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1419 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1420 | { | 1420 | { |
1421 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1421 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1422 | KOAgendaItem *item; | 1422 | KOAgendaItem *item; |
1423 | item = getItemForTodo ( todo ); | 1423 | item = getItemForTodo ( todo ); |
1424 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1424 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1425 | if ( item ) { | 1425 | if ( item ) { |
1426 | blockSignals( true ); | 1426 | blockSignals( true ); |
1427 | //qDebug("item found "); | 1427 | //qDebug("item found "); |
1428 | item->hide(); | 1428 | item->hide(); |
1429 | item->setCellX(-2, -1 ); | 1429 | item->setCellX(-2, -1 ); |
1430 | item->select(false); | 1430 | item->select(false); |
1431 | mUnusedItems.append( item ); | 1431 | mUnusedItems.append( item ); |
1432 | mItems.remove( item ); | 1432 | mItems.remove( item ); |
1433 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1433 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1434 | KOAgendaItem *itemit; | 1434 | KOAgendaItem *itemit; |
1435 | //globalFlagBlockAgendaItemPaint = 1; | 1435 | //globalFlagBlockAgendaItemPaint = 1; |
1436 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1436 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1437 | itemit=oldconflictItems.next() ) { | 1437 | itemit=oldconflictItems.next() ) { |
1438 | if ( itemit != item ) | 1438 | if ( itemit != item ) |
1439 | placeSubCells(itemit); | 1439 | placeSubCells(itemit); |
1440 | } | 1440 | } |
1441 | qApp->processEvents(); | 1441 | qApp->processEvents(); |
1442 | //globalFlagBlockAgendaItemPaint = 0; | 1442 | //globalFlagBlockAgendaItemPaint = 0; |
1443 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1443 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1444 | itemit=oldconflictItems.next() ) { | 1444 | itemit=oldconflictItems.next() ) { |
1445 | globalFlagBlockAgendaItemUpdate = 0; | 1445 | globalFlagBlockAgendaItemUpdate = 0; |
1446 | if ( itemit != item ) | 1446 | if ( itemit != item ) |
1447 | itemit->repaintMe(); | 1447 | itemit->repaintMe(); |
1448 | globalFlagBlockAgendaItemUpdate = 1; | 1448 | globalFlagBlockAgendaItemUpdate = 1; |
1449 | itemit->repaint(); | 1449 | itemit->repaint(); |
1450 | } | 1450 | } |
1451 | blockSignals( false ); | 1451 | blockSignals( false ); |
1452 | } | 1452 | } |
1453 | if ( remove ) { | 1453 | if ( remove ) { |
1454 | //qDebug("remove****************************************** "); | 1454 | //qDebug("remove****************************************** "); |
1455 | return; | 1455 | return; |
1456 | } | 1456 | } |
1457 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1457 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1458 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1458 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1459 | QDate currentDate; | 1459 | QDate currentDate; |
1460 | QDateTime dt; | 1460 | QDateTime dt; |
1461 | if ( todo->hasCompletedDate() ) | 1461 | if ( todo->hasCompletedDate() ) |
1462 | dt = todo->completed(); | 1462 | dt = todo->completed(); |
1463 | else | 1463 | else |
1464 | dt = todo->dtDue(); | 1464 | dt = todo->dtDue(); |
1465 | if ( overdue ) { | 1465 | if ( overdue ) { |
1466 | currentDate = QDate::currentDate(); | 1466 | currentDate = QDate::currentDate(); |
1467 | days += todo->dtDue().date().daysTo( currentDate ); | 1467 | days += todo->dtDue().date().daysTo( currentDate ); |
1468 | } | 1468 | } |
1469 | else | 1469 | else |
1470 | currentDate = dt.date(); | 1470 | currentDate = dt.date(); |
1471 | 1471 | ||
1472 | if ( todo->doesFloat() || overdue ) { | 1472 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1473 | if ( ! mAllDayMode ) return; | 1473 | if ( ! mAllDayMode ) return; |
1474 | // aldayagenda | 1474 | // aldayagenda |
1475 | globalFlagBlockAgendaItemPaint = 1; | 1475 | globalFlagBlockAgendaItemPaint = 1; |
1476 | item = insertAllDayItem(todo, currentDate,days, days); | 1476 | item = insertAllDayItem(todo, currentDate,days, days); |
1477 | item->show(); | 1477 | item->show(); |
1478 | 1478 | ||
1479 | } | 1479 | } |
1480 | else { | 1480 | else { |
1481 | if ( mAllDayMode ) return; | 1481 | if ( mAllDayMode ) return; |
1482 | // mAgenda | 1482 | // mAgenda |
1483 | globalFlagBlockAgendaItemPaint = 1; | 1483 | globalFlagBlockAgendaItemPaint = 1; |
1484 | int endY = timeToY(dt.time()) - 1; | 1484 | int endY = timeToY(dt.time()) - 1; |
1485 | int hi = 12/KOPrefs::instance()->mHourSize; | 1485 | int hi = 12/KOPrefs::instance()->mHourSize; |
1486 | int startY = endY - 1-hi; | 1486 | int startY = endY - 1-hi; |
1487 | item = insertItem(todo,currentDate,days,startY,endY); | 1487 | item = insertItem(todo,currentDate,days,startY,endY); |
1488 | item->show(); | 1488 | item->show(); |
1489 | } | 1489 | } |
1490 | qApp->processEvents(); | 1490 | qApp->processEvents(); |
1491 | globalFlagBlockAgendaItemPaint = 0; | 1491 | globalFlagBlockAgendaItemPaint = 0; |
1492 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1492 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1493 | KOAgendaItem *itemit; | 1493 | KOAgendaItem *itemit; |
1494 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1494 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1495 | itemit=oldconflictItems.next() ) { | 1495 | itemit=oldconflictItems.next() ) { |
1496 | globalFlagBlockAgendaItemUpdate = 0; | 1496 | globalFlagBlockAgendaItemUpdate = 0; |
1497 | itemit->repaintMe(); | 1497 | itemit->repaintMe(); |
1498 | globalFlagBlockAgendaItemUpdate = 1; | 1498 | globalFlagBlockAgendaItemUpdate = 1; |
1499 | itemit->repaint(); | 1499 | itemit->repaint(); |
1500 | } | 1500 | } |
1501 | globalFlagBlockAgendaItemUpdate = 0; | 1501 | globalFlagBlockAgendaItemUpdate = 0; |
1502 | item->repaintMe(); | 1502 | item->repaintMe(); |
1503 | globalFlagBlockAgendaItemUpdate = 1; | 1503 | globalFlagBlockAgendaItemUpdate = 1; |
1504 | item->repaint(); | 1504 | item->repaint(); |
1505 | } | 1505 | } |
1506 | /* | 1506 | /* |
1507 | Insert KOAgendaItem into agenda. | 1507 | Insert KOAgendaItem into agenda. |
1508 | */ | 1508 | */ |
1509 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1509 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1510 | { | 1510 | { |
1511 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | 1511 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; |
1512 | 1512 | ||
1513 | if (mAllDayMode) { | 1513 | if (mAllDayMode) { |
1514 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1514 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; |
1515 | return 0; | 1515 | return 0; |
1516 | } | 1516 | } |
1517 | 1517 | ||
1518 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1518 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1519 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1519 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1520 | 1520 | ||
1521 | int YSize = YBottom - YTop + 1; | 1521 | int YSize = YBottom - YTop + 1; |
1522 | if (YSize < 0) { | 1522 | if (YSize < 0) { |
1523 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | 1523 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; |
1524 | YSize = 1; | 1524 | YSize = 1; |
1525 | } | 1525 | } |
1526 | int iheight = mGridSpacingY * YSize; | 1526 | int iheight = mGridSpacingY * YSize; |
1527 | 1527 | ||
1528 | agendaItem->resize(mGridSpacingX,iheight ); | 1528 | agendaItem->resize(mGridSpacingX,iheight ); |
1529 | agendaItem->setCellXY(X,YTop,YBottom); | 1529 | agendaItem->setCellXY(X,YTop,YBottom); |
1530 | agendaItem->setCellXWidth(X); | 1530 | agendaItem->setCellXWidth(X); |
1531 | 1531 | ||
1532 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1532 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1533 | mItems.append(agendaItem); | 1533 | mItems.append(agendaItem); |
1534 | 1534 | ||
1535 | placeSubCells(agendaItem); | 1535 | placeSubCells(agendaItem); |
1536 | 1536 | ||
1537 | //agendaItem->show(); | 1537 | //agendaItem->show(); |
1538 | 1538 | ||
1539 | marcus_bains(); | 1539 | marcus_bains(); |
1540 | 1540 | ||
1541 | return agendaItem; | 1541 | return agendaItem; |
1542 | } | 1542 | } |
1543 | 1543 | ||
1544 | 1544 | ||
1545 | /* | 1545 | /* |
1546 | Insert all-day KOAgendaItem into agenda. | 1546 | Insert all-day KOAgendaItem into agenda. |
1547 | */ | 1547 | */ |
1548 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1548 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1549 | { | 1549 | { |
1550 | if (!mAllDayMode) { | 1550 | if (!mAllDayMode) { |
1551 | return 0; | 1551 | return 0; |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1554 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1555 | 1555 | ||
1556 | agendaItem->setCellXY(XBegin,0,0); | 1556 | agendaItem->setCellXY(XBegin,0,0); |
1557 | agendaItem->setCellXWidth(XEnd); | 1557 | agendaItem->setCellXWidth(XEnd); |
1558 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1558 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1559 | 1559 | ||
1560 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1560 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1561 | mItems.append(agendaItem); | 1561 | mItems.append(agendaItem); |
1562 | 1562 | ||
1563 | placeSubCells(agendaItem); | 1563 | placeSubCells(agendaItem); |
1564 | 1564 | ||
1565 | //agendaItem->show(); | 1565 | //agendaItem->show(); |
1566 | 1566 | ||
1567 | return agendaItem; | 1567 | return agendaItem; |
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | 1570 | ||
1571 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1571 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1572 | int YTop,int YBottom) | 1572 | int YTop,int YBottom) |
1573 | { | 1573 | { |
1574 | if (mAllDayMode) { | 1574 | if (mAllDayMode) { |
1575 | ; | 1575 | ; |
1576 | return; | 1576 | return; |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | int cellX,cellYTop,cellYBottom; | 1579 | int cellX,cellYTop,cellYBottom; |
1580 | QString newtext; | 1580 | QString newtext; |
1581 | int width = XEnd - XBegin + 1; | 1581 | int width = XEnd - XBegin + 1; |
1582 | int count = 0; | 1582 | int count = 0; |
1583 | KOAgendaItem *current = 0; | 1583 | KOAgendaItem *current = 0; |
1584 | QPtrList<KOAgendaItem> multiItems; | 1584 | QPtrList<KOAgendaItem> multiItems; |
1585 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1585 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1586 | if (cellX == XBegin) cellYTop = YTop; | 1586 | if (cellX == XBegin) cellYTop = YTop; |
1587 | else cellYTop = 0; | 1587 | else cellYTop = 0; |
1588 | if (cellX == XEnd) cellYBottom = YBottom; | 1588 | if (cellX == XEnd) cellYBottom = YBottom; |
1589 | else cellYBottom = rows() - 1; | 1589 | else cellYBottom = rows() - 1; |
1590 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1590 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1591 | newtext.append(event->summary()); | 1591 | newtext.append(event->summary()); |
1592 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1592 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1593 | current->setText(newtext); | 1593 | current->setText(newtext); |
1594 | multiItems.append(current); | 1594 | multiItems.append(current); |
1595 | } | 1595 | } |
1596 | 1596 | ||
1597 | KOAgendaItem *next = 0; | 1597 | KOAgendaItem *next = 0; |
1598 | KOAgendaItem *last = multiItems.last(); | 1598 | KOAgendaItem *last = multiItems.last(); |
1599 | KOAgendaItem *first = multiItems.first(); | 1599 | KOAgendaItem *first = multiItems.first(); |
1600 | KOAgendaItem *setFirst,*setLast; | 1600 | KOAgendaItem *setFirst,*setLast; |
1601 | current = first; | 1601 | current = first; |
1602 | while (current) { | 1602 | while (current) { |
1603 | next = multiItems.next(); | 1603 | next = multiItems.next(); |
1604 | if (current == first) setFirst = 0; | 1604 | if (current == first) setFirst = 0; |
1605 | else setFirst = first; | 1605 | else setFirst = first; |
1606 | if (current == last) setLast = 0; | 1606 | if (current == last) setLast = 0; |
1607 | else setLast = last; | 1607 | else setLast = last; |
1608 | 1608 | ||
1609 | current->setMultiItem(setFirst,next,setLast); | 1609 | current->setMultiItem(setFirst,next,setLast); |
1610 | current = next; | 1610 | current = next; |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | marcus_bains(); | 1613 | marcus_bains(); |
1614 | } | 1614 | } |
1615 | 1615 | ||
1616 | 1616 | ||
1617 | //QSizePolicy KOAgenda::sizePolicy() const | 1617 | //QSizePolicy KOAgenda::sizePolicy() const |
1618 | //{ | 1618 | //{ |
1619 | // Thought this would make the all-day event agenda minimum size and the | 1619 | // Thought this would make the all-day event agenda minimum size and the |
1620 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1620 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1621 | // don´t seem to think that an Expanding widget needs more space than a | 1621 | // don´t seem to think that an Expanding widget needs more space than a |
1622 | // Preferred one. | 1622 | // Preferred one. |
1623 | // But it doesn´t hurt, so it stays. | 1623 | // But it doesn´t hurt, so it stays. |
1624 | // if (mAllDayMode) { | 1624 | // if (mAllDayMode) { |
1625 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1625 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1626 | // } else { | 1626 | // } else { |
1627 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1627 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1628 | // } | 1628 | // } |
1629 | //} | 1629 | //} |
1630 | void KOAgenda::finishResize ( ) | 1630 | void KOAgenda::finishResize ( ) |
1631 | { | 1631 | { |
1632 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1632 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1633 | if ( globalFlagBlockAgenda == 0 ) { | 1633 | if ( globalFlagBlockAgenda == 0 ) { |
1634 | finishUpdate(); | 1634 | finishUpdate(); |
1635 | //qDebug("finishUpdate() called "); | 1635 | //qDebug("finishUpdate() called "); |
1636 | } | 1636 | } |
1637 | } | 1637 | } |
1638 | /* | 1638 | /* |
1639 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1639 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1640 | */ | 1640 | */ |
1641 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1641 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1642 | { | 1642 | { |
1643 | 1643 | ||
1644 | mResizeTimer.start( 150 , true ); | 1644 | mResizeTimer.start( 150 , true ); |
1645 | computeSizes(); | 1645 | computeSizes(); |
1646 | return; | 1646 | return; |
1647 | 1647 | ||
1648 | } | 1648 | } |
1649 | void KOAgenda::computeSizes() | 1649 | void KOAgenda::computeSizes() |
1650 | { | 1650 | { |
1651 | if ( globalFlagBlockStartup ) | 1651 | if ( globalFlagBlockStartup ) |
1652 | return; | 1652 | return; |
1653 | 1653 | ||
1654 | if (mAllDayMode) { | 1654 | if (mAllDayMode) { |
1655 | mGridSpacingX = (width()-3) / mColumns; | 1655 | mGridSpacingX = (width()-3) / mColumns; |
1656 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1656 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1657 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1657 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1658 | // mGridSpacingY = height(); | 1658 | // mGridSpacingY = height(); |
1659 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1659 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1660 | 1660 | ||
1661 | KOAgendaItem *item; | 1661 | KOAgendaItem *item; |
1662 | int subCellWidth; | 1662 | int subCellWidth; |
1663 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1663 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1664 | subCellWidth = mGridSpacingY / item->subCells(); | 1664 | subCellWidth = mGridSpacingY / item->subCells(); |
1665 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1665 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1666 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1666 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1667 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1667 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1668 | item->cellX() * mGridSpacingX, | 1668 | item->cellX() * mGridSpacingX, |
1669 | item->subCell() * subCellWidth); | 1669 | item->subCell() * subCellWidth); |
1670 | } | 1670 | } |
1671 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1671 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1672 | } else { | 1672 | } else { |
1673 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; | 1673 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; |
1674 | if (height() > mGridSpacingY * mRows + 1 ) { | 1674 | if (height() > mGridSpacingY * mRows + 1 ) { |
1675 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1675 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1676 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1676 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1677 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1677 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1678 | emit resizedSignal(); | 1678 | emit resizedSignal(); |
1679 | } else | 1679 | } else |
1680 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1680 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1681 | KOAgendaItem *item; | 1681 | KOAgendaItem *item; |
1682 | int subCellWidth; | 1682 | int subCellWidth; |
1683 | 1683 | ||
1684 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1684 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1685 | subCellWidth = mGridSpacingX / item->subCells(); | 1685 | subCellWidth = mGridSpacingX / item->subCells(); |
1686 | item->resize(subCellWidth,item->height()); | 1686 | item->resize(subCellWidth,item->height()); |
1687 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1687 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1688 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1688 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1689 | item->cellX() * mGridSpacingX) + | 1689 | item->cellX() * mGridSpacingX) + |
1690 | item->subCell() * subCellWidth,childY(item)); | 1690 | item->subCell() * subCellWidth,childY(item)); |
1691 | } | 1691 | } |
1692 | } | 1692 | } |
1693 | int cw = contentsWidth(); | 1693 | int cw = contentsWidth(); |
1694 | int ch = contentsHeight(); | 1694 | int ch = contentsHeight(); |
1695 | if ( mAllDayMode ) { | 1695 | if ( mAllDayMode ) { |
1696 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1696 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1697 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | 1697 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
1698 | paintPixAll->resize( cw, ch ); | 1698 | paintPixAll->resize( cw, ch ); |
1699 | } else { | 1699 | } else { |
1700 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1700 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1701 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1701 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
1702 | KOAgendaItem::resizePixmap( cw , ch ); | 1702 | KOAgendaItem::resizePixmap( cw , ch ); |
1703 | } | 1703 | } |
1704 | 1704 | ||
1705 | checkScrollBoundaries(); | 1705 | checkScrollBoundaries(); |
1706 | marcus_bains(); | 1706 | marcus_bains(); |
1707 | drawContentsToPainter(); | 1707 | drawContentsToPainter(); |
1708 | viewport()->repaint(false); | 1708 | viewport()->repaint(false); |
1709 | } | 1709 | } |
1710 | 1710 | ||
1711 | void KOAgenda::scrollUp() | 1711 | void KOAgenda::scrollUp() |
1712 | { | 1712 | { |
1713 | scrollBy(0,-mScrollOffset); | 1713 | scrollBy(0,-mScrollOffset); |
1714 | } | 1714 | } |
1715 | 1715 | ||
1716 | 1716 | ||
1717 | void KOAgenda::scrollDown() | 1717 | void KOAgenda::scrollDown() |
1718 | { | 1718 | { |
1719 | scrollBy(0,mScrollOffset); | 1719 | scrollBy(0,mScrollOffset); |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | void KOAgenda::popupAlarm() | 1722 | void KOAgenda::popupAlarm() |
1723 | { | 1723 | { |
1724 | if (!mClickedItem) { | 1724 | if (!mClickedItem) { |
1725 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1725 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1726 | return; | 1726 | return; |
1727 | } | 1727 | } |
1728 | // TODO: deal correctly with multiple alarms | 1728 | // TODO: deal correctly with multiple alarms |
1729 | Alarm* alarm; | 1729 | Alarm* alarm; |
1730 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1730 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1731 | for(alarm=list.first();alarm;alarm=list.next()) { | 1731 | for(alarm=list.first();alarm;alarm=list.next()) { |
1732 | alarm->toggleAlarm(); | 1732 | alarm->toggleAlarm(); |
1733 | } | 1733 | } |
1734 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1734 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1735 | mClickedItem->paintMe( true ); | 1735 | mClickedItem->paintMe( true ); |
1736 | mClickedItem->repaint( false ); | 1736 | mClickedItem->repaint( false ); |
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | /* | 1739 | /* |
1740 | Calculates the minimum width | 1740 | Calculates the minimum width |
1741 | */ | 1741 | */ |
1742 | int KOAgenda::minimumWidth() const | 1742 | int KOAgenda::minimumWidth() const |
1743 | { | 1743 | { |
1744 | // TODO:: develop a way to dynamically determine the minimum width | 1744 | // TODO:: develop a way to dynamically determine the minimum width |
1745 | int min = 100; | 1745 | int min = 100; |
1746 | 1746 | ||
1747 | return min; | 1747 | return min; |
1748 | } | 1748 | } |
1749 | 1749 | ||
1750 | void KOAgenda::updateConfig() | 1750 | void KOAgenda::updateConfig() |
1751 | { | 1751 | { |
1752 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1752 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1753 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1753 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1754 | if ( mAllDayMode ) { | 1754 | if ( mAllDayMode ) { |
1755 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1755 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1756 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1756 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1757 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1757 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1758 | // setMaximumHeight( mGridSpacingY+1 ); | 1758 | // setMaximumHeight( mGridSpacingY+1 ); |
1759 | viewport()->repaint( false ); | 1759 | viewport()->repaint( false ); |
1760 | //setFixedHeight( mGridSpacingY+1 ); | 1760 | //setFixedHeight( mGridSpacingY+1 ); |
1761 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1761 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1762 | } | 1762 | } |
1763 | else { | 1763 | else { |
1764 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1764 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1765 | calculateWorkingHours(); | 1765 | calculateWorkingHours(); |
1766 | marcus_bains(); | 1766 | marcus_bains(); |
1767 | } | 1767 | } |
1768 | } | 1768 | } |
1769 | 1769 | ||
1770 | void KOAgenda::checkScrollBoundaries() | 1770 | void KOAgenda::checkScrollBoundaries() |
1771 | { | 1771 | { |
1772 | // Invalidate old values to force update | 1772 | // Invalidate old values to force update |
1773 | mOldLowerScrollValue = -1; | 1773 | mOldLowerScrollValue = -1; |
1774 | mOldUpperScrollValue = -1; | 1774 | mOldUpperScrollValue = -1; |
1775 | 1775 | ||
1776 | checkScrollBoundaries(verticalScrollBar()->value()); | 1776 | checkScrollBoundaries(verticalScrollBar()->value()); |
1777 | } | 1777 | } |
1778 | 1778 | ||
1779 | void KOAgenda::checkScrollBoundaries(int v) | 1779 | void KOAgenda::checkScrollBoundaries(int v) |
1780 | { | 1780 | { |
1781 | if ( mGridSpacingY == 0 ) | 1781 | if ( mGridSpacingY == 0 ) |
1782 | return; | 1782 | return; |
1783 | int yMin = v/mGridSpacingY; | 1783 | int yMin = v/mGridSpacingY; |
1784 | int yMax = (v+visibleHeight())/mGridSpacingY; | 1784 | int yMax = (v+visibleHeight())/mGridSpacingY; |
1785 | 1785 | ||
1786 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 1786 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
1787 | 1787 | ||
1788 | if (yMin != mOldLowerScrollValue) { | 1788 | if (yMin != mOldLowerScrollValue) { |
1789 | mOldLowerScrollValue = yMin; | 1789 | mOldLowerScrollValue = yMin; |
1790 | emit lowerYChanged(yMin); | 1790 | emit lowerYChanged(yMin); |
1791 | } | 1791 | } |
1792 | if (yMax != mOldUpperScrollValue) { | 1792 | if (yMax != mOldUpperScrollValue) { |
1793 | mOldUpperScrollValue = yMax; | 1793 | mOldUpperScrollValue = yMax; |
1794 | emit upperYChanged(yMax); | 1794 | emit upperYChanged(yMax); |
1795 | } | 1795 | } |
1796 | } | 1796 | } |
1797 | 1797 | ||
1798 | void KOAgenda::deselectItem() | 1798 | void KOAgenda::deselectItem() |
1799 | { | 1799 | { |
1800 | if (mSelectedItem.isNull()) return; | 1800 | if (mSelectedItem.isNull()) return; |
1801 | mSelectedItem->select(false); | 1801 | mSelectedItem->select(false); |
1802 | mSelectedItem = 0; | 1802 | mSelectedItem = 0; |
1803 | } | 1803 | } |
1804 | 1804 | ||
1805 | void KOAgenda::selectItem(KOAgendaItem *item) | 1805 | void KOAgenda::selectItem(KOAgendaItem *item) |
1806 | { | 1806 | { |
1807 | if ((KOAgendaItem *)mSelectedItem == item) return; | 1807 | if ((KOAgendaItem *)mSelectedItem == item) return; |
1808 | deselectItem(); | 1808 | deselectItem(); |
1809 | if (item == 0) { | 1809 | if (item == 0) { |
1810 | emit incidenceSelected( 0 ); | 1810 | emit incidenceSelected( 0 ); |
1811 | return; | 1811 | return; |
1812 | } | 1812 | } |
1813 | mSelectedItem = item; | 1813 | mSelectedItem = item; |
1814 | mSelectedItem->select(); | 1814 | mSelectedItem->select(); |
1815 | emit incidenceSelected( mSelectedItem->incidence() ); | 1815 | emit incidenceSelected( mSelectedItem->incidence() ); |
1816 | } | 1816 | } |
1817 | 1817 | ||
1818 | // This function seems never be called. | 1818 | // This function seems never be called. |
1819 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 1819 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
1820 | { | 1820 | { |
1821 | switch(kev->key()) { | 1821 | switch(kev->key()) { |
1822 | case Key_PageDown: | 1822 | case Key_PageDown: |
1823 | verticalScrollBar()->addPage(); | 1823 | verticalScrollBar()->addPage(); |
1824 | break; | 1824 | break; |
1825 | case Key_PageUp: | 1825 | case Key_PageUp: |
1826 | verticalScrollBar()->subtractPage(); | 1826 | verticalScrollBar()->subtractPage(); |
1827 | break; | 1827 | break; |
1828 | case Key_Down: | 1828 | case Key_Down: |
1829 | verticalScrollBar()->addLine(); | 1829 | verticalScrollBar()->addLine(); |
1830 | break; | 1830 | break; |
1831 | case Key_Up: | 1831 | case Key_Up: |
1832 | verticalScrollBar()->subtractLine(); | 1832 | verticalScrollBar()->subtractLine(); |
1833 | break; | 1833 | break; |
1834 | default: | 1834 | default: |
1835 | ; | 1835 | ; |
1836 | } | 1836 | } |
1837 | } | 1837 | } |
1838 | 1838 | ||
1839 | void KOAgenda::calculateWorkingHours() | 1839 | void KOAgenda::calculateWorkingHours() |
1840 | { | 1840 | { |
1841 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 1841 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
1842 | mWorkingHoursEnable = !mAllDayMode; | 1842 | mWorkingHoursEnable = !mAllDayMode; |
1843 | 1843 | ||
1844 | mWorkingHoursYTop = mGridSpacingY * | 1844 | mWorkingHoursYTop = mGridSpacingY * |
1845 | KOPrefs::instance()->mWorkingHoursStart * 4; | 1845 | KOPrefs::instance()->mWorkingHoursStart * 4; |
1846 | mWorkingHoursYBottom = mGridSpacingY * | 1846 | mWorkingHoursYBottom = mGridSpacingY * |
1847 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 1847 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
1848 | } | 1848 | } |
1849 | 1849 | ||
1850 | 1850 | ||
1851 | DateList KOAgenda::dateList() const | 1851 | DateList KOAgenda::dateList() const |
1852 | { | 1852 | { |
1853 | return mSelectedDates; | 1853 | return mSelectedDates; |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | void KOAgenda::setDateList(const DateList &selectedDates) | 1856 | void KOAgenda::setDateList(const DateList &selectedDates) |
1857 | { | 1857 | { |
1858 | mSelectedDates = selectedDates; | 1858 | mSelectedDates = selectedDates; |
1859 | marcus_bains(); | 1859 | marcus_bains(); |
1860 | } | 1860 | } |
1861 | 1861 | ||
1862 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 1862 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
1863 | { | 1863 | { |
1864 | mHolidayMask = mask; | 1864 | mHolidayMask = mask; |
1865 | 1865 | ||
1866 | /* | 1866 | /* |
1867 | kdDebug() << "HolidayMask: "; | 1867 | kdDebug() << "HolidayMask: "; |
1868 | for(uint i=0;i<mask->count();++i) { | 1868 | for(uint i=0;i<mask->count();++i) { |
1869 | kdDebug() << (mask->at(i) ? "*" : "o"); | 1869 | kdDebug() << (mask->at(i) ? "*" : "o"); |
1870 | } | 1870 | } |
1871 | kdDebug() << endl; | 1871 | kdDebug() << endl; |
1872 | */ | 1872 | */ |
1873 | } | 1873 | } |
1874 | 1874 | ||
1875 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 1875 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
1876 | { | 1876 | { |
1877 | 1877 | ||
1878 | QScrollView::contentsMousePressEvent(event); | 1878 | QScrollView::contentsMousePressEvent(event); |
1879 | } | 1879 | } |
1880 | 1880 | ||
1881 | void KOAgenda::storePosition() | 1881 | void KOAgenda::storePosition() |
1882 | { | 1882 | { |
1883 | //mContentPosition | 1883 | //mContentPosition |
1884 | int max = mGridSpacingY*4*24; | 1884 | int max = mGridSpacingY*4*24; |
1885 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 1885 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
1886 | mContentPosition = 0; | 1886 | mContentPosition = 0; |
1887 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 1887 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
1888 | mContentPosition = -1.0; | 1888 | mContentPosition = -1.0; |
1889 | else | 1889 | else |
1890 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 1890 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
1891 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 1891 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
1892 | 1892 | ||
1893 | } | 1893 | } |
1894 | void KOAgenda::restorePosition() | 1894 | void KOAgenda::restorePosition() |
1895 | { | 1895 | { |
1896 | int posY; | 1896 | int posY; |
1897 | int max = mGridSpacingY*4*24; | 1897 | int max = mGridSpacingY*4*24; |
1898 | if ( mContentPosition < 0 ) | 1898 | if ( mContentPosition < 0 ) |
1899 | posY = max-viewport()->height(); | 1899 | posY = max-viewport()->height(); |
1900 | else | 1900 | else |
1901 | if ( mContentPosition == 0 ) | 1901 | if ( mContentPosition == 0 ) |
1902 | posY = 0; | 1902 | posY = 0; |
1903 | else | 1903 | else |
1904 | posY = (max/mContentPosition)-(viewport()->height()/2); | 1904 | posY = (max/mContentPosition)-(viewport()->height()/2); |
1905 | setContentsPos (0, posY ); | 1905 | setContentsPos (0, posY ); |
1906 | //qDebug("posY %d hei %d", posY, max); | 1906 | //qDebug("posY %d hei %d", posY, max); |
1907 | 1907 | ||
1908 | } | 1908 | } |
1909 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 1909 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
1910 | { | 1910 | { |
1911 | ++x; | 1911 | ++x; |
1912 | QScrollView::moveChild( w, x , y ); | 1912 | QScrollView::moveChild( w, x , y ); |
1913 | } | 1913 | } |
1914 | #include <qmessagebox.h> | 1914 | #include <qmessagebox.h> |
1915 | #ifdef DESKTOP_VERSION | 1915 | #ifdef DESKTOP_VERSION |
1916 | #include <qprinter.h> | 1916 | #include <qprinter.h> |
1917 | #include <qpainter.h> | 1917 | #include <qpainter.h> |
1918 | #include <qpaintdevicemetrics.h> | 1918 | #include <qpaintdevicemetrics.h> |
1919 | 1919 | ||
1920 | #endif | 1920 | #endif |
1921 | void KOAgenda::printSelection() | 1921 | void KOAgenda::printSelection() |
1922 | { | 1922 | { |
1923 | #ifdef DESKTOP_VERSION | 1923 | #ifdef DESKTOP_VERSION |
1924 | if ( mStartCellY == mCurrentCellY ) { | 1924 | if ( mStartCellY == mCurrentCellY ) { |
1925 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1925 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1926 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 1926 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
1927 | i18n("OK"), 0, 0, | 1927 | i18n("OK"), 0, 0, |
1928 | 0, 1 ); | 1928 | 0, 1 ); |
1929 | return; | 1929 | return; |
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | float dx, dy; | 1932 | float dx, dy; |
1933 | int x,y,w,h; | 1933 | int x,y,w,h; |
1934 | x= 0; | 1934 | x= 0; |
1935 | w= contentsWidth()+2; | 1935 | w= contentsWidth()+2; |
1936 | // h= contentsHeight(); | 1936 | // h= contentsHeight(); |
1937 | y = mGridSpacingY*mStartCellY; | 1937 | y = mGridSpacingY*mStartCellY; |
1938 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 1938 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
1939 | 1939 | ||
1940 | //return; | 1940 | //return; |
1941 | QPrinter* printer = new QPrinter(); | 1941 | QPrinter* printer = new QPrinter(); |
1942 | if ( !printer->setup()) { | 1942 | if ( !printer->setup()) { |
1943 | delete printer; | 1943 | delete printer; |
1944 | return; | 1944 | return; |
1945 | } | 1945 | } |
1946 | QPainter p( printer ); | 1946 | QPainter p( printer ); |
1947 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 1947 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
1948 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 1948 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
1949 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 1949 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
1950 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 1950 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
1951 | // p.drawText( 0, 0, date ); | 1951 | // p.drawText( 0, 0, date ); |
1952 | int offset = m.width()/8; | 1952 | int offset = m.width()/8; |
1953 | // compute the scale | 1953 | // compute the scale |
1954 | dx = ((float) m.width()-offset) / (float)w; | 1954 | dx = ((float) m.width()-offset) / (float)w; |
1955 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 1955 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
1956 | float scale; | 1956 | float scale; |
1957 | // scale to fit the width or height of the paper | 1957 | // scale to fit the width or height of the paper |
1958 | if ( dx < dy ) | 1958 | if ( dx < dy ) |
1959 | scale = dx; | 1959 | scale = dx; |
1960 | else | 1960 | else |
1961 | scale = dy; | 1961 | scale = dy; |
1962 | // set the scale | 1962 | // set the scale |
1963 | p.drawText( offset* scale, offset* scale*3/4, date ); | 1963 | p.drawText( offset* scale, offset* scale*3/4, date ); |
1964 | 1964 | ||
1965 | int selDay; | 1965 | int selDay; |
1966 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 1966 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
1967 | float startX = 1; | 1967 | float startX = 1; |
1968 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1968 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1969 | { | 1969 | { |
1970 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 1970 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
1971 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 1971 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
1972 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 1972 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
1973 | startX += widOffset; | 1973 | startX += widOffset; |
1974 | 1974 | ||
1975 | } | 1975 | } |
1976 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 1976 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
1977 | p.scale( scale, scale ); | 1977 | p.scale( scale, scale ); |
1978 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 1978 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
1979 | // now printing with y offset: 2 hei | 1979 | // now printing with y offset: 2 hei |
1980 | // p.translate( 0, -y*scale); | 1980 | // p.translate( 0, -y*scale); |
1981 | 1981 | ||
1982 | drawContentsToPainter(&p, true ); | 1982 | drawContentsToPainter(&p, true ); |
1983 | globalFlagBlockAgendaItemUpdate = false; | 1983 | globalFlagBlockAgendaItemUpdate = false; |
1984 | KOAgendaItem *item; | 1984 | KOAgendaItem *item; |
1985 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1985 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1986 | item->select(false); | 1986 | item->select(false); |
1987 | item->paintMe( false, &p ); | 1987 | item->paintMe( false, &p ); |
1988 | } | 1988 | } |
1989 | globalFlagBlockAgendaItemUpdate = true; | 1989 | globalFlagBlockAgendaItemUpdate = true; |
1990 | p.end(); | 1990 | p.end(); |
1991 | delete printer; | 1991 | delete printer; |
1992 | #else | 1992 | #else |
1993 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1993 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1994 | i18n("Not supported \non PDA!\n"), | 1994 | i18n("Not supported \non PDA!\n"), |
1995 | i18n("OK"), 0, 0, | 1995 | i18n("OK"), 0, 0, |
1996 | 0, 1 ); | 1996 | 0, 1 ); |
1997 | #endif | 1997 | #endif |
1998 | } | 1998 | } |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 42a6f7c..8b79788 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -742,808 +742,807 @@ void KOAgendaView::createDayLabels() | |||
742 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 742 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
743 | addString = i18n("Day after tomorrow"); | 743 | addString = i18n("Day after tomorrow"); |
744 | if ( !addString.isEmpty() ) { | 744 | if ( !addString.isEmpty() ) { |
745 | str = addString+", " + str; | 745 | str = addString+", " + str; |
746 | } | 746 | } |
747 | } | 747 | } |
748 | dayLabel->setText(str); | 748 | dayLabel->setText(str); |
749 | dayLabel->setAlignment(QLabel::AlignHCenter); | 749 | dayLabel->setAlignment(QLabel::AlignHCenter); |
750 | if (date == QDate::currentDate()) { | 750 | if (date == QDate::currentDate()) { |
751 | QFont bFont = dlf; | 751 | QFont bFont = dlf; |
752 | bFont.setBold( true ); | 752 | bFont.setBold( true ); |
753 | dayLabel->setFont(bFont); | 753 | dayLabel->setFont(bFont); |
754 | } | 754 | } |
755 | //dayLayout->addWidget(dayLabel); | 755 | //dayLayout->addWidget(dayLabel); |
756 | 756 | ||
757 | #ifndef KORG_NOPLUGINS | 757 | #ifndef KORG_NOPLUGINS |
758 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 758 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
759 | CalendarDecoration *it; | 759 | CalendarDecoration *it; |
760 | for(it = cds.first(); it; it = cds.next()) { | 760 | for(it = cds.first(); it; it = cds.next()) { |
761 | QString text = it->shortText( date ); | 761 | QString text = it->shortText( date ); |
762 | if ( !text.isEmpty() ) { | 762 | if ( !text.isEmpty() ) { |
763 | QLabel *label = new QLabel(text,mDayLabels); | 763 | QLabel *label = new QLabel(text,mDayLabels); |
764 | label->setAlignment(AlignCenter); | 764 | label->setAlignment(AlignCenter); |
765 | dayLayout->addWidget(label); | 765 | dayLayout->addWidget(label); |
766 | } | 766 | } |
767 | } | 767 | } |
768 | 768 | ||
769 | for(it = cds.first(); it; it = cds.next()) { | 769 | for(it = cds.first(); it; it = cds.next()) { |
770 | QWidget *wid = it->smallWidget(mDayLabels,date); | 770 | QWidget *wid = it->smallWidget(mDayLabels,date); |
771 | if ( wid ) { | 771 | if ( wid ) { |
772 | // wid->setHeight(20); | 772 | // wid->setHeight(20); |
773 | dayLayout->addWidget(wid); | 773 | dayLayout->addWidget(wid); |
774 | } | 774 | } |
775 | } | 775 | } |
776 | #endif | 776 | #endif |
777 | } | 777 | } |
778 | if ( ! appendLabels ) { | 778 | if ( ! appendLabels ) { |
779 | dayLabel = mDayLabelsList.next(); | 779 | dayLabel = mDayLabelsList.next(); |
780 | if ( !dayLabel ) | 780 | if ( !dayLabel ) |
781 | appendLabels = true; | 781 | appendLabels = true; |
782 | } | 782 | } |
783 | if ( appendLabels ) { | 783 | if ( appendLabels ) { |
784 | dayLabel = new QLabel(mDayLabels); | 784 | dayLabel = new QLabel(mDayLabels); |
785 | mDayLabelsList.append( dayLabel ); | 785 | mDayLabelsList.append( dayLabel ); |
786 | mLayoutDayLabels->addWidget(dayLabel); | 786 | mLayoutDayLabels->addWidget(dayLabel); |
787 | } | 787 | } |
788 | //dayLabel->hide();//test only | 788 | //dayLabel->hide();//test only |
789 | 789 | ||
790 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 790 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
791 | if ( offset < 0 ) offset = 0; | 791 | if ( offset < 0 ) offset = 0; |
792 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 792 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
793 | dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); | 793 | dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); |
794 | dayLabel->show(); | 794 | dayLabel->show(); |
795 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 795 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
796 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 796 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
797 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 797 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
798 | if ( !appendLabels ) { | 798 | if ( !appendLabels ) { |
799 | dayLabel = mDayLabelsList.next(); | 799 | dayLabel = mDayLabelsList.next(); |
800 | while ( dayLabel ) { | 800 | while ( dayLabel ) { |
801 | //qDebug("!dayLabel %d",dayLabel ); | 801 | //qDebug("!dayLabel %d",dayLabel ); |
802 | dayLabel->hide(); | 802 | dayLabel->hide(); |
803 | dayLabel = mDayLabelsList.next(); | 803 | dayLabel = mDayLabelsList.next(); |
804 | } | 804 | } |
805 | } | 805 | } |
806 | //mDayLabelsFrame->show(); | 806 | //mDayLabelsFrame->show(); |
807 | //mDayLabels->show(); | 807 | //mDayLabels->show(); |
808 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 808 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
809 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 809 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
810 | mDayLabelsFrame->setFixedHeight( newHight ); | 810 | mDayLabelsFrame->setFixedHeight( newHight ); |
811 | } | 811 | } |
812 | 812 | ||
813 | int KOAgendaView::maxDatesHint() | 813 | int KOAgendaView::maxDatesHint() |
814 | { | 814 | { |
815 | // Not sure about the max number of events, so return 0 for now. | 815 | // Not sure about the max number of events, so return 0 for now. |
816 | return 0; | 816 | return 0; |
817 | } | 817 | } |
818 | 818 | ||
819 | int KOAgendaView::currentDateCount() | 819 | int KOAgendaView::currentDateCount() |
820 | { | 820 | { |
821 | return mSelectedDates.count(); | 821 | return mSelectedDates.count(); |
822 | } | 822 | } |
823 | 823 | ||
824 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 824 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
825 | { | 825 | { |
826 | QPtrList<Incidence> selected; | 826 | QPtrList<Incidence> selected; |
827 | Incidence *incidence; | 827 | Incidence *incidence; |
828 | 828 | ||
829 | incidence = mAgenda->selectedIncidence(); | 829 | incidence = mAgenda->selectedIncidence(); |
830 | if (incidence) selected.append(incidence); | 830 | if (incidence) selected.append(incidence); |
831 | 831 | ||
832 | incidence = mAllDayAgenda->selectedIncidence(); | 832 | incidence = mAllDayAgenda->selectedIncidence(); |
833 | if (incidence) selected.append(incidence); | 833 | if (incidence) selected.append(incidence); |
834 | 834 | ||
835 | return selected; | 835 | return selected; |
836 | } | 836 | } |
837 | 837 | ||
838 | DateList KOAgendaView::selectedDates() | 838 | DateList KOAgendaView::selectedDates() |
839 | { | 839 | { |
840 | DateList selected; | 840 | DateList selected; |
841 | QDate qd; | 841 | QDate qd; |
842 | 842 | ||
843 | qd = mAgenda->selectedIncidenceDate(); | 843 | qd = mAgenda->selectedIncidenceDate(); |
844 | if (qd.isValid()) selected.append(qd); | 844 | if (qd.isValid()) selected.append(qd); |
845 | 845 | ||
846 | qd = mAllDayAgenda->selectedIncidenceDate(); | 846 | qd = mAllDayAgenda->selectedIncidenceDate(); |
847 | if (qd.isValid()) selected.append(qd); | 847 | if (qd.isValid()) selected.append(qd); |
848 | 848 | ||
849 | return selected; | 849 | return selected; |
850 | } | 850 | } |
851 | 851 | ||
852 | 852 | ||
853 | void KOAgendaView::updateView() | 853 | void KOAgendaView::updateView() |
854 | { | 854 | { |
855 | if ( mBlockUpdating ) | 855 | if ( mBlockUpdating ) |
856 | return; | 856 | return; |
857 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 857 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
858 | fillAgenda(); | 858 | fillAgenda(); |
859 | 859 | ||
860 | } | 860 | } |
861 | 861 | ||
862 | 862 | ||
863 | /* | 863 | /* |
864 | Update configuration settings for the agenda view. This method is not | 864 | Update configuration settings for the agenda view. This method is not |
865 | complete. | 865 | complete. |
866 | */ | 866 | */ |
867 | void KOAgendaView::updateConfig() | 867 | void KOAgendaView::updateConfig() |
868 | { | 868 | { |
869 | if ( mBlockUpdating ) | 869 | if ( mBlockUpdating ) |
870 | return; | 870 | return; |
871 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; | 871 | // kdDebug() << "KOAgendaView::updateConfig()" << endl; |
872 | 872 | ||
873 | // update config for children | 873 | // update config for children |
874 | mTimeLabels->updateConfig(); | 874 | mTimeLabels->updateConfig(); |
875 | mAgenda->storePosition(); | 875 | mAgenda->storePosition(); |
876 | mAgenda->updateConfig(); | 876 | mAgenda->updateConfig(); |
877 | mAllDayAgenda->updateConfig(); | 877 | mAllDayAgenda->updateConfig(); |
878 | // widget synchronization | 878 | // widget synchronization |
879 | //TODO: find a better way, maybe signal/slot | 879 | //TODO: find a better way, maybe signal/slot |
880 | mTimeLabels->positionChanged(); | 880 | mTimeLabels->positionChanged(); |
881 | 881 | ||
882 | // for some reason, this needs to be called explicitly | 882 | // for some reason, this needs to be called explicitly |
883 | mTimeLabels->repaint(); | 883 | mTimeLabels->repaint(); |
884 | 884 | ||
885 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 885 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
886 | 886 | ||
887 | // ToolTips displaying summary of events | 887 | // ToolTips displaying summary of events |
888 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 888 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
889 | ->mEnableToolTips); | 889 | ->mEnableToolTips); |
890 | 890 | ||
891 | //setHolidayMasks(); | 891 | //setHolidayMasks(); |
892 | 892 | ||
893 | //createDayLabels(); called by via updateView(); | 893 | //createDayLabels(); called by via updateView(); |
894 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 894 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
895 | updateView(); | 895 | updateView(); |
896 | mAgenda->restorePosition(); | 896 | mAgenda->restorePosition(); |
897 | } | 897 | } |
898 | 898 | ||
899 | 899 | ||
900 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 900 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
901 | { | 901 | { |
902 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 902 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
903 | //qDebug("KOAgendaView::updateEventDates "); | 903 | //qDebug("KOAgendaView::updateEventDates "); |
904 | QDateTime startDt,endDt; | 904 | QDateTime startDt,endDt; |
905 | QDate startDate; | 905 | QDate startDate; |
906 | int lenInSecs; | 906 | int lenInSecs; |
907 | // if ( type == KOAgenda::RESIZETOP ) | 907 | // if ( type == KOAgenda::RESIZETOP ) |
908 | // qDebug("RESIZETOP "); | 908 | // qDebug("RESIZETOP "); |
909 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 909 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
910 | // qDebug("RESIZEBOTTOM "); | 910 | // qDebug("RESIZEBOTTOM "); |
911 | // if ( type == KOAgenda::MOVE ) | 911 | // if ( type == KOAgenda::MOVE ) |
912 | // qDebug("MOVE "); | 912 | // qDebug("MOVE "); |
913 | if ( item->incidence()->type() == "Event" ) { | 913 | if ( item->incidence()->type() == "Event" ) { |
914 | startDt =item->incidence()->dtStart(); | 914 | startDt =item->incidence()->dtStart(); |
915 | endDt = item->incidence()->dtEnd(); | 915 | endDt = item->incidence()->dtEnd(); |
916 | lenInSecs = startDt.secsTo( endDt ); | 916 | lenInSecs = startDt.secsTo( endDt ); |
917 | } | 917 | } |
918 | 918 | ||
919 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 919 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
920 | 920 | ||
921 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 921 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
922 | startDate = mSelectedDates[item->mLastMoveXPos]; | 922 | startDate = mSelectedDates[item->mLastMoveXPos]; |
923 | } else { | 923 | } else { |
924 | if (item->cellX() < 0) { | 924 | if (item->cellX() < 0) { |
925 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 925 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
926 | } else { | 926 | } else { |
927 | startDate = mSelectedDates[item->cellX()]; | 927 | startDate = mSelectedDates[item->cellX()]; |
928 | } | 928 | } |
929 | } | 929 | } |
930 | startDt.setDate(startDate); | 930 | startDt.setDate(startDate); |
931 | 931 | ||
932 | if (item->incidence()->doesFloat()) { | 932 | if (item->incidence()->doesFloat()) { |
933 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 933 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
934 | } else { | 934 | } else { |
935 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 935 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
936 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 936 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
937 | if ( item->incidence()->type() == "Event" ) { | 937 | if ( item->incidence()->type() == "Event" ) { |
938 | if ( type == KOAgenda::MOVE ) { | 938 | if ( type == KOAgenda::MOVE ) { |
939 | endDt = startDt.addSecs(lenInSecs); | 939 | endDt = startDt.addSecs(lenInSecs); |
940 | 940 | ||
941 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 941 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
942 | if (item->lastMultiItem()) { | 942 | if (item->lastMultiItem()) { |
943 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 943 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
944 | endDt.setDate(startDate. | 944 | endDt.setDate(startDate. |
945 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 945 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
946 | } else { | 946 | } else { |
947 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 947 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
948 | endDt.setDate(startDate); | 948 | endDt.setDate(startDate); |
949 | } | 949 | } |
950 | } | 950 | } |
951 | } else { | 951 | } else { |
952 | // todo | 952 | // todo |
953 | qDebug("tooooodoooooo "); | 953 | qDebug("tooooodoooooo "); |
954 | if (item->lastMultiItem()) { | 954 | if (item->lastMultiItem()) { |
955 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 955 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
956 | endDt.setDate(startDate. | 956 | endDt.setDate(startDate. |
957 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 957 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
958 | } else { | 958 | } else { |
959 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 959 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
960 | if ( item->cellYBottom() > 0 ) | 960 | if ( item->cellYBottom() > 0 ) |
961 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 961 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
962 | else | 962 | else |
963 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 963 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
964 | endDt.setDate(startDate); | 964 | endDt.setDate(startDate); |
965 | } | 965 | } |
966 | } | 966 | } |
967 | } | 967 | } |
968 | 968 | ||
969 | qDebug("to888"); | 969 | qDebug("to888"); |
970 | if ( item->incidence()->type() == "Event" ) { | 970 | if ( item->incidence()->type() == "Event" ) { |
971 | item->incidence()->setDtStart(startDt); | 971 | item->incidence()->setDtStart(startDt); |
972 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 972 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
973 | } else if ( item->incidence()->type() == "Todo" ) { | 973 | } else if ( item->incidence()->type() == "Todo" ) { |
974 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 974 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); |
975 | } | 975 | } |
976 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 976 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
977 | item->incidence()->setRevision(item->incidence()->revision()+1); | 977 | item->incidence()->setRevision(item->incidence()->revision()+1); |
978 | item->setItemDate(startDt.date()); | 978 | item->setItemDate(startDt.date()); |
979 | //item->updateItem(); | 979 | //item->updateItem(); |
980 | if ( item->incidence()->type() == "Todo" ) { | 980 | if ( item->incidence()->type() == "Todo" ) { |
981 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 981 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
982 | 982 | ||
983 | } | 983 | } |
984 | else | 984 | else |
985 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 985 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
986 | item->updateItem(); | 986 | item->updateItem(); |
987 | } | 987 | } |
988 | 988 | ||
989 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 989 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
990 | { | 990 | { |
991 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 991 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
992 | 992 | ||
993 | mSelectedDates.clear(); | 993 | mSelectedDates.clear(); |
994 | // qDebug("KOAgendaView::showDates "); | 994 | // qDebug("KOAgendaView::showDates "); |
995 | QDate d = start; | 995 | QDate d = start; |
996 | while (d <= end) { | 996 | while (d <= end) { |
997 | mSelectedDates.append(d); | 997 | mSelectedDates.append(d); |
998 | d = d.addDays( 1 ); | 998 | d = d.addDays( 1 ); |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | // and update the view | 1001 | // and update the view |
1002 | fillAgenda(); | 1002 | fillAgenda(); |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | 1005 | ||
1006 | void KOAgendaView::showEvents(QPtrList<Event>) | 1006 | void KOAgendaView::showEvents(QPtrList<Event>) |
1007 | { | 1007 | { |
1008 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1008 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | void KOAgendaView::changeEventDisplay(Event *, int) | 1011 | void KOAgendaView::changeEventDisplay(Event *, int) |
1012 | { | 1012 | { |
1013 | // qDebug("KOAgendaView::changeEventDisplay "); | 1013 | // qDebug("KOAgendaView::changeEventDisplay "); |
1014 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1014 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1015 | // this should be re-written to be MUCH smarter. Right now we | 1015 | // this should be re-written to be MUCH smarter. Right now we |
1016 | // are just playing dumb. | 1016 | // are just playing dumb. |
1017 | fillAgenda(); | 1017 | fillAgenda(); |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | void KOAgendaView::fillAgenda(const QDate &) | 1020 | void KOAgendaView::fillAgenda(const QDate &) |
1021 | { | 1021 | { |
1022 | // qDebug("KOAgendaView::fillAgenda "); | 1022 | // qDebug("KOAgendaView::fillAgenda "); |
1023 | fillAgenda(); | 1023 | fillAgenda(); |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | void KOAgendaView::fillAgenda() | 1026 | void KOAgendaView::fillAgenda() |
1027 | { | 1027 | { |
1028 | if ( globalFlagBlockStartup ) | 1028 | if ( globalFlagBlockStartup ) |
1029 | return; | 1029 | return; |
1030 | if ( globalFlagBlockAgenda == 1 ) | 1030 | if ( globalFlagBlockAgenda == 1 ) |
1031 | return; | 1031 | return; |
1032 | //if ( globalFlagBlockAgenda == 2 ) | 1032 | //if ( globalFlagBlockAgenda == 2 ) |
1033 | //globalFlagBlockAgenda = 0; | 1033 | //globalFlagBlockAgenda = 0; |
1034 | // globalFlagBlockPainting = false; | 1034 | // globalFlagBlockPainting = false; |
1035 | if ( globalFlagBlockAgenda == 0 ) | 1035 | if ( globalFlagBlockAgenda == 0 ) |
1036 | globalFlagBlockAgenda = 1; | 1036 | globalFlagBlockAgenda = 1; |
1037 | // clearView(); | 1037 | // clearView(); |
1038 | //qDebug("fillAgenda()++++ "); | 1038 | //qDebug("fillAgenda()++++ "); |
1039 | globalFlagBlockAgendaItemPaint = 1; | 1039 | globalFlagBlockAgendaItemPaint = 1; |
1040 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1040 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1041 | mAgenda->changeColumns(mSelectedDates.count()); | 1041 | mAgenda->changeColumns(mSelectedDates.count()); |
1042 | qApp->processEvents(); | 1042 | qApp->processEvents(); |
1043 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1043 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1044 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1044 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1045 | setHolidayMasks(); | 1045 | setHolidayMasks(); |
1046 | 1046 | ||
1047 | //mAgenda->hideUnused(); | 1047 | //mAgenda->hideUnused(); |
1048 | //mAllDayAgenda->hideUnused(); | 1048 | //mAllDayAgenda->hideUnused(); |
1049 | 1049 | ||
1050 | // mAgenda->blockNextRepaint( false ); | 1050 | // mAgenda->blockNextRepaint( false ); |
1051 | // mAgenda->viewport()->repaint(); | 1051 | // mAgenda->viewport()->repaint(); |
1052 | // mAgenda->blockNextRepaint( true ); | 1052 | // mAgenda->blockNextRepaint( true ); |
1053 | mMinY.resize(mSelectedDates.count()); | 1053 | mMinY.resize(mSelectedDates.count()); |
1054 | mMaxY.resize(mSelectedDates.count()); | 1054 | mMaxY.resize(mSelectedDates.count()); |
1055 | 1055 | ||
1056 | QPtrList<Event> dayEvents; | 1056 | QPtrList<Event> dayEvents; |
1057 | 1057 | ||
1058 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1058 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1059 | // Therefore, gtodoset all of them. | 1059 | // Therefore, gtodoset all of them. |
1060 | QPtrList<Todo> todos = calendar()->todos(); | 1060 | QPtrList<Todo> todos = calendar()->todos(); |
1061 | 1061 | ||
1062 | mAgenda->setDateList(mSelectedDates); | 1062 | mAgenda->setDateList(mSelectedDates); |
1063 | 1063 | ||
1064 | QDate today = QDate::currentDate(); | 1064 | QDate today = QDate::currentDate(); |
1065 | 1065 | ||
1066 | DateList::ConstIterator dit; | 1066 | DateList::ConstIterator dit; |
1067 | int curCol = 0; | 1067 | int curCol = 0; |
1068 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1068 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1069 | QDate currentDate = *dit; | 1069 | QDate currentDate = *dit; |
1070 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1070 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1071 | // << endl; | 1071 | // << endl; |
1072 | 1072 | ||
1073 | dayEvents = calendar()->events(currentDate,true); | 1073 | dayEvents = calendar()->events(currentDate,true); |
1074 | 1074 | ||
1075 | // Default values, which can never be reached | 1075 | // Default values, which can never be reached |
1076 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1076 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1077 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1077 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1078 | 1078 | ||
1079 | unsigned int numEvent; | 1079 | unsigned int numEvent; |
1080 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1080 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1081 | Event *event = dayEvents.at(numEvent); | 1081 | Event *event = dayEvents.at(numEvent); |
1082 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1082 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1083 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1083 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1084 | continue; | 1084 | continue; |
1085 | // kdDebug() << " Event: " << event->summary() << endl; | 1085 | // kdDebug() << " Event: " << event->summary() << endl; |
1086 | 1086 | ||
1087 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1087 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1088 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1088 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1089 | 1089 | ||
1090 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1090 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1091 | 1091 | ||
1092 | if (event->doesFloat()) { | 1092 | if (event->doesFloat()) { |
1093 | if (event->recurrence()->doesRecur()) { | 1093 | if (event->recurrence()->doesRecur()) { |
1094 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1094 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1095 | } else { | 1095 | } else { |
1096 | if (beginX <= 0 && curCol == 0) { | 1096 | if (beginX <= 0 && curCol == 0) { |
1097 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1097 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1098 | } else if (beginX == curCol) { | 1098 | } else if (beginX == curCol) { |
1099 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1099 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1100 | } | 1100 | } |
1101 | } | 1101 | } |
1102 | } else if (event->isMultiDay()) { | 1102 | } else if (event->isMultiDay()) { |
1103 | if ( event->doesRecur () ) { | 1103 | if ( event->doesRecur () ) { |
1104 | QDate dateit = currentDate; | 1104 | QDate dateit = currentDate; |
1105 | int count = 0; | 1105 | int count = 0; |
1106 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1106 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1107 | while (! event->recursOn( dateit ) && count <= max ) { | 1107 | while (! event->recursOn( dateit ) && count <= max ) { |
1108 | ++count; | 1108 | ++count; |
1109 | dateit = dateit.addDays( -1 ); | 1109 | dateit = dateit.addDays( -1 ); |
1110 | } | 1110 | } |
1111 | bool ok; | 1111 | bool ok; |
1112 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1112 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1113 | if ( ok ) | 1113 | if ( ok ) |
1114 | { | 1114 | { |
1115 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1115 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1116 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1116 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1117 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1117 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1118 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1118 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1119 | 1119 | ||
1120 | } | 1120 | } |
1121 | } | 1121 | } |
1122 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1122 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1123 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1123 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1124 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1124 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1125 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1125 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1126 | //qDebug("insert!!! "); | 1126 | //qDebug("insert!!! "); |
1127 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1127 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1128 | } | 1128 | } |
1129 | if (beginX == curCol) { | 1129 | if (beginX == curCol) { |
1130 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1130 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1131 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1131 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1132 | } else if (endX == curCol) { | 1132 | } else if (endX == curCol) { |
1133 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1133 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1134 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1134 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1135 | } else { | 1135 | } else { |
1136 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1136 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1137 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1137 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1138 | } | 1138 | } |
1139 | } else { | 1139 | } else { |
1140 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1140 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1141 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1141 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1142 | if (endY < startY) endY = startY; | 1142 | if (endY < startY) endY = startY; |
1143 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1143 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1144 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1144 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1145 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1145 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | // ---------- [display Todos -------------- | 1148 | // ---------- [display Todos -------------- |
1149 | unsigned int numTodo; | 1149 | unsigned int numTodo; |
1150 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1150 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1151 | Todo *todo = todos.at(numTodo); | 1151 | Todo *todo = todos.at(numTodo); |
1152 | 1152 | ||
1153 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1153 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1154 | 1154 | ||
1155 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1155 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1156 | // Already completed items can be displayed on their original due date | 1156 | // Already completed items can be displayed on their original due date |
1157 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1157 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1158 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1158 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1159 | bool fillIn = false; | 1159 | bool fillIn = false; |
1160 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1160 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1161 | fillIn = true; | 1161 | fillIn = true; |
1162 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1162 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1163 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1163 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1164 | if ( fillIn ) { | 1164 | if ( fillIn ) { |
1165 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1165 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1166 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1166 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1167 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1167 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1168 | } | 1168 | } |
1169 | else { | 1169 | else { |
1170 | QDateTime dt; | 1170 | QDateTime dt; |
1171 | if ( todo->hasCompletedDate() ) | 1171 | if ( todo->hasCompletedDate() ) |
1172 | dt = todo->completed(); | 1172 | dt = todo->completed(); |
1173 | else | 1173 | else |
1174 | dt = todo->dtDue();; | 1174 | dt = todo->dtDue();; |
1175 | 1175 | ||
1176 | 1176 | ||
1177 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1177 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1178 | int hi = (18/KOPrefs::instance()->mHourSize); | 1178 | int hi = (18/KOPrefs::instance()->mHourSize); |
1179 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1179 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1180 | int startY = endY -hi; | 1180 | int startY = endY -hi; |
1181 | 1181 | ||
1182 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1182 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1183 | 1183 | ||
1184 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1184 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1185 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1185 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1186 | } | 1186 | } |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | // ---------- display Todos] -------------- | 1189 | // ---------- display Todos] -------------- |
1190 | 1190 | ||
1191 | ++curCol; | 1191 | ++curCol; |
1192 | } | 1192 | } |
1193 | mAgenda->hideUnused(); | 1193 | mAgenda->hideUnused(); |
1194 | mAllDayAgenda->hideUnused(); | 1194 | mAllDayAgenda->hideUnused(); |
1195 | mAgenda->checkScrollBoundaries(); | 1195 | mAgenda->checkScrollBoundaries(); |
1196 | 1196 | ||
1197 | deleteSelectedDateTime(); | 1197 | deleteSelectedDateTime(); |
1198 | 1198 | ||
1199 | createDayLabels(); | 1199 | createDayLabels(); |
1200 | emit incidenceSelected( 0 ); | 1200 | emit incidenceSelected( 0 ); |
1201 | 1201 | ||
1202 | if ( globalFlagBlockAgenda == 2 ) { | 1202 | if ( globalFlagBlockAgenda == 2 ) { |
1203 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1203 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1204 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1204 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1205 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1205 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1206 | setStartHour( QTime::currentTime ().hour() ); | 1206 | setStartHour( QTime::currentTime ().hour() ); |
1207 | // qApp->processEvents(); | 1207 | // qApp->processEvents(); |
1208 | } | 1208 | } |
1209 | qApp->processEvents(); | 1209 | qApp->processEvents(); |
1210 | //qDebug("qApp->processEvents(); END "); | 1210 | //qDebug("qApp->processEvents(); END "); |
1211 | globalFlagBlockAgenda = 0; | 1211 | globalFlagBlockAgenda = 0; |
1212 | 1212 | ||
1213 | // mAgenda->hideUnused(); | 1213 | // mAgenda->hideUnused(); |
1214 | //mAllDayAgenda->hideUnused(); | 1214 | //mAllDayAgenda->hideUnused(); |
1215 | mAllDayAgenda->drawContentsToPainter(); | 1215 | mAllDayAgenda->drawContentsToPainter(); |
1216 | mAgenda->drawContentsToPainter(); | 1216 | mAgenda->drawContentsToPainter(); |
1217 | repaintAgenda(); | 1217 | repaintAgenda(); |
1218 | // mAgenda->finishUpdate(); | 1218 | // mAgenda->finishUpdate(); |
1219 | //mAllDayAgenda->finishUpdate(); | 1219 | //mAllDayAgenda->finishUpdate(); |
1220 | 1220 | ||
1221 | // repaintAgenda(); | 1221 | // repaintAgenda(); |
1222 | //qApp->processEvents(); | 1222 | //qApp->processEvents(); |
1223 | // globalFlagBlockAgenda = 0; | 1223 | // globalFlagBlockAgenda = 0; |
1224 | } | 1224 | } |
1225 | void KOAgendaView::repaintAgenda() | 1225 | void KOAgendaView::repaintAgenda() |
1226 | { | 1226 | { |
1227 | // mAllDayAgenda->drawContentsToPainter(); | 1227 | // mAllDayAgenda->drawContentsToPainter(); |
1228 | // mAllDayAgenda->viewport()->repaint( false ); | 1228 | // mAllDayAgenda->viewport()->repaint( false ); |
1229 | // mAgenda->drawContentsToPainter(); | 1229 | // mAgenda->drawContentsToPainter(); |
1230 | // mAgenda->viewport()->repaint( false ); | 1230 | // mAgenda->viewport()->repaint( false ); |
1231 | // qApp->processEvents(); | 1231 | // qApp->processEvents(); |
1232 | 1232 | ||
1233 | //qDebug("KOAgendaView::repaintAgenda() "); | 1233 | //qDebug("KOAgendaView::repaintAgenda() "); |
1234 | //qApp->processEvents(); | 1234 | //qApp->processEvents(); |
1235 | mAgenda->viewport()->repaint( false ); | 1235 | mAgenda->viewport()->repaint( false ); |
1236 | mAllDayAgenda->viewport()->repaint( false ); | 1236 | mAllDayAgenda->viewport()->repaint( false ); |
1237 | mAgenda->finishUpdate(); | 1237 | mAgenda->finishUpdate(); |
1238 | mAllDayAgenda->finishUpdate(); | 1238 | mAllDayAgenda->finishUpdate(); |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | 1241 | ||
1242 | void KOAgendaView::clearView() | 1242 | void KOAgendaView::clearView() |
1243 | { | 1243 | { |
1244 | // kdDebug() << "ClearView" << endl; | 1244 | // kdDebug() << "ClearView" << endl; |
1245 | mAllDayAgenda->clear(); | 1245 | mAllDayAgenda->clear(); |
1246 | mAgenda->clear(); | 1246 | mAgenda->clear(); |
1247 | } | 1247 | } |
1248 | 1248 | ||
1249 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1249 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1250 | const QDate &td) | 1250 | const QDate &td) |
1251 | { | 1251 | { |
1252 | #ifndef KORG_NOPRINTER | 1252 | #ifndef KORG_NOPRINTER |
1253 | if (fd == td) | 1253 | if (fd == td) |
1254 | calPrinter->preview(CalPrinter::Day, fd, td); | 1254 | calPrinter->preview(CalPrinter::Day, fd, td); |
1255 | else | 1255 | else |
1256 | calPrinter->preview(CalPrinter::Week, fd, td); | 1256 | calPrinter->preview(CalPrinter::Week, fd, td); |
1257 | #endif | 1257 | #endif |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | // void KOAgendaView::updateMovedTodo() | 1260 | // void KOAgendaView::updateMovedTodo() |
1261 | // { | 1261 | // { |
1262 | // // updateConfig(); | 1262 | // // updateConfig(); |
1263 | // // emit updateTodoViews(); | 1263 | // // emit updateTodoViews(); |
1264 | // } | 1264 | // } |
1265 | 1265 | ||
1266 | void KOAgendaView::newEvent(int gx, int gy) | 1266 | void KOAgendaView::newEvent(int gx, int gy) |
1267 | { | 1267 | { |
1268 | if (!mSelectedDates.count()) return; | 1268 | if (!mSelectedDates.count()) return; |
1269 | 1269 | ||
1270 | QDate day = mSelectedDates[gx]; | 1270 | QDate day = mSelectedDates[gx]; |
1271 | 1271 | ||
1272 | QTime time = mAgenda->gyToTime(gy); | 1272 | QTime time = mAgenda->gyToTime(gy); |
1273 | QDateTime dt(day,time); | 1273 | QDateTime dt(day,time); |
1274 | // if ( dt < QDateTime::currentDateTime () ) | 1274 | // if ( dt < QDateTime::currentDateTime () ) |
1275 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1275 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1276 | emit newEventSignal(dt); | 1276 | emit newEventSignal(dt); |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1279 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1280 | { | 1280 | { |
1281 | if (!mSelectedDates.count()) return; | 1281 | if (!mSelectedDates.count()) return; |
1282 | 1282 | ||
1283 | QDate dayStart = mSelectedDates[gxStart]; | 1283 | QDate dayStart = mSelectedDates[gxStart]; |
1284 | QDate dayEnd = mSelectedDates[gxEnd]; | 1284 | QDate dayEnd = mSelectedDates[gxEnd]; |
1285 | 1285 | ||
1286 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1286 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1287 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1287 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1288 | 1288 | ||
1289 | QDateTime dtStart(dayStart,timeStart); | 1289 | QDateTime dtStart(dayStart,timeStart); |
1290 | QDateTime dtEnd(dayEnd,timeEnd); | 1290 | QDateTime dtEnd(dayEnd,timeEnd); |
1291 | 1291 | ||
1292 | emit newEventSignal(dtStart,dtEnd); | 1292 | emit newEventSignal(dtStart,dtEnd); |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | void KOAgendaView::newEventAllDay(int gx, int ) | 1295 | void KOAgendaView::newEventAllDay(int gx, int ) |
1296 | { | 1296 | { |
1297 | if (!mSelectedDates.count()) return; | 1297 | if (!mSelectedDates.count()) return; |
1298 | 1298 | ||
1299 | QDate day = mSelectedDates[gx]; | 1299 | QDate day = mSelectedDates[gx]; |
1300 | 1300 | ||
1301 | emit newEventSignal(day); | 1301 | emit newEventSignal(day); |
1302 | } | 1302 | } |
1303 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1303 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1304 | { | 1304 | { |
1305 | if (!mSelectedDates.count()) return; | 1305 | if (!mSelectedDates.count()) return; |
1306 | 1306 | ||
1307 | QDateTime day (mSelectedDates[gx] ); | 1307 | QDateTime day (mSelectedDates[gx] ); |
1308 | emit newTodoSignal(day, true); | 1308 | emit newTodoSignal(day, true); |
1309 | } | 1309 | } |
1310 | void KOAgendaView::newTodo(int gx, int gy ) | 1310 | void KOAgendaView::newTodo(int gx, int gy ) |
1311 | { | 1311 | { |
1312 | if (!mSelectedDates.count()) return; | 1312 | if (!mSelectedDates.count()) return; |
1313 | QDate dayStart = mSelectedDates[gx]; | 1313 | QDate dayStart = mSelectedDates[gx]; |
1314 | QTime timeStart = mAgenda->gyToTime(gy); | 1314 | QTime timeStart = mAgenda->gyToTime(gy); |
1315 | QDateTime dt (dayStart,timeStart); | 1315 | QDateTime dt (dayStart,timeStart); |
1316 | emit newTodoSignal( dt, false ); | 1316 | emit newTodoSignal( dt, false ); |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1319 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1320 | { | 1320 | { |
1321 | uint i; | 1321 | uint i; |
1322 | for(i=0;i<mMinY.size();++i) { | 1322 | for(i=0;i<mMinY.size();++i) { |
1323 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1323 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1324 | else mEventIndicatorTop->enableColumn(i,false); | 1324 | else mEventIndicatorTop->enableColumn(i,false); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | mEventIndicatorTop->update(); | 1327 | mEventIndicatorTop->update(); |
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1330 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1331 | { | 1331 | { |
1332 | uint i; | 1332 | uint i; |
1333 | for(i=0;i<mMaxY.size();++i) { | 1333 | for(i=0;i<mMaxY.size();++i) { |
1334 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1334 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1335 | else mEventIndicatorBottom->enableColumn(i,false); | 1335 | else mEventIndicatorBottom->enableColumn(i,false); |
1336 | } | 1336 | } |
1337 | 1337 | ||
1338 | mEventIndicatorBottom->update(); | 1338 | mEventIndicatorBottom->update(); |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | void KOAgendaView::startDrag(Event *event) | 1341 | void KOAgendaView::startDrag(Event *event) |
1342 | { | 1342 | { |
1343 | #ifndef KORG_NODND | 1343 | #ifndef KORG_NODND |
1344 | DndFactory factory( calendar() ); | 1344 | DndFactory factory( calendar() ); |
1345 | ICalDrag *vd = factory.createDrag(event,this); | 1345 | ICalDrag *vd = factory.createDrag(event,this); |
1346 | if (vd->drag()) { | 1346 | if (vd->drag()) { |
1347 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1347 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1348 | } | 1348 | } |
1349 | #endif | 1349 | #endif |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | void KOAgendaView::readSettings() | 1352 | void KOAgendaView::readSettings() |
1353 | { | 1353 | { |
1354 | readSettings(KOGlobals::config()); | 1354 | readSettings(KOGlobals::config()); |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | void KOAgendaView::readSettings(KConfig *config) | 1357 | void KOAgendaView::readSettings(KConfig *config) |
1358 | { | 1358 | { |
1359 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1359 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1360 | 1360 | ||
1361 | config->setGroup("Views"); | 1361 | config->setGroup("Views"); |
1362 | 1362 | ||
1363 | //#ifndef KORG_NOSPLITTER | 1363 | //#ifndef KORG_NOSPLITTER |
1364 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1364 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1365 | if (sizes.count() == 2) { | 1365 | if (sizes.count() == 2) { |
1366 | if ( sizes[0] < 20 ) { | 1366 | if ( sizes[0] < 20 ) { |
1367 | sizes[1] = sizes[1] +20 - sizes[0]; | 1367 | sizes[1] = sizes[1] +20 - sizes[0]; |
1368 | sizes[0] = 20; | 1368 | sizes[0] = 20; |
1369 | } | 1369 | } |
1370 | mSplitterAgenda->setSizes(sizes); | 1370 | mSplitterAgenda->setSizes(sizes); |
1371 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1371 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1372 | } | 1372 | } |
1373 | //#endif | 1373 | //#endif |
1374 | 1374 | ||
1375 | // updateConfig(); | 1375 | // updateConfig(); |
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | void KOAgendaView::writeSettings(KConfig *config) | 1378 | void KOAgendaView::writeSettings(KConfig *config) |
1379 | { | 1379 | { |
1380 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1380 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1381 | 1381 | ||
1382 | config->setGroup("Views"); | 1382 | config->setGroup("Views"); |
1383 | 1383 | ||
1384 | //#ifndef KORG_NOSPLITTER | 1384 | //#ifndef KORG_NOSPLITTER |
1385 | QValueList<int> list = mSplitterAgenda->sizes(); | 1385 | QValueList<int> list = mSplitterAgenda->sizes(); |
1386 | config->writeEntry("Separator AgendaView",list); | 1386 | config->writeEntry("Separator AgendaView",list); |
1387 | //qDebug("write %d %d ", list[0],list[1] ); | 1387 | //qDebug("write %d %d ", list[0],list[1] ); |
1388 | //#endif | 1388 | //#endif |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | void KOAgendaView::setHolidayMasks() | 1391 | void KOAgendaView::setHolidayMasks() |
1392 | { | 1392 | { |
1393 | mHolidayMask.resize(mSelectedDates.count()); | 1393 | mHolidayMask.resize(mSelectedDates.count()); |
1394 | 1394 | ||
1395 | uint i; | 1395 | uint i; |
1396 | for(i=0;i<mSelectedDates.count();++i) { | 1396 | for(i=0;i<mSelectedDates.count();++i) { |
1397 | QDate date = mSelectedDates[i]; | 1397 | QDate date = mSelectedDates[i]; |
1398 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1398 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1399 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1399 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1400 | bool showHoliday = false; | 1400 | bool showHoliday = false; |
1401 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1401 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1402 | QPtrList<Event> events = calendar()->events( date, true ); | 1402 | QPtrList<Event> events = calendar()->events( date, true ); |
1403 | Event *event; | 1403 | Event *event; |
1404 | for( event = events.first(); event; event = events.next() ) { | 1404 | for( event = events.first(); event; event = events.next() ) { |
1405 | if ( event->categories().contains("Holiday") || | 1405 | if ( event->categories().contains("Holiday") || |
1406 | event->categories().contains(i18n("Holiday"))) { | 1406 | event->categories().contains(i18n("Holiday"))) { |
1407 | showHoliday = true; | 1407 | showHoliday = true; |
1408 | break; | 1408 | break; |
1409 | } | 1409 | } |
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | } | 1412 | } |
1413 | 1413 | ||
1414 | #ifndef KORG_NOPLUGINS | 1414 | #ifndef KORG_NOPLUGINS |
1415 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1415 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1416 | !KOCore::self()->holiday(date).isEmpty(); | 1416 | !KOCore::self()->holiday(date).isEmpty(); |
1417 | #endif | 1417 | #endif |
1418 | bool showDay = showSaturday || showSunday || showHoliday; | 1418 | bool showDay = showSaturday || showSunday || showHoliday; |
1419 | 1419 | ||
1420 | if (showDay) { | 1420 | if (showDay) { |
1421 | mHolidayMask.at(i) = true; | 1421 | mHolidayMask.at(i) = true; |
1422 | } else { | 1422 | } else { |
1423 | mHolidayMask.at(i) = false; | 1423 | mHolidayMask.at(i) = false; |
1424 | } | 1424 | } |
1425 | } | 1425 | } |
1426 | 1426 | ||
1427 | mAgenda->setHolidayMask(&mHolidayMask); | 1427 | mAgenda->setHolidayMask(&mHolidayMask); |
1428 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1428 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | void KOAgendaView::setContentsPos(int y) | 1431 | void KOAgendaView::setContentsPos(int y) |
1432 | { | 1432 | { |
1433 | mAgenda->setContentsPos(0,y); | 1433 | mAgenda->setContentsPos(0,y); |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | void KOAgendaView::setExpandedButton( bool expanded ) | 1436 | void KOAgendaView::setExpandedButton( bool expanded ) |
1437 | { | 1437 | { |
1438 | if ( expanded ) { | 1438 | if ( expanded ) { |
1439 | mExpandButton->setPixmap( mExpandedPixmap ); | 1439 | mExpandButton->setPixmap( mExpandedPixmap ); |
1440 | } else { | 1440 | } else { |
1441 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 1441 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
1442 | } | 1442 | } |
1443 | } | 1443 | } |
1444 | 1444 | ||
1445 | void KOAgendaView::clearSelection() | 1445 | void KOAgendaView::clearSelection() |
1446 | { | 1446 | { |
1447 | mAgenda->deselectItem(); | 1447 | mAgenda->deselectItem(); |
1448 | mAllDayAgenda->deselectItem(); | 1448 | mAllDayAgenda->deselectItem(); |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1451 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1452 | int gxEnd, int gyEnd) | 1452 | int gxEnd, int gyEnd) |
1453 | { | 1453 | { |
1454 | mTimeSpanInAllDay = true; | 1454 | mTimeSpanInAllDay = true; |
1455 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1455 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1456 | } | 1456 | } |
1457 | 1457 | ||
1458 | 1458 | ||
1459 | 1459 | ||
1460 | 1460 | ||
1461 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1461 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1462 | int gxEnd, int gyEnd) | 1462 | int gxEnd, int gyEnd) |
1463 | { | 1463 | { |
1464 | if (!mSelectedDates.count()) return; | 1464 | if (!mSelectedDates.count()) return; |
1465 | 1465 | ||
1466 | QDate dayStart = mSelectedDates[gxStart]; | 1466 | QDate dayStart = mSelectedDates[gxStart]; |
1467 | QDate dayEnd = mSelectedDates[gxEnd]; | 1467 | QDate dayEnd = mSelectedDates[gxEnd]; |
1468 | 1468 | ||
1469 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1469 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1470 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1470 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1471 | 1471 | ||
1472 | QDateTime dtStart(dayStart,timeStart); | 1472 | QDateTime dtStart(dayStart,timeStart); |
1473 | QDateTime dtEnd(dayEnd,timeEnd); | 1473 | QDateTime dtEnd(dayEnd,timeEnd); |
1474 | 1474 | ||
1475 | mTimeSpanBegin = dtStart; | 1475 | mTimeSpanBegin = dtStart; |
1476 | mTimeSpanEnd = dtEnd; | 1476 | mTimeSpanEnd = dtEnd; |
1477 | 1477 | ||
1478 | } | 1478 | } |
1479 | 1479 | ||
1480 | void KOAgendaView::deleteSelectedDateTime() | 1480 | void KOAgendaView::deleteSelectedDateTime() |
1481 | { | 1481 | { |
1482 | mTimeSpanBegin.setDate(QDate()); | 1482 | mTimeSpanBegin.setDate(QDate()); |
1483 | mTimeSpanEnd.setDate(QDate()); | 1483 | mTimeSpanEnd.setDate(QDate()); |
1484 | mTimeSpanInAllDay = false; | 1484 | mTimeSpanInAllDay = false; |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1487 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1488 | { | 1488 | { |
1489 | e->ignore(); | 1489 | e->ignore(); |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | void KOAgendaView::scrollOneHourUp() | 1492 | void KOAgendaView::scrollOneHourUp() |
1493 | { | 1493 | { |
1494 | 1494 | ||
1495 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1495 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1496 | } | 1496 | } |
1497 | void KOAgendaView::scrollOneHourDown() | 1497 | void KOAgendaView::scrollOneHourDown() |
1498 | { | 1498 | { |
1499 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1499 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1500 | } | 1500 | } |
1501 | 1501 | ||
1502 | void KOAgendaView::setStartHour( int h ) | 1502 | void KOAgendaView::setStartHour( int h ) |
1503 | { | 1503 | { |
1504 | mAgenda->setStartHour( h ); | 1504 | mAgenda->setStartHour( h ); |
1505 | 1505 | ||
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | void KOAgendaView::updateTodo( Todo * t, int ) | 1508 | void KOAgendaView::updateTodo( Todo * t, int ) |
1509 | { | 1509 | { |
1510 | |||
1511 | bool remove = false; | 1510 | bool remove = false; |
1512 | bool removeAD = false; | 1511 | bool removeAD = false; |
1513 | QDate da; | 1512 | QDate da; |
1514 | if ( t->hasCompletedDate() ) | 1513 | if ( t->hasCompletedDate() ) |
1515 | da = t->completed().date(); | 1514 | da = t->completed().date(); |
1516 | else | 1515 | else |
1517 | da = t->dtDue().date(); | 1516 | da = t->dtDue().date(); |
1518 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1517 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1519 | remove = true; | 1518 | remove = true; |
1520 | removeAD = true; | 1519 | removeAD = true; |
1521 | } | 1520 | } |
1522 | else { | 1521 | else { |
1523 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1522 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1524 | if ( overdue && | 1523 | if ( overdue && |
1525 | QDate::currentDate() >= mSelectedDates.first() && | 1524 | QDate::currentDate() >= mSelectedDates.first() && |
1526 | QDate::currentDate() <= mSelectedDates.last()) { | 1525 | QDate::currentDate() <= mSelectedDates.last()) { |
1527 | removeAD = false; | 1526 | removeAD = false; |
1528 | remove = true; | 1527 | remove = true; |
1529 | } | 1528 | } |
1530 | else { | 1529 | else { |
1531 | 1530 | ||
1532 | if ( da < mSelectedDates.first() || | 1531 | if ( da < mSelectedDates.first() || |
1533 | da > mSelectedDates.last() ) { | 1532 | da > mSelectedDates.last() ) { |
1534 | remove = true; | 1533 | remove = true; |
1535 | removeAD = true; | 1534 | removeAD = true; |
1536 | } else { | 1535 | } else { |
1537 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1536 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1538 | removeAD = !remove; | 1537 | removeAD = !remove; |
1539 | } | 1538 | } |
1540 | } | 1539 | } |
1541 | } | 1540 | } |
1542 | int days = mSelectedDates.first().daysTo( da ); | 1541 | int days = mSelectedDates.first().daysTo( da ); |
1543 | // qDebug("daysto %d ", days ); | 1542 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1544 | mAgenda->updateTodo( t , days, remove); | 1543 | mAgenda->updateTodo( t , days, remove); |
1545 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1544 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1546 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1545 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1547 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1546 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1548 | 1547 | ||
1549 | } | 1548 | } |
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h index f6c30f8..5f1c3cc 100644 --- a/korganizer/koeditorgeneraltodo.h +++ b/korganizer/koeditorgeneraltodo.h | |||
@@ -1,105 +1,106 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KOEDITORGENERALTODO_H | 23 | #ifndef _KOEDITORGENERALTODO_H |
24 | #define _KOEDITORGENERALTODO_H | 24 | #define _KOEDITORGENERALTODO_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qgroupbox.h> | 30 | #include <qgroupbox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qradiobutton.h> | 35 | #include <qradiobutton.h> |
36 | 36 | ||
37 | #include "koeditorgeneral.h" | 37 | #include "koeditorgeneral.h" |
38 | #include "koglobals.h" | 38 | #include "koglobals.h" |
39 | 39 | ||
40 | class KRestrictedLine; | 40 | class KRestrictedLine; |
41 | 41 | ||
42 | class KDateEdit; | 42 | class KDateEdit; |
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | class KOEditorGeneralTodo : public KOEditorGeneral | 46 | class KOEditorGeneralTodo : public KOEditorGeneral |
47 | { | 47 | { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | KOEditorGeneralTodo (QObject* parent=0,const char* name=0); | 50 | KOEditorGeneralTodo (QObject* parent=0,const char* name=0); |
51 | virtual ~KOEditorGeneralTodo(); | 51 | virtual ~KOEditorGeneralTodo(); |
52 | 52 | ||
53 | void initTime(QWidget *, QBoxLayout *); | 53 | void initTime(QWidget *, QBoxLayout *); |
54 | void initStatus(QWidget *, QBoxLayout *); | 54 | void initStatus(QWidget *, QBoxLayout *); |
55 | void initCompletion(QWidget *, QBoxLayout *); | 55 | void initCompletion(QWidget *, QBoxLayout *); |
56 | void initPriority(QWidget *, QBoxLayout *); | 56 | void initPriority(QWidget *, QBoxLayout *); |
57 | 57 | ||
58 | void finishSetup(); | 58 | void finishSetup(); |
59 | 59 | ||
60 | /** Set widgets to default values */ | 60 | /** Set widgets to default values */ |
61 | void setDefaults(QDateTime due,bool allDay); | 61 | void setDefaults(QDateTime due,bool allDay); |
62 | /** Read todo object and setup widgets accordingly */ | 62 | /** Read todo object and setup widgets accordingly */ |
63 | void readTodo(Todo *); | 63 | void readTodo(Todo *); |
64 | /** Write todo settings to event object */ | 64 | /** Write todo settings to event object */ |
65 | void writeTodo(Todo *); | 65 | void writeTodo(Todo *); |
66 | 66 | ||
67 | /** Check if the input is valid. */ | 67 | /** Check if the input is valid. */ |
68 | bool validateInput(); | 68 | bool validateInput(); |
69 | 69 | ||
70 | /** The todo has been modified externally */ | 70 | /** The todo has been modified externally */ |
71 | void modified (Todo*, int); | 71 | void modified (Todo*, int); |
72 | 72 | ||
73 | signals: | 73 | signals: |
74 | void openCategoryDialog(); | 74 | void openCategoryDialog(); |
75 | 75 | ||
76 | protected slots: | 76 | protected slots: |
77 | void completedChanged(int); | 77 | void completedChanged(int); |
78 | 78 | ||
79 | void enableDueEdit( bool enable ); | 79 | void enableDueEdit( bool enable ); |
80 | void enableStartEdit( bool enable ); | 80 | void enableStartEdit( bool enable ); |
81 | void enableTimeEdits( bool enable ); | 81 | void enableTimeEdits( bool enable ); |
82 | void showAlarm(); | 82 | void showAlarm(); |
83 | 83 | ||
84 | protected: | 84 | protected: |
85 | void setCompletedDate(); | 85 | void setCompletedDate(); |
86 | 86 | ||
87 | private: | 87 | private: |
88 | friend class KOTodoEditor; | ||
88 | KDateEdit *mStartDateEdit; | 89 | KDateEdit *mStartDateEdit; |
89 | KOTimeEdit *mStartTimeEdit; | 90 | KOTimeEdit *mStartTimeEdit; |
90 | QCheckBox *mTimeButton; | 91 | QCheckBox *mTimeButton; |
91 | QCheckBox *mDueCheck; | 92 | QCheckBox *mDueCheck; |
92 | KDateEdit *mDueDateEdit; | 93 | KDateEdit *mDueDateEdit; |
93 | KOTimeEdit *mDueTimeEdit; | 94 | KOTimeEdit *mDueTimeEdit; |
94 | QComboBox *mCompletedCombo; | 95 | QComboBox *mCompletedCombo; |
95 | QLabel *mCompletedLabel; | 96 | QLabel *mCompletedLabel; |
96 | QLabel *mPriorityLabel; | 97 | QLabel *mPriorityLabel; |
97 | QComboBox *mPriorityCombo; | 98 | QComboBox *mPriorityCombo; |
98 | 99 | ||
99 | QCheckBox *mStartCheck; | 100 | QCheckBox *mStartCheck; |
100 | 101 | ||
101 | QDateTime mCompleted; | 102 | QDateTime mCompleted; |
102 | }; | 103 | }; |
103 | 104 | ||
104 | 105 | ||
105 | #endif | 106 | #endif |
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 16c19a4..ec5c2d1 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,375 +1,383 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1997, 1998 Preston Brown | 3 | Copyright (c) 1997, 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qhbox.h> | 29 | #include <qhbox.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kfiledialog.h> | 36 | #include <kfiledialog.h> |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | 39 | ||
40 | #include <libkdepim/categoryselectdialog.h> | 40 | #include <libkdepim/categoryselectdialog.h> |
41 | #include <libkcal/calendarlocal.h> | 41 | #include <libkcal/calendarlocal.h> |
42 | #include <libkcal/calendarresources.h> | 42 | #include <libkcal/calendarresources.h> |
43 | #include <libkcal/resourcecalendar.h> | 43 | #include <libkcal/resourcecalendar.h> |
44 | #include <libkcal/icalformat.h> | 44 | #include <libkcal/icalformat.h> |
45 | #include <kresources/resourceselectdialog.h> | 45 | #include <kresources/resourceselectdialog.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "kolocationbox.h" | ||
48 | 49 | ||
49 | #include "kotodoeditor.h" | 50 | #include "kotodoeditor.h" |
50 | extern int globalFlagBlockAgenda; | 51 | extern int globalFlagBlockAgenda; |
51 | 52 | ||
52 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 53 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
53 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 54 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
54 | { | 55 | { |
55 | mTodo = 0; | 56 | mTodo = 0; |
56 | mRelatedTodo = 0; | 57 | mRelatedTodo = 0; |
57 | findButton(User1)->hide(); | 58 | findButton(User1)->hide(); |
58 | init(); | 59 | init(); |
59 | } | 60 | } |
60 | 61 | ||
61 | KOTodoEditor::~KOTodoEditor() | 62 | KOTodoEditor::~KOTodoEditor() |
62 | { | 63 | { |
63 | emit dialogClose( mTodo ); | 64 | emit dialogClose( mTodo ); |
64 | } | 65 | } |
65 | 66 | ||
66 | void KOTodoEditor::init() | 67 | void KOTodoEditor::init() |
67 | { | 68 | { |
68 | setupGeneral(); | 69 | setupGeneral(); |
69 | setupAttendeesTab(); | 70 | setupAttendeesTab(); |
70 | } | 71 | } |
71 | void KOTodoEditor::setCategories( QString s ) | 72 | void KOTodoEditor::setCategories( QString s ) |
72 | { | 73 | { |
73 | mGeneral->setCategories(s); | 74 | mGeneral->setCategories(s); |
74 | } | 75 | } |
75 | void KOTodoEditor::setSecrecy( int sec ) | 76 | void KOTodoEditor::setSecrecy( int sec ) |
76 | { | 77 | { |
77 | mGeneral->setSecrecy( sec ); | 78 | mGeneral->setSecrecy( sec ); |
78 | } | 79 | } |
79 | void KOTodoEditor::reload() | 80 | void KOTodoEditor::reload() |
80 | { | 81 | { |
81 | if ( mTodo ) readTodo( mTodo ); | 82 | if ( mTodo ) readTodo( mTodo ); |
82 | } | 83 | } |
83 | 84 | ||
84 | void KOTodoEditor::setupGeneral() | 85 | void KOTodoEditor::setupGeneral() |
85 | { | 86 | { |
86 | mGeneral = new KOEditorGeneralTodo(this); | 87 | mGeneral = new KOEditorGeneralTodo(this); |
87 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 88 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
88 | 89 | ||
89 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 90 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
90 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 91 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
91 | // mGeneral,SLOT(setCategories(const QString &))); | 92 | // mGeneral,SLOT(setCategories(const QString &))); |
92 | 93 | ||
93 | if (KOPrefs::instance()->mCompactDialogs) { | 94 | if (KOPrefs::instance()->mCompactDialogs) { |
94 | QFrame *topFrame = addPage(i18n("General")); | 95 | QFrame *topFrame = addPage(i18n("General")); |
95 | 96 | ||
96 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 97 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
97 | if ( QApplication::desktop()->width() < 480 ) { | 98 | if ( QApplication::desktop()->width() < 480 ) { |
98 | topLayout->setMargin(1); | 99 | topLayout->setMargin(1); |
99 | topLayout->setSpacing(1); | 100 | topLayout->setSpacing(1); |
100 | } else { | 101 | } else { |
101 | topLayout->setMargin(marginHint()-1); | 102 | topLayout->setMargin(marginHint()-1); |
102 | topLayout->setSpacing(spacingHint()-1); | 103 | topLayout->setSpacing(spacingHint()-1); |
103 | } | 104 | } |
104 | mGeneral->initHeader(topFrame,topLayout); | 105 | mGeneral->initHeader(topFrame,topLayout); |
105 | mGeneral->initTime(topFrame,topLayout); | 106 | mGeneral->initTime(topFrame,topLayout); |
106 | mGeneral->initAlarm(topFrame,topLayout); | 107 | mGeneral->initAlarm(topFrame,topLayout); |
107 | mGeneral->enableAlarm( false ); | 108 | mGeneral->enableAlarm( false ); |
108 | 109 | ||
109 | 110 | ||
110 | QBoxLayout *priorityLayout; | 111 | QBoxLayout *priorityLayout; |
111 | if ( QApplication::desktop()->width() < 500 ) | 112 | if ( QApplication::desktop()->width() < 500 ) |
112 | priorityLayout = new QVBoxLayout( topLayout ); | 113 | priorityLayout = new QVBoxLayout( topLayout ); |
113 | else | 114 | else |
114 | priorityLayout = new QHBoxLayout( topLayout ); | 115 | priorityLayout = new QHBoxLayout( topLayout ); |
115 | QWidget* prioWidget = new QWidget (topFrame); | 116 | QWidget* prioWidget = new QWidget (topFrame); |
116 | priorityLayout->addWidget( prioWidget ); | 117 | priorityLayout->addWidget( prioWidget ); |
117 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); | 118 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); |
118 | 119 | ||
119 | 120 | ||
120 | QIconSet icon; | 121 | QIconSet icon; |
121 | if ( QApplication::desktop()->width() < 321 ) | 122 | if ( QApplication::desktop()->width() < 321 ) |
122 | icon = SmallIcon("fileexport16"); | 123 | icon = SmallIcon("fileexport16"); |
123 | else | 124 | else |
124 | icon = SmallIcon("fileexport"); | 125 | icon = SmallIcon("fileexport"); |
125 | QPushButton * saveTemplate = new QPushButton( prioWidget); | 126 | QPushButton * saveTemplate = new QPushButton( prioWidget); |
126 | saveTemplate->setIconSet (icon ) ; | 127 | saveTemplate->setIconSet (icon ) ; |
127 | int size = saveTemplate->sizeHint().height(); | 128 | int size = saveTemplate->sizeHint().height(); |
128 | saveTemplate->setFixedSize( size, size ); | 129 | saveTemplate->setFixedSize( size, size ); |
129 | if ( QApplication::desktop()->width() < 321 ) | 130 | if ( QApplication::desktop()->width() < 321 ) |
130 | icon = SmallIcon("fileimport16"); | 131 | icon = SmallIcon("fileimport16"); |
131 | else | 132 | else |
132 | icon = SmallIcon("fileimport"); | 133 | icon = SmallIcon("fileimport"); |
133 | QPushButton * loadTemplate = new QPushButton( prioWidget); | 134 | QPushButton * loadTemplate = new QPushButton( prioWidget); |
134 | loadTemplate->setIconSet (icon ) ; | 135 | loadTemplate->setIconSet (icon ) ; |
135 | loadTemplate->setFixedSize( size, size ); | 136 | loadTemplate->setFixedSize( size, size ); |
136 | 137 | ||
137 | priorityLayout2->addWidget(loadTemplate); | 138 | priorityLayout2->addWidget(loadTemplate); |
138 | priorityLayout2->addWidget(saveTemplate); | 139 | priorityLayout2->addWidget(saveTemplate); |
139 | mGeneral->initPriority(prioWidget,priorityLayout2); | 140 | mGeneral->initPriority(prioWidget,priorityLayout2); |
140 | mGeneral->initCategories( topFrame, priorityLayout ); | 141 | mGeneral->initCategories( topFrame, priorityLayout ); |
141 | topLayout->addStretch(1); | 142 | topLayout->addStretch(1); |
142 | 143 | ||
143 | QFrame *topFrame2 = addPage(i18n("Details")); | 144 | QFrame *topFrame2 = addPage(i18n("Details")); |
144 | 145 | ||
145 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 146 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
146 | topLayout2->setMargin(marginHint()); | 147 | topLayout2->setMargin(marginHint()); |
147 | topLayout2->setSpacing(spacingHint()); | 148 | topLayout2->setSpacing(spacingHint()); |
148 | 149 | ||
149 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); | 150 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); |
150 | mGeneral->initCompletion(topFrame2,completionLayout); | 151 | mGeneral->initCompletion(topFrame2,completionLayout); |
151 | 152 | ||
152 | 153 | ||
153 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 154 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
154 | mGeneral->initDescription(topFrame2,topLayout2); | 155 | mGeneral->initDescription(topFrame2,topLayout2); |
155 | 156 | ||
156 | // QHBox * hb = new QHBox ( topFrame2 ); | 157 | // QHBox * hb = new QHBox ( topFrame2 ); |
157 | // topLayout2->addWidget(hb); | 158 | // topLayout2->addWidget(hb); |
158 | // hb->setSpacing( 3 ); | 159 | // hb->setSpacing( 3 ); |
159 | 160 | ||
160 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 161 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
161 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 162 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
162 | 163 | ||
163 | } else { | 164 | } else { |
164 | QFrame *topFrame = addPage(i18n("General")); | 165 | QFrame *topFrame = addPage(i18n("General")); |
165 | 166 | ||
166 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 167 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
167 | topLayout->setSpacing(spacingHint()); | 168 | topLayout->setSpacing(spacingHint()); |
168 | 169 | ||
169 | mGeneral->initHeader(topFrame,topLayout); | 170 | mGeneral->initHeader(topFrame,topLayout); |
170 | mGeneral->initTime(topFrame,topLayout); | 171 | mGeneral->initTime(topFrame,topLayout); |
171 | mGeneral->initStatus(topFrame,topLayout); | 172 | mGeneral->initStatus(topFrame,topLayout); |
172 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 173 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
173 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 174 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
174 | mGeneral->initDescription(topFrame,topLayout); | 175 | mGeneral->initDescription(topFrame,topLayout); |
175 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 176 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
176 | mGeneral->initCategories( topFrame, detailsLayout ); | 177 | mGeneral->initCategories( topFrame, detailsLayout ); |
177 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 178 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
178 | } | 179 | } |
179 | mGeneral->finishSetup(); | 180 | mGeneral->finishSetup(); |
180 | 181 | ||
181 | } | 182 | } |
182 | 183 | ||
183 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | 184 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) |
184 | { | 185 | { |
185 | //init(); | 186 | //init(); |
186 | 187 | ||
187 | mTodo = todo; | 188 | mTodo = todo; |
188 | readTodo(mTodo); | 189 | readTodo(mTodo); |
189 | if ( editDescription ) { | 190 | if ( editDescription ) { |
190 | showPage( 1 ); | 191 | showPage( 1 ); |
191 | mGeneral->setFocusOn( 1 ); | 192 | mGeneral->setFocusOn( 1 ); |
192 | } else { | 193 | } else { |
193 | showPage( 0 ); | 194 | showPage( 0 ); |
194 | mGeneral->setFocusOn( 2 ); | 195 | mGeneral->setFocusOn( 2 ); |
195 | } | 196 | } |
196 | } | 197 | } |
197 | 198 | ||
198 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 199 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
199 | { | 200 | { |
200 | //init(); | 201 | //init(); |
201 | 202 | ||
202 | mTodo = 0; | 203 | mTodo = 0; |
203 | setDefaults(due,relatedTodo,allDay); | 204 | setDefaults(due,relatedTodo,allDay); |
204 | } | 205 | } |
205 | 206 | ||
206 | void KOTodoEditor::loadDefaults() | 207 | void KOTodoEditor::loadDefaults() |
207 | { | 208 | { |
208 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 209 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
209 | } | 210 | } |
210 | 211 | ||
211 | bool KOTodoEditor::processInput( bool emitTime ) | 212 | bool KOTodoEditor::processInput( bool emitTime ) |
212 | { | 213 | { |
213 | if (!validateInput()) return false; | 214 | if (!validateInput()) return false; |
214 | 215 | ||
215 | Todo *todo = 0; | 216 | Todo *todo = 0; |
216 | 217 | ||
217 | if (mTodo) todo = mTodo; | 218 | if (mTodo) todo = mTodo; |
218 | else { | 219 | else { |
219 | todo = new Todo; | 220 | todo = new Todo; |
220 | todo->setOrganizer(KOPrefs::instance()->email()); | 221 | todo->setOrganizer(KOPrefs::instance()->email()); |
221 | } | 222 | } |
222 | 223 | ||
223 | writeTodo(todo); | 224 | writeTodo(todo); |
224 | if ( emitTime ) { | 225 | if ( emitTime ) { |
225 | globalFlagBlockAgenda = 1; | 226 | globalFlagBlockAgenda = 1; |
226 | emit showAgendaView( false ); | 227 | emit showAgendaView( false ); |
227 | if ( todo->hasDueDate() ) | 228 | if ( todo->hasDueDate() ) |
228 | emit jumpToTime( todo->dtDue().date() ); | 229 | emit jumpToTime( todo->dtDue().date() ); |
229 | globalFlagBlockAgenda = 2; | 230 | globalFlagBlockAgenda = 2; |
230 | } | 231 | } |
231 | if (mTodo) { | 232 | if (mTodo) { |
232 | todo->setRevision(todo->revision()+1); | 233 | todo->setRevision(todo->revision()+1); |
233 | emit todoChanged(todo); | 234 | emit todoChanged(todo); |
234 | } else { | 235 | } else { |
235 | mCalendar->addTodo(todo); | 236 | mCalendar->addTodo(todo); |
236 | mTodo = todo; | 237 | mTodo = todo; |
237 | emit todoAdded(todo); | 238 | emit todoAdded(todo); |
238 | } | 239 | } |
239 | 240 | ||
240 | return true; | 241 | return true; |
241 | } | 242 | } |
242 | 243 | ||
243 | void KOTodoEditor::deleteTodo() | 244 | void KOTodoEditor::deleteTodo() |
244 | { | 245 | { |
245 | if (mTodo) { | 246 | if (mTodo) { |
246 | if (KOPrefs::instance()->mConfirm) { | 247 | if (KOPrefs::instance()->mConfirm) { |
247 | switch (msgItemDelete()) { | 248 | switch (msgItemDelete()) { |
248 | case KMessageBox::Continue: // OK | 249 | case KMessageBox::Continue: // OK |
249 | emit todoToBeDeleted(mTodo); | 250 | emit todoToBeDeleted(mTodo); |
250 | emit dialogClose(mTodo); | 251 | emit dialogClose(mTodo); |
251 | mCalendar->deleteTodo(mTodo); | 252 | mCalendar->deleteTodo(mTodo); |
252 | emit todoDeleted(); | 253 | emit todoDeleted(); |
253 | reject(); | 254 | reject(); |
254 | break; | 255 | break; |
255 | } | 256 | } |
256 | } | 257 | } |
257 | else { | 258 | else { |
258 | emit todoToBeDeleted(mTodo); | 259 | emit todoToBeDeleted(mTodo); |
259 | emit dialogClose(mTodo); | 260 | emit dialogClose(mTodo); |
260 | mCalendar->deleteTodo(mTodo); | 261 | mCalendar->deleteTodo(mTodo); |
261 | emit todoDeleted(); | 262 | emit todoDeleted(); |
262 | reject(); | 263 | reject(); |
263 | } | 264 | } |
264 | } else { | 265 | } else { |
265 | reject(); | 266 | reject(); |
266 | } | 267 | } |
267 | } | 268 | } |
268 | 269 | ||
269 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 270 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
270 | { | 271 | { |
271 | mRelatedTodo = relatedEvent; | 272 | mRelatedTodo = relatedEvent; |
272 | 273 | ||
273 | mGeneral->setDefaults(due,allDay); | 274 | mGeneral->setDefaults(due,allDay); |
274 | mDetails->setDefaults(); | 275 | mDetails->setDefaults(); |
275 | showPage( 0 ); | 276 | showPage( 0 ); |
276 | if ( mRelatedTodo ) { | 277 | if ( mRelatedTodo ) { |
277 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 278 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
278 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 279 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
280 | if ( mRelatedTodo->priority() < 3 ) | ||
281 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | ||
282 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | ||
283 | int len = mRelatedTodo->summary().length(); | ||
284 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | ||
285 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | ||
286 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | ||
279 | 287 | ||
280 | } | 288 | } else |
281 | mGeneral->setFocusOn( 2 ); | 289 | mGeneral->setFocusOn( 2 ); |
282 | } | 290 | } |
283 | 291 | ||
284 | void KOTodoEditor::readTodo(Todo *todo) | 292 | void KOTodoEditor::readTodo(Todo *todo) |
285 | { | 293 | { |
286 | mGeneral->readTodo(todo); | 294 | mGeneral->readTodo(todo); |
287 | mDetails->readEvent(todo); | 295 | mDetails->readEvent(todo); |
288 | mRelatedTodo = 0;//todo->relatedTo(); | 296 | mRelatedTodo = 0;//todo->relatedTo(); |
289 | // categories | 297 | // categories |
290 | // mCategoryDialog->setSelected(todo->categories()); | 298 | // mCategoryDialog->setSelected(todo->categories()); |
291 | 299 | ||
292 | // We should handle read-only events here. | 300 | // We should handle read-only events here. |
293 | } | 301 | } |
294 | 302 | ||
295 | void KOTodoEditor::writeTodo(Todo *event) | 303 | void KOTodoEditor::writeTodo(Todo *event) |
296 | { | 304 | { |
297 | mGeneral->writeTodo(event); | 305 | mGeneral->writeTodo(event); |
298 | mDetails->writeEvent(event); | 306 | mDetails->writeEvent(event); |
299 | 307 | ||
300 | // set related event, i.e. parent to-do in this case. | 308 | // set related event, i.e. parent to-do in this case. |
301 | if (mRelatedTodo) { | 309 | if (mRelatedTodo) { |
302 | event->setRelatedTo(mRelatedTodo); | 310 | event->setRelatedTo(mRelatedTodo); |
303 | } | 311 | } |
304 | } | 312 | } |
305 | 313 | ||
306 | bool KOTodoEditor::validateInput() | 314 | bool KOTodoEditor::validateInput() |
307 | { | 315 | { |
308 | if (!mGeneral->validateInput()) return false; | 316 | if (!mGeneral->validateInput()) return false; |
309 | if (!mDetails->validateInput()) return false; | 317 | if (!mDetails->validateInput()) return false; |
310 | return true; | 318 | return true; |
311 | } | 319 | } |
312 | 320 | ||
313 | int KOTodoEditor::msgItemDelete() | 321 | int KOTodoEditor::msgItemDelete() |
314 | { | 322 | { |
315 | return KMessageBox::warningContinueCancel(this, | 323 | return KMessageBox::warningContinueCancel(this, |
316 | i18n("This item will be permanently deleted."), | 324 | i18n("This item will be permanently deleted."), |
317 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 325 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
318 | } | 326 | } |
319 | 327 | ||
320 | void KOTodoEditor::modified (int modification) | 328 | void KOTodoEditor::modified (int modification) |
321 | { | 329 | { |
322 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 330 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
323 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 331 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
324 | // mCategoryDialog->setSelected (mTodo->categories ()); | 332 | // mCategoryDialog->setSelected (mTodo->categories ()); |
325 | mGeneral->modified (mTodo, modification); | 333 | mGeneral->modified (mTodo, modification); |
326 | 334 | ||
327 | } | 335 | } |
328 | 336 | ||
329 | void KOTodoEditor::slotLoadTemplate() | 337 | void KOTodoEditor::slotLoadTemplate() |
330 | { | 338 | { |
331 | 339 | ||
332 | QString fileName =locateLocal( "templates", "todos" ); | 340 | QString fileName =locateLocal( "templates", "todos" ); |
333 | QDir t_dir; | 341 | QDir t_dir; |
334 | if ( !t_dir.exists(fileName) ) | 342 | if ( !t_dir.exists(fileName) ) |
335 | t_dir.mkdir ( fileName ); | 343 | t_dir.mkdir ( fileName ); |
336 | fileName += "/todo"; | 344 | fileName += "/todo"; |
337 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); | 345 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); |
338 | if ( fileName.length() == 0 ) | 346 | if ( fileName.length() == 0 ) |
339 | return; | 347 | return; |
340 | CalendarLocal cal; | 348 | CalendarLocal cal; |
341 | ICalFormat format; | 349 | ICalFormat format; |
342 | if ( !format.load( &cal, fileName ) ) { | 350 | if ( !format.load( &cal, fileName ) ) { |
343 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 351 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
344 | .arg( fileName ) ); | 352 | .arg( fileName ) ); |
345 | return ; | 353 | return ; |
346 | } | 354 | } |
347 | QPtrList<Todo> todos = cal.todos(); | 355 | QPtrList<Todo> todos = cal.todos(); |
348 | Todo * todo = todos.first(); | 356 | Todo * todo = todos.first(); |
349 | if ( !todo ) { | 357 | if ( !todo ) { |
350 | KMessageBox::error( this, | 358 | KMessageBox::error( this, |
351 | i18n("Template does not\ncontain a valid Todo.")); | 359 | i18n("Template does not\ncontain a valid Todo.")); |
352 | } else { | 360 | } else { |
353 | readTodo( todo ); | 361 | readTodo( todo ); |
354 | } | 362 | } |
355 | 363 | ||
356 | } | 364 | } |
357 | 365 | ||
358 | void KOTodoEditor::slotSaveTemplate() | 366 | void KOTodoEditor::slotSaveTemplate() |
359 | { | 367 | { |
360 | QString fileName =locateLocal( "templates", "todos" ); | 368 | QString fileName =locateLocal( "templates", "todos" ); |
361 | QDir t_dir; | 369 | QDir t_dir; |
362 | if ( !t_dir.exists(fileName) ) | 370 | if ( !t_dir.exists(fileName) ) |
363 | t_dir.mkdir ( fileName ); | 371 | t_dir.mkdir ( fileName ); |
364 | fileName += "/todo"; | 372 | fileName += "/todo"; |
365 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); | 373 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); |
366 | if ( fileName.length() > 0 ) | 374 | if ( fileName.length() > 0 ) |
367 | saveTemplate( fileName ); | 375 | saveTemplate( fileName ); |
368 | } | 376 | } |
369 | 377 | ||
370 | void KOTodoEditor::saveTemplate( const QString &templateName ) | 378 | void KOTodoEditor::saveTemplate( const QString &templateName ) |
371 | { | 379 | { |
372 | Todo *todo = new Todo; | 380 | Todo *todo = new Todo; |
373 | writeTodo( todo ); | 381 | writeTodo( todo ); |
374 | saveAsTemplate( todo, templateName ); | 382 | saveAsTemplate( todo, templateName ); |
375 | } | 383 | } |