author | zautrix <zautrix> | 2005-03-08 09:24:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-08 09:24:53 (UTC) |
commit | 91e7aeec0b15d28eb263c0699fdce4a00a3669c6 (patch) (unidiff) | |
tree | 10bf2d72c94ab030c7a08b22d0880997c99dcfff | |
parent | a50b432c475d2a0b97b3f8707666f7d2990cd8db (diff) | |
download | kdepimpi-91e7aeec0b15d28eb263c0699fdce4a00a3669c6.zip kdepimpi-91e7aeec0b15d28eb263c0699fdce4a00a3669c6.tar.gz kdepimpi-91e7aeec0b15d28eb263c0699fdce4a00a3669c6.tar.bz2 |
todo printing fixes
-rw-r--r-- | korganizer/calprintbase.cpp | 26 | ||||
-rw-r--r-- | korganizer/calprinter.cpp | 2 |
2 files changed, 18 insertions, 10 deletions
diff --git a/korganizer/calprintbase.cpp b/korganizer/calprintbase.cpp index 6bb407d..f66fddc 100644 --- a/korganizer/calprintbase.cpp +++ b/korganizer/calprintbase.cpp | |||
@@ -728,469 +728,477 @@ void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, | |||
728 | } | 728 | } |
729 | 729 | ||
730 | } // doesFloat | 730 | } // doesFloat |
731 | 731 | ||
732 | p.drawText(x+5, y+textY, width-10, lineSpacing, | 732 | p.drawText(x+5, y+textY, width-10, lineSpacing, |
733 | AlignLeft|AlignBottom, outStr); | 733 | AlignLeft|AlignBottom, outStr); |
734 | textY+=lineSpacing; | 734 | textY+=lineSpacing; |
735 | } | 735 | } |
736 | 736 | ||
737 | if ( textY<height ) { | 737 | if ( textY<height ) { |
738 | 738 | ||
739 | Todo::List::ConstIterator it2; | 739 | Todo::List::ConstIterator it2; |
740 | for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) { | 740 | for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) { |
741 | Todo *todo = *it2; | 741 | Todo *todo = *it2; |
742 | QString text; | 742 | QString text; |
743 | if (todo->hasDueDate()) { | 743 | if (todo->hasDueDate()) { |
744 | if (!todo->doesFloat()) { | 744 | if (!todo->doesFloat()) { |
745 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 745 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
746 | text += " "; | 746 | text += " "; |
747 | } | 747 | } |
748 | } | 748 | } |
749 | text += i18n("To-Do: %1").arg(todo->summary()); | 749 | text += i18n("To-Do: %1").arg(todo->summary()); |
750 | 750 | ||
751 | p.drawText(x+5, y+textY, width-10, lineSpacing, | 751 | p.drawText(x+5, y+textY, width-10, lineSpacing, |
752 | AlignLeft|AlignBottom, text); | 752 | AlignLeft|AlignBottom, text); |
753 | textY+=lineSpacing; | 753 | textY+=lineSpacing; |
754 | } | 754 | } |
755 | } | 755 | } |
756 | } | 756 | } |
757 | 757 | ||
758 | 758 | ||
759 | /////////////////////////////////////////////////////////////////////////////// | 759 | /////////////////////////////////////////////////////////////////////////////// |
760 | 760 | ||
761 | void CalPrintBase::drawWeek(QPainter &p, const QDate &qd, | 761 | void CalPrintBase::drawWeek(QPainter &p, const QDate &qd, |
762 | int x, int y, int width, int height) | 762 | int x, int y, int width, int height) |
763 | { | 763 | { |
764 | QDate weekDate = qd; | 764 | QDate weekDate = qd; |
765 | bool portrait = ( mPrinter->orientation() == KPrinter::Portrait ); | 765 | bool portrait = ( mPrinter->orientation() == KPrinter::Portrait ); |
766 | int cellWidth, cellHeight; | 766 | int cellWidth, cellHeight; |
767 | int vcells; | 767 | int vcells; |
768 | if (portrait) { | 768 | if (portrait) { |
769 | cellWidth = width/2; | 769 | cellWidth = width/2; |
770 | vcells=3; | 770 | vcells=3; |
771 | } else { | 771 | } else { |
772 | cellWidth = width/6; | 772 | cellWidth = width/6; |
773 | vcells=1; | 773 | vcells=1; |
774 | } | 774 | } |
775 | cellHeight = height/vcells; | 775 | cellHeight = height/vcells; |
776 | 776 | ||
777 | // correct begin of week | 777 | // correct begin of week |
778 | int weekdayCol = weekdayColumn( qd.dayOfWeek() ); | 778 | int weekdayCol = weekdayColumn( qd.dayOfWeek() ); |
779 | weekDate = qd.addDays( -weekdayCol ); | 779 | weekDate = qd.addDays( -weekdayCol ); |
780 | 780 | ||
781 | for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) { | 781 | for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) { |
782 | if (i<5) { | 782 | if (i<5) { |
783 | drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), | 783 | drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), |
784 | cellWidth, cellHeight, true); | 784 | cellWidth, cellHeight, true); |
785 | } else if (i==5) { | 785 | } else if (i==5) { |
786 | drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), | 786 | drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), |
787 | cellWidth, cellHeight/2, true); | 787 | cellWidth, cellHeight/2, true); |
788 | } else if (i==6) { | 788 | } else if (i==6) { |
789 | drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells), | 789 | drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells), |
790 | y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true); | 790 | y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true); |
791 | } | 791 | } |
792 | } // for i through all weekdays | 792 | } // for i through all weekdays |
793 | } | 793 | } |
794 | 794 | ||
795 | 795 | ||
796 | void CalPrintBase::drawTimeTable(QPainter &p, | 796 | void CalPrintBase::drawTimeTable(QPainter &p, |
797 | const QDate &fromDate, const QDate &toDate, | 797 | const QDate &fromDate, const QDate &toDate, |
798 | QTime &fromTime, QTime &toTime, | 798 | QTime &fromTime, QTime &toTime, |
799 | int x, int y, int width, int height) | 799 | int x, int y, int width, int height) |
800 | { | 800 | { |
801 | // timeline is 1.5 hours: | 801 | // timeline is 1.5 hours: |
802 | int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) ); | 802 | int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) ); |
803 | int timelineWidth = 60; | 803 | int timelineWidth = 60; |
804 | int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) ); | 804 | int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) ); |
805 | int currY=y; | 805 | int currY=y; |
806 | int currX=x; | 806 | int currX=x; |
807 | 807 | ||
808 | drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight); | 808 | drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight); |
809 | currY+=mSubHeaderHeight; | 809 | currY+=mSubHeaderHeight; |
810 | drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight, | 810 | drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight, |
811 | timelineWidth, height-mSubHeaderHeight-alldayHeight ); | 811 | timelineWidth, height-mSubHeaderHeight-alldayHeight ); |
812 | 812 | ||
813 | currX=x+timelineWidth; | 813 | currX=x+timelineWidth; |
814 | // draw each day | 814 | // draw each day |
815 | QDate curDate(fromDate); | 815 | QDate curDate(fromDate); |
816 | while (curDate<=toDate) {Event::List eventList; | 816 | while (curDate<=toDate) {Event::List eventList; |
817 | eventList.fill( mCalendar->events(curDate, true)); | 817 | eventList.fill( mCalendar->events(curDate, true)); |
818 | drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight); | 818 | drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight); |
819 | drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX, | 819 | drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX, |
820 | currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight ); | 820 | currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight ); |
821 | currX+=cellWidth; | 821 | currX+=cellWidth; |
822 | curDate=curDate.addDays(1); | 822 | curDate=curDate.addDays(1); |
823 | } | 823 | } |
824 | 824 | ||
825 | } | 825 | } |
826 | 826 | ||
827 | 827 | ||
828 | /////////////////////////////////////////////////////////////////////////////// | 828 | /////////////////////////////////////////////////////////////////////////////// |
829 | 829 | ||
830 | void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, | 830 | void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, |
831 | int x, int y, int width, int height) | 831 | int x, int y, int width, int height) |
832 | { | 832 | { |
833 | 833 | ||
834 | int yoffset = mSubHeaderHeight; | 834 | int yoffset = mSubHeaderHeight; |
835 | int xoffset = 0; | 835 | int xoffset = 0; |
836 | 836 | ||
837 | QDate monthDate(QDate(qd.year(), qd.month(), 1)); | 837 | QDate monthDate(QDate(qd.year(), qd.month(), 1)); |
838 | QDate monthFirst(monthDate); | 838 | QDate monthFirst(monthDate); |
839 | QDate monthLast(monthDate.addMonths(1).addDays(-1)); | 839 | QDate monthLast(monthDate.addMonths(1).addDays(-1)); |
840 | 840 | ||
841 | 841 | ||
842 | int weekdayCol = weekdayColumn( monthDate.dayOfWeek() ); | 842 | int weekdayCol = weekdayColumn( monthDate.dayOfWeek() ); |
843 | monthDate = monthDate.addDays(-weekdayCol); | 843 | monthDate = monthDate.addDays(-weekdayCol); |
844 | 844 | ||
845 | int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1; | 845 | int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1; |
846 | int cellHeight = (height-yoffset) / rows; | 846 | int cellHeight = (height-yoffset) / rows; |
847 | 847 | ||
848 | if (weeknumbers) { | 848 | if (weeknumbers) { |
849 | QFont oldFont(p.font()); | 849 | QFont oldFont(p.font()); |
850 | QFont newFont(p.font()); | 850 | QFont newFont(p.font()); |
851 | newFont.setPointSize(7); | 851 | newFont.setPointSize(7); |
852 | p.setFont(newFont); | 852 | p.setFont(newFont); |
853 | xoffset += 18; | 853 | xoffset += 18; |
854 | QDate weekDate(monthDate); | 854 | QDate weekDate(monthDate); |
855 | for (int row = 0; row<rows; row++) { | 855 | for (int row = 0; row<rows; row++) { |
856 | int calWeek = weekDate.weekNumber(); | 856 | int calWeek = weekDate.weekNumber(); |
857 | QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight); | 857 | QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight); |
858 | p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) ); | 858 | p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) ); |
859 | weekDate = weekDate.addDays(7); | 859 | weekDate = weekDate.addDays(7); |
860 | } | 860 | } |
861 | p.setFont(oldFont); | 861 | p.setFont(oldFont); |
862 | } | 862 | } |
863 | 863 | ||
864 | drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight ); | 864 | drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight ); |
865 | int cellWidth = (width-xoffset) / 7; | 865 | int cellWidth = (width-xoffset) / 7; |
866 | 866 | ||
867 | QColor back = p.backgroundColor(); | 867 | QColor back = p.backgroundColor(); |
868 | bool darkbg = false; | 868 | bool darkbg = false; |
869 | for (int row = 0; row < rows; row++) { | 869 | for (int row = 0; row < rows; row++) { |
870 | for (int col = 0; col < 7; col++) { | 870 | for (int col = 0; col < 7; col++) { |
871 | // show days from previous/next month with a grayed background | 871 | // show days from previous/next month with a grayed background |
872 | if ( (monthDate < monthFirst) || (monthDate > monthLast) ) { | 872 | if ( (monthDate < monthFirst) || (monthDate > monthLast) ) { |
873 | p.setBackgroundColor( QColor( 240, 240, 240) ); | 873 | p.setBackgroundColor( QColor( 240, 240, 240) ); |
874 | darkbg = true; | 874 | darkbg = true; |
875 | } | 875 | } |
876 | drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight); | 876 | drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight); |
877 | if ( darkbg ) { | 877 | if ( darkbg ) { |
878 | p.setBackgroundColor( back ); | 878 | p.setBackgroundColor( back ); |
879 | darkbg = false; | 879 | darkbg = false; |
880 | } | 880 | } |
881 | monthDate = monthDate.addDays(1); | 881 | monthDate = monthDate.addDays(1); |
882 | } | 882 | } |
883 | } | 883 | } |
884 | } | 884 | } |
885 | 885 | ||
886 | 886 | ||
887 | /////////////////////////////////////////////////////////////////////////////// | 887 | /////////////////////////////////////////////////////////////////////////////// |
888 | 888 | ||
889 | void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos, | 889 | void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos, |
890 | bool desc, int pospriority, int possummary, int posDueDt, int level, | 890 | bool desc, int pospriority, int possummary, int posDueDt, int level, |
891 | int x, int &y, int width, int &height, int pageHeight, | 891 | int x, int &y, int width, int &height, int pageHeight, |
892 | TodoParentStart *r ) | 892 | TodoParentStart *r ) |
893 | { | 893 | { |
894 | if ( !completed && item->isCompleted() ) | 894 | if ( !completed && item->isCompleted() ) |
895 | return; | 895 | return; |
896 | QString outStr; | 896 | QString outStr; |
897 | // int fontHeight = 10; | 897 | // int fontHeight = 10; |
898 | const KLocale *local = KGlobal::locale(); | 898 | const KLocale *local = KGlobal::locale(); |
899 | int priority=item->priority(); | 899 | int priority=item->priority(); |
900 | int posdue=posDueDt; | 900 | int posdue=posDueDt; |
901 | if (posdue<0) posdue=x+width; | 901 | if (posdue<0) posdue=x+width; |
902 | QRect rect; | 902 | QRect rect; |
903 | TodoParentStart startpt; | 903 | TodoParentStart startpt; |
904 | // This list keeps all starting points of the parent todos so the connection | 904 | // This list keeps all starting points of the parent todos so the connection |
905 | // lines of the tree can easily be drawn (needed if a new page is started) | 905 | // lines of the tree can easily be drawn (needed if a new page is started) |
906 | static QPtrList<TodoParentStart> startPoints; | 906 | static QPtrList<TodoParentStart> startPoints; |
907 | if (level<1) { | 907 | if (level<1) { |
908 | startPoints.clear(); | 908 | startPoints.clear(); |
909 | } | 909 | } |
910 | 910 | ||
911 | // size of item | 911 | // size of item |
912 | outStr=item->summary(); | 912 | outStr=item->summary(); |
913 | if ( ! item->location().isEmpty() ) | 913 | if ( ! item->location().isEmpty() ) |
914 | outStr += " ("+item->location()+")"; | 914 | outStr += " ("+item->location()+")"; |
915 | if ( item->hasDueDate() && posDueDt>=0 ) { | 915 | if ( item->hasDueDate() && posDueDt>=0 ) { |
916 | outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; | 916 | outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; |
917 | } | 917 | } |
918 | int left = possummary+(level*10); | 918 | int left = possummary+(level*10); |
919 | rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr); | 919 | rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr); |
920 | //qDebug("bottom1 %d ", rect.bottom() ); | ||
920 | if ( !item->description().isEmpty() && desc ) { | 921 | if ( !item->description().isEmpty() && desc ) { |
921 | outStr = item->description(); | 922 | outStr = item->description(); |
922 | rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1, | 923 | rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1, |
923 | WordBreak, outStr ); | 924 | WordBreak, outStr ); |
924 | } | 925 | } |
926 | //qDebug("bottom2 %d y+h %d y %d ph %d", rect.bottom(), y+height, y , pageHeight ); | ||
925 | // if too big make new page | 927 | // if too big make new page |
926 | if ( rect.bottom() > y+height) { | 928 | if ( rect.bottom() > y+height) { |
927 | // first draw the connection lines from parent todos: | 929 | // first draw the connection lines from parent todos: |
928 | if (level > 0 && connectSubTodos) { | 930 | if (level > 0 && connectSubTodos) { |
929 | TodoParentStart *rct; | 931 | TodoParentStart *rct; |
930 | for ( rct = startPoints.first(); rct; rct = startPoints.next() ) { | 932 | for ( rct = startPoints.first(); rct; rct = startPoints.next() ) { |
931 | int start; | 933 | int start; |
932 | int center = rct->mRect.left() + (rct->mRect.width()/2); | 934 | int center = rct->mRect.left() + (rct->mRect.width()/2); |
933 | int to = p.viewport().bottom(); | 935 | int to = p.viewport().bottom(); |
934 | 936 | ||
935 | // draw either from start point of parent or from top of the page | 937 | // draw either from start point of parent or from top of the page |
936 | if (rct->mSamePage) | 938 | if (rct->mSamePage) |
937 | start = rct->mRect.bottom() + 1; | 939 | start = rct->mRect.bottom() + 1; |
938 | else | 940 | else |
939 | start = p.viewport().top(); | 941 | start = p.viewport().top(); |
940 | p.moveTo( center, start ); | 942 | p.moveTo( center, start ); |
941 | p.lineTo( center, to ); | 943 | p.lineTo( center, to ); |
942 | rct->mSamePage=false; | 944 | rct->mSamePage=false; |
943 | } | 945 | } |
944 | } | 946 | } |
945 | y=0; | 947 | y=0; |
946 | height=pageHeight-y; | 948 | height=pageHeight-y; |
947 | mPrinter->newPage(); | 949 | mPrinter->newPage(); |
948 | } | 950 | } |
949 | 951 | ||
950 | // If this is a sub-item, r will not be 0, and we want the LH side of the priority line up | 952 | // If this is a sub-item, r will not be 0, and we want the LH side of the priority line up |
951 | //to the RH side of the parent item's priority | 953 | //to the RH side of the parent item's priority |
952 | if (r && pospriority >= 0 ) { | 954 | if (r && pospriority >= 0 ) { |
953 | pospriority = r->mRect.right() + 1; | 955 | pospriority = r->mRect.right() + 1; |
954 | } | 956 | } |
955 | 957 | ||
956 | // Priority | 958 | // Priority |
957 | outStr.setNum(priority); | 959 | outStr.setNum(priority); |
958 | rect = p.boundingRect(pospriority, y + 10, 5, -1, AlignCenter, outStr); | 960 | rect = p.boundingRect(pospriority, y + 10, 5, -1, AlignCenter, outStr); |
959 | // Make it a more reasonable size | 961 | // Make it a more reasonable size |
960 | rect.setWidth(19); | 962 | rect.setWidth(19); |
961 | rect.setHeight(19); | 963 | rect.setHeight(19); |
962 | if ( priority > 0 && pospriority>=0 ) { | 964 | if ( priority > 0 && pospriority>=0 ) { |
963 | p.drawText(rect, AlignCenter, outStr); | 965 | p.drawText(rect, AlignCenter, outStr); |
964 | p.drawRect(rect); | 966 | p.drawRect(rect); |
965 | // cross out the rectangle for completed items | 967 | // cross out the rectangle for completed items |
966 | if ( item->isCompleted() ) { | 968 | if ( item->isCompleted() ) { |
967 | p.drawLine( rect.topLeft(), rect.bottomRight() ); | 969 | p.drawLine( rect.topLeft(), rect.bottomRight() ); |
968 | p.drawLine( rect.topRight(), rect.bottomLeft() ); | 970 | p.drawLine( rect.topRight(), rect.bottomLeft() ); |
971 | } else if (item->cancelled() ) { | ||
972 | QPen pen = p.pen(); | ||
973 | p.setPen ( QPen ( black, 2) ); | ||
974 | p.drawLine( rect.left()+2,rect.top()+rect.height()/2, rect.right()-2, +rect.top()+rect.height()/2 ); | ||
975 | p.setPen( pen ); | ||
969 | } | 976 | } |
970 | } | 977 | } |
971 | startpt.mRect = rect; //save for later | 978 | startpt.mRect = rect; //save for later |
972 | 979 | ||
973 | // Connect the dots | 980 | // Connect the dots |
974 | if (level > 0 && connectSubTodos) { | 981 | if (level > 0 && connectSubTodos) { |
975 | int bottom; | 982 | int bottom; |
976 | int center( r->mRect.left() + (r->mRect.width()/2)+1 ); | 983 | int center( r->mRect.left() + (r->mRect.width()/2)+1 ); |
977 | if (r->mSamePage ) | 984 | if (r->mSamePage ) |
978 | bottom = r->mRect.bottom();//lutz + 1; | 985 | bottom = r->mRect.bottom();//lutz + 1; |
979 | else | 986 | else |
980 | bottom = 0; | 987 | bottom = 0; |
981 | int to( rect.top() + (rect.height()/2)+1 ); | 988 | int to( rect.top() + (rect.height()/2)+1 ); |
982 | int endx( rect.left() ); | 989 | int endx( rect.left() ); |
983 | p.moveTo(center, bottom); | 990 | p.moveTo(center, bottom); |
984 | p.lineTo(center, to); | 991 | p.lineTo(center, to); |
985 | p.lineTo(endx, to); | 992 | p.lineTo(endx, to); |
986 | } | 993 | } |
987 | 994 | ||
988 | // if completed, use strike out font | 995 | // if completed, use strike out font |
989 | QFont ft=p.font(); | 996 | // LR does not work - font is underlined, not striked out |
990 | ft.setStrikeOut( item->isCompleted() ); | 997 | //QFont ft=p.font(); |
991 | p.setFont( ft ); | 998 | //ft.setStrikeOut( item->isCompleted() ); |
999 | //p.setFont( ft ); | ||
992 | // summary | 1000 | // summary |
993 | outStr=item->summary(); | 1001 | outStr=item->summary(); |
994 | if ( ! item->location().isEmpty() ) | 1002 | if ( ! item->location().isEmpty() ) |
995 | outStr += " ("+item->location()+")"; | 1003 | outStr += " ("+item->location()+")"; |
996 | if ( item->hasDueDate() && posDueDt>=0 ) { | 1004 | if ( item->hasDueDate() && posDueDt>=0 ) { |
997 | outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; | 1005 | outStr += " [" +item->dtDueStr(true)+"]"; |
998 | } | 1006 | } |
999 | rect = p.boundingRect( left, rect.top(), (posdue-(left + rect.width() + 5)), | 1007 | rect = p.boundingRect( left, rect.top(), (posdue-(left + rect.width() + 5)), |
1000 | -1, WordBreak, outStr); | 1008 | -1, WordBreak, outStr); |
1001 | QRect newrect; | 1009 | QRect newrect; |
1002 | p.drawText( rect, WordBreak, outStr, -1, &newrect ); | 1010 | p.drawText( rect, WordBreak, outStr, -1, &newrect ); |
1003 | ft.setStrikeOut(false); | 1011 | //ft.setStrikeOut(false); |
1004 | p.setFont(ft); | 1012 | // p.setFont(ft); |
1005 | 1013 | ||
1006 | // due | 1014 | // due |
1007 | // if ( item->hasDueDate() && posDueDt>=0 ) { | 1015 | // if ( item->hasDueDate() && posDueDt>=0 ) { |
1008 | // outStr = local->formatDate(item->dtDue().date(),true); | 1016 | // outStr = local->formatDate(item->dtDue().date(),true); |
1009 | // rect = p.boundingRect(posdue, y, x+width, -1, AlignTop|AlignLeft, outStr); | 1017 | // rect = p.boundingRect(posdue, y, x+width, -1, AlignTop|AlignLeft, outStr); |
1010 | // p.drawText(rect, AlignTop|AlignLeft, outStr); | 1018 | // p.drawText(rect, AlignTop|AlignLeft, outStr); |
1011 | // } | 1019 | // } |
1012 | 1020 | ||
1013 | if ( !item->description().isEmpty() && desc ) { | 1021 | if ( !item->description().isEmpty() && desc ) { |
1014 | y=newrect.bottom() + 5; | 1022 | y=newrect.bottom() + 5; |
1015 | outStr = item->description(); | 1023 | outStr = item->description(); |
1016 | rect = p.boundingRect( left+20, y, x+width-(left+10), -1, | 1024 | rect = p.boundingRect( left+20, y, x+width-(left+10), -1, |
1017 | WordBreak, outStr ); | 1025 | WordBreak, outStr ); |
1018 | p.drawText( rect, WordBreak, outStr, -1, &newrect ); | 1026 | p.drawText( rect, WordBreak, outStr, -1, &newrect ); |
1019 | } | 1027 | } |
1020 | 1028 | ||
1021 | // Set the new line position | 1029 | // Set the new line position |
1022 | y=newrect.bottom() + 10; //set the line position | 1030 | y=newrect.bottom() + 10; //set the line position |
1023 | 1031 | ||
1024 | // If the item has subitems, we need to call ourselves recursively | 1032 | // If the item has subitems, we need to call ourselves recursively |
1025 | Incidence::List l;l.fill( item->relations()); | 1033 | Incidence::List l;l.fill( item->relations()); |
1026 | Incidence::List::ConstIterator it; | 1034 | Incidence::List::ConstIterator it; |
1027 | startPoints.append( &startpt ); | 1035 | startPoints.append( &startpt ); |
1028 | for( it = l.begin(); it != l.end(); ++it ) { | 1036 | for( it = l.begin(); it != l.end(); ++it ) { |
1029 | count++; | 1037 | count++; |
1030 | drawTodo( completed, count, static_cast<Todo *>( *it ), p, connectSubTodos, | 1038 | drawTodo( completed, count, static_cast<Todo *>( *it ), p, connectSubTodos, |
1031 | desc, pospriority, possummary, posDueDt, level+1, | 1039 | desc, pospriority, possummary, posDueDt, level+1, |
1032 | x, y, width, height, pageHeight, &startpt); | 1040 | x, y, width, height, pageHeight, &startpt); |
1033 | } | 1041 | } |
1034 | startPoints.remove(&startpt); | 1042 | startPoints.remove(&startpt); |
1035 | } | 1043 | } |
1036 | 1044 | ||
1037 | int CalPrintBase::weekdayColumn( int weekday ) | 1045 | int CalPrintBase::weekdayColumn( int weekday ) |
1038 | { | 1046 | { |
1039 | return ( weekday + 7 - KGlobal::locale()->weekStartDay() ) % 7; | 1047 | return ( weekday + 7 - KGlobal::locale()->weekStartDay() ) % 7; |
1040 | } | 1048 | } |
1041 | 1049 | ||
1042 | void CalPrintBase::drawSplitWeek( QPainter &p, const QDate &fd, | 1050 | void CalPrintBase::drawSplitWeek( QPainter &p, const QDate &fd, |
1043 | const QDate &td ) | 1051 | const QDate &td ) |
1044 | { | 1052 | { |
1045 | QDate curDay, fromDay, toDay, curWeek, fromWeek, toWeek; | 1053 | QDate curDay, fromDay, toDay, curWeek, fromWeek, toWeek; |
1046 | 1054 | ||
1047 | mPrinter->setOrientation(KPrinter::Portrait); | 1055 | mPrinter->setOrientation(KPrinter::Portrait); |
1048 | 1056 | ||
1049 | int minus = 0; | 1057 | int minus = 0; |
1050 | if (KGlobal::locale()->weekStartsMonday()) { | 1058 | if (KGlobal::locale()->weekStartsMonday()) { |
1051 | // correct to monday | 1059 | // correct to monday |
1052 | fromWeek = fd.addDays(-(fd.dayOfWeek()-1)); | 1060 | fromWeek = fd.addDays(-(fd.dayOfWeek()-1)); |
1053 | // correct to sunday | 1061 | // correct to sunday |
1054 | toWeek = td.addDays(7-fd.dayOfWeek()); | 1062 | toWeek = td.addDays(7-fd.dayOfWeek()); |
1055 | minus = 1; | 1063 | minus = 1; |
1056 | } else { | 1064 | } else { |
1057 | // correct to sunday | 1065 | // correct to sunday |
1058 | fromWeek = fd.addDays(-(fd.dayOfWeek()%7)); | 1066 | fromWeek = fd.addDays(-(fd.dayOfWeek()%7)); |
1059 | // correct to saturday | 1067 | // correct to saturday |
1060 | toWeek = td.addDays(6-td.dayOfWeek()); | 1068 | toWeek = td.addDays(6-td.dayOfWeek()); |
1061 | } | 1069 | } |
1062 | 1070 | ||
1063 | fromDay = fd; | 1071 | fromDay = fd; |
1064 | curDay = fd; | 1072 | curDay = fd; |
1065 | toDay = td; | 1073 | toDay = td; |
1066 | p.setFont( QFont("Helvetica") ); | 1074 | p.setFont( QFont("Helvetica") ); |
1067 | // the painter initially begins at 72 dpi per the Qt docs. | 1075 | // the painter initially begins at 72 dpi per the Qt docs. |
1068 | int pageWidth = p.viewport().width(); | 1076 | int pageWidth = p.viewport().width(); |
1069 | int pageHeight = p.viewport().height(); | 1077 | int pageHeight = p.viewport().height(); |
1070 | int margin=0; | 1078 | int margin=0; |
1071 | mHeaderHeight = 110; | 1079 | mHeaderHeight = 110; |
1072 | mSubHeaderHeight = 20; | 1080 | mSubHeaderHeight = 20; |
1073 | 1081 | ||
1074 | p.setViewport(margin, margin, | 1082 | p.setViewport(margin, margin, |
1075 | p.viewport().width()-margin, | 1083 | p.viewport().width()-margin, |
1076 | p.viewport().height()-margin); | 1084 | p.viewport().height()-margin); |
1077 | 1085 | ||
1078 | curWeek = fromWeek.addDays(6); | 1086 | curWeek = fromWeek.addDays(6); |
1079 | 1087 | ||
1080 | int columnWidth = int( pageWidth / 4.5 ); | 1088 | int columnWidth = int( pageWidth / 4.5 ); |
1081 | 1089 | ||
1082 | do { | 1090 | do { |
1083 | 1091 | ||
1084 | // if ( (curDay.dayOfWeek()-1)%7 < 3 ) | 1092 | // if ( (curDay.dayOfWeek()-1)%7 < 3 ) |
1085 | switch((curDay.dayOfWeek()-minus)%7){ | 1093 | switch((curDay.dayOfWeek()-minus)%7){ |
1086 | case 0: | 1094 | case 0: |
1087 | drawSplitTimes( p, pageWidth, columnWidth, pageHeight ); | 1095 | drawSplitTimes( p, pageWidth, columnWidth, pageHeight ); |
1088 | drawSplitDay( p, curDay, columnWidth, pageHeight, | 1096 | drawSplitDay( p, curDay, columnWidth, pageHeight, |
1089 | int( columnWidth * 0.5 ) ); | 1097 | int( columnWidth * 0.5 ) ); |
1090 | break; | 1098 | break; |
1091 | case 1: | 1099 | case 1: |
1092 | drawSplitDay( p, curDay, columnWidth, pageHeight, | 1100 | drawSplitDay( p, curDay, columnWidth, pageHeight, |
1093 | int( columnWidth * 1.5 ) ); | 1101 | int( columnWidth * 1.5 ) ); |
1094 | break; | 1102 | break; |
1095 | case 2: | 1103 | case 2: |
1096 | drawSplitDay( p, curDay, columnWidth, pageHeight, | 1104 | drawSplitDay( p, curDay, columnWidth, pageHeight, |
1097 | int( columnWidth * 2.5 ) ); | 1105 | int( columnWidth * 2.5 ) ); |
1098 | break; | 1106 | break; |
1099 | case 3: | 1107 | case 3: |
1100 | drawSplitDay( p, curDay, columnWidth, pageHeight, | 1108 | drawSplitDay( p, curDay, columnWidth, pageHeight, |
1101 | int( columnWidth * 3.5 ) ); | 1109 | int( columnWidth * 3.5 ) ); |
1102 | mPrinter->newPage(); | 1110 | mPrinter->newPage(); |
1103 | break; | 1111 | break; |
1104 | case 4: | 1112 | case 4: |
1105 | drawSplitTimes( p, int( pageWidth * ( 3.5/ 4.5 ) ), columnWidth, | 1113 | drawSplitTimes( p, int( pageWidth * ( 3.5/ 4.5 ) ), columnWidth, |
1106 | pageHeight ); | 1114 | pageHeight ); |
1107 | drawSplitDay( p, curDay, columnWidth, pageHeight, | 1115 | drawSplitDay( p, curDay, columnWidth, pageHeight, |
1108 | int( columnWidth * 0.5 ) ); | 1116 | int( columnWidth * 0.5 ) ); |
1109 | drawSplitHeaderRight( p, curWeek.addDays( -6 ), curWeek, | 1117 | drawSplitHeaderRight( p, curWeek.addDays( -6 ), curWeek, |
1110 | curWeek, pageWidth, mHeaderHeight ); | 1118 | curWeek, pageWidth, mHeaderHeight ); |
1111 | break; | 1119 | break; |
1112 | case 5: | 1120 | case 5: |
1113 | drawSplitDay( p, curDay, columnWidth, pageHeight, | 1121 | drawSplitDay( p, curDay, columnWidth, pageHeight, |
1114 | int( columnWidth * 1.5 ) ); | 1122 | int( columnWidth * 1.5 ) ); |
1115 | break; | 1123 | break; |
1116 | case 6: | 1124 | case 6: |
1117 | drawSplitDay( p, curDay, columnWidth, pageHeight, | 1125 | drawSplitDay( p, curDay, columnWidth, pageHeight, |
1118 | int( columnWidth * 2.5 ) ); | 1126 | int( columnWidth * 2.5 ) ); |
1119 | if ( curDay < toDay ) | 1127 | if ( curDay < toDay ) |
1120 | mPrinter->newPage(); | 1128 | mPrinter->newPage(); |
1121 | curWeek = curWeek.addDays( 7 ); | 1129 | curWeek = curWeek.addDays( 7 ); |
1122 | break; | 1130 | break; |
1123 | } | 1131 | } |
1124 | curDay = curDay.addDays(1); | 1132 | curDay = curDay.addDays(1); |
1125 | 1133 | ||
1126 | } while (curDay <= toDay); | 1134 | } while (curDay <= toDay); |
1127 | 1135 | ||
1128 | } | 1136 | } |
1129 | 1137 | ||
1130 | void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, | 1138 | void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, |
1131 | const QDate &td, | 1139 | const QDate &td, |
1132 | const QDate &, | 1140 | const QDate &, |
1133 | int width, int ) | 1141 | int width, int ) |
1134 | { | 1142 | { |
1135 | int tempStore = mSubHeaderHeight; | 1143 | int tempStore = mSubHeaderHeight; |
1136 | mSubHeaderHeight+= mSubHeaderHeight; | 1144 | mSubHeaderHeight+= mSubHeaderHeight; |
1137 | KLocale *local = KGlobal::locale(); | 1145 | KLocale *local = KGlobal::locale(); |
1138 | QFont font("helvetica", 18, QFont::Bold); | 1146 | QFont font("helvetica", 18, QFont::Bold); |
1139 | QPen penA( black,0); | 1147 | QPen penA( black,0); |
1140 | QPen penB( black,3); | 1148 | QPen penB( black,3); |
1141 | p.setFont(font); | 1149 | p.setFont(font); |
1142 | int lineSpacing = p.fontMetrics().lineSpacing(); | 1150 | int lineSpacing = p.fontMetrics().lineSpacing(); |
1143 | QString title; | 1151 | QString title; |
1144 | QString myOwner(mCalendar->getOwner()); | 1152 | QString myOwner(mCalendar->getOwner()); |
1145 | if ( fd.month() == td.month() ) { | 1153 | if ( fd.month() == td.month() ) { |
1146 | title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' | 1154 | title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' |
1147 | + '-' + ' ' + QString::number(td.day()); | 1155 | + '-' + ' ' + QString::number(td.day()); |
1148 | } else { | 1156 | } else { |
1149 | title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' | 1157 | title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' |
1150 | + '-' + ' ' + local->monthName(td.month(), false) + ' ' + QString::number(td.day()); | 1158 | + '-' + ' ' + local->monthName(td.month(), false) + ' ' + QString::number(td.day()); |
1151 | } | 1159 | } |
1152 | 1160 | ||
1153 | // Grrrrrrr! why can't I set the font to a serif font?!?!? | 1161 | // Grrrrrrr! why can't I set the font to a serif font?!?!? |
1154 | QFont serifFont("Helvetica", 30); | 1162 | QFont serifFont("Helvetica", 30); |
1155 | // serifFont.setFamily("Serif"); | 1163 | // serifFont.setFamily("Serif"); |
1156 | // serifFont.setWeight(87); | 1164 | // serifFont.setWeight(87); |
1157 | // serifFont.setItalic(true); | 1165 | // serifFont.setItalic(true); |
1158 | p.setFont(serifFont); | 1166 | p.setFont(serifFont); |
1159 | QFontInfo info(p.font()); | 1167 | QFontInfo info(p.font()); |
1160 | 1168 | ||
1161 | lineSpacing = p.fontMetrics().lineSpacing(); | 1169 | lineSpacing = p.fontMetrics().lineSpacing(); |
1162 | p.drawText(0, lineSpacing * 0, width, lineSpacing, AlignRight |AlignTop, title ); | 1170 | p.drawText(0, lineSpacing * 0, width, lineSpacing, AlignRight |AlignTop, title ); |
1163 | 1171 | ||
1164 | title.truncate(0); | 1172 | title.truncate(0); |
1165 | 1173 | ||
1166 | p.setPen(penB ); | 1174 | p.setPen(penB ); |
1167 | p.drawLine(200, lineSpacing * 1, width, lineSpacing * 1); | 1175 | p.drawLine(200, lineSpacing * 1, width, lineSpacing * 1); |
1168 | p.setPen(penA ); | 1176 | p.setPen(penA ); |
1169 | 1177 | ||
1170 | p.setFont(QFont("Helvetica", 20, QFont::Bold, TRUE)); | 1178 | p.setFont(QFont("Helvetica", 20, QFont::Bold, TRUE)); |
1171 | title += QString::number(fd.year()); | 1179 | title += QString::number(fd.year()); |
1172 | p.drawText(0, lineSpacing * 1, width, lineSpacing, AlignRight |AlignTop, title ); | 1180 | p.drawText(0, lineSpacing * 1, width, lineSpacing, AlignRight |AlignTop, title ); |
1173 | mSubHeaderHeight = tempStore ; | 1181 | mSubHeaderHeight = tempStore ; |
1174 | } | 1182 | } |
1175 | 1183 | ||
1176 | void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, | 1184 | void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, |
1177 | int height, int offsetLeft ) | 1185 | int height, int offsetLeft ) |
1178 | { | 1186 | { |
1179 | int tempStore = mSubHeaderHeight; | 1187 | int tempStore = mSubHeaderHeight; |
1180 | mSubHeaderHeight+= mSubHeaderHeight; | 1188 | mSubHeaderHeight+= mSubHeaderHeight; |
1181 | int startHour = KOPrefs::instance()->mDayBegins; | 1189 | int startHour = KOPrefs::instance()->mDayBegins; |
1182 | int endHour = 20; | 1190 | int endHour = 20; |
1183 | int offset = mHeaderHeight + mSubHeaderHeight + 10; | 1191 | int offset = mHeaderHeight + mSubHeaderHeight + 10; |
1184 | Event::List eventList; eventList.fill( mCalendar->events( qd, true )); | 1192 | Event::List eventList; eventList.fill( mCalendar->events( qd, true )); |
1185 | Event::List::Iterator it; | 1193 | Event::List::Iterator it; |
1186 | Event *currEvent; | 1194 | Event *currEvent; |
1187 | KLocale *local = KGlobal::locale(); | 1195 | KLocale *local = KGlobal::locale(); |
1188 | QString dayName; | 1196 | QString dayName; |
1189 | 1197 | ||
1190 | dayName = local->weekDayName(qd.dayOfWeek()) + ' ' + ' ' + QString::number(qd.day()); | 1198 | dayName = local->weekDayName(qd.dayOfWeek()) + ' ' + ' ' + QString::number(qd.day()); |
1191 | //p.setBrush(QBrush(black)); | 1199 | //p.setBrush(QBrush(black)); |
1192 | // width+1 to make sure there's a continuous, black bar across the top. | 1200 | // width+1 to make sure there's a continuous, black bar across the top. |
1193 | p.setPen( QPen(Qt::black,2)); | 1201 | p.setPen( QPen(Qt::black,2)); |
1194 | p.drawRect(offsetLeft, mHeaderHeight + 5, width +1, mSubHeaderHeight); | 1202 | p.drawRect(offsetLeft, mHeaderHeight + 5, width +1, mSubHeaderHeight); |
1195 | p.setPen( Qt::black); | 1203 | p.setPen( Qt::black); |
1196 | p.setFont(QFont("helvetica", 12, QFont::Bold, true)); | 1204 | p.setFont(QFont("helvetica", 12, QFont::Bold, true)); |
diff --git a/korganizer/calprinter.cpp b/korganizer/calprinter.cpp index 6b5b0fe..0cdf28e 100644 --- a/korganizer/calprinter.cpp +++ b/korganizer/calprinter.cpp | |||
@@ -1,299 +1,299 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
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 <qvbuttongroup.h> | 24 | #include <qvbuttongroup.h> |
25 | #include <qwidgetstack.h> | 25 | #include <qwidgetstack.h> |
26 | #include <qradiobutton.h> | 26 | #include <qradiobutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qsplitter.h> | 32 | #include <qsplitter.h> |
33 | 33 | ||
34 | #include <kprinter.h> | 34 | #include <kprinter.h> |
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <ksimpleconfig.h> | 36 | #include <ksimpleconfig.h> |
37 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | //#include <kdeversion.h> | 39 | //#include <kdeversion.h> |
40 | 40 | ||
41 | #include "koprefsdialog.h" | 41 | #include "koprefsdialog.h" |
42 | 42 | ||
43 | #include "calprinter.h" | 43 | #include "calprinter.h" |
44 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
45 | //#include "calprinter.moc" | 45 | //#include "calprinter.moc" |
46 | 46 | ||
47 | #include "calprintplugins.h" | 47 | #include "calprintplugins.h" |
48 | 48 | ||
49 | CalPrinter::CalPrinter( QWidget *parent, Calendar *calendar ) | 49 | CalPrinter::CalPrinter( QWidget *parent, Calendar *calendar ) |
50 | : QObject( parent, "CalPrinter" ) | 50 | : QObject( parent, "CalPrinter" ) |
51 | { | 51 | { |
52 | mCalendar = calendar; | 52 | mCalendar = calendar; |
53 | mParent = parent; | 53 | mParent = parent; |
54 | mPrinter = new KPrinter; | 54 | mPrinter = new KPrinter; |
55 | mPrinter->setOrientation( KPrinter::Portrait ); | 55 | mPrinter->setOrientation( KPrinter::Portrait ); |
56 | mConfig = new KConfig(locateLocal("config","korganizer_printing.rc" )); | 56 | mConfig = new KConfig(locateLocal("config","korganizer_printing.rc" )); |
57 | //KSimpleConfig( "korganizer_printing.rc" ); | 57 | //KSimpleConfig( "korganizer_printing.rc" ); |
58 | 58 | ||
59 | init( mPrinter, calendar ); | 59 | init( mPrinter, calendar ); |
60 | } | 60 | } |
61 | 61 | ||
62 | CalPrinter::~CalPrinter() | 62 | CalPrinter::~CalPrinter() |
63 | { | 63 | { |
64 | kdDebug() << "~CalPrinter()" << endl; | 64 | kdDebug() << "~CalPrinter()" << endl; |
65 | 65 | ||
66 | CalPrintBase *plug = mPrintPlugins.first(); | 66 | CalPrintBase *plug = mPrintPlugins.first(); |
67 | while ( plug ) { | 67 | while ( plug ) { |
68 | plug->doSaveConfig(); | 68 | plug->doSaveConfig(); |
69 | plug = mPrintPlugins.next(); | 69 | plug = mPrintPlugins.next(); |
70 | } | 70 | } |
71 | mConfig->sync(); | 71 | mConfig->sync(); |
72 | delete mConfig; | 72 | delete mConfig; |
73 | delete mPrintDialog; | 73 | delete mPrintDialog; |
74 | delete mPrinter; | 74 | delete mPrinter; |
75 | } | 75 | } |
76 | 76 | ||
77 | void CalPrinter::init( KPrinter *printer, Calendar *calendar ) | 77 | void CalPrinter::init( KPrinter *printer, Calendar *calendar ) |
78 | { | 78 | { |
79 | mPrintPlugins.setAutoDelete( true ); | 79 | mPrintPlugins.setAutoDelete( true ); |
80 | mPrintPlugins.append( new CalPrintDay( printer, calendar, mConfig ) ); | 80 | mPrintPlugins.append( new CalPrintDay( printer, calendar, mConfig ) ); |
81 | mPrintPlugins.append( new CalPrintWeek( printer, calendar, mConfig ) ); | 81 | mPrintPlugins.append( new CalPrintWeek( printer, calendar, mConfig ) ); |
82 | mPrintPlugins.append( new CalPrintMonth( printer, calendar, mConfig ) ); | 82 | mPrintPlugins.append( new CalPrintMonth( printer, calendar, mConfig ) ); |
83 | mPrintPlugins.append( new CalPrintTodos( printer, calendar, mConfig ) ); | 83 | mPrintPlugins.append( new CalPrintTodos( printer, calendar, mConfig ) ); |
84 | 84 | ||
85 | // TODO_RK: Add a plugin interface here | 85 | // TODO_RK: Add a plugin interface here |
86 | mPrintDialog = new CalPrintDialog( mPrintPlugins, mPrinter, mParent ); | 86 | mPrintDialog = new CalPrintDialog( mPrintPlugins, mPrinter, mParent ); |
87 | 87 | ||
88 | CalPrintBase *plug = mPrintPlugins.first(); | 88 | CalPrintBase *plug = mPrintPlugins.first(); |
89 | while ( plug ) { | 89 | while ( plug ) { |
90 | connect( mPrintDialog, SIGNAL( okClicked() ), | 90 | connect( mPrintDialog, SIGNAL( okClicked() ), |
91 | plug, SLOT( readSettingsWidget() ) ); | 91 | plug, SLOT( readSettingsWidget() ) ); |
92 | 92 | ||
93 | plug->doLoadConfig(); | 93 | plug->doLoadConfig(); |
94 | 94 | ||
95 | plug = mPrintPlugins.next(); | 95 | plug = mPrintPlugins.next(); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | void CalPrinter::setupPrinter() | 99 | void CalPrinter::setupPrinter() |
100 | { | 100 | { |
101 | KMessageBox::sorry( mParent, i18n("Not implemented.") ); | 101 | KMessageBox::sorry( mParent, i18n("Not implemented.") ); |
102 | #if 0 | 102 | #if 0 |
103 | KOPrefsDialog *optionsDlg = new KOPrefsDialog(mParent); | 103 | KOPrefsDialog *optionsDlg = new KOPrefsDialog(mParent); |
104 | optionsDlg->readConfig(); | 104 | optionsDlg->readConfig(); |
105 | optionsDlg->showPrinterTab(); | 105 | optionsDlg->showPrinterTab(); |
106 | connect(optionsDlg, SIGNAL(configChanged()), | 106 | connect(optionsDlg, SIGNAL(configChanged()), |
107 | mParent, SLOT(updateConfig())); | 107 | mParent, SLOT(updateConfig())); |
108 | optionsDlg->show(); | 108 | optionsDlg->show(); |
109 | #endif | 109 | #endif |
110 | } | 110 | } |
111 | 111 | ||
112 | void CalPrinter::setDateRange( const QDate &fd, const QDate &td ) | 112 | void CalPrinter::setDateRange( const QDate &fd, const QDate &td ) |
113 | { | 113 | { |
114 | CalPrintBase *plug = mPrintPlugins.first(); | 114 | CalPrintBase *plug = mPrintPlugins.first(); |
115 | while ( plug ) { | 115 | while ( plug ) { |
116 | plug->setDateRange( fd, td ); | 116 | plug->setDateRange( fd, td ); |
117 | plug = mPrintPlugins.next(); | 117 | plug = mPrintPlugins.next(); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | void CalPrinter::preview( PrintType type, const QDate &fd, const QDate &td ) | 121 | void CalPrinter::preview( PrintType type, const QDate &fd, const QDate &td ) |
122 | { | 122 | { |
123 | mPrintDialog->setPreview( true ); | 123 | mPrintDialog->setPreview( true ); |
124 | mPrintDialog->setPrintType( int( type ) ); | 124 | mPrintDialog->setPrintType( int( type ) ); |
125 | setDateRange( fd, td ); | 125 | setDateRange( fd, td ); |
126 | 126 | ||
127 | if ( mPrintDialog->exec() == QDialog::Accepted ) { | 127 | if ( mPrintDialog->exec() == QDialog::Accepted ) { |
128 | doPrint( mPrintDialog->selectedPlugin(), true ); | 128 | doPrint( mPrintDialog->selectedPlugin(), true ); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | void CalPrinter::print( PrintType type, const QDate &fd, const QDate &td ) | 132 | void CalPrinter::print( PrintType type, const QDate &fd, const QDate &td ) |
133 | { | 133 | { |
134 | mPrintDialog->resize( 640, 380 ); | 134 | mPrintDialog->resize( 640, 440 ); |
135 | mPrintDialog->setPreview( false ); | 135 | mPrintDialog->setPreview( false ); |
136 | mPrintDialog->setPrintType( int( type ) ); | 136 | mPrintDialog->setPrintType( int( type ) ); |
137 | setDateRange( fd, td ); | 137 | setDateRange( fd, td ); |
138 | 138 | ||
139 | if ( mPrintDialog->exec() == QDialog::Accepted ) { | 139 | if ( mPrintDialog->exec() == QDialog::Accepted ) { |
140 | doPrint( mPrintDialog->selectedPlugin(), false ); | 140 | doPrint( mPrintDialog->selectedPlugin(), false ); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void CalPrinter::doPrint( CalPrintBase *selectedStyle, bool preview ) | 144 | void CalPrinter::doPrint( CalPrintBase *selectedStyle, bool preview ) |
145 | { | 145 | { |
146 | // FIXME: add a better caption to the Printingdialog | 146 | // FIXME: add a better caption to the Printingdialog |
147 | //mPrinter->setPreviewOnly( preview ); | 147 | //mPrinter->setPreviewOnly( preview ); |
148 | if ( preview || mPrinter->setup( mParent ) ) { | 148 | if ( preview || mPrinter->setup( mParent ) ) { |
149 | switch ( mPrintDialog->orientation() ) { | 149 | switch ( mPrintDialog->orientation() ) { |
150 | case eOrientPlugin: | 150 | case eOrientPlugin: |
151 | mPrinter->setOrientation( selectedStyle->orientation()); | 151 | mPrinter->setOrientation( selectedStyle->orientation()); |
152 | break; | 152 | break; |
153 | case eOrientPortrait: | 153 | case eOrientPortrait: |
154 | mPrinter->setOrientation( KPrinter::Portrait ); | 154 | mPrinter->setOrientation( KPrinter::Portrait ); |
155 | break; | 155 | break; |
156 | case eOrientLandscape: | 156 | case eOrientLandscape: |
157 | mPrinter->setOrientation( KPrinter::Landscape ); | 157 | mPrinter->setOrientation( KPrinter::Landscape ); |
158 | break; | 158 | break; |
159 | case eOrientPrinter: | 159 | case eOrientPrinter: |
160 | default: | 160 | default: |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | selectedStyle->doPrint(); | 163 | selectedStyle->doPrint(); |
164 | } | 164 | } |
165 | //mPrinter->setPreviewOnly( false ); | 165 | //mPrinter->setPreviewOnly( false ); |
166 | } | 166 | } |
167 | 167 | ||
168 | /////////////////////////////////////////////////////////////////////////////// | 168 | /////////////////////////////////////////////////////////////////////////////// |
169 | 169 | ||
170 | void CalPrinter::updateConfig() | 170 | void CalPrinter::updateConfig() |
171 | { | 171 | { |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | /****************************************************************************/ | 175 | /****************************************************************************/ |
176 | 176 | ||
177 | CalPrintDialog::CalPrintDialog( QPtrList<CalPrintBase> plugins, KPrinter *p, | 177 | CalPrintDialog::CalPrintDialog( QPtrList<CalPrintBase> plugins, KPrinter *p, |
178 | QWidget *parent, const char *name ) | 178 | QWidget *parent, const char *name ) |
179 | : KDialogBase( parent, name, /*modal*/true, i18n("Print"), Ok | Cancel ), | 179 | : KDialogBase( parent, name, /*modal*/true, i18n("Print"), Ok | Cancel ), |
180 | mPrinter( p ), mPrintPlugins( plugins ) | 180 | mPrinter( p ), mPrintPlugins( plugins ) |
181 | { | 181 | { |
182 | QVBox *page = new QVBox(this);//makeVBoxMainWidget(); | 182 | QVBox *page = new QVBox(this);//makeVBoxMainWidget(); |
183 | setMainWidget( page ); | 183 | setMainWidget( page ); |
184 | QHBox *printerLayout = new QHBox( page ); | 184 | QHBox *printerLayout = new QHBox( page ); |
185 | 185 | ||
186 | mPrinterLabel = new QLabel( printerLayout ); | 186 | mPrinterLabel = new QLabel( printerLayout ); |
187 | QPushButton *setupButton = new QPushButton( i18n("&Setup Printer..."), | 187 | QPushButton *setupButton = new QPushButton( i18n("&Setup Printer..."), |
188 | printerLayout ); | 188 | printerLayout ); |
189 | setupButton->setSizePolicy( QSizePolicy( | 189 | setupButton->setSizePolicy( QSizePolicy( |
190 | (QSizePolicy::SizeType)4, (QSizePolicy::SizeType)0, | 190 | (QSizePolicy::SizeType)4, (QSizePolicy::SizeType)0, |
191 | 0, 0, setupButton->sizePolicy().hasHeightForWidth() ) ); | 191 | 0, 0, setupButton->sizePolicy().hasHeightForWidth() ) ); |
192 | 192 | ||
193 | QSplitter *splitter = new QSplitter( page ); | 193 | QSplitter *splitter = new QSplitter( page ); |
194 | splitter->setOrientation( QSplitter::Horizontal ); | 194 | splitter->setOrientation( QSplitter::Horizontal ); |
195 | 195 | ||
196 | mTypeGroup = new QVButtonGroup( i18n("View Type"), splitter, "buttonGroup" ); | 196 | mTypeGroup = new QVButtonGroup( i18n("View Type"), splitter, "buttonGroup" ); |
197 | // use the minimal width possible = max width of the radio buttons, not extensible | 197 | // use the minimal width possible = max width of the radio buttons, not extensible |
198 | /* mTypeGroup->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)4, | 198 | /* mTypeGroup->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)4, |
199 | (QSizePolicy::SizeType)5, 0, 0, | 199 | (QSizePolicy::SizeType)5, 0, 0, |
200 | mTypeGroup->sizePolicy().hasHeightForWidth() ) );*/ | 200 | mTypeGroup->sizePolicy().hasHeightForWidth() ) );*/ |
201 | 201 | ||
202 | QWidget *splitterRight = new QWidget( splitter, "splitterRight" ); | 202 | QWidget *splitterRight = new QWidget( splitter, "splitterRight" ); |
203 | QGridLayout *splitterRightLayout = new QGridLayout( splitterRight ); | 203 | QGridLayout *splitterRightLayout = new QGridLayout( splitterRight ); |
204 | splitterRightLayout->setMargin( marginHint() ); | 204 | splitterRightLayout->setMargin( marginHint() ); |
205 | splitterRightLayout->setSpacing( spacingHint() ); | 205 | splitterRightLayout->setSpacing( spacingHint() ); |
206 | 206 | ||
207 | mConfigArea = new QWidgetStack( splitterRight, "configWidgetStack" ); | 207 | mConfigArea = new QWidgetStack( splitterRight, "configWidgetStack" ); |
208 | splitterRightLayout->addMultiCellWidget( mConfigArea, 0,0, 0,1 ); | 208 | splitterRightLayout->addMultiCellWidget( mConfigArea, 0,0, 0,1 ); |
209 | 209 | ||
210 | QLabel *orientationLabel = new QLabel( i18n("Page &orientation:"), | 210 | QLabel *orientationLabel = new QLabel( i18n("Page &orientation:"), |
211 | splitterRight, "orientationLabel" ); | 211 | splitterRight, "orientationLabel" ); |
212 | splitterRightLayout->addWidget( orientationLabel, 1, 0 ); | 212 | splitterRightLayout->addWidget( orientationLabel, 1, 0 ); |
213 | 213 | ||
214 | mOrientationSelection = new QComboBox( splitterRight, "orientationCombo" ); | 214 | mOrientationSelection = new QComboBox( splitterRight, "orientationCombo" ); |
215 | mOrientationSelection->insertItem( i18n("Use Default of Selected Style") ); | 215 | mOrientationSelection->insertItem( i18n("Use Default of Selected Style") ); |
216 | mOrientationSelection->insertItem( i18n("Use Default Setting of Printer") ); | 216 | mOrientationSelection->insertItem( i18n("Use Default Setting of Printer") ); |
217 | mOrientationSelection->insertItem( i18n("Portrait") ); | 217 | mOrientationSelection->insertItem( i18n("Portrait") ); |
218 | mOrientationSelection->insertItem( i18n("Landscape") ); | 218 | mOrientationSelection->insertItem( i18n("Landscape") ); |
219 | splitterRightLayout->addWidget( mOrientationSelection, 1, 1 ); | 219 | splitterRightLayout->addWidget( mOrientationSelection, 1, 1 ); |
220 | 220 | ||
221 | // signals and slots connections | 221 | // signals and slots connections |
222 | connect( setupButton, SIGNAL( clicked() ), SLOT( setupPrinter() ) ); | 222 | connect( setupButton, SIGNAL( clicked() ), SLOT( setupPrinter() ) ); |
223 | connect( mTypeGroup, SIGNAL( clicked( int ) ), SLOT( setPrintType( int ) ) ); | 223 | connect( mTypeGroup, SIGNAL( clicked( int ) ), SLOT( setPrintType( int ) ) ); |
224 | 224 | ||
225 | // buddies | 225 | // buddies |
226 | orientationLabel->setBuddy( mOrientationSelection ); | 226 | orientationLabel->setBuddy( mOrientationSelection ); |
227 | 227 | ||
228 | CalPrintBase *plug = mPrintPlugins.first(); | 228 | CalPrintBase *plug = mPrintPlugins.first(); |
229 | QRadioButton *radioButton; | 229 | QRadioButton *radioButton; |
230 | int id = 0; | 230 | int id = 0; |
231 | while ( plug ) { | 231 | while ( plug ) { |
232 | radioButton = new QRadioButton( plug->description(), mTypeGroup ); | 232 | radioButton = new QRadioButton( plug->description(), mTypeGroup ); |
233 | mTypeGroup->insert( radioButton, id ); | 233 | mTypeGroup->insert( radioButton, id ); |
234 | //radioButton->setMinimumHeight( radioButton->sizeHint().height() - 5 ); | 234 | //radioButton->setMinimumHeight( radioButton->sizeHint().height() - 5 ); |
235 | 235 | ||
236 | mConfigArea->addWidget( plug->configWidget( mConfigArea ), id ); | 236 | mConfigArea->addWidget( plug->configWidget( mConfigArea ), id ); |
237 | 237 | ||
238 | plug = mPrintPlugins.next(); | 238 | plug = mPrintPlugins.next(); |
239 | id++; | 239 | id++; |
240 | } | 240 | } |
241 | 241 | ||
242 | // setMinimumSize( minimumSizeHint() ); | 242 | // setMinimumSize( minimumSizeHint() ); |
243 | //resize( minimumSizeHint() ); | 243 | //resize( minimumSizeHint() ); |
244 | } | 244 | } |
245 | 245 | ||
246 | CalPrintDialog::~CalPrintDialog() | 246 | CalPrintDialog::~CalPrintDialog() |
247 | { | 247 | { |
248 | } | 248 | } |
249 | 249 | ||
250 | void CalPrintDialog::setupPrinter() | 250 | void CalPrintDialog::setupPrinter() |
251 | { | 251 | { |
252 | if ( mPrinter->setup( this ) ) { | 252 | if ( mPrinter->setup( this ) ) { |
253 | setPrinterLabel(); | 253 | setPrinterLabel(); |
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
257 | void CalPrintDialog::setPreview(bool preview) | 257 | void CalPrintDialog::setPreview(bool preview) |
258 | { | 258 | { |
259 | 259 | ||
260 | setButtonText(KDialogBase::Ok, preview ? i18n("&Preview") : i18n("&Print...") ); | 260 | setButtonText(KDialogBase::Ok, preview ? i18n("&Preview") : i18n("&Print...") ); |
261 | 261 | ||
262 | mPreviewText = preview ? i18n("<qt>Preview for printer <b>%1</b></qt>") | 262 | mPreviewText = preview ? i18n("<qt>Preview for printer <b>%1</b></qt>") |
263 | : i18n( "<qt>Printing on printer <b>%1</b></qt>"); | 263 | : i18n( "<qt>Printing on printer <b>%1</b></qt>"); |
264 | setPrinterLabel(); | 264 | setPrinterLabel(); |
265 | } | 265 | } |
266 | 266 | ||
267 | void CalPrintDialog::setPrinterLabel() | 267 | void CalPrintDialog::setPrinterLabel() |
268 | { | 268 | { |
269 | QString printerName( mPrinter->printerName() ); | 269 | QString printerName( mPrinter->printerName() ); |
270 | if ( printerName.isEmpty() ) | 270 | if ( printerName.isEmpty() ) |
271 | mPrinterLabel->setText( mPreviewText.arg( i18n("[Unconfigured]") ) ); | 271 | mPrinterLabel->setText( mPreviewText.arg( i18n("[Unconfigured]") ) ); |
272 | else | 272 | else |
273 | mPrinterLabel->setText( mPreviewText.arg( printerName ) ); | 273 | mPrinterLabel->setText( mPreviewText.arg( printerName ) ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void CalPrintDialog::setPrintType( int i ) | 276 | void CalPrintDialog::setPrintType( int i ) |
277 | { | 277 | { |
278 | // TODO: Make a safe correlation between type and the radio button | 278 | // TODO: Make a safe correlation between type and the radio button |
279 | 279 | ||
280 | mTypeGroup->setButton( i ); | 280 | mTypeGroup->setButton( i ); |
281 | mConfigArea->raiseWidget( i ); | 281 | mConfigArea->raiseWidget( i ); |
282 | } | 282 | } |
283 | 283 | ||
284 | CalPrintBase *CalPrintDialog::selectedPlugin() | 284 | CalPrintBase *CalPrintDialog::selectedPlugin() |
285 | { | 285 | { |
286 | int pos = mTypeGroup->id( mTypeGroup->selected() ); | 286 | int pos = mTypeGroup->id( mTypeGroup->selected() ); |
287 | if ( pos < 0 ) return 0; | 287 | if ( pos < 0 ) return 0; |
288 | CalPrintBase *retval = mPrintPlugins.at( pos ); | 288 | CalPrintBase *retval = mPrintPlugins.at( pos ); |
289 | return retval; | 289 | return retval; |
290 | } | 290 | } |
291 | 291 | ||
292 | void CalPrintDialog::slotOk() | 292 | void CalPrintDialog::slotOk() |
293 | { | 293 | { |
294 | mOrientation = (CalPrinter::ePrintOrientation)mOrientationSelection->currentItem(); | 294 | mOrientation = (CalPrinter::ePrintOrientation)mOrientationSelection->currentItem(); |
295 | KDialogBase::slotOk(); | 295 | KDialogBase::slotOk(); |
296 | emit okClicked(); | 296 | emit okClicked(); |
297 | } | 297 | } |
298 | 298 | ||
299 | #endif | 299 | #endif |