summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calprintbase.cpp26
-rw-r--r--korganizer/calprinter.cpp2
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
@@ -824,277 +824,285 @@ void CalPrintBase::drawTimeTable(QPainter &p,
824 824
825} 825}
826 826
827 827
828/////////////////////////////////////////////////////////////////////////////// 828///////////////////////////////////////////////////////////////////////////////
829 829
830void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, 830void 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
889void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos, 889void 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
1037int CalPrintBase::weekdayColumn( int weekday ) 1045int 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
1042void CalPrintBase::drawSplitWeek( QPainter &p, const QDate &fd, 1050void 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,
diff --git a/korganizer/calprinter.cpp b/korganizer/calprinter.cpp
index 6b5b0fe..0cdf28e 100644
--- a/korganizer/calprinter.cpp
+++ b/korganizer/calprinter.cpp
@@ -38,193 +38,193 @@
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
49CalPrinter::CalPrinter( QWidget *parent, Calendar *calendar ) 49CalPrinter::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
62CalPrinter::~CalPrinter() 62CalPrinter::~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
77void CalPrinter::init( KPrinter *printer, Calendar *calendar ) 77void 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
99void CalPrinter::setupPrinter() 99void 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
112void CalPrinter::setDateRange( const QDate &fd, const QDate &td ) 112void 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
121void CalPrinter::preview( PrintType type, const QDate &fd, const QDate &td ) 121void 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
132void CalPrinter::print( PrintType type, const QDate &fd, const QDate &td ) 132void 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
144void CalPrinter::doPrint( CalPrintBase *selectedStyle, bool preview ) 144void 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
170void CalPrinter::updateConfig() 170void CalPrinter::updateConfig()
171{ 171{
172} 172}
173 173
174 174
175/****************************************************************************/ 175/****************************************************************************/
176 176
177CalPrintDialog::CalPrintDialog( QPtrList<CalPrintBase> plugins, KPrinter *p, 177CalPrintDialog::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;