summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp11
-rw-r--r--korganizer/koagendaview.cpp33
-rw-r--r--korganizer/koeventviewer.cpp18
-rw-r--r--korganizer/kotodoview.cpp13
-rw-r--r--korganizer/kotodoviewitem.cpp7
-rw-r--r--libkcal/kincidenceformatter.cpp18
-rw-r--r--libkcal/todo.cpp5
-rw-r--r--libkcal/todo.h2
8 files changed, 67 insertions, 40 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 002234d..7c41cab 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -653,1341 +653,1346 @@ void KOAgenda::performSelectAction(QPoint viewportPos)
653 int selectionHeight = mSelectionHeight; 653 int selectionHeight = mSelectionHeight;
654 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 654 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
655 655
656 repaintContents( (KOGlobals::self()->reverseLayout() ? 656 repaintContents( (KOGlobals::self()->reverseLayout() ?
657 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 657 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
658 mGridSpacingX, mSelectionYTop, 658 mGridSpacingX, mSelectionYTop,
659 mGridSpacingX, selectionHeight,false ); 659 mGridSpacingX, selectionHeight,false );
660 660
661 mCurrentCellY = gy; 661 mCurrentCellY = gy;
662 } else { 662 } else {
663 } 663 }
664 } 664 }
665} 665}
666 666
667void KOAgenda::endSelectAction( bool emitNewEvent ) 667void KOAgenda::endSelectAction( bool emitNewEvent )
668{ 668{
669 mActionType = NOP; 669 mActionType = NOP;
670 mScrollUpTimer.stop(); 670 mScrollUpTimer.stop();
671 mScrollDownTimer.stop(); 671 mScrollDownTimer.stop();
672 672
673 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 673 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
674 if ( emitNewEvent && mStartCellY < mCurrentCellY ) 674 if ( emitNewEvent && mStartCellY < mCurrentCellY )
675 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 675 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
676} 676}
677 677
678void KOAgenda::startItemAction(QPoint viewportPos) 678void KOAgenda::startItemAction(QPoint viewportPos)
679{ 679{
680 int x,y; 680 int x,y;
681 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 681 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
682 int gx,gy; 682 int gx,gy;
683 contentsToGrid(x,y,gx,gy); 683 contentsToGrid(x,y,gx,gy);
684 684
685 mStartCellX = gx; 685 mStartCellX = gx;
686 mStartCellY = gy; 686 mStartCellY = gy;
687 mCurrentCellX = gx; 687 mCurrentCellX = gx;
688 mCurrentCellY = gy; 688 mCurrentCellY = gy;
689 689
690 if (mAllDayMode) { 690 if (mAllDayMode) {
691 int gridDistanceX = (x - gx * mGridSpacingX); 691 int gridDistanceX = (x - gx * mGridSpacingX);
692 if (gridDistanceX < mResizeBorderWidth && 692 if (gridDistanceX < mResizeBorderWidth &&
693 mActionItem->cellX() == mCurrentCellX) { 693 mActionItem->cellX() == mCurrentCellX) {
694 mActionType = RESIZELEFT; 694 mActionType = RESIZELEFT;
695 setCursor(sizeHorCursor); 695 setCursor(sizeHorCursor);
696 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 696 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
697 mActionItem->cellXWidth() == mCurrentCellX) { 697 mActionItem->cellXWidth() == mCurrentCellX) {
698 mActionType = RESIZERIGHT; 698 mActionType = RESIZERIGHT;
699 setCursor(sizeHorCursor); 699 setCursor(sizeHorCursor);
700 } else { 700 } else {
701 mActionType = MOVE; 701 mActionType = MOVE;
702 mActionItem->startMove(); 702 mActionItem->startMove();
703 setCursor(sizeAllCursor); 703 setCursor(sizeAllCursor);
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
726void KOAgenda::performItemAction(QPoint viewportPos) 726void 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
845void KOAgenda::endItemAction() 845void 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
970void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 970void 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*/
1023void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1023void 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
1106void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1106void 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
1138void KOAgenda::finishUpdate() 1138void 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*/
1164void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1164void 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*/
1314void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1314void 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*/
1324void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1324void 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*/
1336int KOAgenda::timeToY(const QTime &time) 1336int 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*/
1349QTime KOAgenda::gyToTime(int gy) 1349QTime 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
1366void KOAgenda::setStartHour(int startHour) 1366void 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}
1371void KOAgenda::hideUnused() 1371void 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
1382KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1382KOAgendaItem *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}
1406KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1406KOAgendaItem * 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
1419void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1419void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1420{ 1420{
1421 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;
1461 if ( todo->hasCompletedDate() )
1462 dt = todo->completed();
1463 else
1464 dt = todo->dtDue();
1460 if ( overdue ) { 1465 if ( overdue ) {
1461 currentDate = QDate::currentDate(); 1466 currentDate = QDate::currentDate();
1462 days += todo->dtDue().date().daysTo( currentDate ); 1467 days += todo->dtDue().date().daysTo( currentDate );
1463 } 1468 }
1464 else 1469 else
1465 currentDate = todo->dtDue().date(); 1470 currentDate = dt.date();
1466 1471
1467 if ( todo->doesFloat() || overdue ) { 1472 if ( todo->doesFloat() || overdue ) {
1468 if ( ! mAllDayMode ) return; 1473 if ( ! mAllDayMode ) return;
1469 // aldayagenda 1474 // aldayagenda
1470 globalFlagBlockAgendaItemPaint = 1; 1475 globalFlagBlockAgendaItemPaint = 1;
1471 item = insertAllDayItem(todo, currentDate,days, days); 1476 item = insertAllDayItem(todo, currentDate,days, days);
1472 item->show(); 1477 item->show();
1473 1478
1474 } 1479 }
1475 else { 1480 else {
1476 if ( mAllDayMode ) return; 1481 if ( mAllDayMode ) return;
1477 // mAgenda 1482 // mAgenda
1478 globalFlagBlockAgendaItemPaint = 1; 1483 globalFlagBlockAgendaItemPaint = 1;
1479 int endY = timeToY(todo->dtDue().time()) - 1; 1484 int endY = timeToY(dt.time()) - 1;
1480 int hi = 12/KOPrefs::instance()->mHourSize; 1485 int hi = 12/KOPrefs::instance()->mHourSize;
1481 int startY = endY - 1-hi; 1486 int startY = endY - 1-hi;
1482 item = insertItem(todo,currentDate,days,startY,endY); 1487 item = insertItem(todo,currentDate,days,startY,endY);
1483 item->show(); 1488 item->show();
1484 } 1489 }
1485 qApp->processEvents(); 1490 qApp->processEvents();
1486 globalFlagBlockAgendaItemPaint = 0; 1491 globalFlagBlockAgendaItemPaint = 0;
1487 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1492 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1488 KOAgendaItem *itemit; 1493 KOAgendaItem *itemit;
1489 for ( itemit=oldconflictItems.first(); itemit != 0; 1494 for ( itemit=oldconflictItems.first(); itemit != 0;
1490 itemit=oldconflictItems.next() ) { 1495 itemit=oldconflictItems.next() ) {
1491 globalFlagBlockAgendaItemUpdate = 0; 1496 globalFlagBlockAgendaItemUpdate = 0;
1492 itemit->repaintMe(); 1497 itemit->repaintMe();
1493 globalFlagBlockAgendaItemUpdate = 1; 1498 globalFlagBlockAgendaItemUpdate = 1;
1494 itemit->repaint(); 1499 itemit->repaint();
1495 } 1500 }
1496 globalFlagBlockAgendaItemUpdate = 0; 1501 globalFlagBlockAgendaItemUpdate = 0;
1497 item->repaintMe(); 1502 item->repaintMe();
1498 globalFlagBlockAgendaItemUpdate = 1; 1503 globalFlagBlockAgendaItemUpdate = 1;
1499 item->repaint(); 1504 item->repaint();
1500} 1505}
1501/* 1506/*
1502 Insert KOAgendaItem into agenda. 1507 Insert KOAgendaItem into agenda.
1503*/ 1508*/
1504KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1509KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1505{ 1510{
1506 //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;
1507 1512
1508 if (mAllDayMode) { 1513 if (mAllDayMode) {
1509 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; 1514 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl;
1510 return 0; 1515 return 0;
1511 } 1516 }
1512 1517
1513 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1518 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1514 //agendaItem->setFrameStyle(WinPanel|Raised); 1519 //agendaItem->setFrameStyle(WinPanel|Raised);
1515 1520
1516 int YSize = YBottom - YTop + 1; 1521 int YSize = YBottom - YTop + 1;
1517 if (YSize < 0) { 1522 if (YSize < 0) {
1518 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; 1523 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl;
1519 YSize = 1; 1524 YSize = 1;
1520 } 1525 }
1521 int iheight = mGridSpacingY * YSize; 1526 int iheight = mGridSpacingY * YSize;
1522 1527
1523 agendaItem->resize(mGridSpacingX,iheight ); 1528 agendaItem->resize(mGridSpacingX,iheight );
1524 agendaItem->setCellXY(X,YTop,YBottom); 1529 agendaItem->setCellXY(X,YTop,YBottom);
1525 agendaItem->setCellXWidth(X); 1530 agendaItem->setCellXWidth(X);
1526 1531
1527 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1532 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1528 mItems.append(agendaItem); 1533 mItems.append(agendaItem);
1529 1534
1530 placeSubCells(agendaItem); 1535 placeSubCells(agendaItem);
1531 1536
1532 //agendaItem->show(); 1537 //agendaItem->show();
1533 1538
1534 marcus_bains(); 1539 marcus_bains();
1535 1540
1536 return agendaItem; 1541 return agendaItem;
1537} 1542}
1538 1543
1539 1544
1540/* 1545/*
1541 Insert all-day KOAgendaItem into agenda. 1546 Insert all-day KOAgendaItem into agenda.
1542*/ 1547*/
1543KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1548KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1544{ 1549{
1545 if (!mAllDayMode) { 1550 if (!mAllDayMode) {
1546 return 0; 1551 return 0;
1547 } 1552 }
1548 1553
1549 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1554 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1550 1555
1551 agendaItem->setCellXY(XBegin,0,0); 1556 agendaItem->setCellXY(XBegin,0,0);
1552 agendaItem->setCellXWidth(XEnd); 1557 agendaItem->setCellXWidth(XEnd);
1553 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1558 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1554 1559
1555 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1560 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1556 mItems.append(agendaItem); 1561 mItems.append(agendaItem);
1557 1562
1558 placeSubCells(agendaItem); 1563 placeSubCells(agendaItem);
1559 1564
1560 //agendaItem->show(); 1565 //agendaItem->show();
1561 1566
1562 return agendaItem; 1567 return agendaItem;
1563} 1568}
1564 1569
1565 1570
1566void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1571void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1567 int YTop,int YBottom) 1572 int YTop,int YBottom)
1568{ 1573{
1569 if (mAllDayMode) { 1574 if (mAllDayMode) {
1570 ; 1575 ;
1571 return; 1576 return;
1572 } 1577 }
1573 1578
1574 int cellX,cellYTop,cellYBottom; 1579 int cellX,cellYTop,cellYBottom;
1575 QString newtext; 1580 QString newtext;
1576 int width = XEnd - XBegin + 1; 1581 int width = XEnd - XBegin + 1;
1577 int count = 0; 1582 int count = 0;
1578 KOAgendaItem *current = 0; 1583 KOAgendaItem *current = 0;
1579 QPtrList<KOAgendaItem> multiItems; 1584 QPtrList<KOAgendaItem> multiItems;
1580 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1585 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1581 if (cellX == XBegin) cellYTop = YTop; 1586 if (cellX == XBegin) cellYTop = YTop;
1582 else cellYTop = 0; 1587 else cellYTop = 0;
1583 if (cellX == XEnd) cellYBottom = YBottom; 1588 if (cellX == XEnd) cellYBottom = YBottom;
1584 else cellYBottom = rows() - 1; 1589 else cellYBottom = rows() - 1;
1585 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1590 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1586 newtext.append(event->summary()); 1591 newtext.append(event->summary());
1587 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1592 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1588 current->setText(newtext); 1593 current->setText(newtext);
1589 multiItems.append(current); 1594 multiItems.append(current);
1590 } 1595 }
1591 1596
1592 KOAgendaItem *next = 0; 1597 KOAgendaItem *next = 0;
1593 KOAgendaItem *last = multiItems.last(); 1598 KOAgendaItem *last = multiItems.last();
1594 KOAgendaItem *first = multiItems.first(); 1599 KOAgendaItem *first = multiItems.first();
1595 KOAgendaItem *setFirst,*setLast; 1600 KOAgendaItem *setFirst,*setLast;
1596 current = first; 1601 current = first;
1597 while (current) { 1602 while (current) {
1598 next = multiItems.next(); 1603 next = multiItems.next();
1599 if (current == first) setFirst = 0; 1604 if (current == first) setFirst = 0;
1600 else setFirst = first; 1605 else setFirst = first;
1601 if (current == last) setLast = 0; 1606 if (current == last) setLast = 0;
1602 else setLast = last; 1607 else setLast = last;
1603 1608
1604 current->setMultiItem(setFirst,next,setLast); 1609 current->setMultiItem(setFirst,next,setLast);
1605 current = next; 1610 current = next;
1606 } 1611 }
1607 1612
1608 marcus_bains(); 1613 marcus_bains();
1609} 1614}
1610 1615
1611 1616
1612//QSizePolicy KOAgenda::sizePolicy() const 1617//QSizePolicy KOAgenda::sizePolicy() const
1613//{ 1618//{
1614 // 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
1615 // 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
1616 // 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
1617 // Preferred one. 1622 // Preferred one.
1618 // But it doesn´t hurt, so it stays. 1623 // But it doesn´t hurt, so it stays.
1619// if (mAllDayMode) { 1624// if (mAllDayMode) {
1620// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1625// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1621// } else { 1626// } else {
1622// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1627// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1623// } 1628// }
1624//} 1629//}
1625void KOAgenda::finishResize ( ) 1630void KOAgenda::finishResize ( )
1626{ 1631{
1627 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1632 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1628 if ( globalFlagBlockAgenda == 0 ) { 1633 if ( globalFlagBlockAgenda == 0 ) {
1629 finishUpdate(); 1634 finishUpdate();
1630 //qDebug("finishUpdate() called "); 1635 //qDebug("finishUpdate() called ");
1631 } 1636 }
1632} 1637}
1633/* 1638/*
1634 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1639 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1635*/ 1640*/
1636void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1641void KOAgenda::resizeEvent ( QResizeEvent *ev )
1637{ 1642{
1638 1643
1639 mResizeTimer.start( 150 , true ); 1644 mResizeTimer.start( 150 , true );
1640 computeSizes(); 1645 computeSizes();
1641 return; 1646 return;
1642 1647
1643} 1648}
1644void KOAgenda::computeSizes() 1649void KOAgenda::computeSizes()
1645{ 1650{
1646 if ( globalFlagBlockStartup ) 1651 if ( globalFlagBlockStartup )
1647 return; 1652 return;
1648 1653
1649 if (mAllDayMode) { 1654 if (mAllDayMode) {
1650 mGridSpacingX = (width()-3) / mColumns; 1655 mGridSpacingX = (width()-3) / mColumns;
1651 mGridSpacingY = height() - 2 * frameWidth() - 1; 1656 mGridSpacingY = height() - 2 * frameWidth() - 1;
1652 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1657 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1653// mGridSpacingY = height(); 1658// mGridSpacingY = height();
1654// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1659// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1655 1660
1656 KOAgendaItem *item; 1661 KOAgendaItem *item;
1657 int subCellWidth; 1662 int subCellWidth;
1658 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1663 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1659 subCellWidth = mGridSpacingY / item->subCells(); 1664 subCellWidth = mGridSpacingY / item->subCells();
1660 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1665 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1661 moveChild(item,KOGlobals::self()->reverseLayout() ? 1666 moveChild(item,KOGlobals::self()->reverseLayout() ?
1662 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1667 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1663 item->cellX() * mGridSpacingX, 1668 item->cellX() * mGridSpacingX,
1664 item->subCell() * subCellWidth); 1669 item->subCell() * subCellWidth);
1665 } 1670 }
1666 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1671 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1667 } else { 1672 } else {
1668 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; 1673 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns;
1669 if (height() > mGridSpacingY * mRows + 1 ) { 1674 if (height() > mGridSpacingY * mRows + 1 ) {
1670 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1675 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1671 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1676 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1672 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1677 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1673 emit resizedSignal(); 1678 emit resizedSignal();
1674 } else 1679 } else
1675 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1680 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1676 KOAgendaItem *item; 1681 KOAgendaItem *item;
1677 int subCellWidth; 1682 int subCellWidth;
1678 1683
1679 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1684 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1680 subCellWidth = mGridSpacingX / item->subCells(); 1685 subCellWidth = mGridSpacingX / item->subCells();
1681 item->resize(subCellWidth,item->height()); 1686 item->resize(subCellWidth,item->height());
1682 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1687 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1683 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1688 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1684 item->cellX() * mGridSpacingX) + 1689 item->cellX() * mGridSpacingX) +
1685 item->subCell() * subCellWidth,childY(item)); 1690 item->subCell() * subCellWidth,childY(item));
1686 } 1691 }
1687 } 1692 }
1688 int cw = contentsWidth(); 1693 int cw = contentsWidth();
1689 int ch = contentsHeight(); 1694 int ch = contentsHeight();
1690 if ( mAllDayMode ) { 1695 if ( mAllDayMode ) {
1691 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1696 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1692 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) 1697 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1693 paintPixAll->resize( cw, ch ); 1698 paintPixAll->resize( cw, ch );
1694 } else { 1699 } else {
1695 QPixmap* paintPix = KOAgendaItem::paintPix(); 1700 QPixmap* paintPix = KOAgendaItem::paintPix();
1696 if ( paintPix->width() < cw || paintPix->height() < ch ) 1701 if ( paintPix->width() < cw || paintPix->height() < ch )
1697 KOAgendaItem::resizePixmap( cw , ch ); 1702 KOAgendaItem::resizePixmap( cw , ch );
1698 } 1703 }
1699 1704
1700 checkScrollBoundaries(); 1705 checkScrollBoundaries();
1701 marcus_bains(); 1706 marcus_bains();
1702 drawContentsToPainter(); 1707 drawContentsToPainter();
1703 viewport()->repaint(false); 1708 viewport()->repaint(false);
1704} 1709}
1705 1710
1706void KOAgenda::scrollUp() 1711void KOAgenda::scrollUp()
1707{ 1712{
1708 scrollBy(0,-mScrollOffset); 1713 scrollBy(0,-mScrollOffset);
1709} 1714}
1710 1715
1711 1716
1712void KOAgenda::scrollDown() 1717void KOAgenda::scrollDown()
1713{ 1718{
1714 scrollBy(0,mScrollOffset); 1719 scrollBy(0,mScrollOffset);
1715} 1720}
1716 1721
1717void KOAgenda::popupAlarm() 1722void KOAgenda::popupAlarm()
1718{ 1723{
1719 if (!mClickedItem) { 1724 if (!mClickedItem) {
1720 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 1725 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1721 return; 1726 return;
1722 } 1727 }
1723// TODO: deal correctly with multiple alarms 1728// TODO: deal correctly with multiple alarms
1724 Alarm* alarm; 1729 Alarm* alarm;
1725 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1730 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1726 for(alarm=list.first();alarm;alarm=list.next()) { 1731 for(alarm=list.first();alarm;alarm=list.next()) {
1727 alarm->toggleAlarm(); 1732 alarm->toggleAlarm();
1728 } 1733 }
1729 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1734 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1730 mClickedItem->paintMe( true ); 1735 mClickedItem->paintMe( true );
1731 mClickedItem->repaint( false ); 1736 mClickedItem->repaint( false );
1732} 1737}
1733 1738
1734/* 1739/*
1735 Calculates the minimum width 1740 Calculates the minimum width
1736*/ 1741*/
1737int KOAgenda::minimumWidth() const 1742int KOAgenda::minimumWidth() const
1738{ 1743{
1739 // TODO:: develop a way to dynamically determine the minimum width 1744 // TODO:: develop a way to dynamically determine the minimum width
1740 int min = 100; 1745 int min = 100;
1741 1746
1742 return min; 1747 return min;
1743} 1748}
1744 1749
1745void KOAgenda::updateConfig() 1750void KOAgenda::updateConfig()
1746{ 1751{
1747 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 1752 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1748 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 1753 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1749 if ( mAllDayMode ) { 1754 if ( mAllDayMode ) {
1750 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 1755 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1751 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 1756 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1752 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 1757 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1753 // setMaximumHeight( mGridSpacingY+1 ); 1758 // setMaximumHeight( mGridSpacingY+1 );
1754 viewport()->repaint( false ); 1759 viewport()->repaint( false );
1755 //setFixedHeight( mGridSpacingY+1 ); 1760 //setFixedHeight( mGridSpacingY+1 );
1756 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 1761 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1757 } 1762 }
1758 else { 1763 else {
1759 mGridSpacingY = KOPrefs::instance()->mHourSize; 1764 mGridSpacingY = KOPrefs::instance()->mHourSize;
1760 calculateWorkingHours(); 1765 calculateWorkingHours();
1761 marcus_bains(); 1766 marcus_bains();
1762 } 1767 }
1763} 1768}
1764 1769
1765void KOAgenda::checkScrollBoundaries() 1770void KOAgenda::checkScrollBoundaries()
1766{ 1771{
1767 // Invalidate old values to force update 1772 // Invalidate old values to force update
1768 mOldLowerScrollValue = -1; 1773 mOldLowerScrollValue = -1;
1769 mOldUpperScrollValue = -1; 1774 mOldUpperScrollValue = -1;
1770 1775
1771 checkScrollBoundaries(verticalScrollBar()->value()); 1776 checkScrollBoundaries(verticalScrollBar()->value());
1772} 1777}
1773 1778
1774void KOAgenda::checkScrollBoundaries(int v) 1779void KOAgenda::checkScrollBoundaries(int v)
1775{ 1780{
1776 if ( mGridSpacingY == 0 ) 1781 if ( mGridSpacingY == 0 )
1777 return; 1782 return;
1778 int yMin = v/mGridSpacingY; 1783 int yMin = v/mGridSpacingY;
1779 int yMax = (v+visibleHeight())/mGridSpacingY; 1784 int yMax = (v+visibleHeight())/mGridSpacingY;
1780 1785
1781// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 1786// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
1782 1787
1783 if (yMin != mOldLowerScrollValue) { 1788 if (yMin != mOldLowerScrollValue) {
1784 mOldLowerScrollValue = yMin; 1789 mOldLowerScrollValue = yMin;
1785 emit lowerYChanged(yMin); 1790 emit lowerYChanged(yMin);
1786 } 1791 }
1787 if (yMax != mOldUpperScrollValue) { 1792 if (yMax != mOldUpperScrollValue) {
1788 mOldUpperScrollValue = yMax; 1793 mOldUpperScrollValue = yMax;
1789 emit upperYChanged(yMax); 1794 emit upperYChanged(yMax);
1790 } 1795 }
1791} 1796}
1792 1797
1793void KOAgenda::deselectItem() 1798void KOAgenda::deselectItem()
1794{ 1799{
1795 if (mSelectedItem.isNull()) return; 1800 if (mSelectedItem.isNull()) return;
1796 mSelectedItem->select(false); 1801 mSelectedItem->select(false);
1797 mSelectedItem = 0; 1802 mSelectedItem = 0;
1798} 1803}
1799 1804
1800void KOAgenda::selectItem(KOAgendaItem *item) 1805void KOAgenda::selectItem(KOAgendaItem *item)
1801{ 1806{
1802 if ((KOAgendaItem *)mSelectedItem == item) return; 1807 if ((KOAgendaItem *)mSelectedItem == item) return;
1803 deselectItem(); 1808 deselectItem();
1804 if (item == 0) { 1809 if (item == 0) {
1805 emit incidenceSelected( 0 ); 1810 emit incidenceSelected( 0 );
1806 return; 1811 return;
1807 } 1812 }
1808 mSelectedItem = item; 1813 mSelectedItem = item;
1809 mSelectedItem->select(); 1814 mSelectedItem->select();
1810 emit incidenceSelected( mSelectedItem->incidence() ); 1815 emit incidenceSelected( mSelectedItem->incidence() );
1811} 1816}
1812 1817
1813// This function seems never be called. 1818// This function seems never be called.
1814void KOAgenda::keyPressEvent( QKeyEvent *kev ) 1819void KOAgenda::keyPressEvent( QKeyEvent *kev )
1815{ 1820{
1816 switch(kev->key()) { 1821 switch(kev->key()) {
1817 case Key_PageDown: 1822 case Key_PageDown:
1818 verticalScrollBar()->addPage(); 1823 verticalScrollBar()->addPage();
1819 break; 1824 break;
1820 case Key_PageUp: 1825 case Key_PageUp:
1821 verticalScrollBar()->subtractPage(); 1826 verticalScrollBar()->subtractPage();
1822 break; 1827 break;
1823 case Key_Down: 1828 case Key_Down:
1824 verticalScrollBar()->addLine(); 1829 verticalScrollBar()->addLine();
1825 break; 1830 break;
1826 case Key_Up: 1831 case Key_Up:
1827 verticalScrollBar()->subtractLine(); 1832 verticalScrollBar()->subtractLine();
1828 break; 1833 break;
1829 default: 1834 default:
1830 ; 1835 ;
1831 } 1836 }
1832} 1837}
1833 1838
1834void KOAgenda::calculateWorkingHours() 1839void KOAgenda::calculateWorkingHours()
1835{ 1840{
1836// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 1841// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
1837 mWorkingHoursEnable = !mAllDayMode; 1842 mWorkingHoursEnable = !mAllDayMode;
1838 1843
1839 mWorkingHoursYTop = mGridSpacingY * 1844 mWorkingHoursYTop = mGridSpacingY *
1840 KOPrefs::instance()->mWorkingHoursStart * 4; 1845 KOPrefs::instance()->mWorkingHoursStart * 4;
1841 mWorkingHoursYBottom = mGridSpacingY * 1846 mWorkingHoursYBottom = mGridSpacingY *
1842 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 1847 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
1843} 1848}
1844 1849
1845 1850
1846DateList KOAgenda::dateList() const 1851DateList KOAgenda::dateList() const
1847{ 1852{
1848 return mSelectedDates; 1853 return mSelectedDates;
1849} 1854}
1850 1855
1851void KOAgenda::setDateList(const DateList &selectedDates) 1856void KOAgenda::setDateList(const DateList &selectedDates)
1852{ 1857{
1853 mSelectedDates = selectedDates; 1858 mSelectedDates = selectedDates;
1854 marcus_bains(); 1859 marcus_bains();
1855} 1860}
1856 1861
1857void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 1862void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
1858{ 1863{
1859 mHolidayMask = mask; 1864 mHolidayMask = mask;
1860 1865
1861/* 1866/*
1862 kdDebug() << "HolidayMask: "; 1867 kdDebug() << "HolidayMask: ";
1863 for(uint i=0;i<mask->count();++i) { 1868 for(uint i=0;i<mask->count();++i) {
1864 kdDebug() << (mask->at(i) ? "*" : "o"); 1869 kdDebug() << (mask->at(i) ? "*" : "o");
1865 } 1870 }
1866 kdDebug() << endl; 1871 kdDebug() << endl;
1867*/ 1872*/
1868} 1873}
1869 1874
1870void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 1875void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
1871{ 1876{
1872 1877
1873 QScrollView::contentsMousePressEvent(event); 1878 QScrollView::contentsMousePressEvent(event);
1874} 1879}
1875 1880
1876void KOAgenda::storePosition() 1881void KOAgenda::storePosition()
1877{ 1882{
1878 //mContentPosition 1883 //mContentPosition
1879 int max = mGridSpacingY*4*24; 1884 int max = mGridSpacingY*4*24;
1880 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 1885 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
1881 mContentPosition = 0; 1886 mContentPosition = 0;
1882 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)
1883 mContentPosition = -1.0; 1888 mContentPosition = -1.0;
1884 else 1889 else
1885 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 1890 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
1886 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 1891 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
1887 1892
1888} 1893}
1889void KOAgenda::restorePosition() 1894void KOAgenda::restorePosition()
1890{ 1895{
1891 int posY; 1896 int posY;
1892 int max = mGridSpacingY*4*24; 1897 int max = mGridSpacingY*4*24;
1893 if ( mContentPosition < 0 ) 1898 if ( mContentPosition < 0 )
1894 posY = max-viewport()->height(); 1899 posY = max-viewport()->height();
1895 else 1900 else
1896 if ( mContentPosition == 0 ) 1901 if ( mContentPosition == 0 )
1897 posY = 0; 1902 posY = 0;
1898 else 1903 else
1899 posY = (max/mContentPosition)-(viewport()->height()/2); 1904 posY = (max/mContentPosition)-(viewport()->height()/2);
1900 setContentsPos (0, posY ); 1905 setContentsPos (0, posY );
1901 //qDebug("posY %d hei %d", posY, max); 1906 //qDebug("posY %d hei %d", posY, max);
1902 1907
1903} 1908}
1904void KOAgenda::moveChild( QWidget *w, int x , int y ) 1909void KOAgenda::moveChild( QWidget *w, int x , int y )
1905{ 1910{
1906 ++x; 1911 ++x;
1907 QScrollView::moveChild( w, x , y ); 1912 QScrollView::moveChild( w, x , y );
1908} 1913}
1909#include <qmessagebox.h> 1914#include <qmessagebox.h>
1910#ifdef DESKTOP_VERSION 1915#ifdef DESKTOP_VERSION
1911#include <qprinter.h> 1916#include <qprinter.h>
1912#include <qpainter.h> 1917#include <qpainter.h>
1913#include <qpaintdevicemetrics.h> 1918#include <qpaintdevicemetrics.h>
1914 1919
1915#endif 1920#endif
1916void KOAgenda::printSelection() 1921void KOAgenda::printSelection()
1917{ 1922{
1918#ifdef DESKTOP_VERSION 1923#ifdef DESKTOP_VERSION
1919 if ( mStartCellY == mCurrentCellY ) { 1924 if ( mStartCellY == mCurrentCellY ) {
1920 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1925 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1921 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. "),
1922 i18n("OK"), 0, 0, 1927 i18n("OK"), 0, 0,
1923 0, 1 ); 1928 0, 1 );
1924 return; 1929 return;
1925 } 1930 }
1926 1931
1927 float dx, dy; 1932 float dx, dy;
1928 int x,y,w,h; 1933 int x,y,w,h;
1929 x= 0; 1934 x= 0;
1930 w= contentsWidth()+2; 1935 w= contentsWidth()+2;
1931 // h= contentsHeight(); 1936 // h= contentsHeight();
1932 y = mGridSpacingY*mStartCellY; 1937 y = mGridSpacingY*mStartCellY;
1933 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 1938 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
1934 1939
1935 //return; 1940 //return;
1936 QPrinter* printer = new QPrinter(); 1941 QPrinter* printer = new QPrinter();
1937 if ( !printer->setup()) { 1942 if ( !printer->setup()) {
1938 delete printer; 1943 delete printer;
1939 return; 1944 return;
1940 } 1945 }
1941 QPainter p( printer ); 1946 QPainter p( printer );
1942 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 1947 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
1943 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() );
1944 date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 1949 date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
1945 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();
1946 // p.drawText( 0, 0, date ); 1951 // p.drawText( 0, 0, date );
1947 int offset = m.width()/8; 1952 int offset = m.width()/8;
1948 // compute the scale 1953 // compute the scale
1949 dx = ((float) m.width()-offset) / (float)w; 1954 dx = ((float) m.width()-offset) / (float)w;
1950 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 1955 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
1951 float scale; 1956 float scale;
1952 // scale to fit the width or height of the paper 1957 // scale to fit the width or height of the paper
1953 if ( dx < dy ) 1958 if ( dx < dy )
1954 scale = dx; 1959 scale = dx;
1955 else 1960 else
1956 scale = dy; 1961 scale = dy;
1957 // set the scale 1962 // set the scale
1958 p.drawText( offset* scale, offset* scale*3/4, date ); 1963 p.drawText( offset* scale, offset* scale*3/4, date );
1959 1964
1960 int selDay; 1965 int selDay;
1961 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); 1966 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count()));
1962 float startX = 1; 1967 float startX = 1;
1963 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1968 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1964 { 1969 {
1965 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); 1970 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true );
1966 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) );
1967 p.drawText( offset* scale+startX, (offset+hei)* scale, text ); 1972 p.drawText( offset* scale+startX, (offset+hei)* scale, text );
1968 startX += widOffset; 1973 startX += widOffset;
1969 1974
1970 } 1975 }
1971 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); 1976 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale));
1972 p.scale( scale, scale ); 1977 p.scale( scale, scale );
1973 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 );
1974 // now printing with y offset: 2 hei 1979 // now printing with y offset: 2 hei
1975 // p.translate( 0, -y*scale); 1980 // p.translate( 0, -y*scale);
1976 1981
1977 drawContentsToPainter(&p, true ); 1982 drawContentsToPainter(&p, true );
1978 globalFlagBlockAgendaItemUpdate = false; 1983 globalFlagBlockAgendaItemUpdate = false;
1979 KOAgendaItem *item; 1984 KOAgendaItem *item;
1980 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1985 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1981 item->select(false); 1986 item->select(false);
1982 item->paintMe( false, &p ); 1987 item->paintMe( false, &p );
1983 } 1988 }
1984 globalFlagBlockAgendaItemUpdate = true; 1989 globalFlagBlockAgendaItemUpdate = true;
1985 p.end(); 1990 p.end();
1986 delete printer; 1991 delete printer;
1987#else 1992#else
1988 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1993 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1989 i18n("Not supported \non PDA!\n"), 1994 i18n("Not supported \non PDA!\n"),
1990 i18n("OK"), 0, 0, 1995 i18n("OK"), 0, 0,
1991 0, 1 ); 1996 0, 1 );
1992#endif 1997#endif
1993} 1998}
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 1864e22..bbc43e4 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -185,1355 +185,1366 @@ void TimeLabels::updateConfig()
185 setFixedWidth(minimumWidth()); 185 setFixedWidth(minimumWidth());
186 186
187 // update HourSize 187 // update HourSize
188 mCellHeight = KOPrefs::instance()->mHourSize*4; 188 mCellHeight = KOPrefs::instance()->mHourSize*4;
189 resizeContents(50,mRows * mCellHeight); 189 resizeContents(50,mRows * mCellHeight);
190} 190}
191 191
192/** update time label positions */ 192/** update time label positions */
193void TimeLabels::positionChanged() 193void TimeLabels::positionChanged()
194{ 194{
195 int adjustment = mAgenda->contentsY(); 195 int adjustment = mAgenda->contentsY();
196 setContentsPos(0, adjustment); 196 setContentsPos(0, adjustment);
197} 197}
198 198
199/** */ 199/** */
200void TimeLabels::setAgenda(KOAgenda* agenda) 200void TimeLabels::setAgenda(KOAgenda* agenda)
201{ 201{
202 mAgenda = agenda; 202 mAgenda = agenda;
203} 203}
204 204
205void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 205void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
206{ 206{
207 mMouseDownY = e->pos().y(); 207 mMouseDownY = e->pos().y();
208 mOrgCap = topLevelWidget()->caption(); 208 mOrgCap = topLevelWidget()->caption();
209} 209}
210 210
211void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 211void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
212{ 212{
213 int diff = mMouseDownY - e->pos().y(); 213 int diff = mMouseDownY - e->pos().y();
214 if ( diff < 10 && diff > -10 ) 214 if ( diff < 10 && diff > -10 )
215 return; 215 return;
216 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 216 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
217 if ( tSize < 4 ) 217 if ( tSize < 4 )
218 tSize = 4; 218 tSize = 4;
219 if ( tSize > 22 ) 219 if ( tSize > 22 )
220 tSize = 22; 220 tSize = 22;
221 tSize = (tSize-2)/2; 221 tSize = (tSize-2)/2;
222 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 222 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
223 223
224} 224}
225void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 225void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
226{ 226{
227 topLevelWidget()->setCaption( mOrgCap ); 227 topLevelWidget()->setCaption( mOrgCap );
228 int diff = mMouseDownY - e->pos().y(); 228 int diff = mMouseDownY - e->pos().y();
229 if ( diff < 10 && diff > -10 ) 229 if ( diff < 10 && diff > -10 )
230 return; 230 return;
231 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 231 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
232 if ( tSize < 4 ) 232 if ( tSize < 4 )
233 tSize = 4; 233 tSize = 4;
234 if ( tSize > 22 ) 234 if ( tSize > 22 )
235 tSize = 22; 235 tSize = 22;
236 tSize = (tSize/2)*2; 236 tSize = (tSize/2)*2;
237 if ( tSize == KOPrefs::instance()->mHourSize ) 237 if ( tSize == KOPrefs::instance()->mHourSize )
238 return; 238 return;
239 KOPrefs::instance()->mHourSize = tSize; 239 KOPrefs::instance()->mHourSize = tSize;
240 emit scaleChanged(); 240 emit scaleChanged();
241} 241}
242 242
243/** This is called in response to repaint() */ 243/** This is called in response to repaint() */
244void TimeLabels::paintEvent(QPaintEvent*) 244void TimeLabels::paintEvent(QPaintEvent*)
245{ 245{
246 246
247 // kdDebug() << "paintevent..." << endl; 247 // kdDebug() << "paintevent..." << endl;
248 // this is another hack! 248 // this is another hack!
249 // QPainter painter(this); 249 // QPainter painter(this);
250 //QString c 250 //QString c
251 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 251 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
252} 252}
253 253
254//////////////////////////////////////////////////////////////////////////// 254////////////////////////////////////////////////////////////////////////////
255 255
256EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 256EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
257 : QFrame(parent,name) 257 : QFrame(parent,name)
258{ 258{
259 mColumns = 1; 259 mColumns = 1;
260 mTopBox = 0; 260 mTopBox = 0;
261 mLocation = loc; 261 mLocation = loc;
262 mTopLayout = 0; 262 mTopLayout = 0;
263 mPaintWidget = 0; 263 mPaintWidget = 0;
264 mXOffset = 0; 264 mXOffset = 0;
265 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 265 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
266 else mPixmap = SmallIcon("1downarrow"); 266 else mPixmap = SmallIcon("1downarrow");
267 mEnabled.resize(mColumns); 267 mEnabled.resize(mColumns);
268 if (mLocation == Top) 268 if (mLocation == Top)
269 setMaximumHeight(0); 269 setMaximumHeight(0);
270 else 270 else
271 setMinimumHeight(mPixmap.height()); 271 setMinimumHeight(mPixmap.height());
272} 272}
273 273
274EventIndicator::~EventIndicator() 274EventIndicator::~EventIndicator()
275{ 275{
276} 276}
277 277
278void EventIndicator::drawContents(QPainter *p) 278void EventIndicator::drawContents(QPainter *p)
279{ 279{
280 280
281 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 281 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
282 KDGanttSplitterHandle* han = 0; 282 KDGanttSplitterHandle* han = 0;
283 if ( mPaintWidget ) 283 if ( mPaintWidget )
284 han = mPaintWidget->firstHandle(); 284 han = mPaintWidget->firstHandle();
285 if ( ! han ) { 285 if ( ! han ) {
286 int i; 286 int i;
287 for(i=0;i<mColumns;++i) { 287 for(i=0;i<mColumns;++i) {
288 if (mEnabled[i]) { 288 if (mEnabled[i]) {
289 int cellWidth = contentsRect().right()/mColumns; 289 int cellWidth = contentsRect().right()/mColumns;
290 int xOffset = KOGlobals::self()->reverseLayout() ? 290 int xOffset = KOGlobals::self()->reverseLayout() ?
291 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 291 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
292 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 292 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
293 p->drawPixmap(QPoint(xOffset,0),mPixmap); 293 p->drawPixmap(QPoint(xOffset,0),mPixmap);
294 } 294 }
295 } 295 }
296 } else { 296 } else {
297 han->repaint(); 297 han->repaint();
298 //mPaintWidget->setBackgroundColor( red ); 298 //mPaintWidget->setBackgroundColor( red );
299 299
300 QPainter pa( han ); 300 QPainter pa( han );
301 int i; 301 int i;
302 bool setColor = false; 302 bool setColor = false;
303 for(i=0;i<mColumns;++i) { 303 for(i=0;i<mColumns;++i) {
304 if (mEnabled[i]) { 304 if (mEnabled[i]) {
305 setColor = true; 305 setColor = true;
306 306
307 int cellWidth = contentsRect().right()/mColumns; 307 int cellWidth = contentsRect().right()/mColumns;
308 int xOffset = KOGlobals::self()->reverseLayout() ? 308 int xOffset = KOGlobals::self()->reverseLayout() ?
309 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 309 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
310 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 310 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
311 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 311 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
312 //qDebug("222draw pix %d ",xOffset ); 312 //qDebug("222draw pix %d ",xOffset );
313 313
314 } 314 }
315 315
316 } 316 }
317 pa.end(); 317 pa.end();
318 318
319 } 319 }
320} 320}
321 321
322void EventIndicator::setXOffset( int x ) 322void EventIndicator::setXOffset( int x )
323{ 323{
324 mXOffset = x; 324 mXOffset = x;
325} 325}
326void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 326void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
327{ 327{
328 mPaintWidget = w; 328 mPaintWidget = w;
329} 329}
330void EventIndicator::changeColumns(int columns) 330void EventIndicator::changeColumns(int columns)
331{ 331{
332 mColumns = columns; 332 mColumns = columns;
333 mEnabled.resize(mColumns); 333 mEnabled.resize(mColumns);
334 334
335 update(); 335 update();
336} 336}
337 337
338void EventIndicator::enableColumn(int column, bool enable) 338void EventIndicator::enableColumn(int column, bool enable)
339{ 339{
340 mEnabled[column] = enable; 340 mEnabled[column] = enable;
341} 341}
342 342
343 343
344//////////////////////////////////////////////////////////////////////////// 344////////////////////////////////////////////////////////////////////////////
345//////////////////////////////////////////////////////////////////////////// 345////////////////////////////////////////////////////////////////////////////
346//////////////////////////////////////////////////////////////////////////// 346////////////////////////////////////////////////////////////////////////////
347 347
348KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 348KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
349 KOEventView (cal,parent,name) 349 KOEventView (cal,parent,name)
350{ 350{
351 mBlockUpdating = true; 351 mBlockUpdating = true;
352 mStartHour = 8; 352 mStartHour = 8;
353 mSelectedDates.append(QDate::currentDate()); 353 mSelectedDates.append(QDate::currentDate());
354 354
355 mLayoutDayLabels = 0; 355 mLayoutDayLabels = 0;
356 mDayLabelsFrame = 0; 356 mDayLabelsFrame = 0;
357 mDayLabels = 0; 357 mDayLabels = 0;
358 bool isRTL = KOGlobals::self()->reverseLayout(); 358 bool isRTL = KOGlobals::self()->reverseLayout();
359 359
360 if ( KOPrefs::instance()->mVerticalScreen ) { 360 if ( KOPrefs::instance()->mVerticalScreen ) {
361 mExpandedPixmap = SmallIcon( "1downarrow" ); 361 mExpandedPixmap = SmallIcon( "1downarrow" );
362 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 362 mNotExpandedPixmap = SmallIcon( "1uparrow" );
363 } else { 363 } else {
364 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 364 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
365 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 365 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
366 } 366 }
367 367
368 QBoxLayout *topLayout = new QVBoxLayout(this); 368 QBoxLayout *topLayout = new QVBoxLayout(this);
369 369
370 // Create day name labels for agenda columns 370 // Create day name labels for agenda columns
371 mDayLabelsFrame = new QHBox(this); 371 mDayLabelsFrame = new QHBox(this);
372 topLayout->addWidget(mDayLabelsFrame); 372 topLayout->addWidget(mDayLabelsFrame);
373 mDayLabels = new QFrame (mDayLabelsFrame); 373 mDayLabels = new QFrame (mDayLabelsFrame);
374 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 374 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
375 // Create agenda splitter 375 // Create agenda splitter
376#ifndef KORG_NOSPLITTER 376#ifndef KORG_NOSPLITTER
377 mSplitterAgenda = new QSplitter(Vertical,this); 377 mSplitterAgenda = new QSplitter(Vertical,this);
378 topLayout->addWidget(mSplitterAgenda); 378 topLayout->addWidget(mSplitterAgenda);
379 mSplitterAgenda->setOpaqueResize(); 379 mSplitterAgenda->setOpaqueResize();
380 380
381 mAllDayFrame = new QHBox(mSplitterAgenda); 381 mAllDayFrame = new QHBox(mSplitterAgenda);
382 382
383 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 383 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
384#else 384#else
385#if 0 385#if 0
386 QWidget *mainBox = new QWidget( this ); 386 QWidget *mainBox = new QWidget( this );
387 topLayout->addWidget( mainBox ); 387 topLayout->addWidget( mainBox );
388 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 388 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
389 mAllDayFrame = new QHBox(mainBox); 389 mAllDayFrame = new QHBox(mainBox);
390 mainLayout->addWidget(mAllDayFrame); 390 mainLayout->addWidget(mAllDayFrame);
391 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 391 mainLayout->setStretchFactor( mAllDayFrame, 0 );
392 mAllDayFrame->setFocusPolicy(NoFocus); 392 mAllDayFrame->setFocusPolicy(NoFocus);
393 QWidget *agendaFrame = new QWidget(mainBox); 393 QWidget *agendaFrame = new QWidget(mainBox);
394 mainLayout->addWidget(agendaFrame); 394 mainLayout->addWidget(agendaFrame);
395 mainLayout->setStretchFactor( agendaFrame, 10 ); 395 mainLayout->setStretchFactor( agendaFrame, 10 );
396 396
397 agendaFrame->setFocusPolicy(NoFocus); 397 agendaFrame->setFocusPolicy(NoFocus);
398#endif 398#endif
399 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 399 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
400 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 400 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
401 topLayout->addWidget( mSplitterAgenda ); 401 topLayout->addWidget( mSplitterAgenda );
402 mAllDayFrame = new QHBox(mSplitterAgenda); 402 mAllDayFrame = new QHBox(mSplitterAgenda);
403 mAllDayFrame->setFocusPolicy(NoFocus); 403 mAllDayFrame->setFocusPolicy(NoFocus);
404 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 404 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
405 agendaFrame->setFocusPolicy(NoFocus); 405 agendaFrame->setFocusPolicy(NoFocus);
406 406
407#endif 407#endif
408 408
409 // Create all-day agenda widget 409 // Create all-day agenda widget
410 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 410 mDummyAllDayLeft = new QVBox( mAllDayFrame );
411 411
412 mExpandButton = new QPushButton(mDummyAllDayLeft); 412 mExpandButton = new QPushButton(mDummyAllDayLeft);
413 mExpandButton->setPixmap( mNotExpandedPixmap ); 413 mExpandButton->setPixmap( mNotExpandedPixmap );
414 int widebut = mExpandButton->sizeHint().width(); 414 int widebut = mExpandButton->sizeHint().width();
415 if ( QApplication::desktop()->width() < 480 ) 415 if ( QApplication::desktop()->width() < 480 )
416 widebut = widebut*2; 416 widebut = widebut*2;
417 else 417 else
418 widebut = (widebut*3) / 2; 418 widebut = (widebut*3) / 2;
419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
420 // QSizePolicy::Fixed ) ); 420 // QSizePolicy::Fixed ) );
421 mExpandButton->setFixedSize( widebut, widebut); 421 mExpandButton->setFixedSize( widebut, widebut);
422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
423 mExpandButton->setFocusPolicy(NoFocus); 423 mExpandButton->setFocusPolicy(NoFocus);
424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
425 mAllDayAgenda->setFocusPolicy(NoFocus); 425 mAllDayAgenda->setFocusPolicy(NoFocus);
426 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); 426 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame);
427 427
428 // Create event context menu for all day agenda 428 // Create event context menu for all day agenda
429 mAllDayAgendaPopup = eventPopup(); 429 mAllDayAgendaPopup = eventPopup();
430 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 430 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
431 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 431 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
432 432
433 // Create agenda frame 433 // Create agenda frame
434 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 434 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
435 // QHBox *agendaFrame = new QHBox(splitterAgenda); 435 // QHBox *agendaFrame = new QHBox(splitterAgenda);
436 436
437 // create event indicator bars 437 // create event indicator bars
438 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 438 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
439 agendaLayout->addWidget(mEventIndicatorTop,0,1); 439 agendaLayout->addWidget(mEventIndicatorTop,0,1);
440 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 440 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
441 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 441 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
442 agendaFrame); 442 agendaFrame);
443 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 443 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
444 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 444 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
445 agendaLayout->addWidget(dummyAgendaRight,0,2); 445 agendaLayout->addWidget(dummyAgendaRight,0,2);
446 446
447 // Create time labels 447 // Create time labels
448 mTimeLabels = new TimeLabels(24,agendaFrame); 448 mTimeLabels = new TimeLabels(24,agendaFrame);
449 agendaLayout->addWidget(mTimeLabels,1,0); 449 agendaLayout->addWidget(mTimeLabels,1,0);
450 connect(mTimeLabels,SIGNAL( scaleChanged()), 450 connect(mTimeLabels,SIGNAL( scaleChanged()),
451 this,SLOT(updateConfig())); 451 this,SLOT(updateConfig()));
452 452
453 // Create agenda 453 // Create agenda
454 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 454 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
455 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 455 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
456 agendaLayout->setColStretch(1,1); 456 agendaLayout->setColStretch(1,1);
457 mAgenda->setFocusPolicy(NoFocus); 457 mAgenda->setFocusPolicy(NoFocus);
458 // Create event context menu for agenda 458 // Create event context menu for agenda
459 mAgendaPopup = eventPopup(); 459 mAgendaPopup = eventPopup();
460 460
461 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 461 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
462 i18n("Toggle Alarm"),mAgenda, 462 i18n("Toggle Alarm"),mAgenda,
463 SLOT(popupAlarm()),true); 463 SLOT(popupAlarm()),true);
464 464
465 465
466 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 466 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
467 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 467 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
468 468
469 // make connections between dependent widgets 469 // make connections between dependent widgets
470 mTimeLabels->setAgenda(mAgenda); 470 mTimeLabels->setAgenda(mAgenda);
471 471
472 // Update widgets to reflect user preferences 472 // Update widgets to reflect user preferences
473 // updateConfig(); 473 // updateConfig();
474 474
475 // createDayLabels(); 475 // createDayLabels();
476 476
477 // these blank widgets make the All Day Event box line up with the agenda 477 // these blank widgets make the All Day Event box line up with the agenda
478 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 478 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
479 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 479 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
480 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 480 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
481 481
482 // Scrolling 482 // Scrolling
483 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 483 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
484 mTimeLabels, SLOT(positionChanged())); 484 mTimeLabels, SLOT(positionChanged()));
485 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 485 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
486 SLOT(setContentsPos(int))); 486 SLOT(setContentsPos(int)));
487 487
488 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 488 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
489 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 489 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
490 490
491 // Create/Show/Edit/Delete Event 491 // Create/Show/Edit/Delete Event
492 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 492 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
493 SLOT(newEvent(int,int))); 493 SLOT(newEvent(int,int)));
494 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 494 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
495 SLOT(newTodo(int,int))); 495 SLOT(newTodo(int,int)));
496 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 496 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
497 SLOT(newEvent(int,int,int,int))); 497 SLOT(newEvent(int,int,int,int)));
498 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 498 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
499 SLOT(newEventAllDay(int,int))); 499 SLOT(newEventAllDay(int,int)));
500 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 500 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
501 SLOT(newTodoAllDay(int,int))); 501 SLOT(newTodoAllDay(int,int)));
502 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 502 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
503 SLOT(newEventAllDay(int,int))); 503 SLOT(newEventAllDay(int,int)));
504 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 504 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
505 SLOT(newTimeSpanSelected(int,int,int,int))); 505 SLOT(newTimeSpanSelected(int,int,int,int)));
506 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 506 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
507 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 507 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
508 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 508 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
509 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 509 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
510 510
511 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 511 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
512 SIGNAL(editIncidenceSignal(Incidence *))); 512 SIGNAL(editIncidenceSignal(Incidence *)));
513 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 513 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
514 SIGNAL(editIncidenceSignal(Incidence *))); 514 SIGNAL(editIncidenceSignal(Incidence *)));
515 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 515 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
516 SIGNAL(showIncidenceSignal(Incidence *))); 516 SIGNAL(showIncidenceSignal(Incidence *)));
517 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 517 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
518 SIGNAL(showIncidenceSignal(Incidence *))); 518 SIGNAL(showIncidenceSignal(Incidence *)));
519 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 519 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
520 SIGNAL(deleteIncidenceSignal(Incidence *))); 520 SIGNAL(deleteIncidenceSignal(Incidence *)));
521 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 521 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
522 SIGNAL(deleteIncidenceSignal(Incidence *))); 522 SIGNAL(deleteIncidenceSignal(Incidence *)));
523 523
524 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 524 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
525 SLOT(updateEventDates(KOAgendaItem *, int ))); 525 SLOT(updateEventDates(KOAgendaItem *, int )));
526 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 526 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
527 SLOT(updateEventDates(KOAgendaItem *, int))); 527 SLOT(updateEventDates(KOAgendaItem *, int)));
528 528
529 // event indicator update 529 // event indicator update
530 connect(mAgenda,SIGNAL(lowerYChanged(int)), 530 connect(mAgenda,SIGNAL(lowerYChanged(int)),
531 SLOT(updateEventIndicatorTop(int))); 531 SLOT(updateEventIndicatorTop(int)));
532 connect(mAgenda,SIGNAL(upperYChanged(int)), 532 connect(mAgenda,SIGNAL(upperYChanged(int)),
533 SLOT(updateEventIndicatorBottom(int))); 533 SLOT(updateEventIndicatorBottom(int)));
534 // drag signals 534 // drag signals
535 /* 535 /*
536 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 536 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
537 SLOT(startDrag(Event *))); 537 SLOT(startDrag(Event *)));
538 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 538 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
539 SLOT(startDrag(Event *))); 539 SLOT(startDrag(Event *)));
540 */ 540 */
541 // synchronize selections 541 // synchronize selections
542 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 542 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
543 mAllDayAgenda, SLOT( deselectItem() ) ); 543 mAllDayAgenda, SLOT( deselectItem() ) );
544 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 544 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
545 mAgenda, SLOT( deselectItem() ) ); 545 mAgenda, SLOT( deselectItem() ) );
546 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 546 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
547 SIGNAL( incidenceSelected( Incidence * ) ) ); 547 SIGNAL( incidenceSelected( Incidence * ) ) );
548 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 548 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
549 SIGNAL( incidenceSelected( Incidence * ) ) ); 549 SIGNAL( incidenceSelected( Incidence * ) ) );
550 connect( mAgenda, SIGNAL( resizedSignal() ), 550 connect( mAgenda, SIGNAL( resizedSignal() ),
551 SLOT( updateConfig( ) ) ); 551 SLOT( updateConfig( ) ) );
552 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 552 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
553 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 553 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
554 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 554 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
555 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 555 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
556 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 556 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
557 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 557 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
558 558
559 559
560} 560}
561 561
562void KOAgendaView::toggleAllDay() 562void KOAgendaView::toggleAllDay()
563{ 563{
564 if ( mSplitterAgenda->firstHandle() ) 564 if ( mSplitterAgenda->firstHandle() )
565 mSplitterAgenda->firstHandle()->toggle(); 565 mSplitterAgenda->firstHandle()->toggle();
566} 566}
567void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 567void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
568{ 568{
569 calendar()->addIncidence( inc ); 569 calendar()->addIncidence( inc );
570 570
571 if ( incOld ) { 571 if ( incOld ) {
572 if ( incOld->type() == "Todo" ) 572 if ( incOld->type() == "Todo" )
573 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 573 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
574 else 574 else
575 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 575 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
576 } 576 }
577 577
578} 578}
579 579
580KOAgendaView::~KOAgendaView() 580KOAgendaView::~KOAgendaView()
581{ 581{
582 delete mAgendaPopup; 582 delete mAgendaPopup;
583 delete mAllDayAgendaPopup; 583 delete mAllDayAgendaPopup;
584 delete KOAgendaItem::paintPix(); 584 delete KOAgendaItem::paintPix();
585 delete KOAgendaItem::paintPixSel(); 585 delete KOAgendaItem::paintPixSel();
586} 586}
587void KOAgendaView::resizeEvent( QResizeEvent* e ) 587void KOAgendaView::resizeEvent( QResizeEvent* e )
588{ 588{
589 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 589 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
590 bool uc = false; 590 bool uc = false;
591 int ow = e->oldSize().width(); 591 int ow = e->oldSize().width();
592 int oh = e->oldSize().height(); 592 int oh = e->oldSize().height();
593 int w = e->size().width(); 593 int w = e->size().width();
594 int h = e->size().height(); 594 int h = e->size().height();
595 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 595 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
596 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 596 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
597 uc = true; 597 uc = true;
598 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 598 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
599 } 599 }
600 mUpcomingWidth = e->size().width() ; 600 mUpcomingWidth = e->size().width() ;
601 if ( mBlockUpdating || uc ) { 601 if ( mBlockUpdating || uc ) {
602 mBlockUpdating = false; 602 mBlockUpdating = false;
603 //mAgenda->setMinimumSize(800 , 600 ); 603 //mAgenda->setMinimumSize(800 , 600 );
604 //qDebug("mAgenda->resize+++++++++++++++ "); 604 //qDebug("mAgenda->resize+++++++++++++++ ");
605 updateConfig(); 605 updateConfig();
606 //qDebug("KOAgendaView::Updating now possible "); 606 //qDebug("KOAgendaView::Updating now possible ");
607 } else 607 } else
608 createDayLabels(); 608 createDayLabels();
609 //qDebug("resizeEvent end "); 609 //qDebug("resizeEvent end ");
610 610
611} 611}
612void KOAgendaView::createDayLabels() 612void KOAgendaView::createDayLabels()
613{ 613{
614 614
615 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 615 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
616 // qDebug(" KOAgendaView::createDayLabels() blocked "); 616 // qDebug(" KOAgendaView::createDayLabels() blocked ");
617 return; 617 return;
618 618
619 } 619 }
620 int newHight; 620 int newHight;
621 621
622 // ### Before deleting and recreating we could check if mSelectedDates changed... 622 // ### Before deleting and recreating we could check if mSelectedDates changed...
623 // It would remove some flickering and gain speed (since this is called by 623 // It would remove some flickering and gain speed (since this is called by
624 // each updateView() call) 624 // each updateView() call)
625 625
626 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 626 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
627 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 627 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
628 if ( maxWid < 0 ) 628 if ( maxWid < 0 )
629 maxWid = 20; 629 maxWid = 20;
630 630
631 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 631 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
632 QFontMetrics fm ( dlf ); 632 QFontMetrics fm ( dlf );
633 int selCount = mSelectedDates.count(); 633 int selCount = mSelectedDates.count();
634 QString dayTest = "Mon 20"; 634 QString dayTest = "Mon 20";
635 int wid = fm.width( dayTest ); 635 int wid = fm.width( dayTest );
636 maxWid -= ( selCount * 3 ); 636 maxWid -= ( selCount * 3 );
637 if ( maxWid < 0 ) 637 if ( maxWid < 0 )
638 maxWid = 20; 638 maxWid = 20;
639 int needWid = wid * selCount; 639 int needWid = wid * selCount;
640 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 640 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
641 //if ( needWid > maxWid ) 641 //if ( needWid > maxWid )
642 // qDebug("DAYLABELS TOOOOOOO BIG "); 642 // qDebug("DAYLABELS TOOOOOOO BIG ");
643 while ( needWid > maxWid ) { 643 while ( needWid > maxWid ) {
644 dayTest = dayTest.left( dayTest.length() - 1 ); 644 dayTest = dayTest.left( dayTest.length() - 1 );
645 wid = fm.width( dayTest ); 645 wid = fm.width( dayTest );
646 needWid = wid * selCount; 646 needWid = wid * selCount;
647 } 647 }
648 int maxLen = dayTest.length(); 648 int maxLen = dayTest.length();
649 int fontPoint = dlf.pointSize(); 649 int fontPoint = dlf.pointSize();
650 if ( maxLen < 2 ) { 650 if ( maxLen < 2 ) {
651 int fontPoint = dlf.pointSize(); 651 int fontPoint = dlf.pointSize();
652 while ( fontPoint > 4 ) { 652 while ( fontPoint > 4 ) {
653 --fontPoint; 653 --fontPoint;
654 dlf.setPointSize( fontPoint ); 654 dlf.setPointSize( fontPoint );
655 QFontMetrics f( dlf ); 655 QFontMetrics f( dlf );
656 wid = f.width( "20" ); 656 wid = f.width( "20" );
657 needWid = wid * selCount; 657 needWid = wid * selCount;
658 if ( needWid < maxWid ) 658 if ( needWid < maxWid )
659 break; 659 break;
660 } 660 }
661 maxLen = 2; 661 maxLen = 2;
662 } 662 }
663 //qDebug("Max len %d ", dayTest.length() ); 663 //qDebug("Max len %d ", dayTest.length() );
664 664
665 QFontMetrics tempF( dlf ); 665 QFontMetrics tempF( dlf );
666 newHight = tempF.height(); 666 newHight = tempF.height();
667 mDayLabels->setFont( dlf ); 667 mDayLabels->setFont( dlf );
668 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 668 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
669 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 669 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
670 //mLayoutDayLabels->addSpacing( 2 ); 670 //mLayoutDayLabels->addSpacing( 2 );
671 // QFont lFont = dlf; 671 // QFont lFont = dlf;
672 bool appendLabels = false; 672 bool appendLabels = false;
673 QLabel *dayLabel; 673 QLabel *dayLabel;
674 dayLabel = mDayLabelsList.first(); 674 dayLabel = mDayLabelsList.first();
675 if ( !dayLabel ) { 675 if ( !dayLabel ) {
676 appendLabels = true; 676 appendLabels = true;
677 dayLabel = new QLabel(mDayLabels); 677 dayLabel = new QLabel(mDayLabels);
678 mDayLabelsList.append( dayLabel ); 678 mDayLabelsList.append( dayLabel );
679 mLayoutDayLabels->addWidget(dayLabel); 679 mLayoutDayLabels->addWidget(dayLabel);
680 } 680 }
681 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 681 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
682 dayLabel->setFont( dlf ); 682 dayLabel->setFont( dlf );
683 dayLabel->setAlignment(QLabel::AlignHCenter); 683 dayLabel->setAlignment(QLabel::AlignHCenter);
684 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 684 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
685 dayLabel->show(); 685 dayLabel->show();
686 DateList::ConstIterator dit; 686 DateList::ConstIterator dit;
687 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 687 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
688 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 688 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
689 QDate date = *dit; 689 QDate date = *dit;
690 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 690 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
691 if ( ! appendLabels ) { 691 if ( ! appendLabels ) {
692 dayLabel = mDayLabelsList.next(); 692 dayLabel = mDayLabelsList.next();
693 if ( !dayLabel ) 693 if ( !dayLabel )
694 appendLabels = true; 694 appendLabels = true;
695 } 695 }
696 if ( appendLabels ) { 696 if ( appendLabels ) {
697 dayLabel = new QLabel(mDayLabels); 697 dayLabel = new QLabel(mDayLabels);
698 mDayLabelsList.append( dayLabel ); 698 mDayLabelsList.append( dayLabel );
699 mLayoutDayLabels->addWidget(dayLabel); 699 mLayoutDayLabels->addWidget(dayLabel);
700 } 700 }
701 dayLabel->setMinimumWidth( 1 ); 701 dayLabel->setMinimumWidth( 1 );
702 dayLabel->setMaximumWidth( 2048 ); 702 dayLabel->setMaximumWidth( 2048 );
703 dayLabel->setFont( dlf ); 703 dayLabel->setFont( dlf );
704 dayLabel->show(); 704 dayLabel->show();
705 QString str; 705 QString str;
706 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 706 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
707 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 707 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
708 switch ( maxLen ) { 708 switch ( maxLen ) {
709 case 2: 709 case 2:
710 str = QString::number( date.day() ); 710 str = QString::number( date.day() );
711 break; 711 break;
712 712
713 case 3: 713 case 3:
714 str = dayName.left( 1 ) +QString::number( date.day()); 714 str = dayName.left( 1 ) +QString::number( date.day());
715 715
716 break; 716 break;
717 case 4: 717 case 4:
718 str = dayName.left( 1 ) + " " +QString::number( date.day()); 718 str = dayName.left( 1 ) + " " +QString::number( date.day());
719 719
720 break; 720 break;
721 case 5: 721 case 5:
722 str = dayName.left( 2 ) + " " +QString::number( date.day()); 722 str = dayName.left( 2 ) + " " +QString::number( date.day());
723 723
724 break; 724 break;
725 case 6: 725 case 6:
726 str = dayName.left( 3 ) + " " +QString::number( date.day()); 726 str = dayName.left( 3 ) + " " +QString::number( date.day());
727 break; 727 break;
728 728
729 default: 729 default:
730 break; 730 break;
731 } 731 }
732 if ( oneday ) { 732 if ( oneday ) {
733 QString addString; 733 QString addString;
734 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 734 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
735 addString = i18n("Today"); 735 addString = i18n("Today");
736 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 736 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
737 addString = i18n("Tomorrow"); 737 addString = i18n("Tomorrow");
738 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 738 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
739 addString = i18n("Yesterday"); 739 addString = i18n("Yesterday");
740 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 740 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
741 addString = i18n("Day before yesterday"); 741 addString = i18n("Day before yesterday");
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
813int KOAgendaView::maxDatesHint() 813int 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
819int KOAgendaView::currentDateCount() 819int KOAgendaView::currentDateCount()
820{ 820{
821 return mSelectedDates.count(); 821 return mSelectedDates.count();
822} 822}
823 823
824QPtrList<Incidence> KOAgendaView::selectedIncidences() 824QPtrList<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
838DateList KOAgendaView::selectedDates() 838DateList 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
853void KOAgendaView::updateView() 853void 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*/
867void KOAgendaView::updateConfig() 867void 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
900void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 900void 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 if (item->lastMultiItem()) { 954 if (item->lastMultiItem()) {
954 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 955 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
955 endDt.setDate(startDate. 956 endDt.setDate(startDate.
956 addDays(item->lastMultiItem()->cellX() - item->cellX())); 957 addDays(item->lastMultiItem()->cellX() - item->cellX()));
957 } else { 958 } else {
958 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 959 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
959 if ( item->cellYBottom() > 0 ) 960 if ( item->cellYBottom() > 0 )
960 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 961 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
961 else 962 else
962 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 963 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
963 endDt.setDate(startDate); 964 endDt.setDate(startDate);
964 } 965 }
965 } 966 }
966 } 967 }
967 968
968 969 qDebug("to888");
969 if ( item->incidence()->type() == "Event" ) { 970 if ( item->incidence()->type() == "Event" ) {
970 item->incidence()->setDtStart(startDt); 971 item->incidence()->setDtStart(startDt);
971 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 972 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
972 } else if ( item->incidence()->type() == "Todo" ) { 973 } else if ( item->incidence()->type() == "Todo" ) {
973 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 974 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
974 } 975 }
975 //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() );
976 item->incidence()->setRevision(item->incidence()->revision()+1); 977 item->incidence()->setRevision(item->incidence()->revision()+1);
977 item->setItemDate(startDt.date()); 978 item->setItemDate(startDt.date());
978 //item->updateItem(); 979 //item->updateItem();
979 if ( item->incidence()->type() == "Todo" ) { 980 if ( item->incidence()->type() == "Todo" ) {
980 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 981 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
981 982
982 } 983 }
983 else 984 else
984 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 985 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
985 item->updateItem(); 986 item->updateItem();
986} 987}
987 988
988void KOAgendaView::showDates( const QDate &start, const QDate &end ) 989void KOAgendaView::showDates( const QDate &start, const QDate &end )
989{ 990{
990 // kdDebug() << "KOAgendaView::selectDates" << endl; 991 // kdDebug() << "KOAgendaView::selectDates" << endl;
991 992
992 mSelectedDates.clear(); 993 mSelectedDates.clear();
993 // qDebug("KOAgendaView::showDates "); 994 // qDebug("KOAgendaView::showDates ");
994 QDate d = start; 995 QDate d = start;
995 while (d <= end) { 996 while (d <= end) {
996 mSelectedDates.append(d); 997 mSelectedDates.append(d);
997 d = d.addDays( 1 ); 998 d = d.addDays( 1 );
998 } 999 }
999 1000
1000 // and update the view 1001 // and update the view
1001 fillAgenda(); 1002 fillAgenda();
1002} 1003}
1003 1004
1004 1005
1005void KOAgendaView::showEvents(QPtrList<Event>) 1006void KOAgendaView::showEvents(QPtrList<Event>)
1006{ 1007{
1007 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1008 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1008} 1009}
1009 1010
1010void KOAgendaView::changeEventDisplay(Event *, int) 1011void KOAgendaView::changeEventDisplay(Event *, int)
1011{ 1012{
1012 // qDebug("KOAgendaView::changeEventDisplay "); 1013 // qDebug("KOAgendaView::changeEventDisplay ");
1013 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1014 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1014 // 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
1015 // are just playing dumb. 1016 // are just playing dumb.
1016 fillAgenda(); 1017 fillAgenda();
1017} 1018}
1018 1019
1019void KOAgendaView::fillAgenda(const QDate &) 1020void KOAgendaView::fillAgenda(const QDate &)
1020{ 1021{
1021 // qDebug("KOAgendaView::fillAgenda "); 1022 // qDebug("KOAgendaView::fillAgenda ");
1022 fillAgenda(); 1023 fillAgenda();
1023} 1024}
1024 1025
1025void KOAgendaView::fillAgenda() 1026void KOAgendaView::fillAgenda()
1026{ 1027{
1027 if ( globalFlagBlockStartup ) 1028 if ( globalFlagBlockStartup )
1028 return; 1029 return;
1029 if ( globalFlagBlockAgenda == 1 ) 1030 if ( globalFlagBlockAgenda == 1 )
1030 return; 1031 return;
1031 //if ( globalFlagBlockAgenda == 2 ) 1032 //if ( globalFlagBlockAgenda == 2 )
1032 //globalFlagBlockAgenda = 0; 1033 //globalFlagBlockAgenda = 0;
1033 // globalFlagBlockPainting = false; 1034 // globalFlagBlockPainting = false;
1034 if ( globalFlagBlockAgenda == 0 ) 1035 if ( globalFlagBlockAgenda == 0 )
1035 globalFlagBlockAgenda = 1; 1036 globalFlagBlockAgenda = 1;
1036 // clearView(); 1037 // clearView();
1037 //qDebug("fillAgenda()++++ "); 1038 //qDebug("fillAgenda()++++ ");
1038 globalFlagBlockAgendaItemPaint = 1; 1039 globalFlagBlockAgendaItemPaint = 1;
1039 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1040 mAllDayAgenda->changeColumns(mSelectedDates.count());
1040 mAgenda->changeColumns(mSelectedDates.count()); 1041 mAgenda->changeColumns(mSelectedDates.count());
1041 qApp->processEvents(); 1042 qApp->processEvents();
1042 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1043 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1043 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1044 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1044 setHolidayMasks(); 1045 setHolidayMasks();
1045 1046
1046 //mAgenda->hideUnused(); 1047 //mAgenda->hideUnused();
1047 //mAllDayAgenda->hideUnused(); 1048 //mAllDayAgenda->hideUnused();
1048 1049
1049 // mAgenda->blockNextRepaint( false ); 1050 // mAgenda->blockNextRepaint( false );
1050 // mAgenda->viewport()->repaint(); 1051 // mAgenda->viewport()->repaint();
1051 // mAgenda->blockNextRepaint( true ); 1052 // mAgenda->blockNextRepaint( true );
1052 mMinY.resize(mSelectedDates.count()); 1053 mMinY.resize(mSelectedDates.count());
1053 mMaxY.resize(mSelectedDates.count()); 1054 mMaxY.resize(mSelectedDates.count());
1054 1055
1055 QPtrList<Event> dayEvents; 1056 QPtrList<Event> dayEvents;
1056 1057
1057 // 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.
1058 // Therefore, get all of them. 1059 // Therefore, gtodoset all of them.
1059 QPtrList<Todo> todos = calendar()->todos(); 1060 QPtrList<Todo> todos = calendar()->todos();
1060 1061
1061 mAgenda->setDateList(mSelectedDates); 1062 mAgenda->setDateList(mSelectedDates);
1062 1063
1063 QDate today = QDate::currentDate(); 1064 QDate today = QDate::currentDate();
1064 1065
1065 DateList::ConstIterator dit; 1066 DateList::ConstIterator dit;
1066 int curCol = 0; 1067 int curCol = 0;
1067 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1068 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1068 QDate currentDate = *dit; 1069 QDate currentDate = *dit;
1069 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1070 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1070 // << endl; 1071 // << endl;
1071 1072
1072 dayEvents = calendar()->events(currentDate,true); 1073 dayEvents = calendar()->events(currentDate,true);
1073 1074
1074 // Default values, which can never be reached 1075 // Default values, which can never be reached
1075 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1076 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1076 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1077 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1077 1078
1078 unsigned int numEvent; 1079 unsigned int numEvent;
1079 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1080 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1080 Event *event = dayEvents.at(numEvent); 1081 Event *event = dayEvents.at(numEvent);
1081 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1082 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1082 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1083 if ( event->uid().left(15) == QString("last-syncEvent-") )
1083 continue; 1084 continue;
1084 // kdDebug() << " Event: " << event->summary() << endl; 1085 // kdDebug() << " Event: " << event->summary() << endl;
1085 1086
1086 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1087 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1087 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1088 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1088 1089
1089 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1090 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1090 1091
1091 if (event->doesFloat()) { 1092 if (event->doesFloat()) {
1092 if (event->recurrence()->doesRecur()) { 1093 if (event->recurrence()->doesRecur()) {
1093 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1094 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1094 } else { 1095 } else {
1095 if (beginX <= 0 && curCol == 0) { 1096 if (beginX <= 0 && curCol == 0) {
1096 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1097 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1097 } else if (beginX == curCol) { 1098 } else if (beginX == curCol) {
1098 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1099 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1099 } 1100 }
1100 } 1101 }
1101 } else if (event->isMultiDay()) { 1102 } else if (event->isMultiDay()) {
1102 if ( event->doesRecur () ) { 1103 if ( event->doesRecur () ) {
1103 QDate dateit = currentDate; 1104 QDate dateit = currentDate;
1104 int count = 0; 1105 int count = 0;
1105 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1106 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1106 while (! event->recursOn( dateit ) && count <= max ) { 1107 while (! event->recursOn( dateit ) && count <= max ) {
1107 ++count; 1108 ++count;
1108 dateit = dateit.addDays( -1 ); 1109 dateit = dateit.addDays( -1 );
1109 } 1110 }
1110 bool ok; 1111 bool ok;
1111 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1112 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1112 if ( ok ) 1113 if ( ok )
1113 { 1114 {
1114 int secs = event->dtStart().secsTo( event->dtEnd() ); 1115 int secs = event->dtStart().secsTo( event->dtEnd() );
1115 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1116 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1116 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1117 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1117 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1118 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1118 1119
1119 } 1120 }
1120 } 1121 }
1121 int startY = mAgenda->timeToY(event->dtStart().time()); 1122 int startY = mAgenda->timeToY(event->dtStart().time());
1122 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1123 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1123 //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 );
1124 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1125 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1125 //qDebug("insert!!! "); 1126 //qDebug("insert!!! ");
1126 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1127 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1127 } 1128 }
1128 if (beginX == curCol) { 1129 if (beginX == curCol) {
1129 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1130 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1130 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1131 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1131 } else if (endX == curCol) { 1132 } else if (endX == curCol) {
1132 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1133 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1133 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1134 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1134 } else { 1135 } else {
1135 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1136 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1136 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1137 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1137 } 1138 }
1138 } else { 1139 } else {
1139 int startY = mAgenda->timeToY(event->dtStart().time()); 1140 int startY = mAgenda->timeToY(event->dtStart().time());
1140 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1141 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1141 if (endY < startY) endY = startY; 1142 if (endY < startY) endY = startY;
1142 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1143 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1143 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1144 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1144 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1145 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1145 } 1146 }
1146 } 1147 }
1147 // ---------- [display Todos -------------- 1148 // ---------- [display Todos --------------
1148 unsigned int numTodo; 1149 unsigned int numTodo;
1149 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1150 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1150 Todo *todo = todos.at(numTodo); 1151 Todo *todo = todos.at(numTodo);
1151 1152
1152 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
1153 1154
1154 // 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.
1155 // Already completed items can be displayed on their original due date 1156 // Already completed items can be displayed on their original due date
1156 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1157 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1157 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1158 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1158 1159 bool fillIn = false;
1159 if ( ((todo->dtDue().date() == currentDate) && !overdue) || ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1160 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1160 ((currentDate == today) && overdue) ) { 1161 fillIn = true;
1162 if ( ! fillIn && !todo->hasCompletedDate() )
1163 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1164 qDebug("refill todo ");
1165 if ( fillIn ) {
1161 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1166 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1162 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1167 if ( KOPrefs::instance()->mShowTodoInAgenda )
1163 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1168 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1164 } 1169 }
1165 else { 1170 else {
1166 QDateTime dt; 1171 QDateTime dt;
1167 if ( todo->hasCompletedDate() ) 1172 if ( todo->hasCompletedDate() )
1168 dt = todo->completed(); 1173 dt = todo->completed();
1169 else 1174 else
1170 dt = todo->dtDue();; 1175 dt = todo->dtDue();;
1171 1176
1172 1177
1173 int endY = mAgenda->timeToY(dt.time()) - 1; 1178 int endY = mAgenda->timeToY(dt.time()) - 1;
1174 int hi = (18/KOPrefs::instance()->mHourSize); 1179 int hi = (18/KOPrefs::instance()->mHourSize);
1175 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1180 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1176 int startY = endY -hi; 1181 int startY = endY -hi;
1177 1182
1178 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1183 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1179 1184
1180 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1185 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1181 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1186 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1182 } 1187 }
1183 } 1188 }
1184 } 1189 }
1185 // ---------- display Todos] -------------- 1190 // ---------- display Todos] --------------
1186 1191
1187 ++curCol; 1192 ++curCol;
1188 } 1193 }
1189 mAgenda->hideUnused(); 1194 mAgenda->hideUnused();
1190 mAllDayAgenda->hideUnused(); 1195 mAllDayAgenda->hideUnused();
1191 mAgenda->checkScrollBoundaries(); 1196 mAgenda->checkScrollBoundaries();
1192 1197
1193 deleteSelectedDateTime(); 1198 deleteSelectedDateTime();
1194 1199
1195 createDayLabels(); 1200 createDayLabels();
1196 emit incidenceSelected( 0 ); 1201 emit incidenceSelected( 0 );
1197 1202
1198 if ( globalFlagBlockAgenda == 2 ) { 1203 if ( globalFlagBlockAgenda == 2 ) {
1199 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1204 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1200 setStartHour( KOPrefs::instance()->mDayBegins ); 1205 setStartHour( KOPrefs::instance()->mDayBegins );
1201 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1206 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1202 setStartHour( QTime::currentTime ().hour() ); 1207 setStartHour( QTime::currentTime ().hour() );
1203 // qApp->processEvents(); 1208 // qApp->processEvents();
1204 } 1209 }
1205 qApp->processEvents(); 1210 qApp->processEvents();
1206 //qDebug("qApp->processEvents(); END "); 1211 //qDebug("qApp->processEvents(); END ");
1207 globalFlagBlockAgenda = 0; 1212 globalFlagBlockAgenda = 0;
1208 1213
1209 // mAgenda->hideUnused(); 1214 // mAgenda->hideUnused();
1210 //mAllDayAgenda->hideUnused(); 1215 //mAllDayAgenda->hideUnused();
1211 mAllDayAgenda->drawContentsToPainter(); 1216 mAllDayAgenda->drawContentsToPainter();
1212 mAgenda->drawContentsToPainter(); 1217 mAgenda->drawContentsToPainter();
1213 repaintAgenda(); 1218 repaintAgenda();
1214 // mAgenda->finishUpdate(); 1219 // mAgenda->finishUpdate();
1215 //mAllDayAgenda->finishUpdate(); 1220 //mAllDayAgenda->finishUpdate();
1216 1221
1217 // repaintAgenda(); 1222 // repaintAgenda();
1218 //qApp->processEvents(); 1223 //qApp->processEvents();
1219 // globalFlagBlockAgenda = 0; 1224 // globalFlagBlockAgenda = 0;
1220} 1225}
1221void KOAgendaView::repaintAgenda() 1226void KOAgendaView::repaintAgenda()
1222{ 1227{
1223 // mAllDayAgenda->drawContentsToPainter(); 1228 // mAllDayAgenda->drawContentsToPainter();
1224// mAllDayAgenda->viewport()->repaint( false ); 1229// mAllDayAgenda->viewport()->repaint( false );
1225// mAgenda->drawContentsToPainter(); 1230// mAgenda->drawContentsToPainter();
1226// mAgenda->viewport()->repaint( false ); 1231// mAgenda->viewport()->repaint( false );
1227// qApp->processEvents(); 1232// qApp->processEvents();
1228 1233
1229 //qDebug("KOAgendaView::repaintAgenda() "); 1234 //qDebug("KOAgendaView::repaintAgenda() ");
1230 //qApp->processEvents(); 1235 //qApp->processEvents();
1231 mAgenda->viewport()->repaint( false ); 1236 mAgenda->viewport()->repaint( false );
1232 mAllDayAgenda->viewport()->repaint( false ); 1237 mAllDayAgenda->viewport()->repaint( false );
1233 mAgenda->finishUpdate(); 1238 mAgenda->finishUpdate();
1234 mAllDayAgenda->finishUpdate(); 1239 mAllDayAgenda->finishUpdate();
1235} 1240}
1236 1241
1237 1242
1238void KOAgendaView::clearView() 1243void KOAgendaView::clearView()
1239{ 1244{
1240 // kdDebug() << "ClearView" << endl; 1245 // kdDebug() << "ClearView" << endl;
1241 mAllDayAgenda->clear(); 1246 mAllDayAgenda->clear();
1242 mAgenda->clear(); 1247 mAgenda->clear();
1243} 1248}
1244 1249
1245void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1250void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1246 const QDate &td) 1251 const QDate &td)
1247{ 1252{
1248#ifndef KORG_NOPRINTER 1253#ifndef KORG_NOPRINTER
1249 if (fd == td) 1254 if (fd == td)
1250 calPrinter->preview(CalPrinter::Day, fd, td); 1255 calPrinter->preview(CalPrinter::Day, fd, td);
1251 else 1256 else
1252 calPrinter->preview(CalPrinter::Week, fd, td); 1257 calPrinter->preview(CalPrinter::Week, fd, td);
1253#endif 1258#endif
1254} 1259}
1255 1260
1256// void KOAgendaView::updateMovedTodo() 1261// void KOAgendaView::updateMovedTodo()
1257// { 1262// {
1258// // updateConfig(); 1263// // updateConfig();
1259// // emit updateTodoViews(); 1264// // emit updateTodoViews();
1260// } 1265// }
1261 1266
1262void KOAgendaView::newEvent(int gx, int gy) 1267void KOAgendaView::newEvent(int gx, int gy)
1263{ 1268{
1264 if (!mSelectedDates.count()) return; 1269 if (!mSelectedDates.count()) return;
1265 1270
1266 QDate day = mSelectedDates[gx]; 1271 QDate day = mSelectedDates[gx];
1267 1272
1268 QTime time = mAgenda->gyToTime(gy); 1273 QTime time = mAgenda->gyToTime(gy);
1269 QDateTime dt(day,time); 1274 QDateTime dt(day,time);
1270 // if ( dt < QDateTime::currentDateTime () ) 1275 // if ( dt < QDateTime::currentDateTime () )
1271 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1276 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1272 emit newEventSignal(dt); 1277 emit newEventSignal(dt);
1273} 1278}
1274 1279
1275void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1280void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1276{ 1281{
1277 if (!mSelectedDates.count()) return; 1282 if (!mSelectedDates.count()) return;
1278 1283
1279 QDate dayStart = mSelectedDates[gxStart]; 1284 QDate dayStart = mSelectedDates[gxStart];
1280 QDate dayEnd = mSelectedDates[gxEnd]; 1285 QDate dayEnd = mSelectedDates[gxEnd];
1281 1286
1282 QTime timeStart = mAgenda->gyToTime(gyStart); 1287 QTime timeStart = mAgenda->gyToTime(gyStart);
1283 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1288 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1284 1289
1285 QDateTime dtStart(dayStart,timeStart); 1290 QDateTime dtStart(dayStart,timeStart);
1286 QDateTime dtEnd(dayEnd,timeEnd); 1291 QDateTime dtEnd(dayEnd,timeEnd);
1287 1292
1288 emit newEventSignal(dtStart,dtEnd); 1293 emit newEventSignal(dtStart,dtEnd);
1289} 1294}
1290 1295
1291void KOAgendaView::newEventAllDay(int gx, int ) 1296void KOAgendaView::newEventAllDay(int gx, int )
1292{ 1297{
1293 if (!mSelectedDates.count()) return; 1298 if (!mSelectedDates.count()) return;
1294 1299
1295 QDate day = mSelectedDates[gx]; 1300 QDate day = mSelectedDates[gx];
1296 1301
1297 emit newEventSignal(day); 1302 emit newEventSignal(day);
1298} 1303}
1299void KOAgendaView::newTodoAllDay(int gx, int ) 1304void KOAgendaView::newTodoAllDay(int gx, int )
1300{ 1305{
1301 if (!mSelectedDates.count()) return; 1306 if (!mSelectedDates.count()) return;
1302 1307
1303 QDateTime day (mSelectedDates[gx] ); 1308 QDateTime day (mSelectedDates[gx] );
1304 emit newTodoSignal(day, true); 1309 emit newTodoSignal(day, true);
1305} 1310}
1306void KOAgendaView::newTodo(int gx, int gy ) 1311void KOAgendaView::newTodo(int gx, int gy )
1307{ 1312{
1308 if (!mSelectedDates.count()) return; 1313 if (!mSelectedDates.count()) return;
1309 QDate dayStart = mSelectedDates[gx]; 1314 QDate dayStart = mSelectedDates[gx];
1310 QTime timeStart = mAgenda->gyToTime(gy); 1315 QTime timeStart = mAgenda->gyToTime(gy);
1311 QDateTime dt (dayStart,timeStart); 1316 QDateTime dt (dayStart,timeStart);
1312 emit newTodoSignal( dt, false ); 1317 emit newTodoSignal( dt, false );
1313} 1318}
1314 1319
1315void KOAgendaView::updateEventIndicatorTop(int newY) 1320void KOAgendaView::updateEventIndicatorTop(int newY)
1316{ 1321{
1317 uint i; 1322 uint i;
1318 for(i=0;i<mMinY.size();++i) { 1323 for(i=0;i<mMinY.size();++i) {
1319 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1324 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1320 else mEventIndicatorTop->enableColumn(i,false); 1325 else mEventIndicatorTop->enableColumn(i,false);
1321 } 1326 }
1322 1327
1323 mEventIndicatorTop->update(); 1328 mEventIndicatorTop->update();
1324} 1329}
1325 1330
1326void KOAgendaView::updateEventIndicatorBottom(int newY) 1331void KOAgendaView::updateEventIndicatorBottom(int newY)
1327{ 1332{
1328 uint i; 1333 uint i;
1329 for(i=0;i<mMaxY.size();++i) { 1334 for(i=0;i<mMaxY.size();++i) {
1330 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1335 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1331 else mEventIndicatorBottom->enableColumn(i,false); 1336 else mEventIndicatorBottom->enableColumn(i,false);
1332 } 1337 }
1333 1338
1334 mEventIndicatorBottom->update(); 1339 mEventIndicatorBottom->update();
1335} 1340}
1336 1341
1337void KOAgendaView::startDrag(Event *event) 1342void KOAgendaView::startDrag(Event *event)
1338{ 1343{
1339#ifndef KORG_NODND 1344#ifndef KORG_NODND
1340 DndFactory factory( calendar() ); 1345 DndFactory factory( calendar() );
1341 ICalDrag *vd = factory.createDrag(event,this); 1346 ICalDrag *vd = factory.createDrag(event,this);
1342 if (vd->drag()) { 1347 if (vd->drag()) {
1343 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1348 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1344 } 1349 }
1345#endif 1350#endif
1346} 1351}
1347 1352
1348void KOAgendaView::readSettings() 1353void KOAgendaView::readSettings()
1349{ 1354{
1350 readSettings(KOGlobals::config()); 1355 readSettings(KOGlobals::config());
1351} 1356}
1352 1357
1353void KOAgendaView::readSettings(KConfig *config) 1358void KOAgendaView::readSettings(KConfig *config)
1354{ 1359{
1355 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1360 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1356 1361
1357 config->setGroup("Views"); 1362 config->setGroup("Views");
1358 1363
1359 //#ifndef KORG_NOSPLITTER 1364 //#ifndef KORG_NOSPLITTER
1360 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1365 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1361 if (sizes.count() == 2) { 1366 if (sizes.count() == 2) {
1362 if ( sizes[0] < 20 ) { 1367 if ( sizes[0] < 20 ) {
1363 sizes[1] = sizes[1] +20 - sizes[0]; 1368 sizes[1] = sizes[1] +20 - sizes[0];
1364 sizes[0] = 20; 1369 sizes[0] = 20;
1365 } 1370 }
1366 mSplitterAgenda->setSizes(sizes); 1371 mSplitterAgenda->setSizes(sizes);
1367 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1372 // qDebug("read %d %d ",sizes[0],sizes[1] );
1368 } 1373 }
1369 //#endif 1374 //#endif
1370 1375
1371 // updateConfig(); 1376 // updateConfig();
1372} 1377}
1373 1378
1374void KOAgendaView::writeSettings(KConfig *config) 1379void KOAgendaView::writeSettings(KConfig *config)
1375{ 1380{
1376 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1381 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1377 1382
1378 config->setGroup("Views"); 1383 config->setGroup("Views");
1379 1384
1380 //#ifndef KORG_NOSPLITTER 1385 //#ifndef KORG_NOSPLITTER
1381 QValueList<int> list = mSplitterAgenda->sizes(); 1386 QValueList<int> list = mSplitterAgenda->sizes();
1382 config->writeEntry("Separator AgendaView",list); 1387 config->writeEntry("Separator AgendaView",list);
1383 //qDebug("write %d %d ", list[0],list[1] ); 1388 //qDebug("write %d %d ", list[0],list[1] );
1384 //#endif 1389 //#endif
1385} 1390}
1386 1391
1387void KOAgendaView::setHolidayMasks() 1392void KOAgendaView::setHolidayMasks()
1388{ 1393{
1389 mHolidayMask.resize(mSelectedDates.count()); 1394 mHolidayMask.resize(mSelectedDates.count());
1390 1395
1391 uint i; 1396 uint i;
1392 for(i=0;i<mSelectedDates.count();++i) { 1397 for(i=0;i<mSelectedDates.count();++i) {
1393 QDate date = mSelectedDates[i]; 1398 QDate date = mSelectedDates[i];
1394 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1399 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1395 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1400 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1396 bool showHoliday = false; 1401 bool showHoliday = false;
1397 if ( KOPrefs::instance()->mExcludeHolidays ) { 1402 if ( KOPrefs::instance()->mExcludeHolidays ) {
1398 QPtrList<Event> events = calendar()->events( date, true ); 1403 QPtrList<Event> events = calendar()->events( date, true );
1399 Event *event; 1404 Event *event;
1400 for( event = events.first(); event; event = events.next() ) { 1405 for( event = events.first(); event; event = events.next() ) {
1401 if ( event->categories().contains("Holiday") || 1406 if ( event->categories().contains("Holiday") ||
1402 event->categories().contains(i18n("Holiday"))) { 1407 event->categories().contains(i18n("Holiday"))) {
1403 showHoliday = true; 1408 showHoliday = true;
1404 break; 1409 break;
1405 } 1410 }
1406 } 1411 }
1407 1412
1408 } 1413 }
1409 1414
1410#ifndef KORG_NOPLUGINS 1415#ifndef KORG_NOPLUGINS
1411 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1416 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1412 !KOCore::self()->holiday(date).isEmpty(); 1417 !KOCore::self()->holiday(date).isEmpty();
1413#endif 1418#endif
1414 bool showDay = showSaturday || showSunday || showHoliday; 1419 bool showDay = showSaturday || showSunday || showHoliday;
1415 1420
1416 if (showDay) { 1421 if (showDay) {
1417 mHolidayMask.at(i) = true; 1422 mHolidayMask.at(i) = true;
1418 } else { 1423 } else {
1419 mHolidayMask.at(i) = false; 1424 mHolidayMask.at(i) = false;
1420 } 1425 }
1421 } 1426 }
1422 1427
1423 mAgenda->setHolidayMask(&mHolidayMask); 1428 mAgenda->setHolidayMask(&mHolidayMask);
1424 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1429 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1425} 1430}
1426 1431
1427void KOAgendaView::setContentsPos(int y) 1432void KOAgendaView::setContentsPos(int y)
1428{ 1433{
1429 mAgenda->setContentsPos(0,y); 1434 mAgenda->setContentsPos(0,y);
1430} 1435}
1431 1436
1432void KOAgendaView::setExpandedButton( bool expanded ) 1437void KOAgendaView::setExpandedButton( bool expanded )
1433{ 1438{
1434 if ( expanded ) { 1439 if ( expanded ) {
1435 mExpandButton->setPixmap( mExpandedPixmap ); 1440 mExpandButton->setPixmap( mExpandedPixmap );
1436 } else { 1441 } else {
1437 mExpandButton->setPixmap( mNotExpandedPixmap ); 1442 mExpandButton->setPixmap( mNotExpandedPixmap );
1438 } 1443 }
1439} 1444}
1440 1445
1441void KOAgendaView::clearSelection() 1446void KOAgendaView::clearSelection()
1442{ 1447{
1443 mAgenda->deselectItem(); 1448 mAgenda->deselectItem();
1444 mAllDayAgenda->deselectItem(); 1449 mAllDayAgenda->deselectItem();
1445} 1450}
1446 1451
1447void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1452void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1448 int gxEnd, int gyEnd) 1453 int gxEnd, int gyEnd)
1449{ 1454{
1450 mTimeSpanInAllDay = true; 1455 mTimeSpanInAllDay = true;
1451 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1456 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1452} 1457}
1453 1458
1454 1459
1455 1460
1456 1461
1457void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1462void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1458 int gxEnd, int gyEnd) 1463 int gxEnd, int gyEnd)
1459{ 1464{
1460 if (!mSelectedDates.count()) return; 1465 if (!mSelectedDates.count()) return;
1461 1466
1462 QDate dayStart = mSelectedDates[gxStart]; 1467 QDate dayStart = mSelectedDates[gxStart];
1463 QDate dayEnd = mSelectedDates[gxEnd]; 1468 QDate dayEnd = mSelectedDates[gxEnd];
1464 1469
1465 QTime timeStart = mAgenda->gyToTime(gyStart); 1470 QTime timeStart = mAgenda->gyToTime(gyStart);
1466 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1471 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1467 1472
1468 QDateTime dtStart(dayStart,timeStart); 1473 QDateTime dtStart(dayStart,timeStart);
1469 QDateTime dtEnd(dayEnd,timeEnd); 1474 QDateTime dtEnd(dayEnd,timeEnd);
1470 1475
1471 mTimeSpanBegin = dtStart; 1476 mTimeSpanBegin = dtStart;
1472 mTimeSpanEnd = dtEnd; 1477 mTimeSpanEnd = dtEnd;
1473 1478
1474} 1479}
1475 1480
1476void KOAgendaView::deleteSelectedDateTime() 1481void KOAgendaView::deleteSelectedDateTime()
1477{ 1482{
1478 mTimeSpanBegin.setDate(QDate()); 1483 mTimeSpanBegin.setDate(QDate());
1479 mTimeSpanEnd.setDate(QDate()); 1484 mTimeSpanEnd.setDate(QDate());
1480 mTimeSpanInAllDay = false; 1485 mTimeSpanInAllDay = false;
1481} 1486}
1482 1487
1483void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1488void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1484{ 1489{
1485 e->ignore(); 1490 e->ignore();
1486} 1491}
1487 1492
1488void KOAgendaView::scrollOneHourUp() 1493void KOAgendaView::scrollOneHourUp()
1489{ 1494{
1490 1495
1491 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1496 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1492} 1497}
1493void KOAgendaView::scrollOneHourDown() 1498void KOAgendaView::scrollOneHourDown()
1494{ 1499{
1495 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1500 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1496} 1501}
1497 1502
1498void KOAgendaView::setStartHour( int h ) 1503void KOAgendaView::setStartHour( int h )
1499{ 1504{
1500 mAgenda->setStartHour( h ); 1505 mAgenda->setStartHour( h );
1501 1506
1502} 1507}
1503 1508
1504void KOAgendaView::updateTodo( Todo * t, int ) 1509void KOAgendaView::updateTodo( Todo * t, int )
1505{ 1510{
1506 1511
1507 bool remove = false; 1512 bool remove = false;
1508 bool removeAD = false; 1513 bool removeAD = false;
1509 if ( ! t->hasDueDate() ) { 1514 QDate da;
1515 if ( t->hasCompletedDate() )
1516 da = t->completed().date();
1517 else
1518 da = t->dtDue().date();
1519 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1510 remove = true; 1520 remove = true;
1511 removeAD = true; 1521 removeAD = true;
1512 } 1522 }
1513 else { 1523 else {
1514 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1524 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1515 if ( overdue && 1525 if ( overdue &&
1516 QDate::currentDate() >= mSelectedDates.first() && 1526 QDate::currentDate() >= mSelectedDates.first() &&
1517 QDate::currentDate() <= mSelectedDates.last()) { 1527 QDate::currentDate() <= mSelectedDates.last()) {
1518 removeAD = false; 1528 removeAD = false;
1519 remove = true; 1529 remove = true;
1520 } 1530 }
1521 else { 1531 else {
1522 if ( t->dtDue().date() < mSelectedDates.first() || 1532
1523 t->dtDue().date() > mSelectedDates.last() ) { 1533 if ( da < mSelectedDates.first() ||
1534 da > mSelectedDates.last() ) {
1524 remove = true; 1535 remove = true;
1525 removeAD = true; 1536 removeAD = true;
1526 } else { 1537 } else {
1527 remove = t->doesFloat(); 1538 remove = t->doesFloat() && !t->hasCompletedDate();
1528 removeAD = !remove; 1539 removeAD = !remove;
1529 } 1540 }
1530 } 1541 }
1531 } 1542 }
1532 int days = mSelectedDates.first().daysTo( t->dtDue().date() ); 1543 int days = mSelectedDates.first().daysTo( da );
1533 // qDebug("daysto %d ", days ); 1544 // qDebug("daysto %d ", days );
1534 mAgenda->updateTodo( t , days, remove); 1545 mAgenda->updateTodo( t , days, remove);
1535 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1546 if ( KOPrefs::instance()->mShowTodoInAgenda )
1536 mAllDayAgenda->updateTodo( t , days, removeAD); 1547 mAllDayAgenda->updateTodo( t , days, removeAD);
1537 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1548 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1538 1549
1539} 1550}
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 36a2947..7dc1880 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,604 +1,606 @@
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 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.h>
56#else //DESKTOP_VERSION 56#else //DESKTOP_VERSION
57#include <externalapphandler.h> 57#include <externalapphandler.h>
58#include <qtopia/qcopenvelope_qws.h> 58#include <qtopia/qcopenvelope_qws.h>
59#endif //DESKTOP_VERSION 59#endif //DESKTOP_VERSION
60 60
61KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 61KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
62 : QTextBrowser(parent,name) 62 : QTextBrowser(parent,name)
63{ 63{
64 mSyncMode = false; 64 mSyncMode = false;
65 mColorMode = 0; 65 mColorMode = 0;
66} 66}
67 67
68KOEventViewer::~KOEventViewer() 68KOEventViewer::~KOEventViewer()
69{ 69{
70} 70}
71 71
72void KOEventViewer::setSource(const QString& n) 72void KOEventViewer::setSource(const QString& n)
73{ 73{
74 74
75 if ( n.left(3) == "uid" ) 75 if ( n.left(3) == "uid" )
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 { 77 {
78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
79 KABC::AddressBook::Iterator it; 79 KABC::AddressBook::Iterator it;
80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
81 // LR I do not understand, why the uid string is different on zaurus and desktop 81 // LR I do not understand, why the uid string is different on zaurus and desktop
82 QString uid = "uid://"+(*it).uid(); 82 QString uid = "uid://"+(*it).uid();
83 83
84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
85 if (n == uid ) { 85 if (n == uid ) {
86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
87 QDialog dia( this,"dia123", true ); 87 QDialog dia( this,"dia123", true );
88 dia.setCaption( i18n("Details of attendee") ); 88 dia.setCaption( i18n("Details of attendee") );
89 QVBoxLayout lay ( &dia ); 89 QVBoxLayout lay ( &dia );
90 KABC::AddresseeView av ( &dia ); 90 KABC::AddresseeView av ( &dia );
91 av.setAddressee( (*it) ); 91 av.setAddressee( (*it) );
92 lay.addWidget( &av ); 92 lay.addWidget( &av );
93 if ( QApplication::desktop()->width() < 480 ) 93 if ( QApplication::desktop()->width() < 480 )
94 dia.resize( 220, 240); 94 dia.resize( 220, 240);
95 else { 95 else {
96 dia.resize( 400,400); 96 dia.resize( 400,400);
97 } 97 }
98 dia.exec(); 98 dia.exec();
99 break; 99 break;
100 } 100 }
101 } 101 }
102 return; 102 return;
103 } 103 }
104#else 104#else
105 { 105 {
106 if ( "uid:organizer" == n ) { 106 if ( "uid:organizer" == n ) {
107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
108 return; 108 return;
109 } 109 }
110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
111 if (attendees.count()) { 111 if (attendees.count()) {
112 Attendee *a; 112 Attendee *a;
113 for(a=attendees.first();a;a=attendees.next()) { 113 for(a=attendees.first();a;a=attendees.next()) {
114 if ( "uid:"+a->uid() == n ) { 114 if ( "uid:"+a->uid() == n ) {
115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
116 return; 116 return;
117 } 117 }
118 } 118 }
119 } 119 }
120 return; 120 return;
121 } 121 }
122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
123 // the result should now arrive through method insertAttendees 123 // the result should now arrive through method insertAttendees
124 //QString uid = "uid:"+(*it).uid(); 124 //QString uid = "uid:"+(*it).uid();
125#endif 125#endif
126 if ( n.left(6) == "mailto" ) { 126 if ( n.left(6) == "mailto" ) {
127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
128#ifndef DESKTOP_VERSION 128#ifndef DESKTOP_VERSION
129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 129 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
130 e << n.mid(7); 130 e << n.mid(7);
131#endif 131#endif
132 132
133 } 133 }
134 134
135 135
136#ifndef KORG_NODCOP 136#ifndef KORG_NODCOP
137 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 137 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
138 QString tmpStr; 138 QString tmpStr;
139 if (n.startsWith("mailto:")) { 139 if (n.startsWith("mailto:")) {
140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 140 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
141 //emit showIncidence(n); 141 //emit showIncidence(n);
142 return; 142 return;
143 } else if (n.startsWith("uid:")) { 143 } else if (n.startsWith("uid:")) {
144 DCOPClient *client = KApplication::kApplication()->dcopClient(); 144 DCOPClient *client = KApplication::kApplication()->dcopClient();
145 const QByteArray noParamData; 145 const QByteArray noParamData;
146 const QByteArray paramData; 146 const QByteArray paramData;
147 QByteArray replyData; 147 QByteArray replyData;
148 QCString replyTypeStr; 148 QCString replyTypeStr;
149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 149#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
150 bool foundAbbrowser = PING_ABBROWSER; 150 bool foundAbbrowser = PING_ABBROWSER;
151 151
152 if (foundAbbrowser) { 152 if (foundAbbrowser) {
153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 153 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
154 //client->send("kaddressbook","KAddressBookIface", 154 //client->send("kaddressbook","KAddressBookIface",
155 QDataStream arg(paramData, IO_WriteOnly); 155 QDataStream arg(paramData, IO_WriteOnly);
156 arg << n.mid(6); 156 arg << n.mid(6);
157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 157 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
158 return; 158 return;
159 } else { 159 } else {
160 /* 160 /*
161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 161 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
162 We start it without its main interface 162 We start it without its main interface
163 */ 163 */
164 KIconLoader* iconLoader = new KIconLoader(); 164 KIconLoader* iconLoader = new KIconLoader();
165 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 165 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
166 ActionManager::setStartedKAddressBook(true); 166 ActionManager::setStartedKAddressBook(true);
167 tmpStr = "kaddressbook --editor-only --uid "; 167 tmpStr = "kaddressbook --editor-only --uid ";
168 tmpStr += KProcess::quote(n.mid(6)); 168 tmpStr += KProcess::quote(n.mid(6));
169 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 169 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
170 return; 170 return;
171 } 171 }
172 } else { 172 } else {
173 //QTextBrowser::setSource(n); 173 //QTextBrowser::setSource(n);
174 } 174 }
175#endif 175#endif
176} 176}
177 177
178void KOEventViewer::addTag(const QString & tag,const QString & text) 178void KOEventViewer::addTag(const QString & tag,const QString & text)
179{ 179{
180 int number=text.contains("\n"); 180 int number=text.contains("\n");
181 QString str = "<" + tag + ">"; 181 QString str = "<" + tag + ">";
182 QString tmpText=text; 182 QString tmpText=text;
183 QString tmpStr=str; 183 QString tmpStr=str;
184 if(number !=-1) 184 if(number !=-1)
185 { 185 {
186 if (number > 0) { 186 if (number > 0) {
187 int pos=0; 187 int pos=0;
188 QString tmp; 188 QString tmp;
189 for(int i=0;i<=number;i++) { 189 for(int i=0;i<=number;i++) {
190 pos=tmpText.find("\n"); 190 pos=tmpText.find("\n");
191 tmp=tmpText.left(pos); 191 tmp=tmpText.left(pos);
192 tmpText=tmpText.right(tmpText.length()-pos-1); 192 tmpText=tmpText.right(tmpText.length()-pos-1);
193 tmpStr+=tmp+"<br>"; 193 tmpStr+=tmp+"<br>";
194 } 194 }
195 } 195 }
196 else tmpStr += tmpText; 196 else tmpStr += tmpText;
197 tmpStr+="</" + tag + ">"; 197 tmpStr+="</" + tag + ">";
198 mText.append(tmpStr); 198 mText.append(tmpStr);
199 } 199 }
200 else 200 else
201 { 201 {
202 str += text + "</" + tag + ">"; 202 str += text + "</" + tag + ">";
203 mText.append(str); 203 mText.append(str);
204 } 204 }
205} 205}
206 206
207void KOEventViewer::setColorMode( int m ) 207void KOEventViewer::setColorMode( int m )
208{ 208{
209 mColorMode = m; 209 mColorMode = m;
210} 210}
211void KOEventViewer::appendEvent(Event *event, int mode ) 211void KOEventViewer::appendEvent(Event *event, int mode )
212{ 212{
213 mMailSubject = ""; 213 mMailSubject = "";
214 mCurrentIncidence = event; 214 mCurrentIncidence = event;
215 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 215 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
216 topLevelWidget()->setCaption(i18n("Event Viewer")); 216 topLevelWidget()->setCaption(i18n("Event Viewer"));
217 if ( mode == 0 ) { 217 if ( mode == 0 ) {
218 addTag("h2",event->summary()); 218 addTag("h2",event->summary());
219 } 219 }
220 else { 220 else {
221 if ( mColorMode == 1 ) { 221 if ( mColorMode == 1 ) {
222 mText +="<font color=\"#00A000\">"; 222 mText +="<font color=\"#00A000\">";
223 } 223 }
224 if ( mColorMode == 2 ) { 224 if ( mColorMode == 2 ) {
225 mText +="<font color=\"#C00000\">"; 225 mText +="<font color=\"#C00000\">";
226 } 226 }
227 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 227 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
228 if ( mode == 1 ) { 228 if ( mode == 1 ) {
229 addTag("h2",i18n( "Local: " ) +event->summary()); 229 addTag("h2",i18n( "Local: " ) +event->summary());
230 } else { 230 } else {
231 addTag("h2",i18n( "Remote: " ) +event->summary()); 231 addTag("h2",i18n( "Remote: " ) +event->summary());
232 } 232 }
233 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 233 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
234 if ( mColorMode ) 234 if ( mColorMode )
235 mText += "</font>"; 235 mText += "</font>";
236 } 236 }
237 mMailSubject += i18n( "Meeting " )+ event->summary(); 237 mMailSubject += i18n( "Meeting " )+ event->summary();
238 if (event->cancelled ()) { 238 if (event->cancelled ()) {
239 mText +="<font color=\"#B00000\">"; 239 mText +="<font color=\"#B00000\">";
240 addTag("i",i18n("This event has been cancelled!")); 240 addTag("i",i18n("This event has been cancelled!"));
241 mText.append("<br>"); 241 mText.append("<br>");
242 mText += "</font>"; 242 mText += "</font>";
243 mMailSubject += i18n("(cancelled)"); 243 mMailSubject += i18n("(cancelled)");
244 } 244 }
245 if (!event->location().isEmpty()) { 245 if (!event->location().isEmpty()) {
246 addTag("b",i18n("Location: ")); 246 addTag("b",i18n("Location: "));
247 mText.append(event->location()+"<br>"); 247 mText.append(event->location()+"<br>");
248 mMailSubject += i18n(" at ") + event->location(); 248 mMailSubject += i18n(" at ") + event->location();
249 } 249 }
250 if (event->doesFloat()) { 250 if (event->doesFloat()) {
251 if (event->isMultiDay()) { 251 if (event->isMultiDay()) {
252 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 252 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
253 .arg(event->dtStartDateStr(shortDate)) 253 .arg(event->dtStartDateStr(shortDate))
254 .arg(event->dtEndDateStr(shortDate))); 254 .arg(event->dtEndDateStr(shortDate)));
255 } else { 255 } else {
256 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 256 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
257 } 257 }
258 } else { 258 } else {
259 if (event->isMultiDay()) { 259 if (event->isMultiDay()) {
260 mText.append(i18n("<p><b>From:</b> %1</p> ") 260 mText.append(i18n("<p><b>From:</b> %1</p> ")
261 .arg(event->dtStartStr( shortDate))); 261 .arg(event->dtStartStr( shortDate)));
262 mText.append(i18n("<p><b>To:</b> %1</p>") 262 mText.append(i18n("<p><b>To:</b> %1</p>")
263 .arg(event->dtEndStr(shortDate))); 263 .arg(event->dtEndStr(shortDate)));
264 } else { 264 } else {
265 mText.append(i18n("<p><b>On:</b> %1</p> ") 265 mText.append(i18n("<p><b>On:</b> %1</p> ")
266 .arg(event->dtStartDateStr( shortDate ))); 266 .arg(event->dtStartDateStr( shortDate )));
267 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 267 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
268 .arg(event->dtStartTimeStr()) 268 .arg(event->dtStartTimeStr())
269 .arg(event->dtEndTimeStr())); 269 .arg(event->dtEndTimeStr()));
270 } 270 }
271 } 271 }
272 272
273 if (event->recurrence()->doesRecur()) { 273 if (event->recurrence()->doesRecur()) {
274 274
275 QString recurText = event->recurrence()->recurrenceText(); 275 QString recurText = event->recurrence()->recurrenceText();
276 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 276 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
277 bool last; 277 bool last;
278 QDate start = QDate::currentDate(); 278 QDate start = QDate::currentDate();
279 QDate next; 279 QDate next;
280 next = event->recurrence()->getPreviousDate( start , &last ); 280 next = event->recurrence()->getPreviousDate( start , &last );
281 if ( !last ) { 281 if ( !last ) {
282 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 282 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
283 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 283 addTag("p",i18n("<b>Next recurrence is on:</b>") );
284 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 284 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
285 QDateTime nextdt = QDateTime( next, event->dtStart().time()); 285 QDateTime nextdt = QDateTime( next, event->dtStart().time());
286 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); 286 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
287 287
288 } else { 288 } else {
289 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 289 addTag("p",i18n("<b>Last recurrence was on:</b>") );
290 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 290 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
291 } 291 }
292 } else { 292 } else {
293 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 293 mMailSubject += i18n(" - " )+event->dtStartStr( true );
294 294
295 } 295 }
296 296
297 297
298 if (event->isAlarmEnabled()) { 298 if (event->isAlarmEnabled()) {
299 Alarm *alarm =event->alarms().first() ; 299 Alarm *alarm =event->alarms().first() ;
300 QDateTime t = alarm->time(); 300 QDateTime t = alarm->time();
301 int min = t.secsTo( event->dtStart() )/60; 301 int min = t.secsTo( event->dtStart() )/60;
302 QString s =i18n("( %1 min before )").arg( min ); 302 QString s =i18n("( %1 min before )").arg( min );
303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
305 //addTag("p",s); 305 //addTag("p",s);
306 } 306 }
307 307
308 addTag("b",i18n("Access: ")); 308 addTag("b",i18n("Access: "));
309 mText.append(event->secrecyStr()+"<br>"); 309 mText.append(event->secrecyStr()+"<br>");
310 if (!event->description().isEmpty()) { 310 if (!event->description().isEmpty()) {
311 addTag("p",i18n("<b>Details: </b>")); 311 addTag("p",i18n("<b>Details: </b>"));
312 addTag("p",event->description()); 312 addTag("p",event->description());
313 } 313 }
314 314
315 formatCategories(event); 315 formatCategories(event);
316 316
317 formatReadOnly(event); 317 formatReadOnly(event);
318 formatAttendees(event); 318 formatAttendees(event);
319 319
320 setText(mText); 320 setText(mText);
321 //QWhatsThis::add(this,mText); 321 //QWhatsThis::add(this,mText);
322 322
323} 323}
324 324
325void KOEventViewer::appendTodo(Todo *event, int mode ) 325void KOEventViewer::appendTodo(Todo *event, int mode )
326{ 326{
327 mMailSubject = ""; 327 mMailSubject = "";
328 mCurrentIncidence = event; 328 mCurrentIncidence = event;
329 topLevelWidget()->setCaption(i18n("Todo Viewer")); 329 topLevelWidget()->setCaption(i18n("Todo Viewer"));
330 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 330 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
331 if (mode == 0 ) 331 if (mode == 0 )
332 addTag("h2",event->summary()); 332 addTag("h2",event->summary());
333 else { 333 else {
334 if ( mColorMode == 1 ) { 334 if ( mColorMode == 1 ) {
335 mText +="<font color=\"#00A000\">"; 335 mText +="<font color=\"#00A000\">";
336 } 336 }
337 if ( mColorMode == 2 ) { 337 if ( mColorMode == 2 ) {
338 mText +="<font color=\"#B00000\">"; 338 mText +="<font color=\"#B00000\">";
339 } 339 }
340 if ( mode == 1 ) { 340 if ( mode == 1 ) {
341 addTag("h2",i18n( "Local: " ) +event->summary()); 341 addTag("h2",i18n( "Local: " ) +event->summary());
342 } else { 342 } else {
343 addTag("h2",i18n( "Remote: " ) +event->summary()); 343 addTag("h2",i18n( "Remote: " ) +event->summary());
344 } 344 }
345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
346 if ( mColorMode ) 346 if ( mColorMode )
347 mText += "</font>"; 347 mText += "</font>";
348 } 348 }
349 mMailSubject += i18n( "Todo " )+ event->summary(); 349 mMailSubject += i18n( "Todo " )+ event->summary();
350
351 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
352 mText +="<font color=\"#B00000\">";
353 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) );
354 mText += "</font>";
355 } else {
356 mText.append(i18n("<p><i>%1 % completed</i></p>")
357 .arg(event->percentComplete()));
358 }
359
350 if (event->cancelled ()) { 360 if (event->cancelled ()) {
351 mText +="<font color=\"#B00000\">"; 361 mText +="<font color=\"#B00000\">";
352 addTag("i",i18n("This todo has been cancelled!")); 362 addTag("i",i18n("This todo has been cancelled!"));
353 mText.append("<br>"); 363 mText.append("<br>");
354 mText += "</font>"; 364 mText += "</font>";
355 mMailSubject += i18n("(cancelled)"); 365 mMailSubject += i18n("(cancelled)");
356 } 366 }
357 367
358 if (!event->location().isEmpty()) { 368 if (!event->location().isEmpty()) {
359 addTag("b",i18n("Location: ")); 369 addTag("b",i18n("Location: "));
360 mText.append(event->location()+"<br>"); 370 mText.append(event->location()+"<br>");
361 mMailSubject += i18n(" at ") + event->location(); 371 mMailSubject += i18n(" at ") + event->location();
362 } 372 }
363 if (event->hasStartDate()) { 373 if (event->hasStartDate()) {
364 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 374 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
365 } 375 }
366 if (event->hasDueDate()) { 376 if (event->hasDueDate()) {
367 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 377 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
368 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 378 mMailSubject += i18n(" - " )+event->dtDueStr( true );
369 } 379 }
370 addTag("b",i18n("Access: ")); 380 addTag("b",i18n("Access: "));
371 mText.append(event->secrecyStr()+"<br>"); 381 mText.append(event->secrecyStr()+"<br>");
372 if (!event->description().isEmpty()) { 382 if (!event->description().isEmpty()) {
373 addTag("p",i18n("<b>Details: </b>")); 383 addTag("p",i18n("<b>Details: </b>"));
374 addTag("p",event->description()); 384 addTag("p",event->description());
375 } 385 }
376 386
377 formatCategories(event); 387 formatCategories(event);
378 388
379 mText.append(i18n("<p><b>Priority:</b> %2</p>") 389 mText.append(i18n("<p><b>Priority:</b> %2</p>")
380 .arg(QString::number(event->priority()))); 390 .arg(QString::number(event->priority())));
381 391
382 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
383 mText.append(i18n("<p><i>Completed on %1</i></p>")
384 .arg( event->completedStr() ));
385 } else {
386 mText.append(i18n("<p><i>%1 % completed</i></p>")
387 .arg(event->percentComplete()));
388 }
389
390 formatReadOnly(event); 392 formatReadOnly(event);
391 formatAttendees(event); 393 formatAttendees(event);
392 if ( event->relatedTo() ) { 394 if ( event->relatedTo() ) {
393 addTag("b",i18n("Parent todo: ")); 395 addTag("b",i18n("Parent todo: "));
394 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 396 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
395 } 397 }
396 QPtrList<Incidence> Relations = event->relations(); 398 QPtrList<Incidence> Relations = event->relations();
397 Incidence *to; 399 Incidence *to;
398 if ( Relations.first() ) 400 if ( Relations.first() )
399 addTag("b",i18n("Sub todos:<br>")); 401 addTag("b",i18n("Sub todos:<br>"));
400 for (to=Relations.first();to;to=Relations.next()) { 402 for (to=Relations.first();to;to=Relations.next()) {
401 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 403 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
402 404
403 } 405 }
404 setText(mText); 406 setText(mText);
405} 407}
406 408
407void KOEventViewer::formatCategories(Incidence *event) 409void KOEventViewer::formatCategories(Incidence *event)
408{ 410{
409 if (!event->categoriesStr().isEmpty()) { 411 if (!event->categoriesStr().isEmpty()) {
410 if (event->categories().count() == 1) { 412 if (event->categories().count() == 1) {
411 addTag("h3",i18n("Category")); 413 addTag("h3",i18n("Category"));
412 } else { 414 } else {
413 addTag("h3",i18n("Categories")); 415 addTag("h3",i18n("Categories"));
414 } 416 }
415 addTag("p",event->categoriesStr()); 417 addTag("p",event->categoriesStr());
416 } 418 }
417} 419}
418void KOEventViewer::formatAttendees(Incidence *event) 420void KOEventViewer::formatAttendees(Incidence *event)
419{ 421{
420 QPtrList<Attendee> attendees = event->attendees(); 422 QPtrList<Attendee> attendees = event->attendees();
421 if (attendees.count()) { 423 if (attendees.count()) {
422 424
423 425
424 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 426 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
425 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 427 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
426 addTag("h3",i18n("Organizer")); 428 addTag("h3",i18n("Organizer"));
427 mText.append("<ul><li>"); 429 mText.append("<ul><li>");
428#ifndef KORG_NOKABC 430#ifndef KORG_NOKABC
429 431
430#ifdef DESKTOP_VERSION 432#ifdef DESKTOP_VERSION
431 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 433 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
432 KABC::Addressee::List addressList; 434 KABC::Addressee::List addressList;
433 addressList = add_book->findByEmail(event->organizer()); 435 addressList = add_book->findByEmail(event->organizer());
434 KABC::Addressee o = addressList.first(); 436 KABC::Addressee o = addressList.first();
435 if (!o.isEmpty() && addressList.size()<2) { 437 if (!o.isEmpty() && addressList.size()<2) {
436 mText += "<a href=\"uid:" + o.uid() + "\">"; 438 mText += "<a href=\"uid:" + o.uid() + "\">";
437 mText += o.formattedName(); 439 mText += o.formattedName();
438 mText += "</a>\n"; 440 mText += "</a>\n";
439 } else { 441 } else {
440 mText.append(event->organizer()); 442 mText.append(event->organizer());
441 } 443 }
442#else //DESKTOP_VERSION 444#else //DESKTOP_VERSION
443 mText += "<a href=\"uid:organizer\">"; 445 mText += "<a href=\"uid:organizer\">";
444 mText += event->organizer(); 446 mText += event->organizer();
445 mText += "</a>\n"; 447 mText += "</a>\n";
446#endif //DESKTOP_VERSION 448#endif //DESKTOP_VERSION
447 449
448 450
449#else 451#else
450 mText.append(event->organizer()); 452 mText.append(event->organizer());
451#endif 453#endif
452 454
453 if (iconPath) { 455 if (iconPath) {
454 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 456 mText += " <a href=\"mailto:" + event->organizer() + "\">";
455 mText += "<IMG src=\"" + iconPath + "\">"; 457 mText += "<IMG src=\"" + iconPath + "\">";
456 mText += "</a>\n"; 458 mText += "</a>\n";
457 } 459 }
458 mText.append("</li></ul>"); 460 mText.append("</li></ul>");
459 461
460 addTag("h3",i18n("Attendees")); 462 addTag("h3",i18n("Attendees"));
461 Attendee *a; 463 Attendee *a;
462 mText.append("<ul>"); 464 mText.append("<ul>");
463 for(a=attendees.first();a;a=attendees.next()) { 465 for(a=attendees.first();a;a=attendees.next()) {
464#ifndef KORG_NOKABC 466#ifndef KORG_NOKABC
465#ifdef DESKTOP_VERSION 467#ifdef DESKTOP_VERSION
466 if (a->name().isEmpty()) { 468 if (a->name().isEmpty()) {
467 addressList = add_book->findByEmail(a->email()); 469 addressList = add_book->findByEmail(a->email());
468 KABC::Addressee o = addressList.first(); 470 KABC::Addressee o = addressList.first();
469 if (!o.isEmpty() && addressList.size()<2) { 471 if (!o.isEmpty() && addressList.size()<2) {
470 mText += "<a href=\"uid:" + o.uid() + "\">"; 472 mText += "<a href=\"uid:" + o.uid() + "\">";
471 mText += o.formattedName(); 473 mText += o.formattedName();
472 mText += "</a>\n"; 474 mText += "</a>\n";
473 } else { 475 } else {
474 mText += "<li>"; 476 mText += "<li>";
475 mText.append(a->email()); 477 mText.append(a->email());
476 mText += "\n"; 478 mText += "\n";
477 } 479 }
478 } else { 480 } else {
479 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 481 mText += "<li><a href=\"uid:" + a->uid() + "\">";
480 if (!a->name().isEmpty()) mText += a->name(); 482 if (!a->name().isEmpty()) mText += a->name();
481 else mText += a->email(); 483 else mText += a->email();
482 mText += "</a>\n"; 484 mText += "</a>\n";
483 } 485 }
484#else //DESKTOP_VERSION 486#else //DESKTOP_VERSION
485 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 487 mText += "<li><a href=\"uid:" + a->uid() + "\">";
486 if (!a->name().isEmpty()) mText += a->name(); 488 if (!a->name().isEmpty()) mText += a->name();
487 else mText += a->email(); 489 else mText += a->email();
488 mText += "</a>\n"; 490 mText += "</a>\n";
489#endif //DESKTOP_VERSION 491#endif //DESKTOP_VERSION
490#else 492#else
491 //qDebug("nokabc "); 493 //qDebug("nokabc ");
492 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 494 mText += "<li><a href=\"uid:" + a->uid() + "\">";
493 if (!a->name().isEmpty()) mText += a->name(); 495 if (!a->name().isEmpty()) mText += a->name();
494 else mText += a->email(); 496 else mText += a->email();
495 mText += "</a>\n"; 497 mText += "</a>\n";
496#endif 498#endif
497 499
498 500
499 if (!a->email().isEmpty()) { 501 if (!a->email().isEmpty()) {
500 if (iconPath) { 502 if (iconPath) {
501 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 503 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
502 if ( a->RSVP() ) 504 if ( a->RSVP() )
503 mText += "<IMG src=\"" + iconPath + "\">"; 505 mText += "<IMG src=\"" + iconPath + "\">";
504 else 506 else
505 mText += "<IMG src=\"" + NOiconPath + "\">"; 507 mText += "<IMG src=\"" + NOiconPath + "\">";
506 mText += "</a>\n"; 508 mText += "</a>\n";
507 } 509 }
508 } 510 }
509 if (a->status() != Attendee::NeedsAction ) 511 if (a->status() != Attendee::NeedsAction )
510 mText +="[" + a->statusStr() + "] "; 512 mText +="[" + a->statusStr() + "] ";
511 if (a->role() == Attendee::Chair ) 513 if (a->role() == Attendee::Chair )
512 mText +="(" + a->roleStr().left(1) + ".)"; 514 mText +="(" + a->roleStr().left(1) + ".)";
513 } 515 }
514 mText.append("</li></ul>"); 516 mText.append("</li></ul>");
515 } 517 }
516 518
517} 519}
518void KOEventViewer::appendJournal(Journal *jour, int mode ) 520void KOEventViewer::appendJournal(Journal *jour, int mode )
519{ 521{
520 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 522 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
521 if (mode == 0 ) { 523 if (mode == 0 ) {
522 addTag("h2",i18n("Journal from: ")); 524 addTag("h2",i18n("Journal from: "));
523 } 525 }
524 else { 526 else {
525 if ( mode == 1 ) { 527 if ( mode == 1 ) {
526 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 528 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
527 } else { 529 } else {
528 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 530 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
529 } 531 }
530 } 532 }
531 topLevelWidget()->setCaption("Journal Viewer"); 533 topLevelWidget()->setCaption("Journal Viewer");
532 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 534 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
533 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 535 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
534 if (!jour->description().isEmpty()) { 536 if (!jour->description().isEmpty()) {
535 addTag("p",jour->description()); 537 addTag("p",jour->description());
536 } 538 }
537 setText(mText); 539 setText(mText);
538} 540}
539 541
540void KOEventViewer::formatReadOnly(Incidence *event) 542void KOEventViewer::formatReadOnly(Incidence *event)
541{ 543{
542 if (event->isReadOnly()) { 544 if (event->isReadOnly()) {
543 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 545 addTag("p","<em>(" + i18n("read-only") + ")</em>");
544 } 546 }
545} 547}
546void KOEventViewer::setSyncMode( bool b ) 548void KOEventViewer::setSyncMode( bool b )
547{ 549{
548 mSyncMode = b; 550 mSyncMode = b;
549} 551}
550 552
551 553
552void KOEventViewer::setTodo(Todo *event, bool clearV ) 554void KOEventViewer::setTodo(Todo *event, bool clearV )
553{ 555{
554 if ( clearV ) 556 if ( clearV )
555 clearEvents(); 557 clearEvents();
556 if ( mSyncMode ) { 558 if ( mSyncMode ) {
557 if ( clearV ) 559 if ( clearV )
558 appendTodo(event,1 ); 560 appendTodo(event,1 );
559 else 561 else
560 appendTodo(event,2); 562 appendTodo(event,2);
561 } else 563 } else
562 appendTodo(event); 564 appendTodo(event);
563} 565}
564void KOEventViewer::setJournal(Journal *event, bool clearV ) 566void KOEventViewer::setJournal(Journal *event, bool clearV )
565{ 567{
566 if ( clearV ) 568 if ( clearV )
567 clearEvents(); 569 clearEvents();
568 if ( mSyncMode ) { 570 if ( mSyncMode ) {
569 if ( clearV ) 571 if ( clearV )
570 appendJournal(event, 1); 572 appendJournal(event, 1);
571 else 573 else
572 appendJournal(event, 2); 574 appendJournal(event, 2);
573 } else 575 } else
574 appendJournal(event); 576 appendJournal(event);
575} 577}
576 578
577void KOEventViewer::setEvent(Event *event) 579void KOEventViewer::setEvent(Event *event)
578{ 580{
579 clearEvents(); 581 clearEvents();
580 if ( mSyncMode ) 582 if ( mSyncMode )
581 appendEvent(event, 1); 583 appendEvent(event, 1);
582 else 584 else
583 appendEvent(event); 585 appendEvent(event);
584} 586}
585 587
586void KOEventViewer::addEvent(Event *event) 588void KOEventViewer::addEvent(Event *event)
587{ 589{
588 if ( mSyncMode ) 590 if ( mSyncMode )
589 appendEvent(event, 2); 591 appendEvent(event, 2);
590 else 592 else
591 appendEvent(event); 593 appendEvent(event);
592} 594}
593 595
594void KOEventViewer::clearEvents(bool now) 596void KOEventViewer::clearEvents(bool now)
595{ 597{
596 mText = ""; 598 mText = "";
597 if (now) setText(mText); 599 if (now) setText(mText);
598} 600}
599 601
600void KOEventViewer::addText(QString text) 602void KOEventViewer::addText(QString text)
601{ 603{
602 mText.append(text); 604 mText.append(text);
603 setText(mText); 605 setText(mText);
604} 606}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 8c1953d..14e8b5c 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1227 +1,1236 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 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 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27 27
28#include <qvbox.h> 28#include <qvbox.h>
29#include <kdebug.h> 29#include <kdebug.h>
30#include "koprefs.h" 30#include "koprefs.h"
31#include <klocale.h> 31#include <klocale.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kmessagebox.h> 34#include <kmessagebox.h>
35 35
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/vcaldrag.h> 37#include <libkcal/vcaldrag.h>
38#include <libkcal/calfilter.h> 38#include <libkcal/calfilter.h>
39#include <libkcal/dndfactory.h> 39#include <libkcal/dndfactory.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42#include <kresources/resourceselectdialog.h> 42#include <kresources/resourceselectdialog.h>
43#ifndef DESKTOP_VERSION 43#ifndef DESKTOP_VERSION
44#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
45#else 45#else
46#include <qapplication.h> 46#include <qapplication.h>
47#endif 47#endif
48#ifndef KORG_NOPRINTER 48#ifndef KORG_NOPRINTER
49#include "calprinter.h" 49#include "calprinter.h"
50#endif 50#endif
51#include "docprefs.h" 51#include "docprefs.h"
52 52
53#include "kotodoview.h" 53#include "kotodoview.h"
54using namespace KOrg; 54using namespace KOrg;
55 55
56KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 56KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
57 const char *name) : 57 const char *name) :
58 KListView(parent,name) 58 KListView(parent,name)
59{ 59{
60 mName = QString ( name ); 60 mName = QString ( name );
61 mCalendar = calendar; 61 mCalendar = calendar;
62#ifndef DESKTOP_VERSION 62#ifndef DESKTOP_VERSION
63 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 63 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
64#endif 64#endif
65 mOldCurrent = 0; 65 mOldCurrent = 0;
66 mMousePressed = false; 66 mMousePressed = false;
67 67
68 setAcceptDrops(true); 68 setAcceptDrops(true);
69 viewport()->setAcceptDrops(true); 69 viewport()->setAcceptDrops(true);
70 int size = 16; 70 int size = 16;
71 if (qApp->desktop()->width() < 300 ) 71 if (qApp->desktop()->width() < 300 )
72 size = 12; 72 size = 12;
73 setTreeStepSize( size + 6 ); 73 setTreeStepSize( size + 6 );
74 74
75} 75}
76 76
77void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 77void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
78{ 78{
79#ifndef KORG_NODND 79#ifndef KORG_NODND
80// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 80// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
81 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 81 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
82 !QTextDrag::canDecode( e ) ) { 82 !QTextDrag::canDecode( e ) ) {
83 e->ignore(); 83 e->ignore();
84 return; 84 return;
85 } 85 }
86 86
87 mOldCurrent = currentItem(); 87 mOldCurrent = currentItem();
88#endif 88#endif
89} 89}
90 90
91 91
92void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 92void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
93{ 93{
94#ifndef KORG_NODND 94#ifndef KORG_NODND
95// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 95// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
96 96
97 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 97 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
98 !QTextDrag::canDecode( e ) ) { 98 !QTextDrag::canDecode( e ) ) {
99 e->ignore(); 99 e->ignore();
100 return; 100 return;
101 } 101 }
102 102
103 e->accept(); 103 e->accept();
104#endif 104#endif
105} 105}
106 106
107void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 107void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
108{ 108{
109#ifndef KORG_NODND 109#ifndef KORG_NODND
110// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 110// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
111 111
112 setCurrentItem(mOldCurrent); 112 setCurrentItem(mOldCurrent);
113 setSelected(mOldCurrent,true); 113 setSelected(mOldCurrent,true);
114#endif 114#endif
115} 115}
116 116
117void KOTodoListView::contentsDropEvent(QDropEvent *e) 117void KOTodoListView::contentsDropEvent(QDropEvent *e)
118{ 118{
119#ifndef KORG_NODND 119#ifndef KORG_NODND
120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
121 121
122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
123 !QTextDrag::canDecode( e ) ) { 123 !QTextDrag::canDecode( e ) ) {
124 e->ignore(); 124 e->ignore();
125 return; 125 return;
126 } 126 }
127 127
128 DndFactory factory( mCalendar ); 128 DndFactory factory( mCalendar );
129 Todo *todo = factory.createDropTodo(e); 129 Todo *todo = factory.createDropTodo(e);
130 130
131 if (todo) { 131 if (todo) {
132 e->acceptAction(); 132 e->acceptAction();
133 133
134 KOTodoViewItem *destination = 134 KOTodoViewItem *destination =
135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
136 Todo *destinationEvent = 0; 136 Todo *destinationEvent = 0;
137 if (destination) destinationEvent = destination->todo(); 137 if (destination) destinationEvent = destination->todo();
138 138
139 Todo *existingTodo = mCalendar->todo(todo->uid()); 139 Todo *existingTodo = mCalendar->todo(todo->uid());
140 140
141 if(existingTodo) { 141 if(existingTodo) {
142 Incidence *to = destinationEvent; 142 Incidence *to = destinationEvent;
143 while(to) { 143 while(to) {
144 if (to->uid() == todo->uid()) { 144 if (to->uid() == todo->uid()) {
145 KMessageBox::sorry(this, 145 KMessageBox::sorry(this,
146 i18n("Cannot move To-Do to itself\nor a child of itself"), 146 i18n("Cannot move To-Do to itself\nor a child of itself"),
147 i18n("Drop To-Do")); 147 i18n("Drop To-Do"));
148 delete todo; 148 delete todo;
149 return; 149 return;
150 } 150 }
151 to = to->relatedTo(); 151 to = to->relatedTo();
152 } 152 }
153 internalDrop = true; 153 internalDrop = true;
154 if ( destinationEvent ) 154 if ( destinationEvent )
155 reparentTodoSignal( destinationEvent, existingTodo ); 155 reparentTodoSignal( destinationEvent, existingTodo );
156 else 156 else
157 unparentTodoSignal(existingTodo); 157 unparentTodoSignal(existingTodo);
158 delete todo; 158 delete todo;
159 } else { 159 } else {
160 mCalendar->addTodo(todo); 160 mCalendar->addTodo(todo);
161 emit todoDropped(todo, KOGlobals::EVENTADDED); 161 emit todoDropped(todo, KOGlobals::EVENTADDED);
162 if ( destinationEvent ) 162 if ( destinationEvent )
163 reparentTodoSignal( destinationEvent, todo ); 163 reparentTodoSignal( destinationEvent, todo );
164 } 164 }
165 } 165 }
166 else { 166 else {
167 QString text; 167 QString text;
168 if (QTextDrag::decode(e,text)) { 168 if (QTextDrag::decode(e,text)) {
169 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 169 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
170 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 170 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
171 qDebug("Dropped : " + text); 171 qDebug("Dropped : " + text);
172 QStringList emails = QStringList::split(",",text); 172 QStringList emails = QStringList::split(",",text);
173 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 173 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
174 int pos = (*it).find("<"); 174 int pos = (*it).find("<");
175 QString name = (*it).left(pos); 175 QString name = (*it).left(pos);
176 QString email = (*it).mid(pos); 176 QString email = (*it).mid(pos);
177 if (!email.isEmpty() && todoi) { 177 if (!email.isEmpty() && todoi) {
178 todoi->todo()->addAttendee(new Attendee(name,email)); 178 todoi->todo()->addAttendee(new Attendee(name,email));
179 } 179 }
180 } 180 }
181 } 181 }
182 else { 182 else {
183 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 183 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
184 e->ignore(); 184 e->ignore();
185 } 185 }
186 } 186 }
187#endif 187#endif
188} 188}
189 189
190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
191{ 191{
192#ifndef KORG_NODND 192#ifndef KORG_NODND
193 QPoint p(contentsToViewport(e->pos())); 193 QPoint p(contentsToViewport(e->pos()));
194 QListViewItem *i = itemAt(p); 194 QListViewItem *i = itemAt(p);
195 mMousePressed = false; 195 mMousePressed = false;
196 if (i) { 196 if (i) {
197 // if the user clicked into the root decoration of the item, don't 197 // if the user clicked into the root decoration of the item, don't
198 // try to start a drag! 198 // try to start a drag!
199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + 199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
201 itemMargin() || 201 itemMargin() ||
202 p.x() < header()->sectionPos(header()->mapToIndex(0))) { 202 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
203 if (e->button()==Qt::LeftButton) { 203 if (e->button()==Qt::LeftButton) {
204 mPressPos = e->pos(); 204 mPressPos = e->pos();
205 mMousePressed = true; 205 mMousePressed = true;
206 } 206 }
207 } 207 }
208 } 208 }
209#endif 209#endif
210 QListView::contentsMousePressEvent(e); 210 QListView::contentsMousePressEvent(e);
211} 211}
212 212
213void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 213void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
214{ 214{
215 215
216#ifndef KORG_NODND 216#ifndef KORG_NODND
217 QListView::contentsMouseMoveEvent(e); 217 QListView::contentsMouseMoveEvent(e);
218 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 218 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
219 QApplication::startDragDistance()) { 219 QApplication::startDragDistance()) {
220 mMousePressed = false; 220 mMousePressed = false;
221 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 221 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
222 if (item) { 222 if (item) {
223 DndFactory factory( mCalendar ); 223 DndFactory factory( mCalendar );
224 ICalDrag *vd = factory.createDrag( 224 ICalDrag *vd = factory.createDrag(
225 ((KOTodoViewItem *)item)->todo(),viewport()); 225 ((KOTodoViewItem *)item)->todo(),viewport());
226 internalDrop = false; 226 internalDrop = false;
227 // we cannot do any senseful here, because the DnD is still broken in Qt 227 // we cannot do any senseful here, because the DnD is still broken in Qt
228 if (vd->drag()) { 228 if (vd->drag()) {
229 if ( !internalDrop ) { 229 if ( !internalDrop ) {
230 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 230 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
231 qDebug("Dnd: External move: Delete drag source "); 231 qDebug("Dnd: External move: Delete drag source ");
232 } else 232 } else
233 qDebug("Dnd: Internal move "); 233 qDebug("Dnd: Internal move ");
234 234
235 } else { 235 } else {
236 if ( !internalDrop ) { 236 if ( !internalDrop ) {
237 qDebug("Dnd: External Copy"); 237 qDebug("Dnd: External Copy");
238 } else 238 } else
239 qDebug("DnD: Internal copy: Copy pending"); 239 qDebug("DnD: Internal copy: Copy pending");
240 } 240 }
241 } 241 }
242 } 242 }
243#endif 243#endif
244} 244}
245void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 245void KOTodoListView::keyPressEvent ( QKeyEvent * e )
246{ 246{
247 247
248 QListViewItem* cn; 248 QListViewItem* cn;
249 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 249 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
250 cn = currentItem(); 250 cn = currentItem();
251 if ( cn ) { 251 if ( cn ) {
252 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 252 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
253 if ( ci ){ 253 if ( ci ){
254 if ( e->state() == ShiftButton ) 254 if ( e->state() == ShiftButton )
255 ci->setOn( false ); 255 ci->setOn( false );
256 else 256 else
257 ci->setOn( true ); 257 ci->setOn( true );
258 cn = cn->nextSibling(); 258 cn = cn->nextSibling();
259 if ( cn ) { 259 if ( cn ) {
260 setCurrentItem ( cn ); 260 setCurrentItem ( cn );
261 ensureItemVisible ( cn ); 261 ensureItemVisible ( cn );
262 } 262 }
263 263
264 } 264 }
265 } 265 }
266 266
267 return; 267 return;
268 } 268 }
269 269
270 // qDebug("KOTodoListView::keyPressEvent "); 270 // qDebug("KOTodoListView::keyPressEvent ");
271 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 271 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
272 switch ( e->key() ) { 272 switch ( e->key() ) {
273 case Qt::Key_Down: 273 case Qt::Key_Down:
274 case Qt::Key_Up: 274 case Qt::Key_Up:
275 QListView::keyPressEvent ( e ); 275 QListView::keyPressEvent ( e );
276 break; 276 break;
277 case Qt::Key_Left: 277 case Qt::Key_Left:
278 case Qt::Key_Right: 278 case Qt::Key_Right:
279 QListView::keyPressEvent ( e ); 279 QListView::keyPressEvent ( e );
280 e->accept(); 280 e->accept();
281 return; 281 return;
282 break; 282 break;
283 default: 283 default:
284 e->ignore(); 284 e->ignore();
285 break; 285 break;
286 } 286 }
287 return; 287 return;
288 } 288 }
289 e->ignore(); 289 e->ignore();
290} 290}
291void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 291void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
292{ 292{
293 QListView::contentsMouseReleaseEvent(e); 293 QListView::contentsMouseReleaseEvent(e);
294 mMousePressed = false; 294 mMousePressed = false;
295} 295}
296 296
297void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 297void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
298{ 298{
299 if (!e) return; 299 if (!e) return;
300 300
301 QPoint vp = contentsToViewport(e->pos()); 301 QPoint vp = contentsToViewport(e->pos());
302 302
303 QListViewItem *item = itemAt(vp); 303 QListViewItem *item = itemAt(vp);
304 304
305 emit double_Clicked(item); 305 emit double_Clicked(item);
306 if (!item) return; 306 if (!item) return;
307 307
308 emit doubleClicked(item,vp,0); 308 emit doubleClicked(item,vp,0);
309} 309}
310 310
311///////////////////////////////////////////////////////////////////////////// 311/////////////////////////////////////////////////////////////////////////////
312 312
313KOQuickTodo::KOQuickTodo(QWidget *parent) : 313KOQuickTodo::KOQuickTodo(QWidget *parent) :
314 QLineEdit(parent) 314 QLineEdit(parent)
315{ 315{
316 setText(i18n("Click to add a new Todo")); 316 setText(i18n("Click to add a new Todo"));
317} 317}
318 318
319void KOQuickTodo::focusInEvent(QFocusEvent *ev) 319void KOQuickTodo::focusInEvent(QFocusEvent *ev)
320{ 320{
321 if ( text()==i18n("Click to add a new Todo") ) 321 if ( text()==i18n("Click to add a new Todo") )
322 setText(""); 322 setText("");
323 QLineEdit::focusInEvent(ev); 323 QLineEdit::focusInEvent(ev);
324} 324}
325 325
326void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 326void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
327{ 327{
328 setText(i18n("Click to add a new Todo")); 328 setText(i18n("Click to add a new Todo"));
329 QLineEdit::focusOutEvent(ev); 329 QLineEdit::focusOutEvent(ev);
330} 330}
331 331
332///////////////////////////////////////////////////////////////////////////// 332/////////////////////////////////////////////////////////////////////////////
333 333
334KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 334KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
335 KOrg::BaseView(calendar,parent,name) 335 KOrg::BaseView(calendar,parent,name)
336{ 336{
337 isFlatDisplay = false;
337 mNavigator = 0; 338 mNavigator = 0;
338 QBoxLayout *topLayout = new QVBoxLayout(this); 339 QBoxLayout *topLayout = new QVBoxLayout(this);
339 mName = QString ( name ); 340 mName = QString ( name );
340 mBlockUpdate = false; 341 mBlockUpdate = false;
341 mQuickAdd = new KOQuickTodo(this); 342 mQuickAdd = new KOQuickTodo(this);
342 topLayout->addWidget(mQuickAdd); 343 topLayout->addWidget(mQuickAdd);
343 344
344 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 345 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
345 346
346 mTodoListView = new KOTodoListView(calendar,this, name ); 347 mTodoListView = new KOTodoListView(calendar,this, name );
347 topLayout->addWidget(mTodoListView); 348 topLayout->addWidget(mTodoListView);
348 //mTodoListView->header()->setMaximumHeight(30); 349 //mTodoListView->header()->setMaximumHeight(30);
349 mTodoListView->setRootIsDecorated(true); 350 mTodoListView->setRootIsDecorated(true);
350 mTodoListView->setAllColumnsShowFocus(true); 351 mTodoListView->setAllColumnsShowFocus(true);
351 352
352 mTodoListView->setShowSortIndicator(true); 353 mTodoListView->setShowSortIndicator(true);
353 354
354 mTodoListView->addColumn(i18n("Todo")); 355 mTodoListView->addColumn(i18n("Todo"));
355 mTodoListView->addColumn(i18n("Prio")); 356 mTodoListView->addColumn(i18n("Prio"));
356 mTodoListView->setColumnAlignment(1,AlignHCenter); 357 mTodoListView->setColumnAlignment(1,AlignHCenter);
357 mTodoListView->addColumn(i18n("Complete")); 358 mTodoListView->addColumn(i18n("Complete"));
358 mTodoListView->setColumnAlignment(2,AlignCenter); 359 mTodoListView->setColumnAlignment(2,AlignCenter);
359 360
360 mTodoListView->addColumn(i18n("Due Date")); 361 mTodoListView->addColumn(i18n("Due Date"));
361 mTodoListView->setColumnAlignment(3,AlignLeft); 362 mTodoListView->setColumnAlignment(3,AlignLeft);
362 mTodoListView->addColumn(i18n("Due Time")); 363 mTodoListView->addColumn(i18n("Due Time"));
363 mTodoListView->setColumnAlignment(4,AlignHCenter); 364 mTodoListView->setColumnAlignment(4,AlignHCenter);
364 365
365 mTodoListView->addColumn(i18n("Start Date")); 366 mTodoListView->addColumn(i18n("Start Date"));
366 mTodoListView->setColumnAlignment(5,AlignLeft); 367 mTodoListView->setColumnAlignment(5,AlignLeft);
367 mTodoListView->addColumn(i18n("Start Time")); 368 mTodoListView->addColumn(i18n("Start Time"));
368 mTodoListView->setColumnAlignment(6,AlignHCenter); 369 mTodoListView->setColumnAlignment(6,AlignHCenter);
369 370
370 mTodoListView->addColumn(i18n("Cancelled")); 371 mTodoListView->addColumn(i18n("Cancelled"));
371 mTodoListView->addColumn(i18n("Categories")); 372 mTodoListView->addColumn(i18n("Categories"));
372#if 0 373#if 0
373 mTodoListView->addColumn(i18n("Sort Id")); 374 mTodoListView->addColumn(i18n("Sort Id"));
374 mTodoListView->setColumnAlignment(4,AlignHCenter); 375 mTodoListView->setColumnAlignment(4,AlignHCenter);
375#endif 376#endif
376 377
377 mTodoListView->setMinimumHeight( 60 ); 378 mTodoListView->setMinimumHeight( 60 );
378 mTodoListView->setItemsRenameable( true ); 379 mTodoListView->setItemsRenameable( true );
379 mTodoListView->setRenameable( 0 ); 380 mTodoListView->setRenameable( 0 );
380 mTodoListView->setColumnWidth( 0, 120 ); 381 mTodoListView->setColumnWidth( 0, 120 );
381 mTodoListView->setColumnWidthMode(0, QListView::Manual); 382 mTodoListView->setColumnWidthMode(0, QListView::Manual);
382 mTodoListView->setColumnWidthMode(1, QListView::Manual); 383 mTodoListView->setColumnWidthMode(1, QListView::Manual);
383 mTodoListView->setColumnWidthMode(2, QListView::Manual); 384 mTodoListView->setColumnWidthMode(2, QListView::Manual);
384 mTodoListView->setColumnWidthMode(3, QListView::Manual); 385 mTodoListView->setColumnWidthMode(3, QListView::Manual);
385 mTodoListView->setColumnWidthMode(4, QListView::Manual); 386 mTodoListView->setColumnWidthMode(4, QListView::Manual);
386 mTodoListView->setColumnWidthMode(5, QListView::Manual); 387 mTodoListView->setColumnWidthMode(5, QListView::Manual);
387 mTodoListView->setColumnWidthMode(6, QListView::Manual); 388 mTodoListView->setColumnWidthMode(6, QListView::Manual);
388 mTodoListView->setColumnWidthMode(7, QListView::Manual); 389 mTodoListView->setColumnWidthMode(7, QListView::Manual);
389 mTodoListView->setColumnWidthMode(8, QListView::Manual); 390 mTodoListView->setColumnWidthMode(8, QListView::Manual);
390 391
391 392
392 mPriorityPopupMenu = new QPopupMenu(this); 393 mPriorityPopupMenu = new QPopupMenu(this);
393 for (int i = 1; i <= 5; i++) { 394 for (int i = 1; i <= 5; i++) {
394 QString label = QString ("%1").arg (i); 395 QString label = QString ("%1").arg (i);
395 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 396 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
396 } 397 }
397 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 398 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
398 399
399 mPercentageCompletedPopupMenu = new QPopupMenu(this); 400 mPercentageCompletedPopupMenu = new QPopupMenu(this);
400 for (int i = 0; i <= 100; i+=20) { 401 for (int i = 0; i <= 100; i+=20) {
401 QString label = QString ("%1 %").arg (i); 402 QString label = QString ("%1 %").arg (i);
402 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 403 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
403 } 404 }
404 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 405 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
405 406
406 407
407 408
408 mItemPopupMenu = new QPopupMenu(this); 409 mItemPopupMenu = new QPopupMenu(this);
409 mItemPopupMenu->insertItem(i18n("Show..."), this, 410 mItemPopupMenu->insertItem(i18n("Show..."), this,
410 SLOT (showTodo())); 411 SLOT (showTodo()));
411 mItemPopupMenu->insertItem(i18n("Edit..."), this, 412 mItemPopupMenu->insertItem(i18n("Edit..."), this,
412 SLOT (editTodo())); 413 SLOT (editTodo()));
413 mItemPopupMenu->insertItem( i18n("Delete"), this, 414 mItemPopupMenu->insertItem( i18n("Delete"), this,
414 SLOT (deleteTodo())); 415 SLOT (deleteTodo()));
415 mItemPopupMenu->insertItem( i18n("Clone..."), this, 416 mItemPopupMenu->insertItem( i18n("Clone..."), this,
416 SLOT (cloneTodo())); 417 SLOT (cloneTodo()));
417 mItemPopupMenu->insertItem( i18n("Move..."), this, 418 mItemPopupMenu->insertItem( i18n("Move..."), this,
418 SLOT (moveTodo())); 419 SLOT (moveTodo()));
419 mItemPopupMenu->insertItem( i18n("Beam..."), this, 420 mItemPopupMenu->insertItem( i18n("Beam..."), this,
420 SLOT (beamTodo())); 421 SLOT (beamTodo()));
421 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 422 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
422 SLOT (cancelTodo())); 423 SLOT (cancelTodo()));
423 mItemPopupMenu->insertSeparator(); 424 mItemPopupMenu->insertSeparator();
424 425
425 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 426 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
426 SLOT (newTodo())); 427 SLOT (newTodo()));
427 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 428 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
428 SLOT (newSubTodo())); 429 SLOT (newSubTodo()));
429 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 430 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
430 SLOT (unparentTodo()),0,21); 431 SLOT (unparentTodo()),0,21);
431 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 432 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
432 SLOT (reparentTodo()),0,22); 433 SLOT (reparentTodo()),0,22);
433 mItemPopupMenu->insertSeparator(); 434 mItemPopupMenu->insertSeparator();
434#if 0 435#if 0
435 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 436 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
436 this, SLOT( purgeCompleted() ) ); 437 this, SLOT( purgeCompleted() ) );
437 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 438 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
438 this, SLOT( toggleCompleted() ),0, 33 ); 439 this, SLOT( toggleCompleted() ),0, 33 );
439 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 440 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
440 this, SLOT( toggleQuickTodo() ),0, 34 ); 441 this, SLOT( toggleQuickTodo() ),0, 34 );
441 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 442 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
442 this, SLOT( toggleRunning() ),0, 35 ); 443 this, SLOT( toggleRunning() ),0, 35 );
443 444
444#endif 445#endif
445 mPopupMenu = new QPopupMenu(this); 446 mPopupMenu = new QPopupMenu(this);
446 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 447 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
447 SLOT (newTodo()),0,1); 448 SLOT (newTodo()),0,1);
448 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 449 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
449 this, SLOT(purgeCompleted()),0,2); 450 this, SLOT(purgeCompleted()),0,2);
450 mPopupMenu->insertItem(i18n("Show Completed"), 451 mPopupMenu->insertItem(i18n("Show Completed"),
451 this, SLOT( toggleCompleted() ),0,3 ); 452 this, SLOT( toggleCompleted() ),0,3 );
452 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 453 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
453 this, SLOT( toggleQuickTodo() ),0,4 ); 454 this, SLOT( toggleQuickTodo() ),0,4 );
454 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 455 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
455 this, SLOT( toggleRunning() ),0,5 ); 456 this, SLOT( toggleRunning() ),0,5 );
456 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 457 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
457 this, SLOT( setAllOpen() ),0,6 ); 458 this, SLOT( setAllOpen() ),0,6 );
458 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 459 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
459 this, SLOT( setAllClose() ),0,7 ); 460 this, SLOT( setAllClose() ),0,7 );
460 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 461 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
461 this, SLOT( setAllFlat() ),0,8 ); 462 this, SLOT( setAllFlat() ),0,8 );
462 mDocPrefs = new DocPrefs( name ); 463 mDocPrefs = new DocPrefs( name );
463 464
464 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 465 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
465 mPopupMenu->setCheckable( true ); 466 mPopupMenu->setCheckable( true );
466 mItemPopupMenu->setCheckable( true ); 467 mItemPopupMenu->setCheckable( true );
467 468
468 469
469 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 470 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
470 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 471 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
471 472
472 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 473 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
473 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 474 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
474 475
475 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 476 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
476 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 477 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
477 478
478 479
479 // Double clicking conflicts with opening/closing the subtree 480 // Double clicking conflicts with opening/closing the subtree
480 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 481 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
481 SLOT( editItem( QListViewItem *) ) ); 482 SLOT( editItem( QListViewItem *) ) );
482 /* 483 /*
483 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 484 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
484 const QPoint &,int ) ), 485 const QPoint &,int ) ),
485 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 486 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
486 */ 487 */
487 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 488 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
488 const QPoint &,int ) ), 489 const QPoint &,int ) ),
489 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 490 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
490 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 491 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
491 SLOT( itemClicked( QListViewItem * ) ) ); 492 SLOT( itemClicked( QListViewItem * ) ) );
492 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 493 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
493 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 494 SLOT( itemDoubleClicked( QListViewItem * ) ) );
494 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 495 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
495 SLOT( updateView() ) ); 496 SLOT( updateView() ) );
496 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 497 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
497 SLOT( todoModified(Todo *, int) ) ); 498 SLOT( todoModified(Todo *, int) ) );
498 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 499 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
499 SLOT( itemStateChanged( QListViewItem * ) ) ); 500 SLOT( itemStateChanged( QListViewItem * ) ) );
500 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 501 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
501 SLOT( itemStateChanged( QListViewItem * ) ) ); 502 SLOT( itemStateChanged( QListViewItem * ) ) );
502 503
503#if 0 504#if 0
504 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 505 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
505 SLOT(selectionChanged(QListViewItem *))); 506 SLOT(selectionChanged(QListViewItem *)));
506 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 507 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
507 SLOT(selectionChanged(QListViewItem *))); 508 SLOT(selectionChanged(QListViewItem *)));
508 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 509 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
509 SLOT(selectionChanged(QListViewItem *))); 510 SLOT(selectionChanged(QListViewItem *)));
510#endif 511#endif
511 512
512 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 513 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
513 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 514 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
514 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 515 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
515 516
516 connect( mTodoListView, SIGNAL(selectionChanged() ), 517 connect( mTodoListView, SIGNAL(selectionChanged() ),
517 SLOT( processSelectionChange() ) ); 518 SLOT( processSelectionChange() ) );
518 connect( mQuickAdd, SIGNAL( returnPressed () ), 519 connect( mQuickAdd, SIGNAL( returnPressed () ),
519 SLOT( addQuickTodo() ) ); 520 SLOT( addQuickTodo() ) );
520 521
521} 522}
522 523
523KOTodoView::~KOTodoView() 524KOTodoView::~KOTodoView()
524{ 525{
525 delete mDocPrefs; 526 delete mDocPrefs;
526} 527}
527 528
528void KOTodoView::jumpToDate () 529void KOTodoView::jumpToDate ()
529{ 530{
530 // if (mActiveItem) { 531 // if (mActiveItem) {
531// mActiveItem->todo()); 532// mActiveItem->todo());
532// if ( mActiveItem->todo()->hasDueDate() ) 533// if ( mActiveItem->todo()->hasDueDate() )
533// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 534// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
534} 535}
535 536
536void KOTodoView::updateView() 537void KOTodoView::updateView()
537{ 538{
538 pendingSubtodo = 0; 539 pendingSubtodo = 0;
539 if ( mBlockUpdate ) { 540 if ( mBlockUpdate ) {
540 //qDebug("blocked "); 541 //qDebug("blocked ");
541 return; 542 return;
542 } 543 }
543 if ( isFlatDisplay ) { 544 if ( isFlatDisplay ) {
544 setAllFlat(); 545 setAllFlat();
545 return; 546 return;
546 } 547 }
547 //qDebug("update "); 548 //qDebug("update ");
548// kdDebug() << "KOTodoView::updateView()" << endl; 549// kdDebug() << "KOTodoView::updateView()" << endl;
549 QFont fo = KOPrefs::instance()->mTodoViewFont; 550 QFont fo = KOPrefs::instance()->mTodoViewFont;
550 mTodoListView->clear(); 551 mTodoListView->clear();
551 if ( mName == "todolistsmall" ) { 552 if ( mName == "todolistsmall" ) {
552 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 553 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
553 int ps = fo.pointSize() -2; 554 int ps = fo.pointSize() -2;
554 if ( ps > 12 ) 555 if ( ps > 12 )
555 ps -= 2; 556 ps -= 2;
556 fo.setPointSize( ps ); 557 fo.setPointSize( ps );
557 } 558 }
558 } 559 }
559 560
560 mTodoListView->setFont( fo ); 561 mTodoListView->setFont( fo );
561 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 562 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
562 //mTodoListView->header()->setMaximumHeight(fm.height()); 563 //mTodoListView->header()->setMaximumHeight(fm.height());
563 QPtrList<Todo> todoList = calendar()->todos(); 564 QPtrList<Todo> todoList = calendar()->todos();
564 565
565/* 566/*
566 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 567 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
567 Event *t; 568 Event *t;
568 for(t = todoList.first(); t; t = todoList.next()) { 569 for(t = todoList.first(); t; t = todoList.next()) {
569 kdDebug() << " " << t->getSummary() << endl; 570 kdDebug() << " " << t->getSummary() << endl;
570 571
571 if (t->getRelatedTo()) { 572 if (t->getRelatedTo()) {
572 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 573 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
573 } 574 }
574 575
575 QPtrList<Event> l = t->getRelations(); 576 QPtrList<Event> l = t->getRelations();
576 Event *c; 577 Event *c;
577 for(c=l.first();c;c=l.next()) { 578 for(c=l.first();c;c=l.next()) {
578 kdDebug() << " - relation: " << c->getSummary() << endl; 579 kdDebug() << " - relation: " << c->getSummary() << endl;
579 } 580 }
580 } 581 }
581*/ 582*/
582 583
583 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 584 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
584 // specific order of events. That means that we have to generate parent items 585 // specific order of events. That means that we have to generate parent items
585 // recursively for proper hierarchical display of Todos. 586 // recursively for proper hierarchical display of Todos.
586 mTodoMap.clear(); 587 mTodoMap.clear();
587 Todo *todo; 588 Todo *todo;
588 todo = todoList.first();// todo; todo = todoList.next()) { 589 todo = todoList.first();// todo; todo = todoList.next()) {
589 while ( todo ) { 590 while ( todo ) {
590 bool next = true; 591 bool next = true;
591 // qDebug("todo %s ", todo->summary().latin1()); 592 // qDebug("todo %s ", todo->summary().latin1());
592 Incidence *incidence = todo->relatedTo(); 593 Incidence *incidence = todo->relatedTo();
593 while ( incidence ) { 594 while ( incidence ) {
594 if ( incidence->type() == "Todo") { 595 if ( incidence->type() == "Todo") {
595 //qDebug("related %s ",incidence->summary().latin1() ); 596 //qDebug("related %s ",incidence->summary().latin1() );
596 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 597 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
597 //qDebug("related not found "); 598 //qDebug("related not found ");
598 todoList.remove( ); 599 todoList.remove( );
599 todo = todoList.current(); 600 todo = todoList.current();
600 next = false; 601 next = false;
601 incidence = 0; 602 incidence = 0;
602 603
603 } else { 604 } else {
604 //qDebug("related found "); 605 //qDebug("related found ");
605 incidence = incidence->relatedTo(); 606 incidence = incidence->relatedTo();
606 } 607 }
607 } else 608 } else
608 incidence = 0; 609 incidence = 0;
609 } 610 }
610 if ( next ) 611 if ( next )
611 todo = todoList.next(); 612 todo = todoList.next();
612 } 613 }
613// qDebug("again .... "); 614// qDebug("again .... ");
614// for(todo = todoList.first(); todo; todo = todoList.next()) { 615// for(todo = todoList.first(); todo; todo = todoList.next()) {
615 616
616// qDebug("yytodo %s ", todo->summary().latin1()); 617// qDebug("yytodo %s ", todo->summary().latin1());
617// } 618// }
618 //qDebug("for "); 619 //qDebug("for ");
619 for(todo = todoList.first(); todo; todo = todoList.next()) { 620 for(todo = todoList.first(); todo; todo = todoList.next()) {
620 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 621 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
621 { 622 {
622 insertTodoItem(todo); 623 insertTodoItem(todo);
623 } 624 }
624 } 625 }
625 //qDebug("for end "); 626 //qDebug("for end ");
626 // Restore opened/closed state 627 // Restore opened/closed state
627 mTodoListView->blockSignals( true ); 628 mTodoListView->blockSignals( true );
628 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 629 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
629 mTodoListView->blockSignals( false ); 630 mTodoListView->blockSignals( false );
630 mTodoListView->setFocus(); 631 mTodoListView->setFocus();
631 processSelectionChange(); 632 processSelectionChange();
632} 633}
633 634
634bool KOTodoView::checkTodo( Todo * todo ) 635bool KOTodoView::checkTodo( Todo * todo )
635{ 636{
636 637
637 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 638 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
638 return false; 639 return false;
639 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 640 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
640 if ( todo->hasStartDate() ) 641 if ( todo->hasStartDate() )
641 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 642 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
642 return false; 643 return false;
643 if ( todo->hasDueDate() ) 644 if ( todo->hasDueDate() )
644 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 645 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
645 return false; 646 return false;
646 } 647 }
647 return true; 648 return true;
648} 649}
649 650
650void KOTodoView::restoreItemState( QListViewItem *item ) 651void KOTodoView::restoreItemState( QListViewItem *item )
651{ 652{
652 pendingSubtodo = 0; 653 pendingSubtodo = 0;
653 while( item ) { 654 while( item ) {
654 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 655 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
655 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 656 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
656 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 657 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
657 item = item->nextSibling(); 658 item = item->nextSibling();
658 } 659 }
659} 660}
660 661
661 662
662QMap<Todo *,KOTodoViewItem *>::ConstIterator 663QMap<Todo *,KOTodoViewItem *>::ConstIterator
663 KOTodoView::insertTodoItem(Todo *todo) 664 KOTodoView::insertTodoItem(Todo *todo)
664{ 665{
665 666
666// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 667// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
667 // TODO: Check, if dynmaic cast is necessary 668 // TODO: Check, if dynmaic cast is necessary
668 669
669 pendingSubtodo = 0; 670 pendingSubtodo = 0;
670 Incidence *incidence = todo->relatedTo(); 671 Incidence *incidence = todo->relatedTo();
671 if (incidence && incidence->type() == "Todo") { 672 if (incidence && incidence->type() == "Todo") {
672 Todo *relatedTodo = static_cast<Todo *>(incidence); 673 Todo *relatedTodo = static_cast<Todo *>(incidence);
673 674
674// kdDebug() << " has Related" << endl; 675// kdDebug() << " has Related" << endl;
675 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 676 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
676 itemIterator = mTodoMap.find(relatedTodo); 677 itemIterator = mTodoMap.find(relatedTodo);
677 if (itemIterator == mTodoMap.end()) { 678 if (itemIterator == mTodoMap.end()) {
678// kdDebug() << " related not yet in list" << endl; 679// kdDebug() << " related not yet in list" << endl;
679 itemIterator = insertTodoItem (relatedTodo); 680 itemIterator = insertTodoItem (relatedTodo);
680 } 681 }
681 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 682 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
682 // and one into the map. Sure finding is more easy but why? -zecke 683 // and one into the map. Sure finding is more easy but why? -zecke
683 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 684 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
684 return mTodoMap.insert(todo,todoItem); 685 return mTodoMap.insert(todo,todoItem);
685 } else { 686 } else {
686// kdDebug() << " no Related" << endl; 687// kdDebug() << " no Related" << endl;
687 // see above -zecke 688 // see above -zecke
688 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 689 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
689 return mTodoMap.insert(todo,todoItem); 690 return mTodoMap.insert(todo,todoItem);
690 } 691 }
691} 692}
692 693
693 694
694void KOTodoView::updateConfig() 695void KOTodoView::updateConfig()
695{ 696{
696 updateView(); 697 updateView();
697 mTodoListView->repaintContents(); 698 mTodoListView->repaintContents();
698} 699}
699 700
700QPtrList<Incidence> KOTodoView::selectedIncidences() 701QPtrList<Incidence> KOTodoView::selectedIncidences()
701{ 702{
702 QPtrList<Incidence> selected; 703 QPtrList<Incidence> selected;
703 704
704 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 705 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
705// if (!item) item = mActiveItem; 706// if (!item) item = mActiveItem;
706 if (item) selected.append(item->todo()); 707 if (item) selected.append(item->todo());
707 708
708 return selected; 709 return selected;
709} 710}
710 711
711QPtrList<Todo> KOTodoView::selectedTodos() 712QPtrList<Todo> KOTodoView::selectedTodos()
712{ 713{
713 QPtrList<Todo> selected; 714 QPtrList<Todo> selected;
714 715
715 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 716 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
716// if (!item) item = mActiveItem; 717// if (!item) item = mActiveItem;
717 if (item) selected.append(item->todo()); 718 if (item) selected.append(item->todo());
718 719
719 return selected; 720 return selected;
720} 721}
721 722
722void KOTodoView::changeEventDisplay(Event *, int) 723void KOTodoView::changeEventDisplay(Event *, int)
723{ 724{
724 updateView(); 725 updateView();
725} 726}
726 727
727void KOTodoView::showDates(const QDate &, const QDate &) 728void KOTodoView::showDates(const QDate &, const QDate &)
728{ 729{
729} 730}
730 731
731void KOTodoView::showEvents(QPtrList<Event>) 732void KOTodoView::showEvents(QPtrList<Event>)
732{ 733{
733 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 734 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
734} 735}
735 736
736void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 737void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
737 const QDate &td) 738 const QDate &td)
738{ 739{
739#ifndef KORG_NOPRINTER 740#ifndef KORG_NOPRINTER
740 calPrinter->preview(CalPrinter::Todolist, fd, td); 741 calPrinter->preview(CalPrinter::Todolist, fd, td);
741#endif 742#endif
742} 743}
743 744
744void KOTodoView::editItem(QListViewItem *item ) 745void KOTodoView::editItem(QListViewItem *item )
745{ 746{
746 // qDebug("editItem(QListViewItem *item ) "); 747 // qDebug("editItem(QListViewItem *item ) ");
747 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 748 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
748} 749}
749 750
750void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 751void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
751{ 752{
752 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 753 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
753} 754}
754 755
755void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) 756void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column)
756{ 757{
757 pendingSubtodo = 0; 758 pendingSubtodo = 0;
758 mActiveItem = (KOTodoViewItem *)item; 759 mActiveItem = (KOTodoViewItem *)item;
759 if (item) { 760 if (item) {
760 switch (column){ 761 switch (column){
761 case 1: 762 case 1:
762 mPriorityPopupMenu->popup(QCursor::pos ()); break; 763 mPriorityPopupMenu->popup(QCursor::pos ()); break;
763 case 2: 764 case 2:
764 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 765 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
765 case 3: 766 case 3:
766 moveTodo(); 767 moveTodo();
767 break; 768 break;
768 case 8: 769 case 8:
769 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 770 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
770 default: 771 default:
771 mItemPopupMenu->popup(QCursor::pos()); 772 mItemPopupMenu->popup(QCursor::pos());
772 } 773 }
773 } else mPopupMenu->popup(QCursor::pos()); 774 } else mPopupMenu->popup(QCursor::pos());
774} 775}
775void KOTodoView::newTodo() 776void KOTodoView::newTodo()
776{ 777{
777 emit newTodoSignal(); 778 emit newTodoSignal();
778} 779}
779 780
780void KOTodoView::newSubTodo() 781void KOTodoView::newSubTodo()
781{ 782{
782 if (mActiveItem) { 783 if (mActiveItem) {
783 emit newSubTodoSignal(mActiveItem->todo()); 784 emit newSubTodoSignal(mActiveItem->todo());
784 } 785 }
785} 786}
786void KOTodoView::unparentTodo() 787void KOTodoView::unparentTodo()
787{ 788{
788 if (mActiveItem) { 789 if (mActiveItem) {
789 emit unparentTodoSignal(mActiveItem->todo()); 790 emit unparentTodoSignal(mActiveItem->todo());
790 } 791 }
791} 792}
792 793
793void KOTodoView::reparentTodo() 794void KOTodoView::reparentTodo()
794{ 795{
795 if (mActiveItem) { 796 if (mActiveItem) {
796 qDebug("KOTodoView::reparentTodo() "); 797 qDebug("KOTodoView::reparentTodo() ");
797 topLevelWidget()->setCaption(i18n("Click on new parent item")); 798 topLevelWidget()->setCaption(i18n("Click on new parent item"));
798 pendingSubtodo = mActiveItem; 799 pendingSubtodo = mActiveItem;
799 } 800 }
800} 801}
801void KOTodoView::editTodo() 802void KOTodoView::editTodo()
802{ 803{
803 if (mActiveItem) { 804 if (mActiveItem) {
804 emit editTodoSignal(mActiveItem->todo()); 805 emit editTodoSignal(mActiveItem->todo());
805 } 806 }
806} 807}
807void KOTodoView::cloneTodo() 808void KOTodoView::cloneTodo()
808{ 809{
809 if (mActiveItem) { 810 if (mActiveItem) {
810 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 811 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
811 } 812 }
812} 813}
813void KOTodoView::cancelTodo() 814void KOTodoView::cancelTodo()
814{ 815{
815 if (mActiveItem) { 816 if (mActiveItem) {
816 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 817 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
817 } 818 }
818} 819}
819void KOTodoView::moveTodo() 820void KOTodoView::moveTodo()
820{ 821{
821 if (mActiveItem) { 822 if (mActiveItem) {
822 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 823 emit moveTodoSignal((Incidence*)mActiveItem->todo());
823 } 824 }
824} 825}
825void KOTodoView::beamTodo() 826void KOTodoView::beamTodo()
826{ 827{
827 if (mActiveItem) { 828 if (mActiveItem) {
828 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 829 emit beamTodoSignal((Incidence*)mActiveItem->todo());
829 } 830 }
830} 831}
831 832
832 833
833void KOTodoView::showTodo() 834void KOTodoView::showTodo()
834{ 835{
835 if (mActiveItem) { 836 if (mActiveItem) {
836 emit showTodoSignal(mActiveItem->todo()); 837 emit showTodoSignal(mActiveItem->todo());
837 } 838 }
838} 839}
839 840
840void KOTodoView::deleteTodo() 841void KOTodoView::deleteTodo()
841{ 842{
842 if (mActiveItem) { 843 if (mActiveItem) {
843 emit deleteTodoSignal(mActiveItem->todo()); 844 emit deleteTodoSignal(mActiveItem->todo());
844 } 845 }
845} 846}
846 847
847void KOTodoView::setNewPriority(int index) 848void KOTodoView::setNewPriority(int index)
848{ 849{
849 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 850 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
850 mActiveItem->todo()->setPriority(mPriority[index]); 851 mActiveItem->todo()->setPriority(mPriority[index]);
851 mActiveItem->construct(); 852 mActiveItem->construct();
852 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 853 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
853 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 854 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
854 } 855 }
855} 856}
856 857
857void KOTodoView::setNewPercentage(int index) 858void KOTodoView::setNewPercentage(int index)
858{ 859{
859 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 860 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
860 if (mPercentage[index] == 100) { 861 if (mPercentage[index] == 100) {
861 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 862 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
862 } else { 863 } else {
863 mActiveItem->todo()->setCompleted(false); 864 mActiveItem->todo()->setCompleted(false);
864 } 865 }
865 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 866 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
866 mActiveItem->construct(); 867 mActiveItem->construct();
867 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 868 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
868 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 869 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
869 } 870 }
870} 871}
871 872
872 873
873QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 874QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
874{ 875{
875 QPopupMenu* tempMenu = new QPopupMenu (this); 876 QPopupMenu* tempMenu = new QPopupMenu (this);
876 QStringList checkedCategories = todoItem->todo()->categories (); 877 QStringList checkedCategories = todoItem->todo()->categories ();
877 878
878 tempMenu->setCheckable (true); 879 tempMenu->setCheckable (true);
879 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 880 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
880 it != KOPrefs::instance()->mCustomCategories.end (); 881 it != KOPrefs::instance()->mCustomCategories.end ();
881 ++it) { 882 ++it) {
882 int index = tempMenu->insertItem (*it); 883 int index = tempMenu->insertItem (*it);
883 mCategory[index] = *it; 884 mCategory[index] = *it;
884 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 885 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
885 } 886 }
886 887
887 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 888 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
888 return tempMenu; 889 return tempMenu;
889 890
890 891
891} 892}
892void KOTodoView::changedCategories(int index) 893void KOTodoView::changedCategories(int index)
893{ 894{
894 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 895 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
895 QStringList categories = mActiveItem->todo()->categories (); 896 QStringList categories = mActiveItem->todo()->categories ();
896 if (categories.find (mCategory[index]) != categories.end ()) 897 if (categories.find (mCategory[index]) != categories.end ())
897 categories.remove (mCategory[index]); 898 categories.remove (mCategory[index]);
898 else 899 else
899 categories.insert (categories.end(), mCategory[index]); 900 categories.insert (categories.end(), mCategory[index]);
900 categories.sort (); 901 categories.sort ();
901 mActiveItem->todo()->setCategories (categories); 902 mActiveItem->todo()->setCategories (categories);
902 mActiveItem->construct(); 903 mActiveItem->construct();
903 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 904 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
904 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 905 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
905 } 906 }
906} 907}
907void KOTodoView::itemDoubleClicked(QListViewItem *item) 908void KOTodoView::itemDoubleClicked(QListViewItem *item)
908{ 909{
909 if ( pendingSubtodo != 0 ) { 910 if ( pendingSubtodo != 0 ) {
910 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 911 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
911 } 912 }
912 pendingSubtodo = 0; 913 pendingSubtodo = 0;
913 if (!item) { 914 if (!item) {
914 newTodo(); 915 newTodo();
915 return; 916 return;
916 } 917 }
917 if ( KOPrefs::instance()->mEditOnDoubleClick ) 918 if ( KOPrefs::instance()->mEditOnDoubleClick )
918 editItem( item ); 919 editItem( item );
919 else 920 else
920 showItem( item , QPoint(), 0 ); 921 showItem( item , QPoint(), 0 );
921} 922}
922void KOTodoView::itemClicked(QListViewItem *item) 923void KOTodoView::itemClicked(QListViewItem *item)
923{ 924{
924 925
925 if (!item) { 926 if (!item) {
926 if ( pendingSubtodo != 0 ) { 927 if ( pendingSubtodo != 0 ) {
927 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 928 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
928 } 929 }
929 pendingSubtodo = 0; 930 pendingSubtodo = 0;
930 return; 931 return;
931 } 932 }
932 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 933 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
933 if ( pendingSubtodo != 0 ) { 934 if ( pendingSubtodo != 0 ) {
934 bool allowReparent = true; 935 bool allowReparent = true;
935 QListViewItem *par = item; 936 QListViewItem *par = item;
936 while ( par ) { 937 while ( par ) {
937 if ( par == pendingSubtodo ) { 938 if ( par == pendingSubtodo ) {
938 allowReparent = false; 939 allowReparent = false;
939 break; 940 break;
940 } 941 }
941 par = par->parent(); 942 par = par->parent();
942 } 943 }
943 if ( !allowReparent ) { 944 if ( !allowReparent ) {
944 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 945 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
945 qDebug("Recursive reparenting not possible "); 946 qDebug("Recursive reparenting not possible ");
946 pendingSubtodo = 0; 947 pendingSubtodo = 0;
947 } else { 948 } else {
948 Todo* newParent = todoItem->todo(); 949 Todo* newParent = todoItem->todo();
949 Todo* newSub = pendingSubtodo->todo(); 950 Todo* newSub = pendingSubtodo->todo();
950 pendingSubtodo = 0; 951 pendingSubtodo = 0;
951 emit reparentTodoSignal( newParent,newSub ); 952 emit reparentTodoSignal( newParent,newSub );
952 return; 953 return;
953 } 954 }
954 } 955 }
955 int completed = todoItem->todo()->isCompleted(); // Completed or not? 956#if 0
956 957 // handled by the item itself
958 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
959 qDebug("com %d ",completed );
960 qDebug("itemclicked ");
957 if (todoItem->isOn()) { 961 if (todoItem->isOn()) {
962 qDebug("on ");
958 if (!completed) { 963 if (!completed) {
964 qDebug("set true ");
959 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 965 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
960 } 966 }
961 } else { 967 } else {
968 qDebug("not on ");
962 if (completed) { 969 if (completed) {
970 qDebug("set false ");
963 todoItem->todo()->setCompleted(false); 971 todoItem->todo()->setCompleted(false);
964 } 972 }
965 } 973 }
974#endif
966} 975}
967 976
968void KOTodoView::setDocumentId( const QString &id ) 977void KOTodoView::setDocumentId( const QString &id )
969{ 978{
970 kdDebug() << "KOTodoView::setDocumentId()" << endl; 979 kdDebug() << "KOTodoView::setDocumentId()" << endl;
971 980
972 mDocPrefs->setDoc( id ); 981 mDocPrefs->setDoc( id );
973} 982}
974 983
975void KOTodoView::itemStateChanged( QListViewItem *item ) 984void KOTodoView::itemStateChanged( QListViewItem *item )
976{ 985{
977 if (!item) return; 986 if (!item) return;
978 987
979 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 988 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
980 989
981// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 990// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
982 991
983 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 992 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
984} 993}
985 994
986void KOTodoView::saveLayout(KConfig *config, const QString &group) const 995void KOTodoView::saveLayout(KConfig *config, const QString &group) const
987{ 996{
988 mTodoListView->saveLayout(config,group); 997 mTodoListView->saveLayout(config,group);
989} 998}
990 999
991void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1000void KOTodoView::restoreLayout(KConfig *config, const QString &group)
992{ 1001{
993 mTodoListView->restoreLayout(config,group); 1002 mTodoListView->restoreLayout(config,group);
994} 1003}
995 1004
996void KOTodoView::processSelectionChange() 1005void KOTodoView::processSelectionChange()
997{ 1006{
998// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1007// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
999 1008
1000 KOTodoViewItem *item = 1009 KOTodoViewItem *item =
1001 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1010 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1002 1011
1003 if ( !item ) { 1012 if ( !item ) {
1004 emit incidenceSelected( 0 ); 1013 emit incidenceSelected( 0 );
1005 } else { 1014 } else {
1006 emit incidenceSelected( item->todo() ); 1015 emit incidenceSelected( item->todo() );
1007 } 1016 }
1008} 1017}
1009 1018
1010void KOTodoView::modified(bool b) 1019void KOTodoView::modified(bool b)
1011{ 1020{
1012 emit isModified(b); 1021 emit isModified(b);
1013} 1022}
1014void KOTodoView::setTodoModified( Todo* todo ) 1023void KOTodoView::setTodoModified( Todo* todo )
1015{ 1024{
1016 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1025 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1017} 1026}
1018void KOTodoView::clearSelection() 1027void KOTodoView::clearSelection()
1019{ 1028{
1020 mTodoListView->selectAll( false ); 1029 mTodoListView->selectAll( false );
1021} 1030}
1022void KOTodoView::setAllOpen() 1031void KOTodoView::setAllOpen()
1023{ 1032{
1024 if ( isFlatDisplay ) { 1033 if ( isFlatDisplay ) {
1025 isFlatDisplay = false; 1034 isFlatDisplay = false;
1026 mPopupMenu->setItemChecked( 8,false ); 1035 mPopupMenu->setItemChecked( 8,false );
1027 updateView(); 1036 updateView();
1028 } 1037 }
1029 setOpen(mTodoListView->firstChild(), true); 1038 setOpen(mTodoListView->firstChild(), true);
1030} 1039}
1031void KOTodoView::setAllClose() 1040void KOTodoView::setAllClose()
1032{ 1041{
1033 if ( isFlatDisplay ) { 1042 if ( isFlatDisplay ) {
1034 isFlatDisplay = false; 1043 isFlatDisplay = false;
1035 mPopupMenu->setItemChecked( 8,false ); 1044 mPopupMenu->setItemChecked( 8,false );
1036 updateView(); 1045 updateView();
1037 } 1046 }
1038 setOpen(mTodoListView->firstChild(), false); 1047 setOpen(mTodoListView->firstChild(), false);
1039} 1048}
1040void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1049void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1041{ 1050{
1042 1051
1043 while ( item ) { 1052 while ( item ) {
1044 setOpen( item->firstChild(), setOpenI ); 1053 setOpen( item->firstChild(), setOpenI );
1045 item->setOpen( setOpenI ); 1054 item->setOpen( setOpenI );
1046 item = item->nextSibling(); 1055 item = item->nextSibling();
1047 } 1056 }
1048} 1057}
1049 1058
1050void KOTodoView::setAllFlat() 1059void KOTodoView::setAllFlat()
1051{ 1060{
1052 if ( isFlatDisplay ) { 1061 if ( isFlatDisplay ) {
1053 isFlatDisplay = false; 1062 isFlatDisplay = false;
1054 mPopupMenu->setItemChecked( 8,false ); 1063 mPopupMenu->setItemChecked( 8,false );
1055 updateView(); 1064 updateView();
1056 return; 1065 return;
1057 } 1066 }
1058 pendingSubtodo = 0; 1067 pendingSubtodo = 0;
1059 if ( mBlockUpdate ) { 1068 if ( mBlockUpdate ) {
1060 return; 1069 return;
1061 } 1070 }
1062 mPopupMenu->setItemChecked( 8,true ); 1071 mPopupMenu->setItemChecked( 8,true );
1063 isFlatDisplay = true; 1072 isFlatDisplay = true;
1064 QPtrList<Todo> todoList = calendar()->todos(); 1073 QPtrList<Todo> todoList = calendar()->todos();
1065 mTodoMap.clear(); 1074 mTodoMap.clear();
1066 mTodoListView->clear(); 1075 mTodoListView->clear();
1067 Todo *todo; 1076 Todo *todo;
1068 for(todo = todoList.first(); todo; todo = todoList.next()) { 1077 for(todo = todoList.first(); todo; todo = todoList.next()) {
1069 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1078 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1070 mTodoMap.insert(todo,todoItem); 1079 mTodoMap.insert(todo,todoItem);
1071 } 1080 }
1072 mTodoListView->setFocus(); 1081 mTodoListView->setFocus();
1073 processSelectionChange(); 1082 processSelectionChange();
1074} 1083}
1075 1084
1076void KOTodoView::purgeCompleted() 1085void KOTodoView::purgeCompleted()
1077{ 1086{
1078 emit purgeCompletedSignal(); 1087 emit purgeCompletedSignal();
1079} 1088}
1080void KOTodoView::toggleQuickTodo() 1089void KOTodoView::toggleQuickTodo()
1081{ 1090{
1082 if ( mQuickAdd->isVisible() ) { 1091 if ( mQuickAdd->isVisible() ) {
1083 mQuickAdd->hide(); 1092 mQuickAdd->hide();
1084 KOPrefs::instance()->mEnableQuickTodo = false; 1093 KOPrefs::instance()->mEnableQuickTodo = false;
1085 } 1094 }
1086 else { 1095 else {
1087 mQuickAdd->show(); 1096 mQuickAdd->show();
1088 KOPrefs::instance()->mEnableQuickTodo = true; 1097 KOPrefs::instance()->mEnableQuickTodo = true;
1089 } 1098 }
1090 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1099 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1091 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1100 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1092} 1101}
1093 1102
1094void KOTodoView::toggleRunning() 1103void KOTodoView::toggleRunning()
1095{ 1104{
1096 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1105 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1097 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1106 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1098 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1107 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1099 updateView(); 1108 updateView();
1100} 1109}
1101 1110
1102void KOTodoView::toggleCompleted() 1111void KOTodoView::toggleCompleted()
1103{ 1112{
1104 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1113 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1105 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1114 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1106 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1115 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1107 updateView(); 1116 updateView();
1108} 1117}
1109 1118
1110void KOTodoView::addQuickTodo() 1119void KOTodoView::addQuickTodo()
1111{ 1120{
1112 Todo *todo = new Todo(); 1121 Todo *todo = new Todo();
1113 todo->setSummary(mQuickAdd->text()); 1122 todo->setSummary(mQuickAdd->text());
1114 todo->setOrganizer(KOPrefs::instance()->email()); 1123 todo->setOrganizer(KOPrefs::instance()->email());
1115 CalFilter * cf = mCalendar->filter(); 1124 CalFilter * cf = mCalendar->filter();
1116 if ( cf ) { 1125 if ( cf ) {
1117 if ( cf->isEnabled()&& cf->showCategories()) { 1126 if ( cf->isEnabled()&& cf->showCategories()) {
1118 todo->setCategories(cf->categoryList()); 1127 todo->setCategories(cf->categoryList());
1119 } 1128 }
1120 if ( cf->isEnabled() ) 1129 if ( cf->isEnabled() )
1121 todo->setSecrecy( cf->getSecrecy()); 1130 todo->setSecrecy( cf->getSecrecy());
1122 } 1131 }
1123 mCalendar->addTodo(todo); 1132 mCalendar->addTodo(todo);
1124 mQuickAdd->setText(""); 1133 mQuickAdd->setText("");
1125 todoModified (todo, KOGlobals::EVENTADDED ); 1134 todoModified (todo, KOGlobals::EVENTADDED );
1126 updateView(); 1135 updateView();
1127} 1136}
1128void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1137void KOTodoView::keyPressEvent ( QKeyEvent * e )
1129{ 1138{
1130 // e->ignore(); 1139 // e->ignore();
1131 //return; 1140 //return;
1132 //qDebug("KOTodoView::keyPressEvent "); 1141 //qDebug("KOTodoView::keyPressEvent ");
1133 switch ( e->key() ) { 1142 switch ( e->key() ) {
1134 case Qt::Key_Down: 1143 case Qt::Key_Down:
1135 case Qt::Key_Up: 1144 case Qt::Key_Up:
1136 QWidget::keyPressEvent ( e ); 1145 QWidget::keyPressEvent ( e );
1137 break; 1146 break;
1138 1147
1139 case Qt::Key_Q: 1148 case Qt::Key_Q:
1140 toggleQuickTodo(); 1149 toggleQuickTodo();
1141 break; 1150 break;
1142 case Qt::Key_U: 1151 case Qt::Key_U:
1143 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1152 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1144 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1153 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1145 unparentTodo(); 1154 unparentTodo();
1146 e->accept(); 1155 e->accept();
1147 } else 1156 } else
1148 e->ignore(); 1157 e->ignore();
1149 break; 1158 break;
1150 case Qt::Key_S: 1159 case Qt::Key_S:
1151 if ( e->state() == Qt::ControlButton ) { 1160 if ( e->state() == Qt::ControlButton ) {
1152 e->ignore(); 1161 e->ignore();
1153 break; 1162 break;
1154 } 1163 }
1155 if ( e->state() == Qt::ShiftButton ) { 1164 if ( e->state() == Qt::ShiftButton ) {
1156 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1165 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1157 reparentTodo(); 1166 reparentTodo();
1158 e->accept(); 1167 e->accept();
1159 } else 1168 } else
1160 e->ignore(); 1169 e->ignore();
1161 break; 1170 break;
1162 case Qt::Key_P: 1171 case Qt::Key_P:
1163 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1172 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1164 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1173 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1165 if ( pendingSubtodo ) 1174 if ( pendingSubtodo )
1166 itemClicked(mActiveItem); 1175 itemClicked(mActiveItem);
1167 e->accept(); 1176 e->accept();
1168 } else 1177 } else
1169 e->ignore(); 1178 e->ignore();
1170 break; 1179 break;
1171 case Qt::Key_Escape: 1180 case Qt::Key_Escape:
1172 if ( pendingSubtodo ) { 1181 if ( pendingSubtodo ) {
1173 itemClicked(0); 1182 itemClicked(0);
1174 e->accept(); 1183 e->accept();
1175 } else 1184 } else
1176 e->ignore(); 1185 e->ignore();
1177 break; 1186 break;
1178 default: 1187 default:
1179 e->ignore(); 1188 e->ignore();
1180 } 1189 }
1181 1190
1182 if ( true ) { 1191 if ( true ) {
1183 if ( e->key() == Qt::Key_I ) { 1192 if ( e->key() == Qt::Key_I ) {
1184 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1193 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1185 if ( cn ) { 1194 if ( cn ) {
1186 mActiveItem = cn; 1195 mActiveItem = cn;
1187 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1196 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1188 if ( ci ){ 1197 if ( ci ){
1189 showTodo(); 1198 showTodo();
1190 cn = (KOTodoViewItem*)cn->itemBelow(); 1199 cn = (KOTodoViewItem*)cn->itemBelow();
1191 if ( cn ) { 1200 if ( cn ) {
1192 mTodoListView->setCurrentItem ( cn ); 1201 mTodoListView->setCurrentItem ( cn );
1193 mTodoListView->ensureItemVisible ( cn ); 1202 mTodoListView->ensureItemVisible ( cn );
1194 } 1203 }
1195 1204
1196 } 1205 }
1197 } 1206 }
1198 e->accept(); 1207 e->accept();
1199 1208
1200 } 1209 }
1201 1210
1202 } 1211 }
1203 1212
1204} 1213}
1205void KOTodoView::updateTodo( Todo * t, int type ) 1214void KOTodoView::updateTodo( Todo * t, int type )
1206{ 1215{
1207 if ( mBlockUpdate) 1216 if ( mBlockUpdate)
1208 return; 1217 return;
1209 1218
1210 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1219 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1211 itemIterator = mTodoMap.find(t); 1220 itemIterator = mTodoMap.find(t);
1212 if (itemIterator != mTodoMap.end()) { 1221 if (itemIterator != mTodoMap.end()) {
1213 (*itemIterator)->construct(); 1222 (*itemIterator)->construct();
1214 } else { 1223 } else {
1215 if ( type == KOGlobals::EVENTADDED ) { 1224 if ( type == KOGlobals::EVENTADDED ) {
1216 insertTodoItem( t ); 1225 insertTodoItem( t );
1217 } 1226 }
1218 } 1227 }
1219 1228
1220} 1229}
1221 1230
1222void KOTodoView::todoModified(Todo * t , int p ) 1231void KOTodoView::todoModified(Todo * t , int p )
1223{ 1232{
1224 mBlockUpdate = true; 1233 mBlockUpdate = true;
1225 emit todoModifiedSignal ( t, p ); 1234 emit todoModifiedSignal ( t, p );
1226 mBlockUpdate = false; 1235 mBlockUpdate = false;
1227} 1236}
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 21ecb73..2822237 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -1,457 +1,456 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qapp.h> 22#include <qapp.h>
23 23
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include "kotodoviewitem.h" 25#include "kotodoviewitem.h"
26#include "kotodoview.h" 26#include "kotodoview.h"
27#include "koprefs.h" 27#include "koprefs.h"
28 28
29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) 29KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 30 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
31{ 31{
32 construct(); 32 construct();
33} 33}
34 34
35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) 35KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 36 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
37{ 37{
38 construct(); 38 construct();
39} 39}
40 40
41QString KOTodoViewItem::key(int column,bool) const 41QString KOTodoViewItem::key(int column,bool) const
42{ 42{
43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 43 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
44 if (it == mKeyMap.end()) { 44 if (it == mKeyMap.end()) {
45 return text(column).lower(); 45 return text(column).lower();
46 } else { 46 } else {
47 return *it; 47 return *it;
48 } 48 }
49} 49}
50 50
51void KOTodoViewItem:: setup() 51void KOTodoViewItem:: setup()
52{ 52{
53 53
54 int h = 20; 54 int h = 20;
55 if ( listView () ) { 55 if ( listView () ) {
56 QFontMetrics fm ( listView ()->font () ); 56 QFontMetrics fm ( listView ()->font () );
57 h = fm.height(); 57 h = fm.height();
58 } 58 }
59 setHeight( h ); 59 setHeight( h );
60 60
61} 61}
62void KOTodoViewItem::setSortKey(int column,const QString &key) 62void KOTodoViewItem::setSortKey(int column,const QString &key)
63{ 63{
64 mKeyMap.insert(column,key); 64 mKeyMap.insert(column,key);
65} 65}
66 66
67#if QT_VERSION >= 0x030000 67#if QT_VERSION >= 0x030000
68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, 68void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
69 int y,int h) 69 int y,int h)
70{ 70{
71 QListViewItem::paintBranches(p,cg,w,y,h); 71 QListViewItem::paintBranches(p,cg,w,y,h);
72} 72}
73#else 73#else
74#endif 74#endif
75 75
76void KOTodoViewItem::construct() 76void KOTodoViewItem::construct()
77{ 77{
78 // qDebug("KOTodoViewItem::construct() "); 78 // qDebug("KOTodoViewItem::construct() ");
79 m_init = true; 79 m_init = true;
80 QString keyd = "=="; 80 QString keyd = "==";
81 QString keyt = "=="; 81 QString keyt = "==";
82 QString skeyd = "=="; 82 QString skeyd = "==";
83 QString skeyt = "=="; 83 QString skeyt = "==";
84 84
85 setOn(mTodo->isCompleted()); 85 setOn(mTodo->isCompleted());
86 setText(0,mTodo->summary()); 86 setText(0,mTodo->summary());
87 setText(1,QString::number(mTodo->priority())); 87 setText(1,QString::number(mTodo->priority()));
88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 88 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
89 if (mTodo->percentComplete()<100) { 89 if (mTodo->percentComplete()<100) {
90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 90 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
91 else setSortKey(2,QString::number(mTodo->percentComplete())); 91 else setSortKey(2,QString::number(mTodo->percentComplete()));
92 } 92 }
93 else { 93 else {
94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 94 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
95 else setSortKey(2,QString::number(99)); 95 else setSortKey(2,QString::number(99));
96 } 96 }
97 if (mTodo->hasDueDate()) { 97 if (mTodo->hasDueDate()) {
98 setText(3, mTodo->dtDueDateStr()); 98 setText(3, mTodo->dtDueDateStr());
99 QDate d = mTodo->dtDue().date(); 99 QDate d = mTodo->dtDue().date();
100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 100 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
101 // setSortKey(3,keyd); 101 // setSortKey(3,keyd);
102 if (mTodo->doesFloat()) { 102 if (mTodo->doesFloat()) {
103 setText(4,""); 103 setText(4,"");
104 } 104 }
105 else { 105 else {
106 setText(4,mTodo->dtDueTimeStr()); 106 setText(4,mTodo->dtDueTimeStr());
107 QTime t = mTodo->dtDue().time(); 107 QTime t = mTodo->dtDue().time();
108 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 108 keyt.sprintf("%02d%02d",t.hour(),t.minute());
109 //setSortKey(4,keyt); 109 //setSortKey(4,keyt);
110 } 110 }
111 } else { 111 } else {
112 setText(3,""); 112 setText(3,"");
113 setText(4,""); 113 setText(4,"");
114 } 114 }
115 setSortKey(3,keyd); 115 setSortKey(3,keyd);
116 setSortKey(4,keyt); 116 setSortKey(4,keyt);
117 117
118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
120 120
121 121
122 122
123 if (mTodo->hasStartDate()) { 123 if (mTodo->hasStartDate()) {
124 setText(5, mTodo->dtStartDateStr()); 124 setText(5, mTodo->dtStartDateStr());
125 QDate d = mTodo->dtStart().date(); 125 QDate d = mTodo->dtStart().date();
126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
127 127
128 if (mTodo->doesFloat()) { 128 if (mTodo->doesFloat()) {
129 setText(6,""); 129 setText(6,"");
130 } 130 }
131 else { 131 else {
132 setText(6,mTodo->dtStartTimeStr()); 132 setText(6,mTodo->dtStartTimeStr());
133 QTime t = mTodo->dtStart().time(); 133 QTime t = mTodo->dtStart().time();
134 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 134 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
135 135
136 } 136 }
137 } else { 137 } else {
138 setText(5,""); 138 setText(5,"");
139 setText(6,""); 139 setText(6,"");
140 } 140 }
141 setSortKey(5,skeyd); 141 setSortKey(5,skeyd);
142 setSortKey(6,skeyt); 142 setSortKey(6,skeyt);
143 143
144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
145 setText(8,mTodo->categoriesStr()); 145 setText(8,mTodo->categoriesStr());
146 146
147#if 0 147#if 0
148 // Find sort id in description. It's the text behind the last '#' character 148 // Find sort id in description. It's the text behind the last '#' character
149 // found in the description. White spaces are removed from beginning and end 149 // found in the description. White spaces are removed from beginning and end
150 // of sort id. 150 // of sort id.
151 int pos = mTodo->description().findRev('#'); 151 int pos = mTodo->description().findRev('#');
152 if (pos < 0) { 152 if (pos < 0) {
153 setText(6,""); 153 setText(6,"");
154 } else { 154 } else {
155 QString str = mTodo->description().mid(pos+1); 155 QString str = mTodo->description().mid(pos+1);
156 str.stripWhiteSpace(); 156 str.stripWhiteSpace();
157 setText(6,str); 157 setText(6,str);
158 } 158 }
159#endif 159#endif
160 160
161 m_known = false; 161 m_known = false;
162 m_init = false; 162 m_init = false;
163 163
164 setMyPixmap(); 164 setMyPixmap();
165 165
166} 166}
167void KOTodoViewItem::setMyPixmap() 167void KOTodoViewItem::setMyPixmap()
168{ 168{
169 int size = 5; 169 int size = 5;
170 QPixmap pixi = QPixmap( 1, 1 ); 170 QPixmap pixi = QPixmap( 1, 1 );
171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
172// pixi = SmallIcon("redcross16"); 172// pixi = SmallIcon("redcross16");
173// } else { 173// } else {
174 QPainter p; 174 QPainter p;
175 175
176 int pixSize = 0; 176 int pixSize = 0;
177 QPixmap pPix = QPixmap( size, size ); 177 QPixmap pPix = QPixmap( size, size );
178 if ( mTodo->description().length() > 0 ) { 178 if ( mTodo->description().length() > 0 ) {
179 pixi.resize(size, pixSize+size); 179 pixi.resize(size, pixSize+size);
180 pPix.fill( Qt::darkGreen ); 180 pPix.fill( Qt::darkGreen );
181 p.begin( &pixi ); 181 p.begin( &pixi );
182 p. drawPixmap ( 0, pixSize, pPix); 182 p. drawPixmap ( 0, pixSize, pPix);
183 p.end(); 183 p.end();
184 pixSize += size; 184 pixSize += size;
185 } 185 }
186 if ( mTodo->isAlarmEnabled() ) { 186 if ( mTodo->isAlarmEnabled() ) {
187 pixi.resize(size, pixSize+size); 187 pixi.resize(size, pixSize+size);
188 pPix.fill( Qt::red ); 188 pPix.fill( Qt::red );
189 p.begin( &pixi ); 189 p.begin( &pixi );
190 p. drawPixmap ( 0, pixSize, pPix); 190 p. drawPixmap ( 0, pixSize, pPix);
191 p.end(); 191 p.end();
192 pixSize += size; 192 pixSize += size;
193 } 193 }
194 // } 194 // }
195 if ( pixi.width() > 1 ) { 195 if ( pixi.width() > 1 ) {
196 setPixmap ( 0,pixi ) ; 196 setPixmap ( 0,pixi ) ;
197 } else { 197 } else {
198 setPixmap ( 0,QPixmap() ) ; 198 setPixmap ( 0,QPixmap() ) ;
199 } 199 }
200} 200}
201void KOTodoViewItem::stateChange(bool state) 201void KOTodoViewItem::stateChange(bool state)
202{ 202{
203 // qDebug("KOTodoViewItem::stateChange "); 203 // qDebug("KOTodoViewItem::stateChange ");
204 // do not change setting on startup 204 // do not change setting on startup
205 if ( m_init ) return; 205 if ( m_init ) return;
206 206 qDebug("KOTodoViewItem::stateChange ");
207 kdDebug() << "State changed, modified " << state << endl;
208 QString keyd = "=="; 207 QString keyd = "==";
209 QString keyt = "=="; 208 QString keyt = "==";
210 209
211 if (state) mTodo->setCompleted(state); 210 mTodo->setCompleted(state);
212 else mTodo->setPercentComplete(0); 211 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
213 if (isOn()!=state) { 212 if (isOn()!=state) {
214 setOn(state); 213 setOn(state);
215 } 214 }
216 215
217 if (mTodo->hasDueDate()) { 216 if (mTodo->hasDueDate()) {
218 setText(3, mTodo->dtDueDateStr()); 217 setText(3, mTodo->dtDueDateStr());
219 QDate d = mTodo->dtDue().date(); 218 QDate d = mTodo->dtDue().date();
220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 219 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
221 setSortKey(3,keyd); 220 setSortKey(3,keyd);
222 if (mTodo->doesFloat()) { 221 if (mTodo->doesFloat()) {
223 setText(4,""); 222 setText(4,"");
224 } 223 }
225 else { 224 else {
226 setText(4,mTodo->dtDueTimeStr()); 225 setText(4,mTodo->dtDueTimeStr());
227 QTime t = mTodo->dtDue().time(); 226 QTime t = mTodo->dtDue().time();
228 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 227 keyt.sprintf("%02d%02d",t.hour(),t.minute());
229 setSortKey(4,keyt); 228 setSortKey(4,keyt);
230 } 229 }
231 } 230 }
232 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 231 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
233 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 232 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
234 233
235 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 234 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
236 if (mTodo->percentComplete()<100) { 235 if (mTodo->percentComplete()<100) {
237 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 236 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
238 else setSortKey(2,QString::number(mTodo->percentComplete())); 237 else setSortKey(2,QString::number(mTodo->percentComplete()));
239 } 238 }
240 else { 239 else {
241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 240 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
242 else setSortKey(2,QString::number(99)); 241 else setSortKey(2,QString::number(99));
243 } 242 }
244 QListViewItem * myChild = firstChild(); 243 QListViewItem * myChild = firstChild();
245 KOTodoViewItem *item; 244 KOTodoViewItem *item;
246 while( myChild ) { 245 while( myChild ) {
247 item = static_cast<KOTodoViewItem*>(myChild); 246 item = static_cast<KOTodoViewItem*>(myChild);
248 item->stateChange(state); 247 item->stateChange(state);
249 myChild = myChild->nextSibling(); 248 myChild = myChild->nextSibling();
250 } 249 }
251 mTodoView->modified(true); 250 mTodoView->modified(true);
252 setMyPixmap(); 251 setMyPixmap();
253 mTodoView->setTodoModified( mTodo ); 252 mTodoView->setTodoModified( mTodo );
254} 253}
255 254
256bool KOTodoViewItem::isAlternate() 255bool KOTodoViewItem::isAlternate()
257{ 256{
258#ifndef KORG_NOLVALTERNATION 257#ifndef KORG_NOLVALTERNATION
259 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 258 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
260 if (lv && lv->alternateBackground().isValid()) 259 if (lv && lv->alternateBackground().isValid())
261 { 260 {
262 KOTodoViewItem *above = 0; 261 KOTodoViewItem *above = 0;
263 above = dynamic_cast<KOTodoViewItem *>(itemAbove()); 262 above = dynamic_cast<KOTodoViewItem *>(itemAbove());
264 m_known = above ? above->m_known : true; 263 m_known = above ? above->m_known : true;
265 if (m_known) 264 if (m_known)
266 { 265 {
267 m_odd = above ? !above->m_odd : false; 266 m_odd = above ? !above->m_odd : false;
268 } 267 }
269 else 268 else
270 { 269 {
271 KOTodoViewItem *item; 270 KOTodoViewItem *item;
272 bool previous = true; 271 bool previous = true;
273 if (QListViewItem::parent()) 272 if (QListViewItem::parent())
274 { 273 {
275 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); 274 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent());
276 if (item) 275 if (item)
277 previous = item->m_odd; 276 previous = item->m_odd;
278 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 277 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
279 } 278 }
280 else 279 else
281 { 280 {
282 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); 281 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild());
283 } 282 }
284 283
285 while(item) 284 while(item)
286 { 285 {
287 item->m_odd = previous = !previous; 286 item->m_odd = previous = !previous;
288 item->m_known = true; 287 item->m_known = true;
289 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); 288 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling());
290 } 289 }
291 } 290 }
292 return m_odd; 291 return m_odd;
293 } 292 }
294 return false; 293 return false;
295#else 294#else
296 return false; 295 return false;
297#endif 296#endif
298} 297}
299 298
300void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 299void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
301{ 300{
302 QColorGroup _cg = cg; 301 QColorGroup _cg = cg;
303 QColorGroup::ColorRole role; 302 QColorGroup::ColorRole role;
304 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 303 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
305 role = QColorGroup::Text; 304 role = QColorGroup::Text;
306 else 305 else
307 role = QColorGroup::Base; 306 role = QColorGroup::Base;
308 //#ifndef KORG_NOLVALTERNATION 307 //#ifndef KORG_NOLVALTERNATION
309 // if (isAlternate()) 308 // if (isAlternate())
310 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 309 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
311 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 310 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
312 QColor colorToSet; 311 QColor colorToSet;
313 if ( setColor ) { 312 if ( setColor ) {
314 QStringList categories = mTodo->categories(); 313 QStringList categories = mTodo->categories();
315 QString cat = categories.first(); 314 QString cat = categories.first();
316 if ( !cat.isEmpty()) { 315 if ( !cat.isEmpty()) {
317 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 316 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
318 } else 317 } else
319 setColor = false; 318 setColor = false;
320 } 319 }
321 if (mTodo->hasDueDate()) { 320 if (mTodo->hasDueDate()) {
322 if (mTodo->dtDue().date()==QDate::currentDate() && 321 if (mTodo->dtDue().date()==QDate::currentDate() &&
323 !mTodo->isCompleted()) { 322 !mTodo->isCompleted()) {
324 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); 323 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor);
325 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 324 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
326 setColor = true; 325 setColor = true;
327 } 326 }
328 if (mTodo->dtDue().date() < QDate::currentDate() && 327 if (mTodo->dtDue().date() < QDate::currentDate() &&
329 !mTodo->isCompleted()) { 328 !mTodo->isCompleted()) {
330 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); 329 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor);
331 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 330 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
332 setColor = true; 331 setColor = true;
333 } 332 }
334 } 333 }
335 334
336 if ( setColor ) { 335 if ( setColor ) {
337 _cg.setColor(role,colorToSet ); 336 _cg.setColor(role,colorToSet );
338 if ( role == QColorGroup::Base) { 337 if ( role == QColorGroup::Base) {
339 int rgb = colorToSet.red(); 338 int rgb = colorToSet.red();
340 rgb += colorToSet.blue()/2; 339 rgb += colorToSet.blue()/2;
341 rgb += colorToSet.green(); 340 rgb += colorToSet.green();
342 if ( rgb < 200 ) 341 if ( rgb < 200 )
343 _cg.setColor(QColorGroup::Text,Qt::white ); 342 _cg.setColor(QColorGroup::Text,Qt::white );
344 } 343 }
345 } 344 }
346 //#endif 345 //#endif
347 if ( column > 0 ){ 346 if ( column > 0 ){
348 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { 347 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
349 p->save(); 348 p->save();
350 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); 349 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
351 350
352 p->fillRect( 0, 0, width, height(), _cg.base() ); // background 351 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
353 // p->setPen(Qt::black ); //border 352 // p->setPen(Qt::black ); //border
354 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling 353 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
355 QColor fc = KOPrefs::instance()->mHighlightColor; 354 QColor fc = KOPrefs::instance()->mHighlightColor;
356 if ( mTodo->percentComplete() == 100 ) 355 if ( mTodo->percentComplete() == 100 )
357 fc = darkGreen; 356 fc = darkGreen;
358 p->drawRect( 2, 2, width-4, height()-4); 357 p->drawRect( 2, 2, width-4, height()-4);
359 p->fillRect( 3, 3, progress, height()-6, 358 p->fillRect( 3, 3, progress, height()-6,
360 fc ); 359 fc );
361 p->restore(); 360 p->restore();
362 } else { 361 } else {
363 QCheckListItem::paintCell(p, _cg, column, width, alignment); 362 QCheckListItem::paintCell(p, _cg, column, width, alignment);
364 } 363 }
365 return; 364 return;
366 } 365 }
367 366
368 int align = alignment; 367 int align = alignment;
369 368
370 if ( !p ) 369 if ( !p )
371 return; 370 return;
372 371
373 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); 372 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
374 373
375 QListView *lv = listView(); 374 QListView *lv = listView();
376 if ( !lv ) 375 if ( !lv )
377 return; 376 return;
378 int marg = 2;//lv->itemMargin(); 377 int marg = 2;//lv->itemMargin();
379 int r = 0; 378 int r = 0;
380 QCheckListItem::Type myType = QCheckListItem::CheckBox; 379 QCheckListItem::Type myType = QCheckListItem::CheckBox;
381 int BoxSize = 20; 380 int BoxSize = 20;
382 int boxOffset = 2; 381 int boxOffset = 2;
383 int xOffset = 2; 382 int xOffset = 2;
384 if (qApp->desktop()->width() < 300 ) { 383 if (qApp->desktop()->width() < 300 ) {
385 BoxSize = 14; 384 BoxSize = 14;
386 boxOffset = -1; 385 boxOffset = -1;
387 xOffset = 1; 386 xOffset = 1;
388 // marg = 0; 387 // marg = 0;
389 } 388 }
390 if ( height() < BoxSize ) { 389 if ( height() < BoxSize ) {
391 boxOffset = boxOffset - ((BoxSize - height())/2) ; 390 boxOffset = boxOffset - ((BoxSize - height())/2) ;
392 // qDebug("boxOffset %d height %d", boxOffset, height() ); 391 // qDebug("boxOffset %d height %d", boxOffset, height() );
393 BoxSize = height(); 392 BoxSize = height();
394 393
395 } 394 }
396 //bool winStyle = lv->style() == WindowsStyle; 395 //bool winStyle = lv->style() == WindowsStyle;
397 396
398 int lineStart = 5; 397 int lineStart = 5;
399 if ( myType == Controller ) { 398 if ( myType == Controller ) {
400 if ( !pixmap( 0 ) ) 399 if ( !pixmap( 0 ) )
401 r += BoxSize + 4; 400 r += BoxSize + 4;
402 } else { 401 } else {
403 ASSERT( lv ); //### 402 ASSERT( lv ); //###
404 //QFontMetrics fm( lv->font() ); 403 //QFontMetrics fm( lv->font() );
405 //int d = fm.height(); 404 //int d = fm.height();
406 int x = 0; 405 int x = 0;
407 int y = (height() - BoxSize) / 2; 406 int y = (height() - BoxSize) / 2;
408 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); 407 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
409 if ( myType == CheckBox ) { 408 if ( myType == CheckBox ) {
410 if ( isEnabled() ) 409 if ( isEnabled() )
411 p->setPen( QPen( _cg.text(), 1 ) ); 410 p->setPen( QPen( _cg.text(), 1 ) );
412 else 411 else
413 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); 412 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
414 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); 413 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
415 lineStart = x+marg; 414 lineStart = x+marg;
416 ///////////////////// 415 /////////////////////
417 x++; 416 x++;
418 y++; 417 y++;
419 if ( isOn() ) { 418 if ( isOn() ) {
420 QPointArray a( 7*2 ); 419 QPointArray a( 7*2 );
421 int i, xx, yy; 420 int i, xx, yy;
422 xx = x+xOffset+marg+(boxOffset/2); 421 xx = x+xOffset+marg+(boxOffset/2);
423 yy = y+5+boxOffset; 422 yy = y+5+boxOffset;
424 for ( i=0; i<3; i++ ) { 423 for ( i=0; i<3; i++ ) {
425 a.setPoint( 2*i, xx, yy ); 424 a.setPoint( 2*i, xx, yy );
426 a.setPoint( 2*i+1, xx, yy+2 ); 425 a.setPoint( 2*i+1, xx, yy+2 );
427 // qDebug(" "); 426 // qDebug(" ");
428 xx++; yy++; 427 xx++; yy++;
429 } 428 }
430 yy -= 2; 429 yy -= 2;
431 for ( i=3; i<7; i++ ) { 430 for ( i=3; i<7; i++ ) {
432 a.setPoint( 2*i, xx, yy ); 431 a.setPoint( 2*i, xx, yy );
433 a.setPoint( 2*i+1, xx, yy+2 ); 432 a.setPoint( 2*i+1, xx, yy+2 );
434 xx++; yy--; 433 xx++; yy--;
435 } 434 }
436 p->setPen( darkGreen ); 435 p->setPen( darkGreen );
437 p->drawLineSegments( a ); 436 p->drawLineSegments( a );
438 } 437 }
439 //////////////////////// 438 ////////////////////////
440 } 439 }
441 r += BoxSize + 4; 440 r += BoxSize + 4;
442 } 441 }
443 442
444 p->translate( r, 0 ); 443 p->translate( r, 0 );
445 p->setPen( QPen( _cg.text() ) ); 444 p->setPen( QPen( _cg.text() ) );
446 QListViewItem::paintCell( p, _cg, column, width - r, align ); 445 QListViewItem::paintCell( p, _cg, column, width - r, align );
447 if ( mTodo->cancelled () ) { 446 if ( mTodo->cancelled () ) {
448 p->setPen( black ); 447 p->setPen( black );
449 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); 448 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
450 int wid = br.width() +lineStart; 449 int wid = br.width() +lineStart;
451 if ( wid > width-3 ) 450 if ( wid > width-3 )
452 wid = width-3; 451 wid = width-3;
453 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); 452 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
454 453
455 } 454 }
456 455
457} 456}
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index c52f2b3..6d07d4c 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -1,338 +1,338 @@
1#include "kincidenceformatter.h" 1#include "kincidenceformatter.h"
2#include <kstaticdeleter.h> 2#include <kstaticdeleter.h>
3#include <kglobal.h> 3#include <kglobal.h>
4#include <klocale.h> 4#include <klocale.h>
5#ifdef DEKTOP_VERSION 5#ifdef DEKTOP_VERSION
6#include <kabc/stdaddressbook.h> 6#include <kabc/stdaddressbook.h>
7#define size count 7#define size count
8#endif 8#endif
9 9
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; 10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd; 11static KStaticDeleter<KIncidenceFormatter> insd;
12 12
13QString KIncidenceFormatter::getFormattedText( Incidence * inc ) 13QString KIncidenceFormatter::getFormattedText( Incidence * inc )
14{ 14{
15// #ifndef QT_NO_INPUTDIALOG 15// #ifndef QT_NO_INPUTDIALOG
16// return QInputDialog::getItem( caption, label, items, current, editable ); 16// return QInputDialog::getItem( caption, label, items, current, editable );
17// #else 17// #else
18// return QString::null; 18// return QString::null;
19// #endif 19// #endif
20 mText = ""; 20 mText = "";
21 if ( inc->type() == "Event" ) 21 if ( inc->type() == "Event" )
22 setEvent((Event *) inc ); 22 setEvent((Event *) inc );
23 else if ( inc->type() == "Todo" ) 23 else if ( inc->type() == "Todo" )
24 setTodo((Todo *) inc ); 24 setTodo((Todo *) inc );
25 return mText; 25 return mText;
26} 26}
27 27
28KIncidenceFormatter* KIncidenceFormatter::instance() 28KIncidenceFormatter* KIncidenceFormatter::instance()
29{ 29{
30 if (!mInstance) { 30 if (!mInstance) {
31 mInstance = insd.setObject(new KIncidenceFormatter()); 31 mInstance = insd.setObject(new KIncidenceFormatter());
32 } 32 }
33 return mInstance; 33 return mInstance;
34} 34}
35KIncidenceFormatter::~KIncidenceFormatter() 35KIncidenceFormatter::~KIncidenceFormatter()
36{ 36{
37 if (mInstance == this) 37 if (mInstance == this)
38 mInstance = insd.setObject(0); 38 mInstance = insd.setObject(0);
39 //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); 39 //qDebug("KIncidenceFormatter::~KIncidenceFormatter ");
40} 40}
41KIncidenceFormatter::KIncidenceFormatter() 41KIncidenceFormatter::KIncidenceFormatter()
42{ 42{
43 mColorMode = 0; 43 mColorMode = 0;
44} 44}
45void KIncidenceFormatter::setEvent(Event *event) 45void KIncidenceFormatter::setEvent(Event *event)
46{ 46{
47 int mode = 0; 47 int mode = 0;
48 mCurrentIncidence = event; 48 mCurrentIncidence = event;
49 bool shortDate = true; 49 bool shortDate = true;
50 if ( mode == 0 ) { 50 if ( mode == 0 ) {
51 addTag("h3",event->summary()); 51 addTag("h3",event->summary());
52 } 52 }
53 else { 53 else {
54 if ( mColorMode == 1 ) { 54 if ( mColorMode == 1 ) {
55 mText +="<font color=\"#00A000\">"; 55 mText +="<font color=\"#00A000\">";
56 } 56 }
57 if ( mColorMode == 2 ) { 57 if ( mColorMode == 2 ) {
58 mText +="<font color=\"#C00000\">"; 58 mText +="<font color=\"#C00000\">";
59 } 59 }
60 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 60 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
61 if ( mode == 1 ) { 61 if ( mode == 1 ) {
62 addTag("h2",i18n( "Local: " ) +event->summary()); 62 addTag("h2",i18n( "Local: " ) +event->summary());
63 } else { 63 } else {
64 addTag("h2",i18n( "Remote: " ) +event->summary()); 64 addTag("h2",i18n( "Remote: " ) +event->summary());
65 } 65 }
66 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 66 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
67 if ( mColorMode ) 67 if ( mColorMode )
68 mText += "</font>"; 68 mText += "</font>";
69 } 69 }
70 if (event->cancelled ()) { 70 if (event->cancelled ()) {
71 mText +="<font color=\"#B00000\">"; 71 mText +="<font color=\"#B00000\">";
72 addTag("i",i18n("This event has been cancelled!")); 72 addTag("i",i18n("This event has been cancelled!"));
73 mText.append("<br>"); 73 mText.append("<br>");
74 mText += "</font>"; 74 mText += "</font>";
75 } 75 }
76 if (!event->location().isEmpty()) { 76 if (!event->location().isEmpty()) {
77 addTag("b",i18n("Location: ")); 77 addTag("b",i18n("Location: "));
78 mText.append(event->location()+"<br>"); 78 mText.append(event->location()+"<br>");
79 } 79 }
80 if (event->doesFloat()) { 80 if (event->doesFloat()) {
81 if (event->isMultiDay()) { 81 if (event->isMultiDay()) {
82 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 82 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
83 .arg(event->dtStartDateStr(shortDate)) 83 .arg(event->dtStartDateStr(shortDate))
84 .arg(event->dtEndDateStr(shortDate))); 84 .arg(event->dtEndDateStr(shortDate)));
85 } else { 85 } else {
86 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 86 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
87 } 87 }
88 } else { 88 } else {
89 if (event->isMultiDay()) { 89 if (event->isMultiDay()) {
90 mText.append(i18n("<p><b>From:</b> %1</p> ") 90 mText.append(i18n("<p><b>From:</b> %1</p> ")
91 .arg(event->dtStartStr( shortDate))); 91 .arg(event->dtStartStr( shortDate)));
92 mText.append(i18n("<p><b>To:</b> %1</p>") 92 mText.append(i18n("<p><b>To:</b> %1</p>")
93 .arg(event->dtEndStr(shortDate))); 93 .arg(event->dtEndStr(shortDate)));
94 } else { 94 } else {
95 mText.append(i18n("<p><b>On:</b> %1</p> ") 95 mText.append(i18n("<p><b>On:</b> %1</p> ")
96 .arg(event->dtStartDateStr( shortDate ))); 96 .arg(event->dtStartDateStr( shortDate )));
97 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 97 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
98 .arg(event->dtStartTimeStr()) 98 .arg(event->dtStartTimeStr())
99 .arg(event->dtEndTimeStr())); 99 .arg(event->dtEndTimeStr()));
100 } 100 }
101 } 101 }
102 102
103 if (event->recurrence()->doesRecur()) { 103 if (event->recurrence()->doesRecur()) {
104 104
105 QString recurText = event->recurrence()->recurrenceText(); 105 QString recurText = event->recurrence()->recurrenceText();
106 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 106 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
107 bool last; 107 bool last;
108 QDate start = QDate::currentDate(); 108 QDate start = QDate::currentDate();
109 QDate next; 109 QDate next;
110 next = event->recurrence()->getPreviousDate( start , &last ); 110 next = event->recurrence()->getPreviousDate( start , &last );
111 if ( !last ) { 111 if ( !last ) {
112 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 112 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
113 addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) ); 113 addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) );
114 //addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 114 //addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
115 } else { 115 } else {
116 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 116 addTag("p",i18n("<b>Last recurrence was on:</b>") );
117 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 117 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
118 } 118 }
119 } 119 }
120 120
121 121
122 if (event->isAlarmEnabled()) { 122 if (event->isAlarmEnabled()) {
123 Alarm *alarm =event->alarms().first() ; 123 Alarm *alarm =event->alarms().first() ;
124 QDateTime t = alarm->time(); 124 QDateTime t = alarm->time();
125 int min = t.secsTo( event->dtStart() )/60; 125 int min = t.secsTo( event->dtStart() )/60;
126 QString s =i18n("(%1 min before)").arg( min ); 126 QString s =i18n("(%1 min before)").arg( min );
127 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 127 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
128 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 128 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
129 //addTag("p",s); 129 //addTag("p",s);
130 } 130 }
131 131
132 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 132 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
133 // mText.append(event->secrecyStr()+"<br>"); 133 // mText.append(event->secrecyStr()+"<br>");
134 formatCategories(event); 134 formatCategories(event);
135 if (!event->description().isEmpty()) { 135 if (!event->description().isEmpty()) {
136 addTag("p",i18n("<b>Details: </b>")); 136 addTag("p",i18n("<b>Details: </b>"));
137 addTag("p",event->description()); 137 addTag("p",event->description());
138 } 138 }
139 139
140 140
141 formatReadOnly(event); 141 formatReadOnly(event);
142 formatAttendees(event); 142 formatAttendees(event);
143 143
144 144
145} 145}
146 146
147void KIncidenceFormatter::setTodo(Todo *event ) 147void KIncidenceFormatter::setTodo(Todo *event )
148{ 148{
149 int mode = 0; 149 int mode = 0;
150 mCurrentIncidence = event; 150 mCurrentIncidence = event;
151 bool shortDate = true; 151 bool shortDate = true;
152 if (mode == 0 ) 152 if (mode == 0 )
153 addTag("h3",event->summary()); 153 addTag("h3",event->summary());
154 else { 154 else {
155 if ( mColorMode == 1 ) { 155 if ( mColorMode == 1 ) {
156 mText +="<font color=\"#00A000\">"; 156 mText +="<font color=\"#00A000\">";
157 } 157 }
158 if ( mColorMode == 2 ) { 158 if ( mColorMode == 2 ) {
159 mText +="<font color=\"#B00000\">"; 159 mText +="<font color=\"#B00000\">";
160 } 160 }
161 if ( mode == 1 ) { 161 if ( mode == 1 ) {
162 addTag("h2",i18n( "Local: " ) +event->summary()); 162 addTag("h2",i18n( "Local: " ) +event->summary());
163 } else { 163 } else {
164 addTag("h2",i18n( "Remote: " ) +event->summary()); 164 addTag("h2",i18n( "Remote: " ) +event->summary());
165 } 165 }
166 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 166 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
167 if ( mColorMode ) 167 if ( mColorMode )
168 mText += "</font>"; 168 mText += "</font>";
169 } 169 }
170 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
171 mText +="<font color=\"#B00000\">";
172 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) );
173 mText += "</font>";
174 } else {
175 mText.append(i18n("<p><i>%1 % completed</i></p>")
176 .arg(event->percentComplete()));
177 }
170 if (event->cancelled ()) { 178 if (event->cancelled ()) {
171 mText +="<font color=\"#B00000\">"; 179 mText +="<font color=\"#B00000\">";
172 addTag("i",i18n("This todo has been cancelled!")); 180 addTag("i",i18n("This todo has been cancelled!"));
173 mText.append("<br>"); 181 mText.append("<br>");
174 mText += "</font>"; 182 mText += "</font>";
175 } 183 }
176 184
177 if (!event->location().isEmpty()) { 185 if (!event->location().isEmpty()) {
178 addTag("b",i18n("Location: ")); 186 addTag("b",i18n("Location: "));
179 mText.append(event->location()+"<br>"); 187 mText.append(event->location()+"<br>");
180 } 188 }
181 if (event->hasDueDate()) { 189 if (event->hasDueDate()) {
182 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 190 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
183 } 191 }
184 mText.append(i18n("<p><b>Priority:</b> %2</p>") 192 mText.append(i18n("<p><b>Priority:</b> %2</p>")
185 .arg(QString::number(event->priority()))); 193 .arg(QString::number(event->priority())));
186 194
187 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 195 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
188 mText.append(i18n("<p><i>Completed on %1</i></p>")
189 .arg( event->completedStr() ));
190 } else {
191 mText.append(i18n("<p><i>%1 % completed</i></p>")
192 .arg(event->percentComplete()));
193 }
194
195 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
196 formatCategories(event); 196 formatCategories(event);
197 if (!event->description().isEmpty()) { 197 if (!event->description().isEmpty()) {
198 addTag("p",i18n("<b>Details: </b>")); 198 addTag("p",i18n("<b>Details: </b>"));
199 addTag("p",event->description()); 199 addTag("p",event->description());
200 } 200 }
201 201
202 202
203 203
204 formatReadOnly(event); 204 formatReadOnly(event);
205 formatAttendees(event); 205 formatAttendees(event);
206 206
207} 207}
208 208
209void KIncidenceFormatter::setJournal(Journal* ) 209void KIncidenceFormatter::setJournal(Journal* )
210{ 210{
211 211
212} 212}
213 213
214void KIncidenceFormatter::formatCategories(Incidence *event) 214void KIncidenceFormatter::formatCategories(Incidence *event)
215{ 215{
216 if (!event->categoriesStr().isEmpty()) { 216 if (!event->categoriesStr().isEmpty()) {
217 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); 217 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() );
218 //mText.append(event->categoriesStr()); 218 //mText.append(event->categoriesStr());
219 } 219 }
220} 220}
221void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 221void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
222{ 222{
223 int number=text.contains("\n"); 223 int number=text.contains("\n");
224 QString str = "<" + tag + ">"; 224 QString str = "<" + tag + ">";
225 QString tmpText=text; 225 QString tmpText=text;
226 QString tmpStr=str; 226 QString tmpStr=str;
227 if(number !=-1) 227 if(number !=-1)
228 { 228 {
229 if (number > 0) { 229 if (number > 0) {
230 int pos=0; 230 int pos=0;
231 QString tmp; 231 QString tmp;
232 for(int i=0;i<=number;i++) { 232 for(int i=0;i<=number;i++) {
233 pos=tmpText.find("\n"); 233 pos=tmpText.find("\n");
234 tmp=tmpText.left(pos); 234 tmp=tmpText.left(pos);
235 tmpText=tmpText.right(tmpText.length()-pos-1); 235 tmpText=tmpText.right(tmpText.length()-pos-1);
236 tmpStr+=tmp+"<br>"; 236 tmpStr+=tmp+"<br>";
237 } 237 }
238 } 238 }
239 else tmpStr += tmpText; 239 else tmpStr += tmpText;
240 tmpStr+="</" + tag + ">"; 240 tmpStr+="</" + tag + ">";
241 mText.append(tmpStr); 241 mText.append(tmpStr);
242 } 242 }
243 else 243 else
244 { 244 {
245 str += text + "</" + tag + ">"; 245 str += text + "</" + tag + ">";
246 mText.append(str); 246 mText.append(str);
247 } 247 }
248} 248}
249 249
250void KIncidenceFormatter::formatAttendees(Incidence *event) 250void KIncidenceFormatter::formatAttendees(Incidence *event)
251{ 251{
252 QPtrList<Attendee> attendees = event->attendees(); 252 QPtrList<Attendee> attendees = event->attendees();
253 if (attendees.count()) { 253 if (attendees.count()) {
254 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 254 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
255 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 255 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
256 addTag("h3",i18n("Organizer")); 256 addTag("h3",i18n("Organizer"));
257 mText.append("<ul><li>"); 257 mText.append("<ul><li>");
258#if 0 258#if 0
259 //ndef KORG_NOKABC 259 //ndef KORG_NOKABC
260 260
261 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 261 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
262 KABC::Addressee::List addressList; 262 KABC::Addressee::List addressList;
263 addressList = add_book->findByEmail(event->organizer()); 263 addressList = add_book->findByEmail(event->organizer());
264 KABC::Addressee o = addressList.first(); 264 KABC::Addressee o = addressList.first();
265 if (!o.isEmpty() && addressList.size()<2) { 265 if (!o.isEmpty() && addressList.size()<2) {
266 mText += "<a href=\"uid:" + o.uid() + "\">"; 266 mText += "<a href=\"uid:" + o.uid() + "\">";
267 mText += o.formattedName(); 267 mText += o.formattedName();
268 mText += "</a>\n"; 268 mText += "</a>\n";
269 } else { 269 } else {
270 mText.append(event->organizer()); 270 mText.append(event->organizer());
271 } 271 }
272#else 272#else
273 mText.append(event->organizer()); 273 mText.append(event->organizer());
274#endif 274#endif
275 if (iconPath) { 275 if (iconPath) {
276 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 276 mText += " <a href=\"mailto:" + event->organizer() + "\">";
277 mText += "<IMG src=\"" + iconPath + "\">"; 277 mText += "<IMG src=\"" + iconPath + "\">";
278 mText += "</a>\n"; 278 mText += "</a>\n";
279 } 279 }
280 mText.append("</li></ul>"); 280 mText.append("</li></ul>");
281 281
282 addTag("h3",i18n("Attendees")); 282 addTag("h3",i18n("Attendees"));
283 Attendee *a; 283 Attendee *a;
284 mText.append("<ul>"); 284 mText.append("<ul>");
285 for(a=attendees.first();a;a=attendees.next()) { 285 for(a=attendees.first();a;a=attendees.next()) {
286#if 0 286#if 0
287//ndef KORG_NOKABC 287//ndef KORG_NOKABC
288 if (a->name().isEmpty()) { 288 if (a->name().isEmpty()) {
289 addressList = add_book->findByEmail(a->email()); 289 addressList = add_book->findByEmail(a->email());
290 KABC::Addressee o = addressList.first(); 290 KABC::Addressee o = addressList.first();
291 if (!o.isEmpty() && addressList.size()<2) { 291 if (!o.isEmpty() && addressList.size()<2) {
292 mText += "<a href=\"uid:" + o.uid() + "\">"; 292 mText += "<a href=\"uid:" + o.uid() + "\">";
293 mText += o.formattedName(); 293 mText += o.formattedName();
294 mText += "</a>\n"; 294 mText += "</a>\n";
295 } else { 295 } else {
296 mText += "<li>"; 296 mText += "<li>";
297 mText.append(a->email()); 297 mText.append(a->email());
298 mText += "\n"; 298 mText += "\n";
299 } 299 }
300 } else { 300 } else {
301 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 301 mText += "<li><a href=\"uid:" + a->uid() + "\">";
302 if (!a->name().isEmpty()) mText += a->name(); 302 if (!a->name().isEmpty()) mText += a->name();
303 else mText += a->email(); 303 else mText += a->email();
304 mText += "</a>\n"; 304 mText += "</a>\n";
305 } 305 }
306#else 306#else
307 //qDebug("nokabc "); 307 //qDebug("nokabc ");
308 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 308 mText += "<li><a href=\"uid:" + a->uid() + "\">";
309 if (!a->name().isEmpty()) mText += a->name(); 309 if (!a->name().isEmpty()) mText += a->name();
310 else mText += a->email(); 310 else mText += a->email();
311 mText += "</a>\n"; 311 mText += "</a>\n";
312#endif 312#endif
313 313
314 if (!a->email().isEmpty()) { 314 if (!a->email().isEmpty()) {
315 if (iconPath) { 315 if (iconPath) {
316 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 316 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
317 if ( a->RSVP() ) 317 if ( a->RSVP() )
318 mText += "<IMG src=\"" + iconPath + "\">"; 318 mText += "<IMG src=\"" + iconPath + "\">";
319 else 319 else
320 mText += "<IMG src=\"" + NOiconPath + "\">"; 320 mText += "<IMG src=\"" + NOiconPath + "\">";
321 mText += "</a>\n"; 321 mText += "</a>\n";
322 } 322 }
323 } 323 }
324 if (a->status() != Attendee::NeedsAction ) 324 if (a->status() != Attendee::NeedsAction )
325 mText +="[" + a->statusStr() + "] "; 325 mText +="[" + a->statusStr() + "] ";
326 if (a->role() == Attendee::Chair ) 326 if (a->role() == Attendee::Chair )
327 mText +="(" + a->roleStr().left(1) + ".)"; 327 mText +="(" + a->roleStr().left(1) + ".)";
328 } 328 }
329 mText.append("</li></ul>"); 329 mText.append("</li></ul>");
330 } 330 }
331} 331}
332 332
333void KIncidenceFormatter::formatReadOnly(Incidence *event) 333void KIncidenceFormatter::formatReadOnly(Incidence *event)
334{ 334{
335 if (event->isReadOnly()) { 335 if (event->isReadOnly()) {
336 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 336 addTag("p","<em>(" + i18n("read-only") + ")</em>");
337 } 337 }
338} 338}
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 7362bdf..7d04793 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,379 +1,380 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "todo.h" 25#include "todo.h"
26 26
27using namespace KCal; 27using namespace KCal;
28 28
29Todo::Todo(): Incidence() 29Todo::Todo(): Incidence()
30{ 30{
31// mStatus = TENTATIVE; 31// mStatus = TENTATIVE;
32 32
33 mHasDueDate = false; 33 mHasDueDate = false;
34 setHasStartDate( false ); 34 setHasStartDate( false );
35 mCompleted = getEvenTime(QDateTime::currentDateTime()); 35 mCompleted = getEvenTime(QDateTime::currentDateTime());
36 mHasCompletedDate = false; 36 mHasCompletedDate = false;
37 mPercentComplete = 0; 37 mPercentComplete = 0;
38} 38}
39 39
40Todo::Todo(const Todo &t) : Incidence(t) 40Todo::Todo(const Todo &t) : Incidence(t)
41{ 41{
42 mDtDue = t.mDtDue; 42 mDtDue = t.mDtDue;
43 mHasDueDate = t.mHasDueDate; 43 mHasDueDate = t.mHasDueDate;
44 mCompleted = t.mCompleted; 44 mCompleted = t.mCompleted;
45 mHasCompletedDate = t.mHasCompletedDate; 45 mHasCompletedDate = t.mHasCompletedDate;
46 mPercentComplete = t.mPercentComplete; 46 mPercentComplete = t.mPercentComplete;
47} 47}
48 48
49Todo::~Todo() 49Todo::~Todo()
50{ 50{
51 51
52} 52}
53 53
54Incidence *Todo::clone() 54Incidence *Todo::clone()
55{ 55{
56 return new Todo(*this); 56 return new Todo(*this);
57} 57}
58 58
59bool Todo::contains ( Todo* from ) 59bool Todo::contains ( Todo* from )
60{ 60{
61 61
62 if ( !from->summary().isEmpty() ) 62 if ( !from->summary().isEmpty() )
63 if ( !summary().startsWith( from->summary() )) 63 if ( !summary().startsWith( from->summary() ))
64 return false; 64 return false;
65 if ( from->hasStartDate() ) { 65 if ( from->hasStartDate() ) {
66 if ( !hasStartDate() ) 66 if ( !hasStartDate() )
67 return false; 67 return false;
68 if ( from->dtStart() != dtStart()) 68 if ( from->dtStart() != dtStart())
69 return false; 69 return false;
70 } 70 }
71 if ( from->hasDueDate() ){ 71 if ( from->hasDueDate() ){
72 if ( !hasDueDate() ) 72 if ( !hasDueDate() )
73 return false; 73 return false;
74 if ( from->dtDue() != dtDue()) 74 if ( from->dtDue() != dtDue())
75 return false; 75 return false;
76 } 76 }
77 if ( !from->location().isEmpty() ) 77 if ( !from->location().isEmpty() )
78 if ( !location().startsWith( from->location() ) ) 78 if ( !location().startsWith( from->location() ) )
79 return false; 79 return false;
80 if ( !from->description().isEmpty() ) 80 if ( !from->description().isEmpty() )
81 if ( !description().startsWith( from->description() )) 81 if ( !description().startsWith( from->description() ))
82 return false; 82 return false;
83 if ( from->alarms().count() ) { 83 if ( from->alarms().count() ) {
84 Alarm *a = from->alarms().first(); 84 Alarm *a = from->alarms().first();
85 if ( a->enabled() ){ 85 if ( a->enabled() ){
86 if ( !alarms().count() ) 86 if ( !alarms().count() )
87 return false; 87 return false;
88 Alarm *b = alarms().first(); 88 Alarm *b = alarms().first();
89 if( ! b->enabled() ) 89 if( ! b->enabled() )
90 return false; 90 return false;
91 if ( ! (a->offset() == b->offset() )) 91 if ( ! (a->offset() == b->offset() ))
92 return false; 92 return false;
93 } 93 }
94 } 94 }
95 95
96 QStringList cat = categories(); 96 QStringList cat = categories();
97 QStringList catFrom = from->categories(); 97 QStringList catFrom = from->categories();
98 QString nCat; 98 QString nCat;
99 int iii; 99 int iii;
100 for ( iii = 0; iii < catFrom.count();++iii ) { 100 for ( iii = 0; iii < catFrom.count();++iii ) {
101 nCat = catFrom[iii]; 101 nCat = catFrom[iii];
102 if ( !nCat.isEmpty() ) 102 if ( !nCat.isEmpty() )
103 if ( !cat.contains( nCat )) { 103 if ( !cat.contains( nCat )) {
104 return false; 104 return false;
105 } 105 }
106 } 106 }
107 if ( from->isCompleted() ) { 107 if ( from->isCompleted() ) {
108 if ( !isCompleted() ) 108 if ( !isCompleted() )
109 return false; 109 return false;
110 } 110 }
111 if( priority() != from->priority() ) 111 if( priority() != from->priority() )
112 return false; 112 return false;
113 113
114 114
115 return true; 115 return true;
116 116
117} 117}
118bool KCal::operator==( const Todo& t1, const Todo& t2 ) 118bool KCal::operator==( const Todo& t1, const Todo& t2 )
119{ 119{
120 120
121 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); 121 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
122 if ( ! ret ) 122 if ( ! ret )
123 return false; 123 return false;
124 if ( t1.hasDueDate() == t2.hasDueDate() ) { 124 if ( t1.hasDueDate() == t2.hasDueDate() ) {
125 if ( t1.hasDueDate() ) { 125 if ( t1.hasDueDate() ) {
126 if ( t1.doesFloat() == t2.doesFloat() ) { 126 if ( t1.doesFloat() == t2.doesFloat() ) {
127 if ( t1.doesFloat() ) { 127 if ( t1.doesFloat() ) {
128 if ( t1.dtDue().date() != t2.dtDue().date() ) 128 if ( t1.dtDue().date() != t2.dtDue().date() )
129 return false; 129 return false;
130 } else 130 } else
131 if ( t1.dtDue() != t2.dtDue() ) 131 if ( t1.dtDue() != t2.dtDue() )
132 return false; 132 return false;
133 } else 133 } else
134 return false;// float != 134 return false;// float !=
135 } 135 }
136 136
137 } else 137 } else
138 return false; 138 return false;
139 if ( t1.percentComplete() != t2.percentComplete() ) 139 if ( t1.percentComplete() != t2.percentComplete() )
140 return false; 140 return false;
141 if ( t1.isCompleted() ) { 141 if ( t1.isCompleted() ) {
142 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { 142 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
143 if ( t1.hasCompletedDate() ) { 143 if ( t1.hasCompletedDate() ) {
144 if ( t1.completed() != t2.completed() ) 144 if ( t1.completed() != t2.completed() )
145 return false; 145 return false;
146 } 146 }
147 147
148 } else 148 } else
149 return false; 149 return false;
150 } 150 }
151 return true; 151 return true;
152 152
153} 153}
154 154
155void Todo::setDtDue(const QDateTime &dtDue) 155void Todo::setDtDue(const QDateTime &dtDue)
156{ 156{
157 //int diffsecs = mDtDue.secsTo(dtDue); 157 //int diffsecs = mDtDue.secsTo(dtDue);
158 158
159 /*if (mReadOnly) return; 159 /*if (mReadOnly) return;
160 const QPtrList<Alarm>& alarms = alarms(); 160 const QPtrList<Alarm>& alarms = alarms();
161 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { 161 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
162 if (alarm->enabled()) { 162 if (alarm->enabled()) {
163 alarm->setTime(alarm->time().addSecs(diffsecs)); 163 alarm->setTime(alarm->time().addSecs(diffsecs));
164 } 164 }
165 }*/ 165 }*/
166 mDtDue = getEvenTime(dtDue); 166 mDtDue = getEvenTime(dtDue);
167 167
168 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; 168 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
169 169
170 /*const QPtrList<Alarm>& alarms = alarms(); 170 /*const QPtrList<Alarm>& alarms = alarms();
171 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) 171 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
172 alarm->setAlarmStart(mDtDue);*/ 172 alarm->setAlarmStart(mDtDue);*/
173 173
174 updated(); 174 updated();
175} 175}
176 176
177QDateTime Todo::dtDue() const 177QDateTime Todo::dtDue() const
178{ 178{
179 return mDtDue; 179 return mDtDue;
180} 180}
181 181
182QString Todo::dtDueTimeStr() const 182QString Todo::dtDueTimeStr() const
183{ 183{
184 return KGlobal::locale()->formatTime(mDtDue.time()); 184 return KGlobal::locale()->formatTime(mDtDue.time());
185} 185}
186 186
187QString Todo::dtDueDateStr(bool shortfmt) const 187QString Todo::dtDueDateStr(bool shortfmt) const
188{ 188{
189 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 189 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
190} 190}
191 191
192QString Todo::dtDueStr(bool shortfmt) const 192QString Todo::dtDueStr(bool shortfmt) const
193{ 193{
194 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); 194 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
195} 195}
196 196
197bool Todo::hasDueDate() const 197bool Todo::hasDueDate() const
198{ 198{
199 return mHasDueDate; 199 return mHasDueDate;
200} 200}
201 201
202void Todo::setHasDueDate(bool f) 202void Todo::setHasDueDate(bool f)
203{ 203{
204 if (mReadOnly) return; 204 if (mReadOnly) return;
205 mHasDueDate = f; 205 mHasDueDate = f;
206 updated(); 206 updated();
207} 207}
208 208
209 209
210#if 0 210#if 0
211void Todo::setStatus(const QString &statStr) 211void Todo::setStatus(const QString &statStr)
212{ 212{
213 if (mReadOnly) return; 213 if (mReadOnly) return;
214 QString ss(statStr.upper()); 214 QString ss(statStr.upper());
215 215
216 if (ss == "X-ACTION") 216 if (ss == "X-ACTION")
217 mStatus = NEEDS_ACTION; 217 mStatus = NEEDS_ACTION;
218 else if (ss == "NEEDS ACTION") 218 else if (ss == "NEEDS ACTION")
219 mStatus = NEEDS_ACTION; 219 mStatus = NEEDS_ACTION;
220 else if (ss == "ACCEPTED") 220 else if (ss == "ACCEPTED")
221 mStatus = ACCEPTED; 221 mStatus = ACCEPTED;
222 else if (ss == "SENT") 222 else if (ss == "SENT")
223 mStatus = SENT; 223 mStatus = SENT;
224 else if (ss == "TENTATIVE") 224 else if (ss == "TENTATIVE")
225 mStatus = TENTATIVE; 225 mStatus = TENTATIVE;
226 else if (ss == "CONFIRMED") 226 else if (ss == "CONFIRMED")
227 mStatus = CONFIRMED; 227 mStatus = CONFIRMED;
228 else if (ss == "DECLINED") 228 else if (ss == "DECLINED")
229 mStatus = DECLINED; 229 mStatus = DECLINED;
230 else if (ss == "COMPLETED") 230 else if (ss == "COMPLETED")
231 mStatus = COMPLETED; 231 mStatus = COMPLETED;
232 else if (ss == "DELEGATED") 232 else if (ss == "DELEGATED")
233 mStatus = DELEGATED; 233 mStatus = DELEGATED;
234 234
235 updated(); 235 updated();
236} 236}
237 237
238void Todo::setStatus(int status) 238void Todo::setStatus(int status)
239{ 239{
240 if (mReadOnly) return; 240 if (mReadOnly) return;
241 mStatus = status; 241 mStatus = status;
242 updated(); 242 updated();
243} 243}
244 244
245int Todo::status() const 245int Todo::status() const
246{ 246{
247 return mStatus; 247 return mStatus;
248} 248}
249 249
250QString Todo::statusStr() const 250QString Todo::statusStr() const
251{ 251{
252 switch(mStatus) { 252 switch(mStatus) {
253 case NEEDS_ACTION: 253 case NEEDS_ACTION:
254 return QString("NEEDS ACTION"); 254 return QString("NEEDS ACTION");
255 break; 255 break;
256 case ACCEPTED: 256 case ACCEPTED:
257 return QString("ACCEPTED"); 257 return QString("ACCEPTED");
258 break; 258 break;
259 case SENT: 259 case SENT:
260 return QString("SENT"); 260 return QString("SENT");
261 break; 261 break;
262 case TENTATIVE: 262 case TENTATIVE:
263 return QString("TENTATIVE"); 263 return QString("TENTATIVE");
264 break; 264 break;
265 case CONFIRMED: 265 case CONFIRMED:
266 return QString("CONFIRMED"); 266 return QString("CONFIRMED");
267 break; 267 break;
268 case DECLINED: 268 case DECLINED:
269 return QString("DECLINED"); 269 return QString("DECLINED");
270 break; 270 break;
271 case COMPLETED: 271 case COMPLETED:
272 return QString("COMPLETED"); 272 return QString("COMPLETED");
273 break; 273 break;
274 case DELEGATED: 274 case DELEGATED:
275 return QString("DELEGATED"); 275 return QString("DELEGATED");
276 break; 276 break;
277 } 277 }
278 return QString(""); 278 return QString("");
279} 279}
280#endif 280#endif
281 281
282bool Todo::isCompleted() const 282bool Todo::isCompleted() const
283{ 283{
284 if (mPercentComplete == 100) return true; 284 if (mPercentComplete == 100) return true;
285 else return false; 285 else return false;
286} 286}
287 287
288void Todo::setCompleted(bool completed) 288void Todo::setCompleted(bool completed)
289{ 289{
290 if (completed) mPercentComplete = 100; 290 if (completed) mPercentComplete = 100;
291 else { 291 else {
292 mPercentComplete = 0; 292 mPercentComplete = 0;
293 mHasCompletedDate = false; 293 mHasCompletedDate = false;
294 } 294 }
295 updated(); 295 updated();
296} 296}
297 297
298QDateTime Todo::completed() const 298QDateTime Todo::completed() const
299{ 299{
300 return mCompleted; 300 return mCompleted;
301} 301}
302 302
303QString Todo::completedStr() const 303QString Todo::completedStr( bool shortF ) const
304{ 304{
305 return KGlobal::locale()->formatDateTime(mCompleted); 305 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
306} 306}
307 307
308void Todo::setCompleted(const QDateTime &completed) 308void Todo::setCompleted(const QDateTime &completed)
309{ 309{
310 qDebug("Todo::setCompleted ");
310 mHasCompletedDate = true; 311 mHasCompletedDate = true;
311 mPercentComplete = 100; 312 mPercentComplete = 100;
312 mCompleted = getEvenTime(completed); 313 mCompleted = getEvenTime(completed);
313 updated(); 314 updated();
314} 315}
315 316
316bool Todo::hasCompletedDate() const 317bool Todo::hasCompletedDate() const
317{ 318{
318 return mHasCompletedDate; 319 return mHasCompletedDate;
319} 320}
320 321
321int Todo::percentComplete() const 322int Todo::percentComplete() const
322{ 323{
323 return mPercentComplete; 324 return mPercentComplete;
324} 325}
325 326
326void Todo::setPercentComplete(int v) 327void Todo::setPercentComplete(int v)
327{ 328{
328 mPercentComplete = v; 329 mPercentComplete = v;
329 if ( v != 100 ) 330 if ( v != 100 )
330 mHasCompletedDate = false; 331 mHasCompletedDate = false;
331 updated(); 332 updated();
332} 333}
333QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 334QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
334{ 335{
335 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 336 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
336 *ok = false; 337 *ok = false;
337 return QDateTime (); 338 return QDateTime ();
338 } 339 }
339 QDateTime incidenceStart; 340 QDateTime incidenceStart;
340 incidenceStart = dtDue(); 341 incidenceStart = dtDue();
341 bool enabled = false; 342 bool enabled = false;
342 Alarm* alarm; 343 Alarm* alarm;
343 int off; 344 int off;
344 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 345 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
345 // if ( QDateTime::currentDateTime() > incidenceStart ){ 346 // if ( QDateTime::currentDateTime() > incidenceStart ){
346// *ok = false; 347// *ok = false;
347// return incidenceStart; 348// return incidenceStart;
348// } 349// }
349 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 350 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
350 if (alarm->enabled()) { 351 if (alarm->enabled()) {
351 if ( alarm->hasTime () ) { 352 if ( alarm->hasTime () ) {
352 if ( alarm->time() < alarmStart ) { 353 if ( alarm->time() < alarmStart ) {
353 alarmStart = alarm->time(); 354 alarmStart = alarm->time();
354 enabled = true; 355 enabled = true;
355 off = alarmStart.secsTo( incidenceStart ); 356 off = alarmStart.secsTo( incidenceStart );
356 } 357 }
357 358
358 } else { 359 } else {
359 int secs = alarm->startOffset().asSeconds(); 360 int secs = alarm->startOffset().asSeconds();
360 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 361 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
361 alarmStart = incidenceStart.addSecs( secs ); 362 alarmStart = incidenceStart.addSecs( secs );
362 enabled = true; 363 enabled = true;
363 off = -secs; 364 off = -secs;
364 } 365 }
365 } 366 }
366 } 367 }
367 } 368 }
368 if ( enabled ) { 369 if ( enabled ) {
369 if ( alarmStart > QDateTime::currentDateTime() ) { 370 if ( alarmStart > QDateTime::currentDateTime() ) {
370 *ok = true; 371 *ok = true;
371 * offset = off; 372 * offset = off;
372 return alarmStart; 373 return alarmStart;
373 } 374 }
374 } 375 }
375 *ok = false; 376 *ok = false;
376 return QDateTime (); 377 return QDateTime ();
377 378
378} 379}
379 380
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 0f22c59..41f5841 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -1,122 +1,122 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef TODO_H 20#ifndef TODO_H
21#define TODO_H 21#define TODO_H
22// 22//
23// Todo component, representing a VTODO object 23// Todo component, representing a VTODO object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28namespace KCal { 28namespace KCal {
29 29
30/** 30/**
31 This class provides a Todo in the sense of RFC2445. 31 This class provides a Todo in the sense of RFC2445.
32*/ 32*/
33class Todo : public Incidence 33class Todo : public Incidence
34{ 34{
35 public: 35 public:
36 Todo(); 36 Todo();
37 Todo(const Todo &); 37 Todo(const Todo &);
38 ~Todo(); 38 ~Todo();
39 typedef ListBase<Todo> List; 39 typedef ListBase<Todo> List;
40 QCString type() const { return "Todo"; } 40 QCString type() const { return "Todo"; }
41 41
42 /** Return an exact copy of this todo. */ 42 /** Return an exact copy of this todo. */
43 Incidence *clone(); 43 Incidence *clone();
44 QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const; 44 QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const;
45 45
46 /** for setting the todo's due date/time with a QDateTime. */ 46 /** for setting the todo's due date/time with a QDateTime. */
47 void setDtDue(const QDateTime &dtDue); 47 void setDtDue(const QDateTime &dtDue);
48 /** returns an event's Due date/time as a QDateTime. */ 48 /** returns an event's Due date/time as a QDateTime. */
49 QDateTime dtDue() const; 49 QDateTime dtDue() const;
50 /** returns an event's due time as a string formatted according to the 50 /** returns an event's due time as a string formatted according to the
51 users locale settings */ 51 users locale settings */
52 QString dtDueTimeStr() const; 52 QString dtDueTimeStr() const;
53 /** returns an event's due date as a string formatted according to the 53 /** returns an event's due date as a string formatted according to the
54 users locale settings */ 54 users locale settings */
55 QString dtDueDateStr(bool shortfmt=true) const; 55 QString dtDueDateStr(bool shortfmt=true) const;
56 /** returns an event's due date and time as a string formatted according 56 /** returns an event's due date and time as a string formatted according
57 to the users locale settings */ 57 to the users locale settings */
58 QString dtDueStr(bool shortfmt=true) const; 58 QString dtDueStr(bool shortfmt=true) const;
59 59
60 /** returns TRUE or FALSE depending on whether the todo has a due date */ 60 /** returns TRUE or FALSE depending on whether the todo has a due date */
61 bool hasDueDate() const; 61 bool hasDueDate() const;
62 /** sets the event's hasDueDate value. */ 62 /** sets the event's hasDueDate value. */
63 void setHasDueDate(bool f); 63 void setHasDueDate(bool f);
64 64
65 65
66 /** sets the event's status to the string specified. The string 66 /** sets the event's status to the string specified. The string
67 * must be a recognized value for the status field, i.e. a string 67 * must be a recognized value for the status field, i.e. a string
68 * equivalent of the possible status enumerations previously described. */ 68 * equivalent of the possible status enumerations previously described. */
69// void setStatus(const QString &statStr); 69// void setStatus(const QString &statStr);
70 /** sets the event's status to the value specified. See the enumeration 70 /** sets the event's status to the value specified. See the enumeration
71 * above for possible values. */ 71 * above for possible values. */
72// void setStatus(int); 72// void setStatus(int);
73 /** return the event's status. */ 73 /** return the event's status. */
74// int status() const; 74// int status() const;
75 /** return the event's status in string format. */ 75 /** return the event's status in string format. */
76// QString statusStr() const; 76// QString statusStr() const;
77 77
78 /** return, if this todo is completed */ 78 /** return, if this todo is completed */
79 bool isCompleted() const; 79 bool isCompleted() const;
80 /** set completed state of this todo */ 80 /** set completed state of this todo */
81 void setCompleted(bool); 81 void setCompleted(bool);
82 82
83 /** 83 /**
84 Return how many percent of the task are completed. Returns a value 84 Return how many percent of the task are completed. Returns a value
85 between 0 and 100. 85 between 0 and 100.
86 */ 86 */
87 int percentComplete() const; 87 int percentComplete() const;
88 /** 88 /**
89 Set how many percent of the task are completed. Valid values are in the 89 Set how many percent of the task are completed. Valid values are in the
90 range from 0 to 100. 90 range from 0 to 100.
91 */ 91 */
92 void setPercentComplete(int); 92 void setPercentComplete(int);
93 93
94 /** return date and time when todo was completed */ 94 /** return date and time when todo was completed */
95 QDateTime completed() const; 95 QDateTime completed() const;
96 QString completedStr() const; 96 QString completedStr(bool shortF = true) const;
97 /** set date and time of completion */ 97 /** set date and time of completion */
98 void setCompleted(const QDateTime &completed); 98 void setCompleted(const QDateTime &completed);
99 99
100 /** Return true, if todo has a date associated with completion */ 100 /** Return true, if todo has a date associated with completion */
101 bool hasCompletedDate() const; 101 bool hasCompletedDate() const;
102 bool contains ( Todo*); 102 bool contains ( Todo*);
103 103
104 private: 104 private:
105 bool accept(Visitor &v) { return v.visit(this); } 105 bool accept(Visitor &v) { return v.visit(this); }
106 106
107 QDateTime mDtDue; // due date of todo 107 QDateTime mDtDue; // due date of todo
108 108
109 bool mHasDueDate; // if todo has associated due date 109 bool mHasDueDate; // if todo has associated due date
110 110
111// int mStatus; // confirmed/delegated/tentative/etc 111// int mStatus; // confirmed/delegated/tentative/etc
112 112
113 QDateTime mCompleted; 113 QDateTime mCompleted;
114 bool mHasCompletedDate; 114 bool mHasCompletedDate;
115 115
116 int mPercentComplete; 116 int mPercentComplete;
117}; 117};
118 118
119 bool operator==( const Todo&, const Todo& ); 119 bool operator==( const Todo&, const Todo& );
120} 120}
121 121
122#endif 122#endif