26 #include <tqpainter.h>
32 #include <tdeconfig.h>
33 #include <kcalendarsystem.h>
34 #include <kwordwrap.h>
36 #include "calprintpluginbase.h"
39 #ifndef KORG_NOPRINTER
41 inline int roundToInt(
const double x)
43 return int(x > 0.0 ? x + 0.5 : x - 0.5);
46 static TQString cleanStr(
const TQString &instr )
49 return ret.replace(
'\n',
' ' );
55 class CalPrintPluginBase::TodoParentStart
58 TodoParentStart( TQRect pt = TQRect(),
bool page =
true )
59 : mRect( pt ), mSamePage( page ) {}
71 class PrintCellItem :
public KOrg::CellItem
74 PrintCellItem(
Event *event,
const TQDateTime &start,
const TQDateTime &end )
75 : mEvent( event ), mStart( start), mEnd( end )
79 Event *event()
const {
return mEvent; }
81 TQString label()
const {
return mEvent->
summary(); }
83 TQDateTime start()
const {
return mStart; }
84 TQDateTime end()
const {
return mEnd; }
88 bool overlaps( KOrg::CellItem *o )
const
90 PrintCellItem *other =
static_cast<PrintCellItem *
>( o );
93 kdDebug(5850) <<
"PrintCellItem::overlaps() " << event()->summary()
94 <<
" <-> " << other->event()->summary() << endl;
95 kdDebug(5850) <<
" start : " << start.toString() << endl;
96 kdDebug(5850) <<
" end : " << end.toString() << endl;
97 kdDebug(5850) <<
" otherStart: " << otherStart.toString() << endl;
98 kdDebug(5850) <<
" otherEnd : " << otherEnd.toString() << endl;
101 return !( other->start() >= end() || other->end() <= start() );
106 TQDateTime mStart, mEnd;
118 mHeaderHeight( -1 ), mSubHeaderHeight( SUBHEADER_HEIGHT ), mFooterHeight( -1 ),
119 mMargin( MARGIN_SIZE ), mPadding( PADDING_SIZE), mCalSys( 0 )
122 CalPrintPluginBase::~CalPrintPluginBase()
130 TQFrame *wdg =
new TQFrame( w );
131 TQVBoxLayout *layout =
new TQVBoxLayout( wdg );
133 TQLabel *title =
new TQLabel(
description(), wdg );
134 TQFont titleFont( title->font() );
135 titleFont.setPointSize( 20 );
136 titleFont.setBold(
true );
137 title->setFont( titleFont );
139 layout->addWidget( title );
140 layout->addWidget(
new TQLabel(
info(), wdg ) );
141 layout->addSpacing( 20 );
142 layout->addWidget(
new TQLabel( i18n(
"This printing style does not "
143 "have any configuration options."),
145 layout->addStretch();
151 if ( !printer )
return;
155 mPrinter->setColorMode( mUseColors?(KPrinter::Color):(KPrinter::GrayScale) );
161 int margins = margin();
162 p.setViewport( margins, margins,
163 p.viewport().width() - 2*margins,
164 p.viewport().height() - 2*margins );
169 int pageWidth = p.window().width();
170 int pageHeight = p.window().height();
174 print( p, pageWidth, pageHeight );
183 TDEConfigGroupSaver saver( mConfig,
description() );
185 TQDateTime currDate( TQDate::currentDate() );
186 mFromDate = mConfig->readDateTimeEntry(
"FromDate", &currDate ).date();
187 mToDate = mConfig->readDateTimeEntry(
"ToDate" ).date();
188 mUseColors = mConfig->readBoolEntry(
"UseColors",
true );
189 setUseColors( mUseColors );
192 kdDebug(5850) <<
"No config available in loadConfig!!!!" << endl;
199 TDEConfigGroupSaver saver( mConfig,
description() );
201 mConfig->writeEntry(
"FromDate", TQDateTime( mFromDate ) );
202 mConfig->writeEntry(
"ToDate", TQDateTime( mToDate ) );
203 mConfig->writeEntry(
"UseColors", mUseColors );
206 kdDebug(5850) <<
"No config available in saveConfig!!!!" << endl;
215 PrintPlugin::setKOrgCoreHelper( helper );
217 setCalendarSystem( helper->calendarSystem() );
220 bool CalPrintPluginBase::useColors()
const
224 void CalPrintPluginBase::setUseColors(
bool useColors )
226 mUseColors = useColors;
229 KPrinter::Orientation CalPrintPluginBase::orientation()
const
236 TQTime CalPrintPluginBase::dayStart()
238 TQTime start( 8,0,0 );
239 if ( mCoreHelper ) start = mCoreHelper->dayStart();
243 void CalPrintPluginBase::setCategoryColors( TQPainter &p,
Incidence *incidence )
246 if ( bgColor.isValid() )
247 p.setBrush( bgColor );
248 TQColor tColor( textColor( bgColor ) );
249 if ( tColor.isValid() )
255 if (mCoreHelper && incidence)
256 return mCoreHelper->categoryColor( incidence->
categories() );
261 TQColor CalPrintPluginBase::textColor(
const TQColor &color )
263 return (mCoreHelper)?(mCoreHelper->textColor( color )):TQColor();
266 bool CalPrintPluginBase::isWorkingDay(
const TQDate &dt )
268 return (mCoreHelper)?( mCoreHelper->isWorkingDay( dt ) ):
true;
271 TQString CalPrintPluginBase::holidayString(
const TQDate &dt )
273 return (mCoreHelper)?(mCoreHelper->holidayString(dt)):(TQString());
277 Event *CalPrintPluginBase::holiday(
const TQDate &dt )
279 TQString hstring( holidayString( dt ) );
280 if ( !hstring.isEmpty() ) {
292 const KCalendarSystem *CalPrintPluginBase::calendarSystem()
const
296 void CalPrintPluginBase::setCalendarSystem(
const KCalendarSystem *calsys )
303 if ( mHeaderHeight >= 0 )
304 return mHeaderHeight;
305 else if ( orientation() == KPrinter::Portrait )
306 return PORTRAIT_HEADER_HEIGHT;
308 return LANDSCAPE_HEADER_HEIGHT;
310 void CalPrintPluginBase::setHeaderHeight(
const int height )
312 mHeaderHeight = height;
315 int CalPrintPluginBase::subHeaderHeight()
const
317 return mSubHeaderHeight;
319 void CalPrintPluginBase::setSubHeaderHeight(
const int height )
321 mSubHeaderHeight = height;
326 if ( mFooterHeight >= 0 )
327 return mFooterHeight;
328 else if ( orientation() == KPrinter::Portrait )
329 return PORTRAIT_FOOTER_HEIGHT;
331 return LANDSCAPE_FOOTER_HEIGHT;
333 void CalPrintPluginBase::setFooterHeight(
const int height )
335 mFooterHeight = height;
338 int CalPrintPluginBase::margin()
const
342 void CalPrintPluginBase::setMargin(
const int margin )
347 int CalPrintPluginBase::padding()
const
351 void CalPrintPluginBase::setPadding(
const int padding )
356 int CalPrintPluginBase::borderWidth()
const
360 void CalPrintPluginBase::setBorderWidth(
const int borderwidth )
362 mBorder = borderwidth;
370 TQPen pen( p.pen() );
372 pen.setWidth( linewidth );
380 TQBrush oldbrush( p.brush() );
383 p.setBrush( oldbrush );
388 TQRect newbox( box );
389 newbox.addCoords( 3, 1, -1, -1 );
390 p.drawText( newbox, (flags==-1)?(TQt::AlignTop | TQt::AlignJustify | TQt::BreakAnywhere):flags, str );
395 Incidence *incidence,
const TQString &str,
int flags )
397 TQPen oldpen( p.pen() );
398 TQBrush oldbrush( p.brush() );
400 if ( mUseColors & bgColor.isValid() ) {
401 p.setBrush( bgColor );
403 p.setBrush( TQColor( 232, 232, 232 ) );
405 drawBox( p, ( linewidth > 0 ) ? linewidth : EVENT_BORDER_WIDTH, box );
407 if ( mUseColors && bgColor.isValid() ) {
408 p.setPen( textColor( bgColor ) );
412 p.setBrush( oldbrush );
418 drawShadedBox( p, BOX_BORDER_WIDTH, TQColor( 232, 232, 232 ), box );
419 TQFont oldfont( p.font() );
420 p.setFont( TQFont(
"sans-serif", 10, TQFont::Bold ) );
421 p.drawText( box, TQt::AlignCenter | TQt::AlignVCenter, str );
422 p.setFont( oldfont );
426 const TQString &str,
int flags )
430 TQRect rotatedBox( -box.top()-box.height(), box.left(), box.height(), box.width() );
432 ( flags == -1 ) ? TQt::AlignLeft | TQt::AlignVCenter | TQt::SingleLine : flags );
444 const TQString &caption,
const TQString &contents,
bool sameLine,
bool expand,
const TQFont &captionFont,
const TQFont &textFont )
446 TQFont oldFont( p.font() );
453 TQRect box( allbox );
456 TQRect captionBox( box.left() + padding(), box.top() + padding(), 0, 0 );
457 p.setFont( captionFont );
458 captionBox = p.boundingRect( captionBox, TQt::AlignLeft | TQt::AlignTop | TQt::SingleLine, caption );
459 p.setFont( oldFont );
460 if ( captionBox.right() > box.right() )
461 captionBox.setRight( box.right() );
462 if ( expand && captionBox.bottom() + padding() > box.bottom() )
463 box.setBottom( captionBox.bottom() + padding() );
466 TQRect textBox( captionBox );
467 if ( !contents.isEmpty() ) {
469 textBox.setLeft( captionBox.right() + padding() );
471 textBox.setTop( captionBox.bottom() + padding() );
473 textBox.setRight( box.right() );
474 textBox.setHeight( 0 );
475 p.setFont( textFont );
476 textBox = p.boundingRect( textBox, TQt::WordBreak | TQt::AlignTop | TQt::AlignLeft, contents );
477 p.setFont( oldFont );
478 if ( textBox.bottom() + padding() > box.bottom() ) {
480 box.setBottom( textBox.bottom() + padding() );
482 textBox.setBottom( box.bottom() );
487 drawBox( p, BOX_BORDER_WIDTH, box );
488 p.setFont( captionFont );
489 p.drawText( captionBox, TQt::AlignLeft | TQt::AlignTop | TQt::SingleLine, caption );
490 if ( !contents.isEmpty() ) {
491 p.setFont( textFont );
492 p.drawText( textBox, TQt::WordBreak | TQt::AlignTop | TQt::AlignLeft, contents );
494 p.setFont( oldFont );
499 return textBox.bottom();
507 const TQDate &month1,
const TQDate &month2,
const TQRect &allbox,
bool expand )
510 int smallMonthWidth = (allbox.width()/4) - 10;
511 if (smallMonthWidth>100) smallMonthWidth=100;
513 int right = allbox.right();
514 if ( month1.isValid() ) right -= (20+smallMonthWidth);
515 if ( month2.isValid() ) right -= (20+smallMonthWidth);
516 TQRect box( allbox );
517 TQRect textRect( allbox );
518 textRect.addCoords( 5, 0, 0, 0 );
519 textRect.setRight( right );
522 TQFont oldFont( p.font() );
523 TQFont newFont(
"sans-serif", (textRect.height()<60)?16:18, TQFont::Bold);
525 p.setFont( newFont );
526 TQRect boundingR = p.boundingRect( textRect, TQt::AlignLeft | TQt::AlignVCenter | TQt::WordBreak, title );
527 p.setFont( oldFont );
528 int h = boundingR.height();
529 if ( h > allbox.height() ) {
531 textRect.setHeight( h );
535 drawShadedBox( p, BOX_BORDER_WIDTH, TQColor( 232, 232, 232 ), box );
537 TQRect monthbox( box.right()-10-smallMonthWidth, box.top(), smallMonthWidth, box.height() );
538 if (month2.isValid()) {
539 drawSmallMonth( p, TQDate(month2.year(), month2.month(), 1), monthbox );
540 monthbox.moveBy( -20 - smallMonthWidth, 0 );
542 if (month1.isValid()) {
543 drawSmallMonth( p, TQDate(month1.year(), month1.month(), 1), monthbox );
544 monthbox.moveBy( -20 - smallMonthWidth, 0 );
548 p.setFont( newFont );
549 p.drawText( textRect, TQt::AlignLeft | TQt::AlignVCenter | TQt::WordBreak, title );
550 p.setFont( oldFont );
552 return textRect.bottom();
558 TQFont oldfont( p.font() );
559 p.setFont( TQFont(
"sans-serif", 6 ) );
560 TQFontMetrics fm( p.font() );
561 TQString dateStr = TDEGlobal::locale()->formatDateTime( TQDateTime::currentDateTime(),
false );
562 p.drawText( footbox, TQt::AlignCenter | TQt::AlignVCenter | TQt::SingleLine,
563 i18n(
"print date: formatted-datetime",
"printed: %1" ).arg( dateStr ) );
564 p.setFont( oldfont );
566 return footbox.bottom();
574 int month = qd.month();
575 TQDate monthDate(TQDate(qd.year(), qd.month(), 1));
577 TQDate monthDate2( monthDate.addDays( -weekdayCol ) );
579 double cellWidth = double(box.width())/double(7);
580 int rownr = 3 + ( qd.daysInMonth() + weekdayCol - 1 ) / 7;
582 double cellHeight = (box.height() - 5) / rownr;
583 TQFont oldFont( p.font() );
584 p.setFont(TQFont(
"sans-serif",
int(cellHeight-1), TQFont::Normal));
588 TQRect titleBox( box );
589 titleBox.setHeight(
int(cellHeight+1) );
590 p.drawText( titleBox, TQt::AlignTop | TQt::AlignHCenter, mCalSys->monthName( qd ) );
594 TQRect wdayBox( box );
595 wdayBox.setTop(
int( box.top() + 3 + cellHeight ) );
596 wdayBox.setHeight(
int(2*cellHeight)-
int(cellHeight) );
599 for (
int col = 0; col < 7; ++col) {
600 TQString tmpStr = mCalSys->weekDayName( monthDate2 )[0].upper();
601 wdayBox.setLeft(
int(box.left() + col*cellWidth) );
602 wdayBox.setRight(
int(box.left() + (col+1)*cellWidth) );
603 p.drawText( wdayBox, TQt::AlignCenter, tmpStr );
604 monthDate2 = monthDate2.addDays( 1 );
609 int calStartY = wdayBox.bottom() + 2;
610 p.drawLine( box.left(), calStartY, box.right(), calStartY );
611 monthDate = monthDate.addDays( -weekdayCol );
613 for (
int row = 0; row < (rownr-2); row++ ) {
614 for (
int col = 0; col < 7; col++ ) {
615 if ( monthDate.month() == month ) {
616 TQRect dayRect(
int( box.left() + col*cellWidth ),
int( calStartY + row*cellHeight ), 0, 0 );
617 dayRect.setRight(
int( box.left() + (col+1)*cellWidth ) );
618 dayRect.setBottom(
int( calStartY + (row+1)*cellHeight ) );
619 p.drawText( dayRect, TQt::AlignCenter, TQString::number( monthDate.day() ) );
621 monthDate = monthDate.addDays(1);
624 p.setFont( oldFont );
638 const TQDate &fromDate,
const TQDate &toDate,
const TQRect &box )
640 double cellWidth = double(box.width()) / double(fromDate.daysTo( toDate )+1);
641 TQDate cellDate( fromDate );
642 TQRect dateBox( box );
645 while ( cellDate <= toDate ) {
646 dateBox.setLeft( box.left() +
int(i*cellWidth) );
647 dateBox.setRight( box.left() +
int((i+1)*cellWidth) );
649 cellDate = cellDate.addDays(1);
658 drawSubHeaderBox( p, (mCalSys)?(mCalSys->weekDayName( qd )):(TQString()), box );
663 const TQTime &toTime,
const TQRect &box )
665 drawBox( p, BOX_BORDER_WIDTH, box );
667 int totalsecs = fromTime.secsTo( toTime );
668 float minlen = (float)box.height() * 60. / (float)totalsecs;
669 float cellHeight = ( 60. * (float)minlen );
670 float currY = box.top();
672 int xcenter = box.left() + box.width() / 2;
674 TQTime curTime( fromTime );
675 TQTime endTime( toTime );
676 if ( fromTime.minute() > 30 ) {
677 curTime = TQTime( fromTime.hour()+1, 0, 0 );
678 }
else if ( fromTime.minute() > 0 ) {
679 curTime = TQTime( fromTime.hour(), 30, 0 );
680 float yy = currY + minlen * (float)fromTime.secsTo( curTime ) / 60.;
681 p.drawLine( xcenter, (
int)yy, box.right(), (int)yy );
682 curTime = TQTime( fromTime.hour() + 1, 0, 0 );
684 currY += ( float( fromTime.secsTo( curTime ) * minlen ) / 60. );
686 while ( curTime < endTime ) {
687 p.drawLine( box.left(), (int)currY, box.right(), (int)currY );
688 int newY = (int)( currY + cellHeight / 2. );
690 if ( newY < box.bottom() ) {
691 TQFont oldFont( p.font() );
693 if ( !TDEGlobal::locale()->use12Clock() ) {
694 p.drawLine( xcenter, (
int)newY, box.right(), (
int)newY );
695 numStr.setNum( curTime.hour() );
696 if ( cellHeight > 30 ) {
697 p.setFont( TQFont(
"sans-serif", 14, TQFont::Bold ) );
699 p.setFont( TQFont(
"sans-serif", 12, TQFont::Bold ) );
701 p.drawText( box.left() + 4, (
int)currY + 2, box.width() / 2 - 2, (
int)cellHeight,
702 TQt::AlignTop | TQt::AlignRight, numStr );
703 p.setFont( TQFont (
"helvetica", 10, TQFont::Normal ) );
704 p.drawText( xcenter + 4, (
int)currY + 2, box.width() / 2 + 2, (
int)(cellHeight / 2 ) - 3,
705 TQt::AlignTop | TQt::AlignLeft,
"00" );
707 p.drawLine( box.left(), (
int)newY, box.right(), (
int)newY );
708 TQTime time( curTime.hour(), 0 );
709 numStr = TDEGlobal::locale()->formatTime( time );
710 if ( box.width() < 60 ) {
711 p.setFont( TQFont(
"sans-serif", 7, TQFont::Bold ) );
713 p.setFont( TQFont(
"sans-serif", 12, TQFont::Bold ) );
715 p.drawText( box.left() + 2, (
int)currY + 2, box.width() - 4, (
int)cellHeight / 2 - 3,
716 TQt::AlignTop|TQt::AlignLeft, numStr );
719 p.setFont( oldFont );
721 if ( curTime.secsTo( endTime ) > 3600 ) {
722 curTime = curTime.addSecs( 3600 );
736 const TQDate &qd,
bool expandable,
const TQRect &box )
738 Event::List::Iterator it, itold;
740 int offset=box.top();
742 TQString multiDayStr;
744 Event*hd = holiday( qd );
745 if ( hd ) eventList.prepend( hd );
747 it = eventList.begin();
748 Event *currEvent = 0;
750 while( it!=eventList.end() ) {
754 if ( currEvent && currEvent->
doesFloat() ) {
757 TQRect eventBox( box );
758 eventBox.setTop( offset );
760 offset += box.height();
762 if ( !multiDayStr.isEmpty() ) multiDayStr +=
", ";
763 multiDayStr += currEvent->
summary();
765 eventList.remove( itold );
770 int ret = box.height();
771 TQRect eventBox( box );
773 if (!multiDayStr.isEmpty()) {
774 drawShadedBox( p, BOX_BORDER_WIDTH, TQColor( 128, 128, 128 ), eventBox );
777 drawBox( p, BOX_BORDER_WIDTH, eventBox );
780 ret = offset - box.top();
781 eventBox.setBottom( ret );
782 drawBox( p, BOX_BORDER_WIDTH, eventBox );
789 const TQDate &qd,
bool expandable,
790 TQTime &fromTime, TQTime &toTime,
791 const TQRect &oldbox )
793 if ( !isWorkingDay( qd ) ) {
794 drawShadedBox( p, BOX_BORDER_WIDTH, TQColor( 232, 232, 232 ), oldbox );
796 drawBox( p, BOX_BORDER_WIDTH, oldbox );
798 TQRect box( oldbox );
806 Event::List::ConstIterator it;
807 for ( it = events.begin(); it != events.end(); ++it ) {
809 if ( event->
dtStart().time() < fromTime )
810 fromTime =
event->
dtStart().time();
811 if ( event->
dtEnd().time() > toTime )
812 toTime =
event->dtEnd().time();
823 int totalsecs = fromTime.secsTo( toTime );
824 float minlen = box.height() * 60. / totalsecs;
825 float cellHeight = 60. * minlen;
826 float currY = box.top();
829 TQTime curTime( TQTime( fromTime.hour(), 0, 0 ) );
830 currY += fromTime.secsTo( curTime ) * minlen / 60;
832 while ( curTime < toTime && curTime.isValid() ) {
833 if ( currY > box.top() )
834 p.drawLine( box.left(),
int( currY ), box.right(),
int( currY ) );
835 currY += cellHeight / 2;
836 if ( ( currY > box.top() ) && ( currY < box.bottom() ) ) {
838 TQPen oldPen( p.pen() );
839 p.setPen( TQColor( 192, 192, 192 ) );
840 p.drawLine( box.left(),
int( currY ), box.right(),
int( currY ) );
843 if ( curTime.secsTo( toTime ) > 3600 )
844 curTime = curTime.addSecs( 3600 );
845 else curTime = toTime;
846 currY += cellHeight / 2;
849 TQDateTime startPrintDate = TQDateTime( qd, fromTime );
850 TQDateTime endPrintDate = TQDateTime( qd, toTime );
855 TQPtrList<KOrg::CellItem> cells;
856 cells.setAutoDelete(
true );
858 Event::List::ConstIterator itEvents;
859 for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) {
860 TQValueList<TQDateTime> times = (*itEvents)->startDateTimesForDate( qd );
861 for ( TQValueList<TQDateTime>::ConstIterator it = times.begin();
862 it != times.end(); ++it ) {
863 cells.append(
new PrintCellItem( *itEvents, (*it), (*itEvents)->endDateForStart( *it ) ) );
867 TQPtrListIterator<KOrg::CellItem> it1( cells );
868 for( it1.toFirst(); it1.current(); ++it1 ) {
869 KOrg::CellItem *placeItem = it1.current();
870 KOrg::CellItem::placeItem( cells, placeItem );
875 for( it1.toFirst(); it1.current(); ++it1 ) {
876 PrintCellItem *placeItem =
static_cast<PrintCellItem *
>( it1.current() );
877 drawAgendaItem( placeItem, p, startPrintDate, endPrintDate, minlen, box );
884 void CalPrintPluginBase::drawAgendaItem( PrintCellItem *item, TQPainter &p,
885 const TQDateTime &startPrintDate,
886 const TQDateTime &endPrintDate,
887 float minlen,
const TQRect &box )
889 Event *
event = item->event();
892 TQDateTime startTime = item->start();
893 TQDateTime endTime = item->end();
894 if ( ( startTime < endPrintDate && endTime > startPrintDate ) ||
895 ( endTime > startPrintDate && startTime < endPrintDate ) ) {
896 if ( startTime < startPrintDate ) startTime = startPrintDate;
897 if ( endTime > endPrintDate ) endTime = endPrintDate;
898 int currentWidth = box.width() / item->subCells();
899 int currentX = box.left() + item->subCell() * currentWidth;
900 int currentYPos = int( box.top() + startPrintDate.secsTo( startTime ) *
902 int currentHeight = int( box.top() + startPrintDate.secsTo( endTime ) * minlen / 60. ) - currentYPos;
904 TQRect eventBox( currentX, currentYPos, currentWidth, currentHeight );
906 if ( event->location().isEmpty() ) {
907 str = i18n(
"starttime - endtime summary",
909 arg( TDEGlobal::locale()->formatTime( startTime.time() ) ).
910 arg( TDEGlobal::locale()->formatTime( endTime.time() ) ).
911 arg( cleanStr( event->summary() ) );
913 str = i18n(
"starttime - endtime summary, location",
915 arg( TDEGlobal::locale()->formatTime( startTime.time() ) ).
916 arg( TDEGlobal::locale()->formatTime( endTime.time() ) ).
917 arg( cleanStr( event->summary() ) ).
918 arg( cleanStr( event->location() ) );
920 showEventBox( p, EVENT_BORDER_WIDTH, eventBox, event, str );
927 bool fullDate,
bool printRecurDaily,
bool printRecurWeekly )
930 const TDELocale*local = TDEGlobal::locale();
933 if ( fullDate && mCalSys ) {
935 dayNumStr = i18n(
"weekday month date",
"%1 %2 %3")
936 .arg( mCalSys->weekDayName( qd ) )
937 .arg( mCalSys->monthName( qd ) )
941 dayNumStr = TQString::number( qd.day() );
944 TQRect subHeaderBox( box );
945 subHeaderBox.setHeight( mSubHeaderHeight );
946 drawShadedBox( p, BOX_BORDER_WIDTH, p.backgroundColor(), box );
947 drawShadedBox( p, 0, TQColor( 232, 232, 232 ), subHeaderBox );
948 drawBox( p, BOX_BORDER_WIDTH, box );
949 TQString hstring( holidayString( qd ) );
950 TQFont oldFont( p.font() );
952 TQRect headerTextBox( subHeaderBox );
953 headerTextBox.setLeft( subHeaderBox.left()+5 );
954 headerTextBox.setRight( subHeaderBox.right()-5 );
955 if (!hstring.isEmpty()) {
956 p.setFont( TQFont(
"sans-serif", 8, TQFont::Bold,
true ) );
958 p.drawText( headerTextBox, TQt::AlignLeft | TQt::AlignVCenter, hstring );
960 p.setFont(TQFont(
"sans-serif", 10, TQFont::Bold));
961 p.drawText( headerTextBox, TQt::AlignRight | TQt::AlignVCenter, dayNumStr);
963 Event::List eventList = mCalendar->
events( qd,
967 p.setFont( TQFont(
"sans-serif", 8 ) );
969 int textY=mSubHeaderHeight+3;
970 Event::List::ConstIterator it;
972 for( it = eventList.begin(); it != eventList.end() && textY<box.height(); ++it ) {
973 Event *currEvent = *it;
974 if ( ( !printRecurDaily && currEvent->recurrenceType() == Recurrence::rDaily ) ||
975 ( !printRecurWeekly && currEvent->recurrenceType() == Recurrence::rWeekly ) ) {
981 timeText = local->formatTime( currEvent->
dtStart().time() );
985 if ( !currEvent->
location().isEmpty() ) {
986 str = i18n(
"summary, location",
"%1, %2" ).
991 drawIncidence( p, box, timeText, str, textY );
994 if ( textY < box.height() ) {
995 Todo::List todos = mCalendar->
todos( qd );
996 Todo::List::ConstIterator it2;
997 for ( it2 = todos.begin(); it2 != todos.end() && textY <box.height(); ++it2 ) {
999 if ( ( !printRecurDaily && todo->recurrenceType() == Recurrence::rDaily ) ||
1000 ( !printRecurWeekly && todo->recurrenceType() == Recurrence::rWeekly ) ) {
1004 timeText = TDEGlobal::locale()->formatTime( todo->
dtStart().time() ) +
" ";
1008 TQString summaryStr;
1009 if ( !todo->
location().isEmpty() ) {
1010 summaryStr = i18n(
"summary, location",
"%1, %2" ).
1018 str = i18n(
"%1 (Due: %2)" ).
1020 arg( TDEGlobal::locale()->formatDateTime( todo->
dtDue() ) );
1022 str = i18n(
"%1 (Due: %2)" ).
1024 arg( TDEGlobal::locale()->formatDate( todo->
dtDue().date(),
true ) );
1029 drawIncidence( p, box, timeText, i18n(
"To-do: %1").arg( str ), textY );
1033 p.setFont( oldFont );
1037 void CalPrintPluginBase::drawIncidence( TQPainter &p,
const TQRect &dayBox,
const TQString &time,
const TQString &summary,
int &textY )
1039 kdDebug(5850) <<
"summary = " << summary << endl;
1041 int flags = TQt::AlignLeft;
1042 TQFontMetrics fm = p.fontMetrics();
1043 TQRect timeBound = p.boundingRect( dayBox.x() + 5, dayBox.y() + textY,
1044 dayBox.width() - 10, fm.lineSpacing(),
1046 p.drawText( timeBound, flags, time );
1048 int summaryWidth = time.isEmpty() ? 0 : timeBound.width() + 4;
1049 TQRect summaryBound = TQRect( dayBox.x() + 5 + summaryWidth, dayBox.y() + textY,
1050 dayBox.width() - summaryWidth -5, dayBox.height() );
1052 KWordWrap *ww = KWordWrap::formatText( fm, summaryBound, flags, summary );
1053 ww->drawText( &p, dayBox.x() + 5 + summaryWidth, dayBox.y() + textY, flags );
1055 textY += ww->boundingRect().height();
1065 TQDate weekDate = qd;
1066 bool portrait = ( box.height() > box.width() );
1067 int cellWidth, cellHeight;
1070 cellWidth = box.width()/2;
1073 cellWidth = box.width()/6;
1076 cellHeight = box.height()/vcells;
1080 weekDate = qd.addDays( -weekdayCol );
1082 for (
int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) {
1084 int hpos = ((i<6)?i:(i-1)) / vcells;
1085 int vpos = ((i<6)?i:(i-1)) % vcells;
1086 TQRect dayBox( box.left()+cellWidth*hpos, box.top()+cellHeight*vpos + ((i==6)?(cellHeight/2):0),
1087 cellWidth, (i<5)?(cellHeight):(cellHeight/2) );
1094 const TQDate &fromDate,
const TQDate &toDate,
1095 TQTime &fromTime, TQTime &toTime,
1099 int alldayHeight = (int)( 3600.*box.height()/(fromTime.secsTo(toTime)+3600.) );
1100 int timelineWidth = TIMELINE_WIDTH;
1102 TQRect dowBox( box );
1103 dowBox.setLeft( box.left() + timelineWidth );
1104 dowBox.setHeight( mSubHeaderHeight );
1107 TQRect tlBox( box );
1108 tlBox.setWidth( timelineWidth );
1109 tlBox.setTop( dowBox.bottom() + BOX_BORDER_WIDTH + alldayHeight );
1113 TQDate curDate(fromDate);
1115 double cellWidth = double(dowBox.width()) / double(fromDate.daysTo(toDate)+1);
1116 while (curDate<=toDate) {
1117 TQRect allDayBox( dowBox.left()+
int(i*cellWidth), dowBox.bottom() + BOX_BORDER_WIDTH,
1118 int((i+1)*cellWidth)-
int(i*cellWidth), alldayHeight );
1119 TQRect dayBox( allDayBox );
1120 dayBox.setTop( tlBox.top() );
1121 dayBox.setBottom( box.bottom() );
1122 Event::List eventList = mCalendar->
events(curDate,
1125 alldayHeight =
drawAllDayBox( p, eventList, curDate,
false, allDayBox );
1126 drawAgendaDayBox( p, eventList, curDate,
false, fromTime, toTime, dayBox );
1128 curDate=curDate.addDays(1);
1136 class MonthEventStruct
1139 MonthEventStruct() : event(0) {}
1140 MonthEventStruct(
const TQDateTime &s,
const TQDateTime &e,
Event *ev)
1145 if ( event->doesFloat() ) {
1146 start = TQDateTime( start.date(), TQTime(0,0,0) );
1147 end = TQDateTime( end.date().addDays(1), TQTime(0,0,0) ).addSecs(-1);
1150 bool operator<(
const MonthEventStruct &mes) {
return start < mes.start; }
1158 const KCalendarSystem *calsys = calendarSystem();
1159 TQRect subheaderBox( box );
1160 subheaderBox.setHeight( subHeaderHeight() );
1161 TQRect borderBox( box );
1162 borderBox.setTop( subheaderBox.bottom()+1 );
1165 int correction = (BOX_BORDER_WIDTH)/2;
1166 TQRect daysBox( borderBox );
1167 daysBox.addCoords( correction, correction, -correction, -correction );
1169 int daysinmonth = calsys->daysInMonth( dt );
1170 if ( maxdays <= 0 ) maxdays = daysinmonth;
1173 float dayheight = float(daysBox.height()) / float( maxdays );
1175 TQColor holidayColor( 240, 240, 240 );
1176 TQColor workdayColor( 255, 255, 255 );
1177 int dayNrWidth = p.fontMetrics().width(
"99" );
1180 if ( daysinmonth<maxdays ) {
1181 TQRect dayBox( box.left(), daysBox.top() + roundToInt(dayheight*daysinmonth), box.width(), 0 );
1182 dayBox.setBottom( daysBox.bottom() );
1183 p.fillRect( dayBox, TQt::DiagCrossPattern );
1186 TQBrush oldbrush( p.brush() );
1187 for ( d = 0; d < daysinmonth; ++d ) {
1189 calsys->setYMD( day, dt.year(), dt.month(), d+1 );
1190 TQRect dayBox( daysBox.left(), daysBox.top() + roundToInt(dayheight*d), daysBox.width(), 0 );
1192 dayBox.setBottom( daysBox.top()+roundToInt(dayheight*(d+1)) - 1 );
1194 p.setBrush( isWorkingDay( day )?workdayColor:holidayColor );
1195 p.drawRect( dayBox );
1196 TQRect dateBox( dayBox );
1197 dateBox.setWidth( dayNrWidth+3 );
1198 p.drawText( dateBox, TQt::AlignRight | TQt::AlignVCenter | TQt::SingleLine,
1199 TQString::number(d+1) );
1201 p.setBrush( oldbrush );
1202 int xstartcont = box.left() + dayNrWidth + 5;
1205 calsys->setYMD( start, dt.year(), dt.month(), 1 );
1206 end = calsys->addMonths( start, 1 );
1207 end = calsys->addDays( end, -1 );
1209 Event::List events = mCalendar->
events( start, end );
1210 TQMap<int, TQStringList> textEvents;
1211 TQPtrList<KOrg::CellItem> timeboxItems;
1212 timeboxItems.setAutoDelete(
true );
1222 Event::List holidays;
1223 holidays.setAutoDelete(
true );
1224 for ( TQDate d(start); d <= end; d = d.addDays(1) ) {
1225 Event *e = holiday( d );
1227 holidays.append( e );
1228 if ( holidaysFlags & TimeBoxes ) {
1229 timeboxItems.append(
new PrintCellItem( e, TQDateTime(d, TQTime(0,0,0) ),
1230 TQDateTime( d.addDays(1), TQTime(0,0,0) ) ) );
1232 if ( holidaysFlags & Text ) {
1233 textEvents[ d.day() ] << e->
summary();
1238 TQValueList<MonthEventStruct> monthentries;
1240 for ( Event::List::ConstIterator evit = events.begin();
1241 evit != events.end(); ++evit ) {
1249 TQValueList<TQDateTime>::ConstIterator it = starttimes.begin();
1250 for ( ; it != starttimes.end(); ++it ) {
1251 monthentries.append( MonthEventStruct( *it, e->
endDateForStart( *it ), e ) );
1259 TQDate d1( start.addDays(1) );
1260 while ( d1 <= end ) {
1263 for ( TimeList::ConstIterator it = times.begin();
1264 it != times.end(); ++it ) {
1265 TQDateTime d1start( d1, *it );
1266 monthentries.append( MonthEventStruct( d1start, e->
endDateForStart( d1start ), e ) );
1272 monthentries.append( MonthEventStruct( e->
dtStart(), e->
dtEnd(), e ) );
1275 qHeapSort( monthentries );
1277 TQValueList<MonthEventStruct>::ConstIterator mit = monthentries.begin();
1278 TQDateTime endofmonth( end, TQTime(0,0,0) );
1279 endofmonth = endofmonth.addDays(1);
1280 for ( ; mit != monthentries.end(); ++mit ) {
1281 if ( (*mit).start.date() == (*mit).end.date() ) {
1283 if ( subDailyFlags & TimeBoxes ) {
1284 timeboxItems.append(
new PrintCellItem( (*mit).event, (*mit).start, (*mit).end ) );
1287 if ( subDailyFlags & Text ) {
1288 textEvents[ (*mit).start.date().day() ] << (*mit).event->summary();
1292 TQDateTime thisstart( (*mit).start );
1293 TQDateTime thisend( (*mit).end );
1294 if ( thisstart.date()<start ) thisstart = start;
1295 if ( thisend>endofmonth ) thisend = endofmonth;
1296 timeboxItems.append(
new PrintCellItem( (*mit).event, thisstart, thisend ) );
1301 TQPtrListIterator<KOrg::CellItem> it1( timeboxItems );
1302 for( it1.toFirst(); it1.current(); ++it1 ) {
1303 KOrg::CellItem *placeItem = it1.current();
1304 KOrg::CellItem::placeItem( timeboxItems, placeItem );
1306 TQDateTime starttime( start, TQTime( 0, 0, 0 ) );
1307 int newxstartcont = xstartcont;
1309 TQFont oldfont( p.font() );
1310 p.setFont( TQFont(
"sans-serif", 7 ) );
1311 for( it1.toFirst(); it1.current(); ++it1 ) {
1312 PrintCellItem *placeItem =
static_cast<PrintCellItem *
>( it1.current() );
1313 int minsToStart = starttime.secsTo( placeItem->start() )/60;
1314 int minsToEnd = starttime.secsTo( placeItem->end() )/60;
1316 TQRect eventBox( xstartcont + placeItem->subCell()*17,
1317 daysBox.top() + roundToInt(
double( minsToStart*daysBox.height()) /
double(maxdays*24*60) ),
1319 eventBox.setBottom( daysBox.top() + roundToInt(
double( minsToEnd*daysBox.height()) /
double(maxdays*24*60) ) );
1321 newxstartcont = TQMAX( newxstartcont, eventBox.right() );
1323 xstartcont = newxstartcont;
1327 for (
int d=0; d<daysinmonth; ++d ) {
1328 TQStringList dayEvents( textEvents[d+1] );
1329 TQString txt = dayEvents.join(
", ");
1330 TQRect dayBox( xstartcont, daysBox.top()+roundToInt(dayheight*d), 0, 0 );
1331 dayBox.setRight( box.right() );
1332 dayBox.setBottom( daysBox.top()+roundToInt(dayheight*(d+1)) );
1333 printEventString(p, dayBox, txt, TQt::AlignTop | TQt::AlignLeft | TQt::BreakAnywhere );
1335 p.setFont( oldfont );
1337 drawBox( p, BOX_BORDER_WIDTH, borderBox );
1344 bool recurDaily,
bool recurWeekly,
1347 int yoffset = mSubHeaderHeight;
1349 TQDate monthDate(TQDate(qd.year(), qd.month(), 1));
1350 TQDate monthFirst(monthDate);
1351 TQDate monthLast(monthDate.addMonths(1).addDays(-1));
1355 monthDate = monthDate.addDays(-weekdayCol);
1361 int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1;
1362 double cellHeight = ( box.height() - yoffset ) / (1.*rows);
1363 double cellWidth = ( box.width() - xoffset ) / 7.;
1367 int coledges[8], rowedges[8];
1368 for (
int i = 0; i <= 7; i++ ) {
1369 rowedges[i] = int( box.top() + yoffset + i*cellHeight );
1370 coledges[i] = int( box.left() + xoffset + i*cellWidth );
1374 TQFont oldFont(p.font());
1375 TQFont newFont(p.font());
1376 newFont.setPointSize(6);
1378 TQDate weekDate(monthDate);
1379 for (
int row = 0; row<rows; ++row ) {
1380 int calWeek = weekDate.weekNumber();
1381 TQRect rc( box.left(), rowedges[row], coledges[0] - 3 - box.left(), rowedges[row+1]-rowedges[row] );
1382 p.drawText( rc, TQt::AlignRight | TQt::AlignVCenter, TQString::number( calWeek ) );
1383 weekDate = weekDate.addDays( 7 );
1385 p.setFont( oldFont );
1388 TQRect daysOfWeekBox( box );
1389 daysOfWeekBox.setHeight( mSubHeaderHeight );
1390 daysOfWeekBox.setLeft( box.left()+xoffset );
1391 drawDaysOfWeek( p, monthDate, monthDate.addDays( 6 ), daysOfWeekBox );
1393 TQColor back = p.backgroundColor();
1394 bool darkbg =
false;
1395 for (
int row = 0; row < rows; ++row ) {
1396 for (
int col = 0; col < 7; ++col ) {
1398 if ( (monthDate < monthFirst) || (monthDate > monthLast) ) {
1399 p.setBackgroundColor( back.dark( 120 ) );
1402 TQRect dayBox( coledges[col], rowedges[row], coledges[col+1]-coledges[col], rowedges[row+1]-rowedges[row] );
1403 drawDayBox(p, monthDate, dayBox,
false, recurDaily, recurWeekly );
1405 p.setBackgroundColor( back );
1408 monthDate = monthDate.addDays(1);
1418 bool connectSubTodos,
bool strikeoutCompleted,
1419 bool desc,
int posPriority,
int posSummary,
1420 int posDueDt,
int posPercentComplete,
1421 int level,
int x,
int &y,
int width,
1422 int pageHeight,
const Todo::List &todoList,
1423 TodoParentStart *r )
1426 const TDELocale *local = TDEGlobal::locale();
1428 TodoParentStart startpt;
1432 static TQPtrList<TodoParentStart> startPoints;
1434 startPoints.clear();
1438 int rhs = posPercentComplete;
1439 if ( rhs < 0 ) rhs = posDueDt;
1440 if ( rhs < 0 ) rhs = x+width;
1444 int left = posSummary + ( level*10 );
1445 rect = p.boundingRect( left, y, ( rhs-left-5 ), -1, TQt::WordBreak, outStr );
1448 rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1,
1449 TQt::WordBreak, outStr );
1452 if ( rect.bottom() > pageHeight ) {
1454 if ( level > 0 && connectSubTodos ) {
1455 TodoParentStart *rct;
1456 for ( rct = startPoints.first(); rct; rct = startPoints.next() ) {
1458 int center = rct->mRect.left() + (rct->mRect.width()/2);
1459 int to = p.viewport().bottom();
1462 if ( rct->mSamePage )
1463 start = rct->mRect.bottom() + 1;
1465 start = p.viewport().top();
1466 p.moveTo( center, start );
1467 p.lineTo( center, to );
1468 rct->mSamePage =
false;
1477 bool showPriority = posPriority>=0;
1478 int lhs = posPriority;
1480 lhs = r->mRect.right() + 1;
1484 rect = p.boundingRect( lhs, y + 10, 5, -1, TQt::AlignCenter, outStr );
1490 p.setBrush( TQBrush( TQt::NoBrush ) );
1494 p.drawLine( rect.topLeft(), rect.bottomRight() );
1495 p.drawLine( rect.topRight(), rect.bottomLeft() );
1497 lhs = rect.right() + 3;
1500 if ( todo->
priority() > 0 && showPriority ) {
1501 p.drawText( rect, TQt::AlignCenter, outStr );
1503 startpt.mRect = rect;
1506 if ( level > 0 && connectSubTodos ) {
1508 int center( r->mRect.left() + (r->mRect.width()/2) );
1510 bottom = r->mRect.bottom() + 1;
1513 int to( rect.top() + (rect.height()/2) );
1514 int endx( rect.left() );
1515 p.moveTo( center, bottom );
1516 p.lineTo( center, to );
1517 p.lineTo( endx, to );
1522 rect = p.boundingRect( lhs, rect.top(), (rhs-(left + rect.width() + 5)),
1523 -1, TQt::WordBreak, outStr );
1528 TQFont f( p.font() );
1529 if ( todo->
isCompleted() && strikeoutCompleted ) {
1530 f.setStrikeOut(
true );
1533 p.drawText( rect, TQt::WordBreak, outStr, -1, &newrect );
1534 f.setStrikeOut(
false );
1538 p.drawText( rect, TQt::WordBreak, outStr, -1, &newrect );
1539 if ( todo->
isCompleted() && strikeoutCompleted ) {
1543 int delta = p.fontMetrics().lineSpacing();
1544 int lines = ( rect.height() / delta ) + 1;
1545 for (
int i=0; i<lines; i++ ) {
1546 p.moveTo( rect.left(), rect.top() + ( delta/2 ) + ( i*delta ) );
1547 p.lineTo( rect.right(), rect.top() + ( delta/2 ) + ( i*delta ) );
1553 outStr = local->formatDate( todo->
dtDue().date(), true );
1554 rect = p.boundingRect( posDueDt, y, x + width, -1,
1555 TQt::AlignTop | TQt::AlignLeft, outStr );
1556 p.drawText( rect, TQt::AlignTop | TQt::AlignLeft, outStr );
1560 bool showPercentComplete = posPercentComplete>=0;
1561 if ( showPercentComplete ) {
1567 p.setBrush( TQBrush( TQt::NoBrush ) );
1568 p.drawRect( posPercentComplete, y+3, lwidth, lheight );
1569 if ( progress > 0 ) {
1570 p.setBrush( TQColor( 128, 128, 128 ) );
1571 p.drawRect( posPercentComplete, y+3, progress, lheight );
1576 rect = p.boundingRect( posPercentComplete+lwidth+3, y, x + width, -1,
1577 TQt::AlignTop | TQt::AlignLeft, outStr );
1578 p.drawText( rect, TQt::AlignTop | TQt::AlignLeft, outStr );
1583 y = newrect.bottom() + 5;
1585 rect = p.boundingRect( left+20, y, x+width-(left+10), -1,
1586 TQt::WordBreak, outStr );
1587 p.drawText( rect, TQt::WordBreak, outStr, -1, &newrect );
1591 y = newrect.bottom() + 10;
1596 Incidence::List::ConstIterator it;
1597 startPoints.append( &startpt );
1598 for( it = l.begin(); it != l.end(); ++it ) {
1604 Todo* subtodo =
dynamic_cast<Todo *
>( *it );
1605 if (subtodo && todoList.contains( subtodo ) ) {
1606 drawTodo( count, subtodo, p, connectSubTodos, strikeoutCompleted,
1607 desc, posPriority, posSummary, posDueDt, posPercentComplete,
1608 level+1, x, y, width, pageHeight, todoList, &startpt );
1615 Incidence::List::ConstIterator it;
1616 for( it=l.begin(); it!=l.end(); ++it ) {
1621 Todo* subtodo =
dynamic_cast<Todo *
>( *it );
1622 if ( subtodo && todoList.contains( subtodo ) ) {
1623 t.append( subtodo );
1628 Todo::List sl = mCalendar->
sortTodos( &t, sortField, sortDir );
1629 Todo::List::ConstIterator isl;
1630 startPoints.append( &startpt );
1631 for( isl = sl.begin(); isl != sl.end(); ++isl ) {
1633 drawTodo( count, ( *isl ), p, sortField, sortDir,
1634 connectSubTodos, strikeoutCompleted,
1635 desc, posPriority, posSummary, posDueDt, posPercentComplete,
1636 level+1, x, y, width, pageHeight, todoList, &startpt );
1638 startPoints.remove( &startpt );
1643 return ( weekday + 7 - TDEGlobal::locale()->weekStartDay() ) % 7;
1646 void CalPrintPluginBase::drawJournalField( TQPainter &p, TQString field, TQString text,
1647 int x,
int &y,
int width,
int pageHeight )
1649 if ( text.isEmpty() )
return;
1651 TQString entry( field.arg( text ) );
1653 TQRect rect( p.boundingRect( x, y, width, -1, TQt::WordBreak, entry) );
1654 if ( rect.bottom() > pageHeight) {
1660 rect = p.boundingRect( x, y, width, -1, TQt::WordBreak, entry);
1663 p.drawText( rect, TQt::WordBreak, entry, -1, &newrect );
1664 y = newrect.bottom() + 7;
1668 int width,
int pageHeight )
1670 TQFont oldFont( p.font() );
1671 p.setFont( TQFont(
"sans-serif", 15 ) );
1672 TQString headerText;
1673 TQString dateText( TDEGlobal::locale()->
1674 formatDate( journal->
dtStart().date(),
false ) );
1676 if ( journal->
summary().isEmpty() ) {
1677 headerText = dateText;
1679 headerText = i18n(
"Description - date",
"%1 - %2")
1684 TQRect rect( p.boundingRect( x, y, width, -1, TQt::WordBreak, headerText) );
1685 if ( rect.bottom() > pageHeight) {
1689 rect = p.boundingRect( x, y, width, -1, TQt::WordBreak, headerText );
1692 p.drawText( rect, TQt::WordBreak, headerText, -1, &newrect );
1693 p.setFont( oldFont );
1695 y = newrect.bottom() + 4;
1697 p.drawLine( x + 3, y, x + width - 6, y );
1700 drawJournalField( p, i18n(
"Person: %1"), journal->organizer().fullName(), x, y, width, pageHeight );
1701 drawJournalField( p, i18n(
"%1"), journal->
description(), x, y, width, pageHeight );
1706 void CalPrintPluginBase::drawSplitHeaderRight( TQPainter &p,
const TQDate &fd,
1711 TQFont oldFont( p.font() );
1713 TQPen oldPen( p.pen() );
1714 TQPen pen( TQt::black, 4 );
1718 if ( fd.month() == td.month() ) {
1719 title = i18n(
"Date range: Month dayStart - dayEnd",
"%1 %2 - %3")
1720 .arg( mCalSys->monthName( fd.month(),
false ) )
1721 .arg( mCalSys->dayString( fd,
false ) )
1722 .arg( mCalSys->dayString( td,
false ) );
1724 title = i18n(
"Date range: monthStart dayStart - monthEnd dayEnd",
"%1 %2 - %3 %4")
1725 .arg( mCalSys->monthName( fd.month(),
false ) )
1726 .arg( mCalSys->dayString( fd,
false ) )
1727 .arg( mCalSys->monthName( td.month(),
false ) )
1728 .arg( mCalSys->dayString( td,
false ) );
1732 TQFont serifFont(
"Times", 30);
1733 p.setFont(serifFont);
1735 int lineSpacing = p.fontMetrics().lineSpacing();
1736 p.drawText( 0, lineSpacing * 0, width, lineSpacing,
1737 TQt::AlignRight | TQt::AlignTop, title );
1742 p.drawLine(300, lineSpacing * 1, width, lineSpacing * 1);
1745 p.setFont(TQFont(
"Times", 20, TQFont::Bold, TRUE));
1746 int newlineSpacing = p.fontMetrics().lineSpacing();
1747 title += TQString::number(fd.year());
1748 p.drawText( 0, lineSpacing * 1 + 4, width, newlineSpacing,
1749 TQt::AlignRight | TQt::AlignTop, title );
1751 p.setFont( oldFont );
void printEventString(TQPainter &p, const TQRect &box, const TQString &str, int flags=-1)
Print the given string (event summary) in the given rectangle.
void drawDaysOfWeek(TQPainter &p, const TQDate &fromDate, const TQDate &toDate, const TQRect &box)
Draw a horizontal bar with the weekday names of the given date range in the given area of the painter...
virtual void loadConfig()=0
Load print format configuration from config file.
int footerHeight() const
Returns the height of the page footer.
void doSaveConfig()
Save complete config.
void drawMonth(TQPainter &p, const TQDate &dt, const TQRect &box, int maxdays=-1, int subDailyFlags=TimeBoxes, int holidaysFlags=Text)
Draw a vertical representation of the month containing the date dt.
void drawSmallMonth(TQPainter &p, const TQDate &qd, const TQRect &box)
Draw a small calendar with the days of a month into the given area.
TQColor categoryBgColor(Incidence *incidence)
Helper functions to hide the KOrg::CoreHelper.
virtual TQWidget * createConfigWidget(TQWidget *)
Returns widget for configuring the print format.
static void drawBox(TQPainter &p, int linewidth, const TQRect &rect)
Draw a box with given width at the given coordinates.
int drawBoxWithCaption(TQPainter &p, const TQRect &box, const TQString &caption, const TQString &contents, bool sameLine, bool expand, const TQFont &captionFont, const TQFont &textFont)
Draw a component box with a heading (printed in bold).
CalPrintPluginBase()
Constructor.
int headerHeight() const
Returns the height of the page header.
void drawSubHeaderBox(TQPainter &p, const TQString &str, const TQRect &box)
Draw a subheader box with a shaded background and the given string.
void drawDayBox(TQPainter &p, const TQDate &qd, const TQRect &box, bool fullDate=false, bool printRecurDaily=true, bool printRecurWeekly=true)
Draw the box containing a list of all events of the given day (with their times, of course).
void showEventBox(TQPainter &p, int linewidth, const TQRect &box, Incidence *incidence, const TQString &str, int flags=-1)
Print the box for the given event with the given string.
virtual void doPrint(KPrinter *printer)
Start printing.
void drawTimeTable(TQPainter &p, const TQDate &fromDate, const TQDate &toDate, TQTime &fromTime, TQTime &toTime, const TQRect &box)
Draw the timetable view of the given time range from fromDate to toDate.
void drawDaysOfWeekBox(TQPainter &p, const TQDate &qd, const TQRect &box)
Draw a single weekday name in a box inside the given area of the painter.
void drawJournal(Journal *journal, TQPainter &p, int x, int &y, int width, int pageHeight)
Draws single journal item.
void drawMonthTable(TQPainter &p, const TQDate &qd, bool weeknumbers, bool recurDaily, bool recurWeekly, const TQRect &box)
Draw the month table of the month containing the date qd.
int drawAllDayBox(TQPainter &p, Event::List &eventList, const TQDate &qd, bool expandable, const TQRect &box)
Draw the all-day box for the agenda print view (the box on top which doesn't have a time on the time ...
virtual void print(TQPainter &p, int width, int height)=0
Actually do the printing.
static int weekdayColumn(int weekday)
Determines the column of the given weekday ( 1=Monday, 7=Sunday ), taking the start of the week setti...
void drawTodo(int &count, Todo *todo, TQPainter &p, TodoSortField sortField, SortDirection sortDir, bool connectSubTodos, bool strikeoutCompleted, bool desc, int posPriority, int posSummary, int posDueDt, int posPercentComplete, int level, int x, int &y, int width, int pageHeight, const Todo::List &todoList, TodoParentStart *r=0)
Draws single to-do and its (intented) sub-to-dos, optionally connects them by a tree-like line,...
static void drawShadedBox(TQPainter &p, int linewidth, const TQBrush &brush, const TQRect &rect)
Draw a shaded box with given width at the given coordinates.
int drawHeader(TQPainter &p, TQString title, const TQDate &month1, const TQDate &month2, const TQRect &box, bool expand=false)
Draw the gray header bar of the printout to the TQPainter.
void drawVerticalBox(TQPainter &p, int linewidth, const TQRect &box, const TQString &str, int flags=-1)
Draw an event box with vertical text.
void setKOrgCoreHelper(KOrg::CoreHelper *helper)
HELPER FUNCTIONS.
void drawTimeLine(TQPainter &p, const TQTime &fromTime, const TQTime &toTime, const TQRect &box)
Draw a (vertical) time scale from time fromTime to toTime inside the given area of the painter.
virtual void saveConfig()=0
Write print format configuration to config file.
void drawWeek(TQPainter &p, const TQDate &qd, const TQRect &box)
Draw the week (filofax) table of the week containing the date qd.
void doLoadConfig()
Load complete config.
int drawFooter(TQPainter &p, TQRect &box)
Draw a page footer containing the printing date and possibly other things, like a page number.
void drawAgendaDayBox(TQPainter &p, Event::List &eventList, const TQDate &qd, bool expandable, TQTime &fromTime, TQTime &toTime, const TQRect &box)
Draw the agenda box for the day print style (the box showing all events of that day).
static Todo::List sortTodos(Todo::List *todoList, TodoSortField sortField, SortDirection sortDirection)
virtual Event::List events(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
virtual Todo::List todos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
virtual TQDateTime dtEnd() const
void setDtEnd(const TQDateTime &dtEnd)
virtual TQDateTime dtStart() const
void setSummary(const TQString &summary)
TQString description() const
TQStringList categories() const
virtual void setDtStart(const TQDateTime &dtStart)
void setCategories(const TQStringList &categories)
Incidence::List relations() const
TQString location() const
virtual TQValueList< TQDateTime > startDateTimesForDate(const TQDate &date) const
Recurrence * recurrence() const
virtual bool recursOn(const TQDate &qd) const
virtual TQDateTime endDateForStart(const TQDateTime &startDt) const
TQValueList< TQTime > recurTimesOn(const TQDate &date) const
bool recursOn(const TQDate &qd) const
bool hasStartDate() const
TQDateTime dtStart(bool first=false) const
int percentComplete() const
TQDateTime dtDue(bool first=false) const
virtual TQString description()=0
Returns short description of print format.
virtual TQString info()=0
Returns long description of print format.
KPrinter * mPrinter
The printer object.