summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-08 09:24:53 (UTC)
committer zautrix <zautrix>2005-03-08 09:24:53 (UTC)
commit91e7aeec0b15d28eb263c0699fdce4a00a3669c6 (patch) (unidiff)
tree10bf2d72c94ab030c7a08b22d0880997c99dcfff
parenta50b432c475d2a0b97b3f8707666f7d2990cd8db (diff)
downloadkdepimpi-91e7aeec0b15d28eb263c0699fdce4a00a3669c6.zip
kdepimpi-91e7aeec0b15d28eb263c0699fdce4a00a3669c6.tar.gz
kdepimpi-91e7aeec0b15d28eb263c0699fdce4a00a3669c6.tar.bz2
todo printing fixes
Diffstat (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
@@ -536,769 +536,777 @@ void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events,
536 float currY = y; 536 float currY = y;
537 537
538 // print grid: 538 // print grid:
539 QTime curTime( QTime( fromTime.hour(), 0, 0 ) ); 539 QTime curTime( QTime( fromTime.hour(), 0, 0 ) );
540 currY += fromTime.secsTo( curTime ) * minlen / 60; 540 currY += fromTime.secsTo( curTime ) * minlen / 60;
541 541
542 while ( curTime < toTime && curTime.isValid() ) { 542 while ( curTime < toTime && curTime.isValid() ) {
543 if ( currY > y ) p.drawLine( x, int( currY ), x + width, int( currY ) ); 543 if ( currY > y ) p.drawLine( x, int( currY ), x + width, int( currY ) );
544 currY += cellHeight / 2; 544 currY += cellHeight / 2;
545 if ( ( currY > y ) && ( currY < y + height ) ) { 545 if ( ( currY > y ) && ( currY < y + height ) ) {
546 QPen oldPen( p.pen() ); 546 QPen oldPen( p.pen() );
547 p.setPen( QColor( 192, 192, 192 ) ); 547 p.setPen( QColor( 192, 192, 192 ) );
548 p.drawLine( x, int( currY ), x + width, int( currY ) ); 548 p.drawLine( x, int( currY ), x + width, int( currY ) );
549 p.setPen( oldPen ); 549 p.setPen( oldPen );
550 } // enough space for half-hour line 550 } // enough space for half-hour line
551 if ( curTime.secsTo( toTime ) > 3600 ) 551 if ( curTime.secsTo( toTime ) > 3600 )
552 curTime = curTime.addSecs( 3600 ); 552 curTime = curTime.addSecs( 3600 );
553 else curTime = toTime; 553 else curTime = toTime;
554 currY += cellHeight / 2; 554 currY += cellHeight / 2;
555 } 555 }
556 556
557 QDateTime startPrintDate = QDateTime( qd, fromTime ); 557 QDateTime startPrintDate = QDateTime( qd, fromTime );
558 QDateTime endPrintDate = QDateTime( qd, toTime ); 558 QDateTime endPrintDate = QDateTime( qd, toTime );
559 559
560 // Calculate horizontal positions and widths of events taking into account 560 // Calculate horizontal positions and widths of events taking into account
561 // overlapping events 561 // overlapping events
562 562
563 QPtrList<KOrg::CellItem> cells; 563 QPtrList<KOrg::CellItem> cells;
564 cells.setAutoDelete( true ); 564 cells.setAutoDelete( true );
565 565
566 Event::List::ConstIterator itEvents; 566 Event::List::ConstIterator itEvents;
567 for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) { 567 for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) {
568 cells.append( new PrintCellItem( *itEvents, qd ) ); 568 cells.append( new PrintCellItem( *itEvents, qd ) );
569 } 569 }
570 570
571 QPtrListIterator<KOrg::CellItem> it1( cells ); 571 QPtrListIterator<KOrg::CellItem> it1( cells );
572 for( it1.toFirst(); it1.current(); ++it1 ) { 572 for( it1.toFirst(); it1.current(); ++it1 ) {
573 KOrg::CellItem *placeItem = it1.current(); 573 KOrg::CellItem *placeItem = it1.current();
574 574
575 KOrg::CellItem::placeItem( cells, placeItem ); 575 KOrg::CellItem::placeItem( cells, placeItem );
576 } 576 }
577 577
578 QPen oldPen = p.pen(); 578 QPen oldPen = p.pen();
579 QColor oldBgColor = p.backgroundColor(); 579 QColor oldBgColor = p.backgroundColor();
580 QBrush oldBrush = p.brush(); 580 QBrush oldBrush = p.brush();
581 581
582 p.setFont( QFont( "helvetica", 10 ) ); 582 p.setFont( QFont( "helvetica", 10 ) );
583 //p.setBrush( QBrush( Dense7Pattern ) ); 583 //p.setBrush( QBrush( Dense7Pattern ) );
584 584
585 for( it1.toFirst(); it1.current(); ++it1 ) { 585 for( it1.toFirst(); it1.current(); ++it1 ) {
586 PrintCellItem *placeItem = static_cast<PrintCellItem *>( it1.current() ); 586 PrintCellItem *placeItem = static_cast<PrintCellItem *>( it1.current() );
587 587
588 drawAgendaItem( placeItem, p, qd, startPrintDate, endPrintDate, minlen, x, 588 drawAgendaItem( placeItem, p, qd, startPrintDate, endPrintDate, minlen, x,
589 y, width ); 589 y, width );
590 590
591 p.setBrush( oldBrush ); 591 p.setBrush( oldBrush );
592 p.setPen( oldPen ); 592 p.setPen( oldPen );
593 p.setBackgroundColor( oldBgColor ); 593 p.setBackgroundColor( oldBgColor );
594 } 594 }
595 595
596 p.setBrush( QBrush( NoBrush ) ); 596 p.setBrush( QBrush( NoBrush ) );
597} 597}
598 598
599 599
600void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, 600void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p,
601 const QDate &qd, 601 const QDate &qd,
602 const QDateTime &startPrintDate, 602 const QDateTime &startPrintDate,
603 const QDateTime &endPrintDate, 603 const QDateTime &endPrintDate,
604 float minlen, int x, int y, int width ) 604 float minlen, int x, int y, int width )
605{ 605{
606 Event *event = item->event(); 606 Event *event = item->event();
607 607
608 // set the colors according to the categories 608 // set the colors according to the categories
609 if ( mUseColors ) setCategoryColors( p, event ); 609 if ( mUseColors ) setCategoryColors( p, event );
610 else p.setBrush( Qt::white ); 610 else p.setBrush( Qt::white );
611 // start/end of print area for event 611 // start/end of print area for event
612 QDateTime startTime = event->dtStart(); 612 QDateTime startTime = event->dtStart();
613 QDateTime endTime = event->dtEnd(); 613 QDateTime endTime = event->dtEnd();
614 if ( event->doesRecur() ) { 614 if ( event->doesRecur() ) {
615 startTime.setDate( qd ); 615 startTime.setDate( qd );
616 endTime.setDate( qd ); 616 endTime.setDate( qd );
617 } 617 }
618 if ( ( startTime < endPrintDate && endTime > startPrintDate ) || 618 if ( ( startTime < endPrintDate && endTime > startPrintDate ) ||
619 ( endTime > startPrintDate && startTime < endPrintDate ) ) { 619 ( endTime > startPrintDate && startTime < endPrintDate ) ) {
620 if ( startTime < startPrintDate ) startTime = startPrintDate; 620 if ( startTime < startPrintDate ) startTime = startPrintDate;
621 if ( endTime > endPrintDate ) endTime = endPrintDate; 621 if ( endTime > endPrintDate ) endTime = endPrintDate;
622 int eventLength = int( startTime.secsTo( endTime ) / 60. * minlen ); 622 int eventLength = int( startTime.secsTo( endTime ) / 60. * minlen );
623 int currentyPos = int( y + startPrintDate.secsTo( startTime ) * 623 int currentyPos = int( y + startPrintDate.secsTo( startTime ) *
624 minlen / 60. ); 624 minlen / 60. );
625 int currentWidth = width / item->subCells(); 625 int currentWidth = width / item->subCells();
626 int currentX = x + item->subCell() * currentWidth; 626 int currentX = x + item->subCell() * currentWidth;
627 QString text = KGlobal::locale()->formatTime(event->dtStart().time())+ 627 QString text = KGlobal::locale()->formatTime(event->dtStart().time())+
628 "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+ 628 "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+
629 " "+event->summary(); 629 " "+event->summary();
630 if ( !event->location().isEmpty() ) 630 if ( !event->location().isEmpty() )
631 text += " (" +event->location()+")"; 631 text += " (" +event->location()+")";
632 // p.save(); 632 // p.save();
633 QPen pe = p.pen(); 633 QPen pe = p.pen();
634 pe.setWidth( 2 ); 634 pe.setWidth( 2 );
635 p.setPen( pe ); 635 p.setPen( pe );
636 p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 ); 636 p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 );
637 p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3, 637 p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3,
638 AlignLeft | AlignTop | AlignJustify | WordBreak, 638 AlignLeft | AlignTop | AlignJustify | WordBreak,
639 text); 639 text);
640 // p.restore(); 640 // p.restore();
641 } 641 }
642} 642}
643 643
644void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, 644void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd,
645 int x, int y, int width, int height, 645 int x, int y, int width, int height,
646 bool fullDate) 646 bool fullDate)
647{ 647{
648 QString dayNumStr; 648 QString dayNumStr;
649 QString ampm; 649 QString ampm;
650 const KLocale*local = KGlobal::locale(); 650 const KLocale*local = KGlobal::locale();
651 651
652 652
653 // This has to be localized 653 // This has to be localized
654 if (fullDate) { 654 if (fullDate) {
655 /*int index; 655 /*int index;
656 dayNumStr= qd.toString(); 656 dayNumStr= qd.toString();
657 index = dayNumStr.find(' '); 657 index = dayNumStr.find(' ');
658 dayNumStr.remove(0, index); 658 dayNumStr.remove(0, index);
659 index = dayNumStr.findRev(' '); 659 index = dayNumStr.findRev(' ');
660 dayNumStr.truncate(index);*/ 660 dayNumStr.truncate(index);*/
661 661
662 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 662 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
663 dayNumStr = i18n("weekday month date", "%1 %2 %3") 663 dayNumStr = i18n("weekday month date", "%1 %2 %3")
664 .arg( calSys->weekDayName( qd ) ) 664 .arg( calSys->weekDayName( qd ) )
665 .arg( calSys->monthName( qd ) ) 665 .arg( calSys->monthName( qd ) )
666 .arg( qd.day() ); 666 .arg( qd.day() );
667// dayNumStr = local->formatDate(qd); 667// dayNumStr = local->formatDate(qd);
668 } else { 668 } else {
669 dayNumStr = QString::number( qd.day() ); 669 dayNumStr = QString::number( qd.day() );
670 } 670 }
671 671
672 p.eraseRect( x, y, width, height ); 672 p.eraseRect( x, y, width, height );
673 p.drawRect( x, y, width, height ); 673 p.drawRect( x, y, width, height );
674 // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) ); 674 // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) );
675 p.drawRect( x, y, width, mSubHeaderHeight ); 675 p.drawRect( x, y, width, mSubHeaderHeight );
676 //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) ); 676 //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) );
677 QString hstring; 677 QString hstring;
678#ifndef KORG_NOPLUGINS 678#ifndef KORG_NOPLUGINS
679 hstring=KOCore::self()->holiday(qd); 679 hstring=KOCore::self()->holiday(qd);
680#endif 680#endif
681 681
682 if (!hstring.isEmpty()) { 682 if (!hstring.isEmpty()) {
683 p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) ); 683 p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) );
684 684
685 p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter, 685 p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter,
686 hstring ); 686 hstring );
687 } 687 }
688 p.setFont(QFont("helvetica", 10, QFont::Bold)); 688 p.setFont(QFont("helvetica", 10, QFont::Bold));
689 p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter, 689 p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter,
690 dayNumStr); 690 dayNumStr);
691 Event::List eventList; 691 Event::List eventList;
692 eventList.fill( mCalendar->events( qd, true )); 692 eventList.fill( mCalendar->events( qd, true ));
693 Todo::List todos; 693 Todo::List todos;
694 todos.fill( mCalendar->todos( qd )); 694 todos.fill( mCalendar->todos( qd ));
695 QString outStr; 695 QString outStr;
696 p.setFont( QFont( "helvetica", 8 ) ); 696 p.setFont( QFont( "helvetica", 8 ) );
697 int lineSpacing = p.fontMetrics().lineSpacing(); 697 int lineSpacing = p.fontMetrics().lineSpacing();
698 698
699 int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry 699 int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry
700 Event::List::ConstIterator it; 700 Event::List::ConstIterator it;
701 int entryCount = eventList.count() +todos.count(); 701 int entryCount = eventList.count() +todos.count();
702 if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) { 702 if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) {
703 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) { 703 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) {
704 p.setFont( QFont( "helvetica", 7 ) ); 704 p.setFont( QFont( "helvetica", 7 ) );
705 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) 705 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY )
706 p.setFont( QFont( "helvetica", 6 ) ); 706 p.setFont( QFont( "helvetica", 6 ) );
707 } 707 }
708 lineSpacing = p.fontMetrics().lineSpacing()-1; 708 lineSpacing = p.fontMetrics().lineSpacing()-1;
709 } 709 }
710 // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY ); 710 // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY );
711 for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) { 711 for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) {
712 Event *currEvent = *it; 712 Event *currEvent = *it;
713 if (currEvent->doesFloat() || currEvent->isMultiDay()) 713 if (currEvent->doesFloat() || currEvent->isMultiDay())
714 outStr = currEvent->summary(); 714 outStr = currEvent->summary();
715 715
716 else { 716 else {
717 if ( fullDate ) { 717 if ( fullDate ) {
718 outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+ 718 outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+
719 "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+ 719 "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+
720 " "+ currEvent->summary(); 720 " "+ currEvent->summary();
721 if ( ! currEvent->location().isEmpty() ) 721 if ( ! currEvent->location().isEmpty() )
722 outStr += " (" + currEvent->location()+")"; 722 outStr += " (" + currEvent->location()+")";
723 } else { 723 } else {
724 QTime t1 = currEvent->dtStart().time(); 724 QTime t1 = currEvent->dtStart().time();
725 725
726 outStr = local->formatTime(t1); 726 outStr = local->formatTime(t1);
727 outStr += " " + currEvent->summary(); 727 outStr += " " + currEvent->summary();
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
761void CalPrintBase::drawWeek(QPainter &p, const QDate &qd, 761void 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
796void CalPrintBase::drawTimeTable(QPainter &p, 796void 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
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,
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
1130void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, 1138void 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
1176void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, 1184void 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));
1197 p.drawText(offsetLeft, mHeaderHeight + 5, 1205 p.drawText(offsetLeft, mHeaderHeight + 5,
1198 width, mSubHeaderHeight, AlignHCenter | AlignVCenter, 1206 width, mSubHeaderHeight, AlignHCenter | AlignVCenter,
1199 dayName); 1207 dayName);
1200 1208
1201 p.setPen( QPen(Qt::black,2)); 1209 p.setPen( QPen(Qt::black,2));
1202 p.setFont(QFont("helvetica", 12)); 1210 p.setFont(QFont("helvetica", 12));
1203 p.setBrush(Qt::white); 1211 p.setBrush(Qt::white);
1204 it = eventList.begin(); 1212 it = eventList.begin();
1205 int allDays = 0; 1213 int allDays = 0;
1206 /* 1214 /*
1207 while( it != eventList.end() ) { 1215 while( it != eventList.end() ) {
1208 Event *currEvent = *it; 1216 Event *currEvent = *it;
1209 if ( currEvent->doesFloat() ) { 1217 if ( currEvent->doesFloat() ) {
1210 p.drawRect( offsetLeft, offset, width, 35 ); 1218 p.drawRect( offsetLeft, offset, width, 35 );
1211 p.drawText( offsetLeft + 5, offset + 10, width - 10, 30, 1219 p.drawText( offsetLeft + 5, offset + 10, width - 10, 30,
1212 AlignLeft | AlignTop, currEvent->summary() ); 1220 AlignLeft | AlignTop, currEvent->summary() );
1213 offset += 40; 1221 offset += 40;
1214 allDays++; 1222 allDays++;
1215 it = eventList.remove( it ); 1223 it = eventList.remove( it );
1216 } else { 1224 } else {
1217 ++it; 1225 ++it;
1218 } 1226 }
1219 } 1227 }
1220 */ 1228 */
1221 //p.setBrush(QBrush()); 1229 //p.setBrush(QBrush());
1222 int tmpEnd; 1230 int tmpEnd;
1223 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 1231 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
1224 Event *currEvent = *it; 1232 Event *currEvent = *it;
1225 tmpEnd = currEvent->dtEnd().time().hour(); 1233 tmpEnd = currEvent->dtEnd().time().hour();
1226 if (currEvent->dtEnd().time().minute() > 0) 1234 if (currEvent->dtEnd().time().minute() > 0)
1227 tmpEnd++; 1235 tmpEnd++;
1228 if (tmpEnd > endHour) 1236 if (tmpEnd > endHour)
1229 endHour = tmpEnd; 1237 endHour = tmpEnd;
1230 } 1238 }
1231 int hours = endHour - startHour; 1239 int hours = endHour - startHour;
1232 int cellHeight = (height-offset) / hours; // hour increments. 1240 int cellHeight = (height-offset) / hours; // hour increments.
1233 1241
1234 p.setFont(QFont("helvetica", 12)); 1242 p.setFont(QFont("helvetica", 12));
1235 //p.setBrush(QBrush(Dense7Pattern)); 1243 //p.setBrush(QBrush(Dense7Pattern));
1236 p.setBrush(Qt::white); 1244 p.setBrush(Qt::white);
1237 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 1245 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
1238 Event *currEvent = *it; 1246 Event *currEvent = *it;
1239 int startTime = currEvent->dtStart().time().hour(); 1247 int startTime = currEvent->dtStart().time().hour();
1240 int endTime = currEvent->dtEnd().time().hour(); 1248 int endTime = currEvent->dtEnd().time().hour();
1241 float minuteInc = cellHeight / 60.0; 1249 float minuteInc = cellHeight / 60.0;
1242 if ((startTime >= startHour) && (endTime <= (startHour + hours))) { 1250 if ((startTime >= startHour) && (endTime <= (startHour + hours))) {
1243 startTime -= startHour; 1251 startTime -= startHour;
1244 int startMinuteOff = (int) (minuteInc * 1252 int startMinuteOff = (int) (minuteInc *
1245 currEvent->dtStart().time().minute()); 1253 currEvent->dtStart().time().minute());
1246 QString text = currEvent->summary() ; 1254 QString text = currEvent->summary() ;
1247 if ( ! currEvent->location().isEmpty() ) 1255 if ( ! currEvent->location().isEmpty() )
1248 text += "\n("+currEvent->location()+")"; 1256 text += "\n("+currEvent->location()+")";
1249 int endMinuteOff = (int) (minuteInc * currEvent->dtEnd().time().minute()); 1257 int endMinuteOff = (int) (minuteInc * currEvent->dtEnd().time().minute());
1250 int cheight = (int) (minuteInc * 1258 int cheight = (int) (minuteInc *
1251 currEvent->dtStart().secsTo(currEvent->dtEnd()) / 60 ); 1259 currEvent->dtStart().secsTo(currEvent->dtEnd()) / 60 );
1252 p.drawRect(offsetLeft+2, 1+offset+startMinuteOff+startTime*cellHeight, 1260 p.drawRect(offsetLeft+2, 1+offset+startMinuteOff+startTime*cellHeight,
1253 width-4, cheight); 1261 width-4, cheight);
1254 p.drawText(offsetLeft+12, offset+startMinuteOff+startTime*cellHeight+5, width-24, 1262 p.drawText(offsetLeft+12, offset+startMinuteOff+startTime*cellHeight+5, width-24,
1255 cheight-10, AlignHCenter | AlignTop, text); 1263 cheight-10, AlignHCenter | AlignTop, text);
1256 } 1264 }
1257 } 1265 }
1258 p.setBrush(QBrush(NoBrush)); 1266 p.setBrush(QBrush(NoBrush));
1259 mSubHeaderHeight = tempStore ; 1267 mSubHeaderHeight = tempStore ;
1260} 1268}
1261 1269
1262void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth, 1270void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth,
1263 int height ) 1271 int height )
1264{ 1272{
1265 int tempStore = mSubHeaderHeight; 1273 int tempStore = mSubHeaderHeight;
1266 mSubHeaderHeight+= mSubHeaderHeight; 1274 mSubHeaderHeight+= mSubHeaderHeight;
1267 int startHour = KOPrefs::instance()->mDayBegins; 1275 int startHour = KOPrefs::instance()->mDayBegins;
1268 int endHour = 20; 1276 int endHour = 20;
1269 int offset = mHeaderHeight + mSubHeaderHeight + 10; 1277 int offset = mHeaderHeight + mSubHeaderHeight + 10;
1270 int hours = endHour - startHour; 1278 int hours = endHour - startHour;
1271 int cellHeight = (height-offset) / hours; // hour increments. 1279 int cellHeight = (height-offset) / hours; // hour increments.
1272 1280
1273 QString numStr; 1281 QString numStr;
1274 for (int i = 0; i < hours; i++) { 1282 for (int i = 0; i < hours; i++) {
1275 p.setPen(QPen(black,1)); 1283 p.setPen(QPen(black,1));
1276 p.drawLine(0, offset+i*cellHeight, width, offset+i*cellHeight); 1284 p.drawLine(0, offset+i*cellHeight, width, offset+i*cellHeight);
1277 p.setPen(QPen(gray,0)); 1285 p.setPen(QPen(gray,0));
1278 p.drawLine(37, offset+i*cellHeight+(cellHeight/2), 1286 p.drawLine(37, offset+i*cellHeight+(cellHeight/2),
1279 width, offset+i*cellHeight+(cellHeight/2)); 1287 width, offset+i*cellHeight+(cellHeight/2));
1280 p.setPen(QPen(black,0)); 1288 p.setPen(QPen(black,0));
1281 1289
1282 if ( !KGlobal::locale()->use12Clock() ) { 1290 if ( !KGlobal::locale()->use12Clock() ) {
1283 numStr.setNum(i+startHour); 1291 numStr.setNum(i+startHour);
1284 if (cellHeight > 40) { 1292 if (cellHeight > 40) {
1285 p.setFont(QFont("helvetica", 16, QFont::Bold)); 1293 p.setFont(QFont("helvetica", 16, QFont::Bold));
1286 } else { 1294 } else {
1287 p.setFont(QFont("helvetica", 14, QFont::Bold)); 1295 p.setFont(QFont("helvetica", 14, QFont::Bold));
1288 } 1296 }
1289 p.drawText(0, offset+i*cellHeight, 33, cellHeight/2, 1297 p.drawText(0, offset+i*cellHeight, 33, cellHeight/2,
1290 AlignTop|AlignRight, numStr); 1298 AlignTop|AlignRight, numStr);
1291 p.setFont(QFont("helvetica", 12, QFont::Bold)); 1299 p.setFont(QFont("helvetica", 12, QFont::Bold));
1292 p.drawText(37, offset+i*cellHeight, 45, cellHeight/2, 1300 p.drawText(37, offset+i*cellHeight, 45, cellHeight/2,
1293 AlignTop | AlignLeft, "00"); 1301 AlignTop | AlignLeft, "00");
1294 } else { 1302 } else {
1295 QTime time( i + startHour, 0 ); 1303 QTime time( i + startHour, 0 );
1296 numStr = KGlobal::locale()->formatTime( time ); 1304 numStr = KGlobal::locale()->formatTime( time );
1297 p.setFont(QFont("helvetica", 12, QFont::Bold)); 1305 p.setFont(QFont("helvetica", 12, QFont::Bold));
1298 p.drawText(4, offset+i*cellHeight, 70, cellHeight/2, 1306 p.drawText(4, offset+i*cellHeight, 70, cellHeight/2,
1299 AlignTop|AlignLeft, numStr); 1307 AlignTop|AlignLeft, numStr);
1300 } 1308 }
1301 } mSubHeaderHeight = tempStore ; 1309 } mSubHeaderHeight = tempStore ;
1302} 1310}
1303 1311
1304#endif 1312#endif
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
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;
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
246CalPrintDialog::~CalPrintDialog() 246CalPrintDialog::~CalPrintDialog()
247{ 247{
248} 248}
249 249
250void CalPrintDialog::setupPrinter() 250void CalPrintDialog::setupPrinter()
251{ 251{
252 if ( mPrinter->setup( this ) ) { 252 if ( mPrinter->setup( this ) ) {
253 setPrinterLabel(); 253 setPrinterLabel();
254 } 254 }
255} 255}
256 256
257void CalPrintDialog::setPreview(bool preview) 257void 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
267void CalPrintDialog::setPrinterLabel() 267void 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
276void CalPrintDialog::setPrintType( int i ) 276void 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
284CalPrintBase *CalPrintDialog::selectedPlugin() 284CalPrintBase *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
292void CalPrintDialog::slotOk() 292void 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