33 #include <Akonadi/Calendar/ETMCalendar>
34 #include <calendarsupport/kcalprefs.h>
35 #include <calendarsupport/utils.h>
37 #include <KCalCore/Visitor>
39 #include <KCalUtils/IncidenceFormatter>
40 #include <KCalUtils/Stringify>
42 #include <KCalendarSystem>
44 #include <KConfigGroup>
45 #include <KSystemTimeZones>
51 using namespace KCalUtils;
53 static QString
cleanStr(
const QString &instr )
56 return ret.replace( QLatin1Char(
'\n'), QLatin1Char(
' ') );
132 class TimePrintStringsVisitor :
public Visitor
135 TimePrintStringsVisitor() {}
137 bool act( IncidenceBase::Ptr incidence )
139 return incidence->accept( *
this, incidence );
141 QString mStartCaption, mStartString;
142 QString mEndCaption, mEndString;
143 QString mDurationCaption, mDurationString;
146 bool visit( Event::Ptr event ) {
147 if ( event->dtStart().isValid() ) {
148 mStartCaption = i18n(
"Start date: " );
149 mStartString = IncidenceFormatter::dateTimeToString(
150 event->dtStart(),
event->allDay(), false );
152 mStartCaption = i18n(
"No start date" );
153 mStartString.clear();
156 if ( event->hasEndDate() ) {
157 mEndCaption = i18n(
"End date: " );
158 mEndString = IncidenceFormatter::dateTimeToString(
159 event->dtEnd(),
event->allDay(), false );
160 }
else if ( event->hasDuration() ) {
161 mEndCaption = i18n(
"Duration: " );
162 int mins =
event->duration().asSeconds() / 60;
164 mEndString += i18np(
"1 hour ",
"%1 hours ", mins / 60 );
166 if ( mins % 60 > 0 ) {
167 mEndString += i18np(
"1 minute ",
"%1 minutes ", mins % 60 );
170 mEndCaption = i18n(
"No end date" );
175 bool visit( Todo::Ptr todo ) {
176 if ( todo->hasStartDate() ) {
177 mStartCaption = i18n(
"Start date: " );
178 mStartString = IncidenceFormatter::dateTimeToString(
179 todo->dtStart(), todo->allDay(), false );
181 mStartCaption = i18n(
"No start date" );
182 mStartString.clear();
185 if ( todo->hasDueDate() ) {
186 mEndCaption = i18n(
"Due date: " );
187 mEndString = IncidenceFormatter::dateTimeToString(
188 todo->dtDue(), todo->allDay(), false );
190 mEndCaption = i18n(
"No due date" );
195 bool visit( Journal::Ptr journal ) {
196 mStartCaption = i18n(
"Start date: " );
197 mStartString = IncidenceFormatter::dateTimeToString(
198 journal->dtStart(), journal->allDay(), false );
203 bool visit( FreeBusy::Ptr fb ) {
210 const QString &caption,
212 QFont captionFont, QFont textFont )
214 QFontMetrics captionFM( captionFont );
215 int textWd = captionFM.width( caption );
216 QRect textRect( box );
218 QFont oldFont( p.font() );
219 p.setFont( captionFont );
220 p.drawText( box, Qt::AlignLeft|Qt::AlignTop|Qt::TextSingleLine, caption );
222 if ( !text.isEmpty() ) {
223 textRect.setLeft( textRect.left() + textWd );
224 p.setFont( textFont );
225 p.drawText( textRect, Qt::AlignLeft|Qt::AlignTop|Qt::TextSingleLine, text );
227 p.setFont( oldFont );
228 return textRect.bottom();
233 QFont oldFont( p.font() );
234 QFont textFont( QLatin1String(
"sans-serif"), 11, QFont::Normal );
235 QFont captionFont( QLatin1String(
"sans-serif"), 11, QFont::Bold );
236 p.setFont( textFont );
237 int lineHeight = p.fontMetrics().lineSpacing();
240 Incidence::List::ConstIterator it;
250 const bool isJournal = ( (*it)->type() == Incidence::TypeJournal );
282 QRect box( 0, 0, width, height );
283 QRect titleBox( box );
287 int titleBottom =
drawHeader( p, (*it)->summary(), QDate(), QDate(),
288 titleBox,
true, headerColor );
289 titleBox.setBottom( titleBottom );
291 QRect timesBox( titleBox );
292 timesBox.setTop( titleBox.bottom() +
padding() );
293 timesBox.setHeight( height / 8 );
295 TimePrintStringsVisitor stringVis;
296 int h = timesBox.top();
297 if ( stringVis.act( *it ) ) {
298 QRect textRect( timesBox.left() +
padding(),
299 timesBox.top() +
padding(), 0, lineHeight );
300 textRect.setRight( timesBox.center().x() );
302 stringVis.mStartString, captionFont, textFont );
304 textRect.setLeft( textRect.right() );
305 textRect.setRight( timesBox.right() -
padding() );
307 stringVis.mEndString, captionFont, textFont ), h );
311 if ( (*it)->recurs() ) {
313 timesBox.right() -
padding(), lineHeight );
314 KCalCore::Recurrence *recurs = (*it)->recurrence();
315 QString displayString = IncidenceFormatter::recurrenceString((*it));
317 QString exceptString;
318 if ( !recurs->exDates().isEmpty() ) {
319 exceptString = i18nc(
"except for listed dates",
" except" );
320 for (
int i = 0; i < recurs->exDates().size(); ++i ) {
321 exceptString.append( QLatin1String(
" ") );
322 exceptString.append( KGlobal::locale()->formatDate( recurs->exDates()[i],
323 KLocale::ShortDate ) );
326 displayString.append( exceptString );
328 displayString, captionFont, textFont ), h );
334 timesBox.right() -
padding(), lineHeight );
335 Alarm::List alarms = (*it)->alarms();
336 if ( alarms.count() == 0 ) {
337 cap = i18n(
"No reminders" );
340 cap = i18np(
"Reminder: ",
"%1 reminders: ", alarms.count() );
342 QStringList alarmStrings;
343 KCalCore::Alarm::List::ConstIterator it;
344 for ( it = alarms.constBegin(); it != alarms.constEnd(); ++it ) {
345 Alarm::Ptr alarm = *it;
348 KLocalizedString offsetstr;
350 if ( alarm->hasStartOffset() ) {
351 offset = alarm->startOffset().asSeconds();
353 offsetstr = ki18nc(
"N days/hours/minutes before/after the start/end",
354 "%1 before the start" );
357 offsetstr = ki18nc(
"N days/hours/minutes before/after the start/end",
358 "%1 after the start" );
360 }
else if ( alarm->hasEndOffset() ) {
361 offset = alarm->endOffset().asSeconds();
363 offsetstr = ki18nc(
"N days/hours/minutes before/after the start/end",
364 "%1 before the end" );
367 offsetstr = ki18nc(
"N days/hours/minutes before/after the start/end",
368 "%1 after the end" );
372 offset = offset / 60;
373 int useoffset = offset;
375 if ( offset % ( 24 * 60 ) == 0 && offset > 0 ) {
376 useoffset = offset / ( 24 * 60 );
377 offsetstr = offsetstr.subs( i18np(
"1 day",
"%1 days", useoffset ) );
378 }
else if ( offset % 60 == 0 && offset > 0 ) {
379 useoffset = offset / 60;
380 offsetstr = offsetstr.subs( i18np(
"1 hour",
"%1 hours", useoffset ) );
383 offsetstr = offsetstr.subs( i18np(
"1 minute",
"%1 minutes", useoffset ) );
385 alarmStrings << offsetstr.toString();
387 txt = alarmStrings.join( i18nc(
"Spacer for the joined list of categories",
", " ) );
393 timesBox.right() -
padding(), lineHeight );
395 (*it)->organizer()->fullName(), captionFont, textFont ), h );
398 timesBox.setBottom( qMax( timesBox.bottom(), h +
padding() ) );
401 QRect locationBox( timesBox );
402 locationBox.setTop( timesBox.bottom() +
padding() );
403 locationBox.setHeight( 0 );
404 int locationBottom = 0;
407 (*it)->location(),
true,
408 true, captionFont, textFont );
410 locationBox.setBottom( locationBottom );
413 QRect footerBox( locationBox );
414 footerBox.setBottom( box.bottom() );
415 footerBox.setTop( footerBox.bottom() - lineHeight - 2 *
padding() );
417 QRect categoriesBox( footerBox );
418 categoriesBox.setBottom( footerBox.top() );
419 categoriesBox.setTop( categoriesBox.bottom() - lineHeight - 2 *
padding() );
420 QRect attendeesBox( box.left(), categoriesBox.top() -
padding() - box.height() / 9,
421 box.width(), box.height() / 9 );
422 QRect attachmentsBox( box.left(), attendeesBox.top() -
padding() - box.height() / 9,
423 box.width() * 3 / 4 -
padding(), box.height() / 9 );
424 QRect optionsBox( isJournal ? box.left() : attachmentsBox.right() +
padding(),
425 attachmentsBox.top(), 0, 0 );
426 optionsBox.setRight( box.right() );
427 optionsBox.setBottom( attachmentsBox.bottom() );
428 QRect notesBox( optionsBox.left(),
429 isJournal ? ( timesBox.bottom() +
padding() ) :
430 ( locationBox.bottom() +
padding() ),
431 optionsBox.width(), 0 );
432 notesBox.setBottom( optionsBox.top() -
padding() );
433 QRect descriptionBox( notesBox );
434 descriptionBox.setLeft( box.left() );
435 descriptionBox.setRight( attachmentsBox.right() );
439 descriptionBox.setRight( box.right() );
442 descriptionBox.setBottom( attachmentsBox.bottom() );
443 optionsBox.setTop( attendeesBox.top() );
444 optionsBox.setBottom( attendeesBox.bottom() );
445 notesBox.setBottom( attachmentsBox.bottom() );
447 attendeesBox.setRight( attachmentsBox.right() );
451 descriptionBox.setBottom( attendeesBox.bottom() );
454 descriptionBox.setBottom( attendeesBox.bottom() );
455 notesBox.setBottom( attendeesBox.bottom() );
461 attachmentsBox.setRight( box.right() );
462 attachmentsBox.setRight( box.right() );
465 attachmentsBox.setTop( attendeesBox.top() );
466 attachmentsBox.setBottom( attendeesBox.bottom() );
470 (*it)->description(),
false,
471 false, captionFont, textFont,
472 (*it)->descriptionIsRich() );
477 Akonadi::Item item =
mCalendar->item( (*it)->uid() );
478 Akonadi::Item::List relations =
mCalendar->childItems( item.id() );
481 if ( relations.isEmpty() || (*it)->type() != Incidence::TypeTodo ) {
484 false, captionFont, textFont );
488 QString subitemCaption;
489 if ( relations.count() == 0 ) {
490 subitemCaption = i18n(
"No Subitems" );
493 subitemCaption = i18np(
"1 Subitem:",
498 QString subitemString;
499 QString statusString;
502 foreach (
const Akonadi::Item &item, relations ) {
503 Todo::Ptr todo = CalendarSupport::todo( item );
509 statusString = Stringify::incidenceStatus( todo->status() );
510 if ( statusString.isEmpty() ) {
511 if ( todo->status() == Incidence::StatusNone ) {
512 statusString = i18nc(
"no status",
"none" );
514 statusString = i18nc(
"unknown status",
"unknown" );
519 KDateTime::Spec spec = CalendarSupport::KCalPrefs::instance()->timeSpec();
520 if ( todo->dtStart().isValid() ) {
521 datesString += i18nc(
522 "subitem start date",
"Start Date: %1\n",
523 KGlobal::locale()->formatDate( todo->dtStart().toTimeSpec( spec ).date(),
524 KLocale::ShortDate ) );
525 if ( !todo->allDay() ) {
526 datesString += i18nc(
527 "subitem start time",
"Start Time: %1\n",
528 KGlobal::locale()->formatTime( todo->dtStart().toTimeSpec( spec ).time(),
532 if ( todo->dateTime( Incidence::RoleEnd ).isValid() ) {
534 i18nc(
"subitem due date",
"Due Date: %1\n",
535 KGlobal::locale()->formatDate(
536 todo->dateTime( Incidence::RoleEnd ).toTimeSpec( spec ).date(),
537 KLocale::ShortDate ) );
539 if ( !todo->allDay() ) {
540 subitemString += i18nc(
541 "subitem due time",
"Due Time: %1\n",
542 KGlobal::locale()->formatTime(
543 todo->dateTime( Incidence::RoleEnd ).toTimeSpec( spec ).time(),
547 subitemString += i18nc(
"subitem counter",
"%1: ", count );
548 subitemString += todo->summary();
549 subitemString += QLatin1Char(
'\n');
550 if ( !datesString.isEmpty() ) {
551 subitemString += datesString;
552 subitemString += QLatin1Char(
'\n');
554 subitemString += i18nc(
"subitem Status: statusString",
557 subitemString += IncidenceFormatter::recurrenceString( todo ) + QLatin1Char(
'\n');
558 subitemString += i18nc(
"subitem Priority: N",
559 "Priority: <numid>%1</numid>\n",
561 subitemString += i18nc(
"subitem Secrecy: secrecyString",
563 Stringify::incidenceSecrecy( todo->secrecy() ) );
564 subitemString += QLatin1Char(
'\n');
567 subitemString,
false,
568 false, captionFont, textFont );
573 Attachment::List attachments = (*it)->attachments();
574 QString attachmentCaption;
575 if ( attachments.count() == 0 ) {
576 attachmentCaption = i18n(
"No Attachments" );
579 attachmentCaption = i18np(
"1 Attachment:",
581 attachments.count() );
583 QString attachmentString;
584 Attachment::List::ConstIterator ait = attachments.constBegin();
585 for ( ; ait != attachments.constEnd(); ++ait ) {
586 if ( !attachmentString.isEmpty() ) {
587 attachmentString += i18nc(
"Spacer for list of attachments",
" " );
589 attachmentString.append( (*ait)->label() );
592 attachmentCaption, attachmentString,
594 captionFont, textFont );
597 Attendee::List attendees = (*it)->attendees();
598 QString attendeeCaption;
599 if ( attendees.count() == 0 ) {
600 attendeeCaption = i18n(
"No Attendees" );
602 attendeeCaption = i18np(
"1 Attendee:",
606 QString attendeeString;
607 Attendee::List::ConstIterator ait = attendees.constBegin();
608 for ( ; ait != attendees.constEnd(); ++ait ) {
609 if ( !attendeeString.isEmpty() ) {
610 attendeeString += QLatin1Char(
'\n');
612 attendeeString += i18nc(
613 "Formatting of an attendee: "
614 "'Name (Role): Status', e.g. 'Reinhold Kainhofer "
615 "<reinhold@kainhofer.com> (Participant): Awaiting Response'",
618 Stringify::attendeeRole( (*ait)->role() ),
619 Stringify::attendeeStatus( ( *ait )->status() ) );
623 captionFont, textFont );
627 QString optionsString;
628 if ( !Stringify::incidenceStatus( (*it)->status() ).isEmpty() ) {
629 optionsString += i18n(
"Status: %1", Stringify::incidenceStatus( (*it)->status() ) );
630 optionsString += QLatin1Char(
'\n');
632 if ( !Stringify::incidenceSecrecy( (*it)->secrecy() ).isEmpty() ) {
633 optionsString += i18n(
"Secrecy: %1", Stringify::incidenceSecrecy( (*it)->secrecy() ) );
634 optionsString += QLatin1Char(
'\n');
636 if ( (*it)->type() == Incidence::TypeEvent ) {
637 Event::Ptr e = (*it).staticCast<Event>();
638 if ( e->transparency() == Event::Opaque ) {
639 optionsString += i18n(
"Show as: Busy" );
641 optionsString += i18n(
"Show as: Free" );
643 optionsString += QLatin1Char(
'\n');
644 }
else if ( (*it)->type() == Incidence::TypeTodo ) {
645 Todo::Ptr t = (*it).staticCast<Todo>();
646 if ( t->isOverdue() ) {
647 optionsString += i18n(
"This task is overdue!" );
648 optionsString += QLatin1Char(
'\n');
650 }
else if ( (*it)->type() == Incidence::TypeJournal ) {
654 optionsString,
false,
false,
655 captionFont, textFont );
659 (*it)->categories().join( i18nc(
"Spacer for the joined list of categories",
", " ) ),
660 true,
false, captionFont, textFont );
666 p.setFont( oldFont );
692 mToDate = cfg->mToDate->date();
694 if ( cfg->mPrintTypeFilofax->isChecked() ) {
696 }
else if ( cfg->mPrintTypeTimetable->isChecked() ) {
723 cfg->mToDate->setDate(
mToDate );
749 QDate dt = QDate::currentDate();
751 QDateTime startTm( dt, tm1 );
752 QDateTime endTm( dt, tm1.addSecs( 12 * 60 * 60 ) );
753 mStartTime = grp.readEntry(
"Start time", startTm ).time();
754 mEndTime = grp.readEntry(
"End time", endTm ).time();
771 QDateTime dt = QDateTime::currentDateTime();
773 grp.writeEntry(
"Start time", dt );
775 grp.writeEntry(
"End time", dt );
792 cfg->mFromDate->setDate( from );
793 cfg->mToDate->setDate( to );
801 KDateTime::Spec timeSpec = KSystemTimeZones::local();
807 KLocale *local = KGlobal::locale();
813 QRect daysBox( headerBox );
814 daysBox.setTop( headerBox.bottom() +
padding() );
815 daysBox.setBottom( height );
816 QString line1 = local->formatDate(
mFromDate );
817 QString line2 = local->formatDate(
mToDate );
820 title = i18nc(
"date from-to",
"%1 - %2", line1, line2 );
822 title = i18nc(
"date from-\nto",
"%1 -\n%2", line1, line2 );
849 if ( curEndTime <= curStartTime ) {
850 curStartTime = QTime( curStartTime.hour(), 0, 0 );
851 curEndTime = curStartTime.addSecs( 3600 );
854 drawHeader( p, local->formatDate( curDay ), curDay, QDate(), headerBox );
855 KCalCore::Event::List eventList =
mCalendar->events( curDay, timeSpec,
856 KCalCore::EventSortStartDate,
857 KCalCore::SortDirectionAscending );
860 KCalCore::Event::List alldayEvents, timedEvents;
861 foreach(
const KCalCore::Event::Ptr &event, eventList ) {
862 if ( event->allDay() ) {
863 alldayEvents.append( event );
865 timedEvents.append( event );
870 QFont textFont( QLatin1String(
"sans-serif"), fontSize, QFont::Normal );
871 p.setFont( textFont );
872 int lineSpacing = p.fontMetrics().lineSpacing();
874 int maxAllDayEvents = 8;
875 int allDayHeight = qMin( alldayEvents.count(), maxAllDayEvents ) * lineSpacing;
876 allDayHeight = qMax( allDayHeight, ( 5 * lineSpacing ) ) + ( 2 *
padding() );
879 if ( alldayEvents.count() > 0 ) {
881 QFont oldFont( p.font() );
882 p.setFont( QFont( QLatin1String(
"sans-serif"), 9, QFont::Normal ) );
886 i18n(
"Today's Events" ),
887 Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap );
888 p.setFont( oldFont );
893 QRect eventBox( allDayBox );
895 eventBox.setTop( eventBox.top() +
padding() );
896 eventBox.setBottom( eventBox.top() + lineSpacing );
898 foreach (
const KCalCore::Event::Ptr &event, alldayEvents ) {
899 if ( count == maxAllDayEvents ) {
904 if ( event->location().isEmpty() ) {
907 str = i18nc(
"summary, location",
"%1, %2",
911 eventBox.setTop( eventBox.bottom() );
912 eventBox.setBottom( eventBox.top() + lineSpacing );
915 allDayBox.setBottom( headerBox.bottom() );
918 QRect dayBox( allDayBox );
919 dayBox.setTop( allDayBox.bottom() +
padding() );
920 dayBox.setBottom( height );
923 curStartTime, curEndTime, dayBox,
928 QRect tlBox( dayBox );
937 curDay = curDay.addDays( 1 );
967 mToDate = cfg->mToDate->date();
969 if ( cfg->mPrintTypeFilofax->isChecked() ) {
971 }
else if ( cfg->mPrintTypeTimetable->isChecked() ) {
973 }
else if ( cfg->mPrintTypeSplitWeek->isChecked() ) {
999 cfg->mToDate->setDate(
mToDate );
1024 QDate dt = QDate::currentDate();
1026 QDateTime startTm( dt, tm1 );
1027 QDateTime endTm( dt, tm1.addSecs( 43200 ) );
1028 mStartTime = grp.readEntry(
"Start time", startTm ).time();
1029 mEndTime = grp.readEntry(
"End time", endTm ).time();
1045 QDateTime dt = QDateTime::currentDateTime();
1047 grp.writeEntry(
"Start time", dt );
1049 grp.writeEntry(
"End time", dt );
1062 return QPrinter::Portrait;
1064 return QPrinter::Portrait;
1066 return QPrinter::Landscape;
1076 cfg->mFromDate->setDate( from );
1077 cfg->mToDate->setDate( to );
1083 QDate curWeek, fromWeek, toWeek;
1087 fromWeek =
mFromDate.addDays( -weekdayCol );
1089 toWeek =
mToDate.addDays( 6 - weekdayCol );
1091 curWeek = fromWeek.addDays( 6 );
1092 KLocale *local = KGlobal::locale();
1094 QString line1, line2, title;
1099 QRect weekBox( headerBox );
1100 weekBox.setTop( headerBox.bottom() +
padding() );
1101 weekBox.setBottom( height );
1106 line1 = local->formatDate( curWeek.addDays( -6 ) );
1107 line2 = local->formatDate( curWeek );
1109 title = i18nc(
"date from-to",
"%1 - %2", line1, line2 );
1111 title = i18nc(
"date from-\nto",
"%1 -\n%2", line1, line2 );
1113 drawHeader( p, title, curWeek.addDays( -6 ), QDate(), headerBox );
1123 curWeek = curWeek.addDays( 7 );
1124 if ( curWeek <= toWeek ) {
1127 }
while ( curWeek <= toWeek );
1133 line1 = local->formatDate( curWeek.addDays( -6 ) );
1134 line2 = local->formatDate( curWeek );
1136 title = i18nc(
"date from - to (week number)",
"%1 - %2 (Week %3)",
1137 line1, line2, curWeek.weekNumber() );
1139 title = i18nc(
"date from -\nto (week number)",
"%1 -\n%2 (Week %3)",
1140 line1, line2, curWeek.weekNumber() );
1142 drawHeader( p, title, curWeek, QDate(), headerBox );
1153 fromWeek = fromWeek.addDays( 7 );
1154 curWeek = fromWeek.addDays( 6 );
1155 if ( curWeek <= toWeek ) {
1158 }
while ( curWeek <= toWeek );
1163 QRect weekBox1( weekBox );
1169 QDate endLeft( fromWeek.addDays( 3 ) );
1191 fromWeek = fromWeek.addDays( 7 );
1192 curWeek = fromWeek.addDays( 6 );
1193 if ( curWeek <= toWeek ) {
1196 }
while ( curWeek <= toWeek );
1224 mFromDate = QDate( cfg->mFromYear->value(), cfg->mFromMonth->currentIndex()+1, 1 );
1225 mToDate = QDate( cfg->mToYear->value(), cfg->mToMonth->currentIndex()+1, 1 );
1266 mWeekNumbers = grp.readEntry(
"Print week numbers",
true );
1267 mRecurDaily = grp.readEntry(
"Print daily incidences",
true );
1268 mRecurWeekly = grp.readEntry(
"Print weekly incidences",
true );
1283 grp.writeEntry(
"Print daily incidences",
mRecurDaily );
1284 grp.writeEntry(
"Print weekly incidences",
mRecurWeekly );
1298 if ( cfg && calSys ) {
1299 cfg->mFromMonth->clear();
1300 for (
int i=0; i<calSys->monthsInYear(
mFromDate ); ++i ) {
1301 cfg->mFromMonth->addItem( calSys->monthName( i+1,
mFromDate.year() ) );
1303 cfg->mToMonth->clear();
1304 for (
int i=0; i<calSys->monthsInYear(
mToDate ); ++i ) {
1305 cfg->mToMonth->addItem( calSys->monthName( i+1,
mToDate.year() ) );
1309 cfg->mFromMonth->setCurrentIndex( from.month()-1 );
1310 cfg->mFromYear->setValue( to.year() );
1311 cfg->mToMonth->setCurrentIndex(
mToDate.month()-1 );
1312 cfg->mToYear->setValue(
mToDate.year() );
1318 QDate curMonth, fromMonth, toMonth;
1323 curMonth = fromMonth;
1333 QRect monthBox( 0, 0, width, height );
1334 monthBox.setTop( headerBox.bottom() +
padding() );
1337 QString title( i18nc(
"monthname year",
"%1 <numid>%2</numid>",
1338 calSys->monthName( curMonth ),
1339 curMonth.year() ) );
1340 QDate tmp( fromMonth );
1342 tmp = tmp.addDays( -weekdayCol );
1344 drawHeader( p, title, curMonth.addMonths( -1 ), curMonth.addMonths( 1 ),
1347 curMonth, QTime(), QTime(),
1357 curMonth = curMonth.addDays( curMonth.daysInMonth() );
1358 if ( curMonth <= toMonth ) {
1361 }
while ( curMonth <= toMonth );
1391 if ( cfg->mPrintAll->isChecked() ) {
1393 }
else if ( cfg->mPrintUnfinished->isChecked() ) {
1395 }
else if ( cfg->mPrintDueRange->isChecked() ) {
1402 mToDate = cfg->mToDate->date();
1432 cfg->mToDate->setDate(
mToDate );
1445 cfg->mSortField->addItem( i18nc(
"@option sort by title",
"Title" ) );
1446 cfg->mSortField->addItem( i18nc(
"@option sort by start date/time",
"Start Date" ) );
1447 cfg->mSortField->addItem( i18nc(
"@option sort by due date/time",
"Due Date" ) );
1448 cfg->mSortField->addItem( i18nc(
"@option sort by priority",
"Priority" ) );
1449 cfg->mSortField->addItem( i18nc(
"@option sort by percent completed",
"Percent Complete" ) );
1455 cfg->mSortDirection->addItem( i18nc(
"@option sort in increasing order",
"Ascending" ) );
1456 cfg->mSortDirection->addItem( i18nc(
"@option sort in descreasing order",
"Descending" ) );
1468 mPageTitle = grp.readEntry(
"Page title", i18n(
"To-do list" ) );
1505 int pospriority = 0;
1506 int possummary = 100;
1507 int posdue = width - 65;
1508 int poscomplete = posdue - 70;
1509 int lineSpacing = 15;
1522 QFont oldFont( p.font() );
1524 p.setFont( QFont( QLatin1String(
"sans-serif"), 9, QFont::Bold ) );
1525 lineSpacing = p.fontMetrics().lineSpacing();
1526 mCurrentLinePos += lineSpacing;
1528 outStr += i18n(
"Priority" );
1529 p.drawText( pospriority, mCurrentLinePos - 2, outStr );
1534 outStr.truncate( 0 );
1535 outStr += i18nc(
"@label to-do summary",
"Title" );
1536 p.drawText( possummary, mCurrentLinePos - 2, outStr );
1540 poscomplete = posdue;
1542 outStr.truncate( 0 );
1543 outStr += i18nc(
"@label to-do percentage complete",
"Complete" );
1544 p.drawText( poscomplete, mCurrentLinePos - 2, outStr );
1550 outStr.truncate( 0 );
1551 outStr += i18nc(
"@label to-do due date",
"Due" );
1552 p.drawText( posdue, mCurrentLinePos - 2, outStr );
1557 p.setFont( QFont( QLatin1String(
"sans-serif"), 10 ) );
1560 KCalCore::Todo::List todoList;
1561 KCalCore::Todo::List tempList;
1563 KCalCore::SortDirection sortDirection = KCalCore::SortDirectionAscending;
1566 sortDirection = KCalCore::SortDirectionAscending;
1569 sortDirection = KCalCore::SortDirectionDescending;
1575 KCalCore::TodoSortField sortField = KCalCore::TodoSortSummary;
1578 sortField = KCalCore::TodoSortSummary;
1581 sortField = KCalCore::TodoSortStartDate;
1584 sortField = KCalCore::TodoSortDueDate;
1587 sortField = KCalCore::TodoSortPriority;
1590 sortField = KCalCore::TodoSortPercentComplete;
1597 todoList =
mCalendar->todos( sortField, sortDirection );
1602 foreach(
const KCalCore::Todo::Ptr& todo, todoList ) {
1604 if ( !todo->isCompleted() ) {
1605 tempList.append( todo );
1608 todoList = tempList;
1611 foreach(
const KCalCore::Todo::Ptr& todo, todoList ) {
1613 if ( todo->hasDueDate() ) {
1614 if ( todo->dtDue().date() >=
mFromDate && todo->dtDue().date() <=
mToDate ) {
1615 tempList.append( todo );
1618 tempList.append( todo );
1621 todoList = tempList;
1627 foreach(
const KCalCore::Todo::Ptr& todo, todoList ) {
1629 (
mExcludePrivate && todo->secrecy() == Incidence::SecrecyPrivate ) ) {
1633 if ( todo->relatedTo().isEmpty() ) {
1636 sortField, sortDirection,
1639 pospriority, possummary, posdue, poscomplete,
1640 0, 0, mCurrentLinePos, width, height, todoList, 0,
1648 p.setFont( oldFont );
void drawDays(QPainter &p, const QDate &start, const QDate &end, const QTime &fromTime, const QTime &toTime, const QRect &box, bool singleLineLimit, bool showNoteLines, bool includeDescription, bool excludeConfidential, bool excludePrivate)
Draw the (filofax) table for a bunch of days, using drawDayBox.
static QString cleanStr(const QString &instr)
int drawHeader(QPainter &p, const QString &title, const QDate &month1, const QDate &month2, const QRect &box, bool expand=false, QColor backColor=QColor())
Draw the gray header bar of the printout to the QPainter.
virtual void saveConfig()
Write print format configuration to config file.
virtual void saveConfig()
Write print format configuration to config file.
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
virtual QString groupName()
Returns KConfig group name where store settings.
QPrinter::Orientation orientation() const
virtual void loadConfig()
Load print format configuration from config file.
virtual QString groupName()
Returns KConfig group name where store settings.
virtual void loadConfig()
Load print format configuration from config file.
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
virtual void loadConfig()
Load print format configuration from config file.
void print(QPainter &p, int width, int height)
Actually do the printing.
QPrinter * mPrinter
The printer object.
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
int printCaptionAndText(QPainter &p, const QRect &box, const QString &caption, const QString &text, QFont captionFont, QFont textFont)
virtual void loadConfig()
Load print format configuration from config file.
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
QColor categoryBgColor(const Incidence::Ptr &incidence)
Helper functions to hide the KOrg::CoreHelper.
virtual QString groupName()
Returns KConfig group name where store settings.
enum CalPrintDay::eDayPrintType mDayPrintType
static int weekdayColumn(int weekday)
Determines the column of the given weekday ( 1=Monday, 7=Sunday ), taking the start of the week setti...
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
enum CalPrintTodos::eTodoSortDirection mTodoSortDirection
void drawSplitHeaderRight(QPainter &p, const QDate &fd, const QDate &td, const QDate &cd, int width, int height)
virtual void saveConfig()
Write print format configuration to config file.
void drawNoteLines(QPainter &p, const QRect &box, int startY)
Draws dotted lines for notes in a box.
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
bool mExcludeConfidential
virtual void saveConfig()
Write print format configuration to config file.
int headerHeight() const
Returns the height of the page header.
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
virtual QString groupName()
Returns KConfig group name where store settings.
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
static void drawBox(QPainter &p, int linewidth, const QRect &rect)
Draw a box with given width at the given coordinates.
void print(QPainter &p, int width, int height)
Actually do the printing.
void print(QPainter &p, int width, int height)
Actually do the printing.
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
virtual QString groupName()
Returns KConfig group name where store settings.
void print(QPainter &p, int width, int height)
Actually do the printing.
void drawTimeTable(QPainter &p, const QDate &fromDate, const QDate &toDate, bool expandable, const QTime &fromTime, const QTime &toTime, const QRect &box, bool includeDescription, bool excludeTime, bool excludeConfidential, bool excludePrivate)
Draw the timetable view of the given time range from fromDate to toDate.
virtual ~CalPrintIncidence()
int drawBoxWithCaption(QPainter &p, const QRect &box, const QString &caption, const QString &contents, bool sameLine, bool expand, const QFont &captionFont, const QFont &textFont, bool richContents=false)
Draw a component box with a heading (printed in bold).
Base class for KOrganizer printing classes.
static KOGlobals * self()
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
void drawMonthTable(QPainter &p, const QDate &qd, const QTime &fromTime, const QTime &toTime, bool weeknumbers, bool recurDaily, bool recurWeekly, bool singleLineLimit, bool showNoteLines, bool includeDescription, bool excludeConfidential, bool excludePrivate, const QRect &box)
Draw the month table of the month containing the date qd.
enum CalPrintTodos::eTodoPrintType mTodoPrintType
QList< QDate > workDays(const QDate &start, const QDate &end) const
Returns a list containing work days between start and .
const KCalendarSystem * calendarSystem() const
void print(QPainter &p, int width, int height)
Actually do the printing.
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
virtual void loadConfig()
Load print format configuration from config file.
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
void drawTodo(int &count, const KCalCore::Todo::Ptr &todo, QPainter &p, KCalCore::TodoSortField sortField, KCalCore::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 KCalCore::Todo::List &todoList, TodoParentStart *r, bool excludeConfidential, bool excludePrivate)
Draws single to-do and its (intented) sub-to-dos, optionally connects them by a tree-like line...
int drawFooter(QPainter &p, const QRect &box)
Draw a page footer containing the printing date and possibly other things, like a page number...
int footerHeight() const
Returns the height of the page footer.
virtual QPrinter::Orientation defaultOrientation()
Returns the default orientation for the eWeekPrintType.
void printEventString(QPainter &p, const QRect &box, const QString &str, int flags=-1)
Print the given string (event summary) in the given rectangle.
void drawWeek(QPainter &p, const QDate &qd, const QTime &fromTime, const QTime &toTime, const QRect &box, bool singleLineLimit, bool showNoteLines, bool includeDescription, bool excludeConfidential, bool excludePrivate)
Draw the week (filofax) table of the week containing the date qd.
void drawAgendaDayBox(QPainter &p, const KCalCore::Event::List &eventList, const QDate &qd, bool expandable, const QTime &fromTime, const QTime &toTime, const QRect &box, bool includeDescription, bool excludeTime, bool mExcludeConfidential, bool mExcludePrivate, const QList< QDate > &workDays)
Draw the agenda box for the day print style (the box showing all events of that day).
void drawTimeLine(QPainter &p, const QTime &fromTime, const QTime &toTime, const QRect &box)
Draw a (vertical) time scale from time fromTime to toTime inside the given area of the painter...
virtual void saveConfig()
Write print format configuration to config file.
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
QPointer< QWidget > mConfigWidget
enum CalPrintTodos::eTodoSortField mTodoSortField
Akonadi::ETMCalendar::Ptr mCalendar
void drawVerticalBox(QPainter &p, int linewidth, const QRect &box, const QString &str, int flags=-1)
Draw an event box with vertical text.
bool mIncludePercentComplete
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
enum CalPrintWeek::eWeekPrintType mWeekPrintType
KCalCore::Incidence::List mSelectedIncidences