31 #include <Akonadi/Item>
33 #include <KCalendarSystem>
34 #include <KConfigGroup>
36 #include <KSystemTimeZones>
39 #include <QAbstractTextDocumentLayout>
44 #include <QTextCursor>
45 #include <QTextDocument>
46 #include <QTextDocumentFragment>
49 using namespace CalendarSupport;
60 class CalPrintPluginBase::TodoParentStart
63 TodoParentStart(
const QRect &pt =
QRect(),
bool hasLine =
false,
bool page =
true )
64 : mRect( pt ), mHasLine( hasLine ), mSamePage( page ) {}
75 class PrintCellItem :
public CellItem
78 PrintCellItem(
const KCalCore::Event::Ptr &
event,
const KDateTime &start,
const KDateTime &end )
79 : mEvent( event ), mStart( start ), mEnd( end )
83 KCalCore::Event::Ptr
event()
const {
return mEvent; }
85 QString label()
const {
return mEvent->summary(); }
87 KDateTime start()
const {
return mStart; }
88 KDateTime end()
const {
return mEnd; }
94 PrintCellItem *other =
static_cast<PrintCellItem *
>( o );
95 return !( other->start() >= end() || other->end() <= start() );
99 KCalCore::Event::Ptr mEvent;
100 KDateTime mStart, mEnd;
108 :
PrintPlugin(), mUseColors( true ), mPrintFooter( true ),
109 mHeaderHeight( -1 ), mSubHeaderHeight(
SUBHEADER_HEIGHT ), mFooterHeight( -1 ),
126 titleFont.setBold(
true );
133 new QLabel( i18n(
"This printing style does not have any configuration options." ), wdg ) );
165 print( p, pageWidth, pageHeight );
177 mFromDate = group.readEntry(
"FromDate", dt ).date();
178 mToDate = group.readEntry(
"ToDate", dt ).date();
179 mUseColors = group.readEntry(
"UseColors",
true );
183 kDebug() <<
"No config available in loadConfig!!!!";
194 group.writeEntry(
"FromDate", dt );
196 group.writeEntry(
"ToDate", dt );
201 kDebug() <<
"No config available in saveConfig!!!!";
230 QColor CalPrintPluginBase::getTextColor(
const QColor &c )
const
232 double luminance = ( c.
red() * 0.299 ) + ( c.
green() * 0.587 ) + ( c.
blue() * 0.114 );
233 return ( luminance > 128.0 ) ?
QColor( 0, 0, 0 ) :
QColor( 255, 255, 255 );
238 QTime start( 8, 0, 0 );
241 start = dayBegins.
time();
246 void CalPrintPluginBase::setColorsByIncidenceCategory(
QPainter &p,
const KCalCore::Incidence::Ptr &
incidence )
const
252 QColor tColor( getTextColor( bgColor ) );
253 if ( tColor.isValid() ) {
277 QColor backColor = categoryColor( incidence->categories() );
278 if ( incidence->type() == KCalCore::Incidence::TypeTodo ) {
279 if ( ( incidence.staticCast<KCalCore::Todo>() )->isOverdue() ) {
280 backColor =
QColor( 255, 100, 100 );
289 QString CalPrintPluginBase::holidayString(
const QDate &date )
const
292 return lst.
join( i18nc(
"@item:intext delimiter for joining holiday names",
"," ) );
295 KCalCore::Event::Ptr CalPrintPluginBase::holidayEvent(
const QDate &date )
const
297 QString hstring( holidayString( date ) );
298 if ( hstring.isEmpty() ) {
299 return KCalCore::Event::Ptr();
302 KCalCore::Event::Ptr
holiday(
new KCalCore::Event );
303 holiday->setSummary( hstring );
304 holiday->setCategories( i18n(
"Holiday" ) );
306 KDateTime kdt( date,
QTime(), KSystemTimeZones::local() );
317 mCalSys = KGlobal::locale()->calendar();
331 }
else if (
orientation() == QPrinter::Portrait ) {
361 }
else if (
orientation() == QPrinter::Portrait ) {
408 if ( linewidth >= 0 ) {
409 pen.setWidth( linewidth );
428 const QString &str,
int flags )
431 newbox.
adjust( 3, 1, -1, -1 );
432 p.
drawText( newbox, ( flags == -1 ) ?
433 ( Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap ) : flags, str );
437 const KCalCore::Incidence::Ptr &incidence,
const QString &str,
450 p.
setPen( getTextColor( bgColor ) );
462 p.
drawText( box, Qt::AlignCenter | Qt::AlignVCenter, str );
467 const QString &str,
int flags )
472 showEventBox( p, linewidth, rotatedBox, KCalCore::Incidence::Ptr(), str,
473 ( flags == -1 ) ? Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine : flags );
485 bool sameLine,
bool expand,
486 const QFont &captionFont,
487 const QFont &textFont,
502 Qt::AlignLeft | Qt::AlignTop | Qt::TextSingleLine,
505 if ( captionBox.right() > box.right() ) {
506 captionBox.setRight( box.right() );
508 if ( expand && captionBox.bottom() +
padding() > box.bottom() ) {
509 box.setBottom( captionBox.bottom() +
padding() );
513 QRect textBox( captionBox );
524 p.
drawText( captionBox, Qt::AlignLeft | Qt::AlignTop | Qt::TextSingleLine,
531 p.
drawText( textBox, Qt::AlignLeft | Qt::AlignTop | Qt::TextSingleLine,
536 if ( richContents ) {
541 int boxHeight = allbox.
height();
543 boxHeight -= captionBox.height();
549 QRect clipBox( 0, 0, box.width(), boxHeight );
567 bool expand,
QColor backColor )
570 int smallMonthWidth = ( allbox.
width() / 4 ) - 10;
571 if ( smallMonthWidth > 100 ) {
572 smallMonthWidth = 100;
576 QRect textRect( allbox );
583 p.
boundingRect( textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, title );
585 int h = boundingR.
height();
586 if ( h > allbox.
height() ) {
593 backColor =
QColor( 232, 232, 232 );
601 smallMonthWidth, box.
height() );
604 textRect.
setRight( monthbox2.left() );
606 QRect monthbox1( monthbox2.left()-10-smallMonthWidth, box.
top(),
607 smallMonthWidth, box.
height() );
610 textRect.
setRight( monthbox1.left() );
615 textRect.
adjust( 5, 0, 0, 0 );
616 p.
drawText( textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, title );
621 smallMonthWidth, box.
height() );
624 textRect.
setRight( monthbox2.left() );
629 textRect.
setLeft( monthbox1.right() );
634 p.
drawText( textRect, Qt::AlignCenter | Qt::AlignVCenter | Qt::TextWordWrap, title );
647 p.
drawText( footbox, Qt::AlignCenter | Qt::AlignVCenter | Qt::TextSingleLine,
648 i18nc(
"print date: formatted-datetime",
"printed: %1", dateStr ) );
657 int month = qd.
month();
662 double cellWidth = double( box.
width() ) /
double( 7 );
663 int rownr = 3 + ( qd.
daysInMonth() + weekdayCol - 1 ) / 7;
665 double cellHeight = ( box.
height() - 5 ) / rownr;
671 QRect titleBox( box );
672 titleBox.
setHeight(
int( cellHeight + 1 ) );
673 p.
drawText( titleBox, Qt::AlignTop | Qt::AlignHCenter,
mCalSys->monthName( qd ) );
677 QRect wdayBox( box );
678 wdayBox.
setTop(
int( box.
top() + 3 + cellHeight ) );
679 wdayBox.
setHeight(
int( 2 * cellHeight ) -
int( cellHeight ) );
682 for (
int col = 0; col < 7; ++col ) {
684 wdayBox.
setLeft(
int( box.
left() + col * cellWidth ) );
685 wdayBox.
setRight(
int( box.
left() + ( col + 1 ) * cellWidth ) );
686 p.
drawText( wdayBox, Qt::AlignCenter, tmpStr );
687 monthDate2 = monthDate2.addDays( 1 );
692 int calStartY = wdayBox.
bottom() + 2;
694 monthDate = monthDate.
addDays( -weekdayCol );
696 for (
int row = 0; row < (rownr-2); row++ ) {
697 for (
int col = 0; col < 7; col++ ) {
698 if ( monthDate.
month() == month ) {
699 QRect dayRect(
int( box.
left() + col * cellWidth ),
700 int( calStartY + row * cellHeight ), 0, 0 );
701 dayRect.
setRight(
int( box.
left() + ( col + 1 ) * cellWidth ) );
702 dayRect.setBottom(
int( calStartY + ( row + 1 ) * cellHeight ) );
705 monthDate = monthDate.
addDays(1);
716 const QDate &fromDate,
719 double cellWidth = double( box.
width() ) /
double( fromDate.
daysTo( toDate ) + 1 );
720 QDate cellDate( fromDate );
721 QRect dateBox( box );
724 while ( cellDate <= toDate ) {
725 dateBox.
setLeft( box.
left() + int( i * cellWidth ) );
726 dateBox.
setRight( box.
left() + int( ( i + 1 ) * cellWidth ) );
728 cellDate = cellDate.addDays( 1 );
743 int totalsecs = fromTime.
secsTo( toTime );
744 float minlen = (float)box.
height() * 60. / (float)totalsecs;
745 float cellHeight = ( 60. * (float)minlen );
746 float currY = box.
top();
748 int xcenter = box.
left() + box.
width() / 2;
750 QTime curTime( fromTime );
751 QTime endTime( toTime );
752 if ( fromTime.
minute() > 30 ) {
753 curTime =
QTime( fromTime.
hour()+1, 0, 0 );
754 }
else if ( fromTime.
minute() > 0 ) {
755 curTime =
QTime( fromTime.
hour(), 30, 0 );
756 float yy = currY + minlen * (float)fromTime.
secsTo( curTime ) / 60.;
758 curTime =
QTime( fromTime.
hour() + 1, 0, 0 );
760 currY += ( float( fromTime.
secsTo( curTime ) * minlen ) / 60. );
762 while ( curTime < endTime ) {
764 int newY = (int)( currY + cellHeight / 2. );
766 if ( newY < box.
bottom() ) {
769 if ( !KGlobal::locale()->use12Clock() ) {
772 if ( cellHeight > 30 ) {
777 p.
drawText( box.
left() + 4, (int)currY + 2, box.
width() / 2 - 2, (int)cellHeight,
778 Qt::AlignTop | Qt::AlignRight, numStr );
780 p.
drawText( xcenter + 4, (
int)currY+2, box.
width() / 2 + 2, (int)( cellHeight / 2 ) - 3,
785 numStr = KGlobal::locale()->formatTime( time );
786 if ( box.
width() < 60 ) {
791 p.
drawText( box.
left() + 2, (int)currY + 2, box.
width() - 4, (int)cellHeight / 2 - 3,
792 Qt::AlignTop|Qt::AlignLeft, numStr );
797 if ( curTime.
secsTo( endTime ) > 3600 ) {
798 curTime = curTime.
addSecs( 3600 );
812 const QDate &qd,
bool expandable,
814 bool excludeConfidential,
815 bool excludePrivate )
817 KCalCore::Event::List::Iterator it;
818 int offset = box.
top();
821 KCalCore::Event::List eventList = eventList_;
822 KCalCore::Event::Ptr hd = holidayEvent( qd );
824 eventList.prepend( hd );
827 it = eventList.begin();
828 while ( it != eventList.end() ) {
829 KCalCore::Event::Ptr currEvent = *it;
830 if ( ( excludeConfidential && currEvent->secrecy() == KCalCore::Incidence::SecrecyConfidential ) ||
831 ( excludePrivate && currEvent->secrecy() == KCalCore::Incidence::SecrecyPrivate ) ) {
834 if ( currEvent && currEvent->allDay() ) {
837 QRect eventBox( box );
838 eventBox.
setTop( offset );
842 if ( !multiDayStr.
isEmpty() ) {
845 multiDayStr += currEvent->summary();
847 it = eventList.erase( it );
854 QRect eventBox( box );
856 if ( !multiDayStr.
isEmpty() ) {
863 ret = offset - box.
top();
871 const QDate &qd,
bool expandable,
872 const QTime &fromTime,
875 bool includeDescription,
877 bool excludeConfidential,
881 QTime myFromTime, myToTime;
883 myFromTime = fromTime;
885 myFromTime =
QTime( 0, 0, 0 );
890 myToTime =
QTime( 23, 59, 59 );
904 Q_FOREACH (
const KCalCore::Event::Ptr &
event, events ) {
906 if ( ( excludeConfidential && event->secrecy() == KCalCore::Incidence::SecrecyConfidential ) ||
907 ( excludePrivate && event->secrecy() == KCalCore::Incidence::SecrecyPrivate ) ) {
911 if ( event->allDay() ) {
914 if ( event->dtStart().time() < myFromTime ) {
915 myFromTime =
event->dtStart().time();
917 if ( event->dtEnd().time() > myToTime ) {
918 myToTime =
event->dtEnd().time();
924 int totalsecs = myFromTime.
secsTo( myToTime );
925 float minlen = box.
height() * 60. / totalsecs;
926 float cellHeight = 60. * minlen;
927 float currY = box.
top();
931 currY += myFromTime.
secsTo( curTime ) * minlen / 60;
933 while ( curTime < myToTime && curTime.
isValid() ) {
934 if ( currY > box.
top() ) {
937 currY += cellHeight / 2;
938 if ( ( currY > box.
top() ) && ( currY < box.
bottom() ) ) {
945 if ( curTime.
secsTo( myToTime ) > 3600 ) {
946 curTime = curTime.
addSecs( 3600 );
950 currY += cellHeight / 2;
953 KDateTime startPrintDate = KDateTime( qd, myFromTime );
954 KDateTime endPrintDate = KDateTime( qd, myToTime );
961 Akonadi::Item::List::ConstIterator itEvents;
962 foreach (
const KCalCore::Event::Ptr &
event, events ) {
963 if ( event->allDay() ) {
969 cells.
append(
new PrintCellItem( event, (*it), event->endDateForStart( *it ) ) );
981 PrintCellItem *placeItem =
static_cast<PrintCellItem *
>( it2.
next() );
982 drawAgendaItem( placeItem, p, startPrintDate, endPrintDate, minlen, box,
983 includeDescription, excludeTime );
988 const KDateTime &startPrintDate,
989 const KDateTime &endPrintDate,
990 float minlen,
const QRect &box,
991 bool includeDescription,
994 KCalCore::Event::Ptr
event = item->event();
997 KDateTime startTime = item->start();
998 KDateTime endTime = item->end();
999 if ( ( startTime < endPrintDate && endTime > startPrintDate ) ||
1000 ( endTime > startPrintDate && startTime < endPrintDate ) ) {
1001 if ( startTime < startPrintDate ) {
1002 startTime = startPrintDate;
1004 if ( endTime > endPrintDate ) {
1005 endTime = endPrintDate;
1007 int currentWidth = box.
width() / item->subCells();
1008 int currentX = box.
left() + item->subCell() * currentWidth;
1010 int( box.
top() + startPrintDate.secsTo( startTime ) * minlen / 60. );
1012 int( box.
top() + startPrintDate.secsTo( endTime ) * minlen / 60. ) - currentYPos;
1014 QRect eventBox( currentX, currentYPos, currentWidth, currentHeight );
1016 if ( excludeTime ) {
1017 if (
event->location().isEmpty() ) {
1020 str = i18nc(
"summary, location",
"%1, %2",
1024 if (
event->location().isEmpty() ) {
1025 str = i18nc(
"starttime - endtime summary",
1027 KGlobal::locale()->formatTime( item->start().toLocalZone().time() ),
1028 KGlobal::locale()->formatTime( item->end().toLocalZone().time() ),
1031 str = i18nc(
"starttime - endtime summary, location",
1033 KGlobal::locale()->formatTime( item->start().toLocalZone().time() ),
1034 KGlobal::locale()->formatTime( item->end().toLocalZone().time() ),
1039 if ( includeDescription && !
event->description().isEmpty() ) {
1041 if (
event->descriptionIsRich() ) {
1044 str +=
event->description();
1048 if ( eventBox.height() < 24 ) {
1049 if ( eventBox.height() < 12 ) {
1050 if ( eventBox.height() < 8 ) {
1068 const QRect &box,
bool fullDate,
1069 bool printRecurDaily,
bool printRecurWeekly,
1070 bool singleLineLimit,
bool showNoteLines,
1071 bool includeDescription,
1072 bool excludeConfidential,
1073 bool excludePrivate )
1076 const KLocale *local = KGlobal::locale();
1078 QTime myFromTime, myToTime;
1080 myFromTime = fromTime;
1082 myFromTime =
QTime( 0, 0, 0 );
1087 myToTime =
QTime( 23, 59, 59 );
1091 dayNumStr = i18nc(
"weekday, shortmonthname daynumber",
1092 "%1, %2 <numid>%3</numid>",
1094 mCalSys->monthName( qd, KCalendarSystem::ShortName ),
1100 QRect subHeaderBox( box );
1105 QString hstring( holidayString( qd ) );
1108 QRect headerTextBox( subHeaderBox );
1109 headerTextBox.setLeft( subHeaderBox.
left() + 5 );
1110 headerTextBox.setRight( subHeaderBox.
right() - 5 );
1113 p.
drawText( headerTextBox, Qt::AlignLeft | Qt::AlignVCenter, hstring );
1116 p.
drawText( headerTextBox, Qt::AlignRight | Qt::AlignVCenter, dayNumStr );
1118 const KCalCore::Event::List eventList =
1119 mCalendar->events( qd, KSystemTimeZones::local(),
1120 KCalCore::EventSortStartDate,
1121 KCalCore::SortDirectionAscending );
1127 unsigned int visibleEventsCounter = 0;
1128 Q_FOREACH (
const KCalCore::Event::Ptr &currEvent, eventList ) {
1129 Q_ASSERT( currEvent );
1130 if ( !currEvent->allDay() ) {
1131 if ( currEvent->dtEnd().toLocalZone().time() <= myFromTime ||
1132 currEvent->dtStart().toLocalZone().time() > myToTime ) {
1136 if ( ( !printRecurDaily && currEvent->recurrenceType() == KCalCore::Recurrence::rDaily ) ||
1137 ( !printRecurWeekly && currEvent->recurrenceType() == KCalCore::Recurrence::rWeekly ) ) {
1140 if ( ( excludeConfidential && currEvent->secrecy() == KCalCore::Incidence::SecrecyConfidential ) ||
1141 ( excludePrivate && currEvent->secrecy() == KCalCore::Incidence::SecrecyPrivate ) ) {
1144 if ( currEvent->allDay() || currEvent->isMultiDay() ) {
1147 timeText = local->formatTime( currEvent->dtStart().toLocalZone().time() ) +
QLatin1Char(
' ');
1150 setColorsByIncidenceCategory( p, currEvent );
1151 QString summaryStr = currEvent->summary();
1152 if ( !currEvent->location().isEmpty() ) {
1153 summaryStr = i18nc(
"summary, location",
1154 "%1, %2", summaryStr, currEvent->location() );
1157 summaryStr, currEvent->description(),
1158 textY, singleLineLimit, includeDescription,
1159 currEvent->descriptionIsRich() );
1161 visibleEventsCounter++;
1163 if ( textY >= box.
height() ) {
1164 const QChar downArrow( 0x21e3 );
1166 const unsigned int invisibleIncidences =
1167 ( eventList.count() - visibleEventsCounter ) +
mCalendar->todos( qd ).count();
1168 if ( invisibleIncidences > 0 ) {
1172 QRect msgRect = fm.boundingRect( warningMsg );
1174 box.
bottom() - msgRect.height() - 2,
1175 msgRect.width(), msgRect.height() );
1179 p.
drawText( msgRect, Qt::AlignLeft, warningMsg );
1186 if ( textY < box.
height() ) {
1188 foreach (
const KCalCore::Todo::Ptr &
todo, todos ) {
1189 if ( !todo->allDay() ) {
1190 if ( ( todo->hasDueDate() && todo->dtDue().toLocalZone().time() <= myFromTime ) ||
1191 ( todo->hasStartDate() && todo->dtStart().toLocalZone().time() > myToTime ) ) {
1195 if ( ( !printRecurDaily && todo->recurrenceType() == KCalCore::Recurrence::rDaily ) ||
1196 ( !printRecurWeekly && todo->recurrenceType() == KCalCore::Recurrence::rWeekly ) ) {
1199 if ( ( excludeConfidential && todo->secrecy() == KCalCore::Incidence::SecrecyConfidential ) ||
1200 ( excludePrivate && todo->secrecy() == KCalCore::Incidence::SecrecyPrivate ) ) {
1203 if ( todo->hasStartDate() && !todo->allDay() ) {
1204 timeText = KGlobal::locale()->formatTime( todo->dtStart().toLocalZone().time() ) +
QLatin1Char(
' ');
1209 setColorsByIncidenceCategory( p, todo );
1210 QString summaryStr = todo->summary();
1211 if ( !todo->location().isEmpty() ) {
1212 summaryStr = i18nc(
"summary, location",
1213 "%1, %2", summaryStr, todo->location() );
1217 if ( todo->hasDueDate() ) {
1218 if ( !todo->allDay() ) {
1219 str = i18nc(
"to-do summary (Due: datetime)",
"%1 (Due: %2)",
1221 KGlobal::locale()->formatDateTime( todo->dtDue().toLocalZone() ) );
1223 str = i18nc(
"to-do summary (Due: date)",
"%1 (Due: %2)",
1225 KGlobal::locale()->formatDate(
1226 todo->dtDue().toLocalZone().date(), KLocale::ShortDate ) );
1232 i18n(
"To-do: %1", str ), todo->description(),
1233 textY, singleLineLimit, includeDescription,
1234 todo->descriptionIsRich() );
1238 if ( showNoteLines ) {
1249 int &textY,
bool singleLineLimit,
1250 bool includeDescription,
1251 bool richDescription )
1253 kDebug() <<
"summary =" << summary <<
", singleLineLimit=" << singleLineLimit;
1255 int flags = Qt::AlignLeft | Qt::OpaqueMode;
1263 int summaryWidth = time.
isEmpty() ? 0 : timeBound.
width() + 3;
1264 QRect summaryBound =
QRect( dayBox.
x() + borderWidth + summaryWidth,
1265 dayBox.
y() + textY + 1,
1266 dayBox.
width() - summaryWidth - ( borderWidth * 2 ),
1267 dayBox.
height() - textY );
1269 QString summaryText = summary;
1271 bool boxOverflow =
false;
1273 if ( singleLineLimit ) {
1274 if ( includeDescription && !descText.
isEmpty() ) {
1278 int textBoxHeight = ( totalHeight > ( dayBox.
height() - textY ) ) ?
1279 dayBox.
height() - textY :
1281 summaryBound.
setHeight( textBoxHeight );
1283 dayBox.
width() - ( borderWidth * 2 ), textBoxHeight );
1286 p.
drawText( timeBound, flags, time );
1288 p.
drawText( summaryBound, flags, summaryText );
1292 if ( richDescription ) {
1295 if ( includeDescription && !description.
isEmpty() ) {
1301 if ( includeDescription && !descText.
isEmpty() ) {
1310 p.
translate( summaryBound.
x(), summaryBound.
y() );
1315 clipBox.setHeight( summaryBound.
height() );
1319 QRect backBox( timeBound.
x(), timeBound.
y(),
1320 dayBox.
width() - ( borderWidth * 2 ), clipBox.height() );
1328 p.
drawText( timeBound, flags, time );
1330 p.
translate( summaryBound.
x(), summaryBound.
y() );
1342 textY += summaryBound.
height();
1345 if ( boxOverflow ) {
1347 int x = dayBox.
x() + dayBox.
width();
1348 int y = dayBox.
y() + dayBox.
height();
1363 bool singleLineLimit,
bool showNoteLines,
1364 bool includeDescription,
1365 bool excludeConfidential,
1366 bool excludePrivate )
1368 QDate weekDate = qd;
1369 const bool portrait = ( box.
height() > box.
width() );
1373 cellWidth = box.
width() / 2;
1376 cellWidth = box.
width() / 6;
1379 const int cellHeight = box.
height() / vcells;
1383 weekDate = qd.
addDays( -weekdayCol );
1385 for (
int i = 0; i < 7; ++i, weekDate = weekDate.addDays(1) ) {
1387 int hpos = ( ( i < 6 ) ? i : ( i - 1 ) ) / vcells;
1388 int vpos = ( ( i < 6 ) ? i : ( i - 1 ) ) % vcells;
1390 box.
left() + cellWidth * hpos,
1391 box.
top() + cellHeight * vpos + ( ( i == 6 ) ? ( cellHeight / 2 ) : 0 ),
1392 cellWidth, ( i < 5 ) ? ( cellHeight ) : ( cellHeight / 2 ) );
1393 drawDayBox( p, weekDate, fromTime, toTime, dayBox,
true,
true,
true,
1394 singleLineLimit, showNoteLines, includeDescription,
1395 excludeConfidential, excludePrivate );
1403 bool singleLineLimit,
bool showNoteLines,
1404 bool includeDescription,
1405 bool excludeConfidential,
bool excludePrivate )
1407 const int numberOfDays = start.
daysTo( end ) + 1;
1409 const bool portrait = ( box.
height() > box.
width() );
1413 vcells = qCeil( static_cast<double>( numberOfDays ) / 2.0 );
1414 if ( numberOfDays > 1 ) {
1415 cellWidth = box.
width() / 2;
1417 cellWidth = box.
width();
1422 cellWidth = box.
width() / numberOfDays;
1424 const int cellHeight = box.
height() / vcells;
1425 QDate weekDate = start;
1426 for (
int i = 0; i < numberOfDays; ++i, weekDate = weekDate.
addDays(1) ) {
1427 const int hpos = i / vcells;
1428 const int vpos = i % vcells;
1430 box.
left() + cellWidth * hpos,
1431 box.
top() + cellHeight * vpos,
1432 cellWidth, cellHeight );
1433 drawDayBox( p, weekDate, fromTime, toTime, dayBox,
1434 true,
true,
true, singleLineLimit,
1435 showNoteLines, includeDescription, excludeConfidential,
1441 const QDate &fromDate,
1442 const QDate &toDate,
1444 const QTime &fromTime,
1445 const QTime &toTime,
1447 bool includeDescription,
1449 bool excludeConfidential,
1450 bool excludePrivate )
1452 QTime myFromTime = fromTime;
1453 QTime myToTime = toTime;
1455 QDate curDate( fromDate );
1456 KDateTime::Spec timeSpec = KSystemTimeZones::local();
1457 while ( curDate <= toDate ) {
1458 KCalCore::Event::List eventList =
mCalendar->events( curDate, timeSpec );
1459 Q_FOREACH (
const KCalCore::Event::Ptr &
event, eventList ) {
1461 if ( event->allDay() ) {
1464 if ( event->dtStart().time() < myFromTime ) {
1465 myFromTime =
event->dtStart().time();
1467 if ( event->dtEnd().time() > myToTime ) {
1468 myToTime =
event->dtEnd().time();
1476 int alldayHeight = (int)( 3600. * box.
height() / ( myFromTime.
secsTo( myToTime ) + 3600. ) );
1479 QRect dowBox( box );
1490 QDate curDate( fromDate );
1491 KDateTime::Spec timeSpec = KSystemTimeZones::local();
1493 double cellWidth = double( dowBox.
width() ) /
double( fromDate.
daysTo( toDate ) + 1 );
1495 while ( curDate <= toDate ) {
1497 int( ( i + 1 ) * cellWidth ) - int( i * cellWidth ), alldayHeight );
1498 QRect dayBox( allDayBox );
1499 dayBox.setTop( tlBox.
top() );
1500 dayBox.setBottom( box.
bottom() );
1501 KCalCore::Event::List eventList =
mCalendar->events( curDate, timeSpec,
1502 KCalCore::EventSortStartDate,
1503 KCalCore::SortDirectionAscending );
1505 alldayHeight =
drawAllDayBox( p, eventList, curDate,
false, allDayBox,
1506 excludeConfidential, excludePrivate );
1508 dayBox, includeDescription, excludeTime,
1509 excludeConfidential, excludePrivate, workDays );
1516 class MonthEventStruct
1519 MonthEventStruct() :
event(0) {}
1520 MonthEventStruct(
const KDateTime &s,
const KDateTime &e,
const KCalCore::Event::Ptr &ev )
1525 if (
event->allDay() ) {
1526 start = KDateTime( start.date(),
QTime( 0, 0, 0 ) );
1527 end = KDateTime( end.date().addDays(1),
QTime( 0, 0, 0 ) ).addSecs(-1);
1530 bool operator < (
const MonthEventStruct &mes ) {
return start < mes.start; }
1533 KCalCore::Event::Ptr
event;
1537 const QRect &box,
int maxdays,
1538 int subDailyFlags,
int holidaysFlags,
1539 bool excludeConfidential,
bool excludePrivate )
1543 QRect subheaderBox( box );
1545 QRect borderBox( box );
1550 QRect daysBox( borderBox );
1551 daysBox.
adjust( correction, correction, -correction, -correction );
1553 int daysinmonth = calsys->daysInMonth( dt );
1554 if ( maxdays <= 0 ) {
1555 maxdays = daysinmonth;
1559 float dayheight = float( daysBox.
height() ) /
float( maxdays );
1561 QColor holidayColor( 240, 240, 240 );
1562 QColor workdayColor( 255, 255, 255 );
1566 if ( daysinmonth<maxdays ) {
1567 QRect dayBox( box.
left(), daysBox.
top() + qRound( dayheight * daysinmonth ), box.
width(), 0 );
1569 p.
fillRect( dayBox, Qt::DiagCrossPattern );
1580 calsys->setDate( endDate, dt.
year(), dt.
month(), daysinmonth );
1585 for ( d = 0; d < daysinmonth; ++d ) {
1590 daysBox.
top() + qRound( dayheight * d ), daysBox.
width(), 0 );
1593 dayBox.
setBottom( daysBox.
top() + qRound( dayheight * ( d + 1 ) ) - 1 );
1595 p.
setBrush( workDays.contains( day ) ? workdayColor : holidayColor );
1597 QRect dateBox( dayBox );
1598 dateBox.
setWidth( dayNrWidth + 3 );
1600 Qt::AlignRight | Qt::AlignVCenter | Qt::TextSingleLine,
1604 int xstartcont = box.
left() + dayNrWidth + 5;
1609 end = calsys->
addDays( end, -1 );
1611 const KCalCore::Event::List events =
mCalendar->events( start, end );
1624 KCalCore::Event::Ptr e = holidayEvent( d );
1628 timeboxItems.
append(
new PrintCellItem( e, KDateTime( d,
QTime( 0, 0, 0 ) ),
1629 KDateTime( d.addDays(1),
QTime( 0, 0, 0 ) ) ) );
1631 if ( holidaysFlags &
Text ) {
1632 textEvents[d.day()] << e->summary();
1639 KDateTime::Spec timeSpec = KSystemTimeZones::local();
1640 Q_FOREACH (
const KCalCore::Event::Ptr &e, events ) {
1644 if ( ( excludeConfidential && e->secrecy() == KCalCore::Incidence::SecrecyConfidential ) ||
1645 ( excludePrivate && e->secrecy() == KCalCore::Incidence::SecrecyPrivate ) ) {
1648 if ( e->recurs() ) {
1649 if ( e->recursOn( start, timeSpec ) ) {
1654 for ( ; it != starttimes.
constEnd(); ++it ) {
1655 monthentries.
append( MonthEventStruct( *it, e->endDateForStart( *it ), e ) );
1662 KCalCore::Recurrence *recur = e->recurrence();
1664 while ( d1 <= end ) {
1665 if ( recur->recursOn( d1, timeSpec ) ) {
1666 KCalCore::TimeList times( recur->recurTimesOn( d1, timeSpec ) );
1667 for ( KCalCore::TimeList::ConstIterator it = times.constBegin();
1668 it != times.constEnd(); ++it ) {
1669 KDateTime d1start( d1, *it, timeSpec );
1670 monthentries.
append( MonthEventStruct( d1start, e->endDateForStart( d1start ), e ) );
1676 monthentries.
append( MonthEventStruct( e->dtStart(), e->dtEnd(), e ) );
1685 KDateTime endofmonth( end,
QTime( 0, 0, 0 ) );
1686 endofmonth = endofmonth.addDays(1);
1687 for ( ; mit != monthentries.
constEnd(); ++mit ) {
1688 if ( (*mit).start.date() == (*mit).end.date() ) {
1692 new PrintCellItem( (*mit).event, (*mit).start, (*mit).end ) );
1695 if ( subDailyFlags &
Text ) {
1696 textEvents[(*mit).start.date().day()] << (*mit).event->summary();
1700 KDateTime thisstart( (*mit).start );
1701 KDateTime thisend( (*mit).end );
1702 if ( thisstart.date() < start ) {
1703 thisstart.setDate( start );
1705 if ( thisend > endofmonth ) {
1706 thisend = endofmonth;
1709 new PrintCellItem( (*mit).event, thisstart, thisend ) );
1719 KDateTime starttime( start,
QTime( 0, 0, 0 ) );
1720 int newxstartcont = xstartcont;
1725 PrintCellItem *placeItem =
static_cast<PrintCellItem *
>( it1.
next() );
1726 int minsToStart = starttime.secsTo( placeItem->start() ) / 60;
1727 int minsToEnd = starttime.secsTo( placeItem->end() ) / 60;
1730 xstartcont + placeItem->subCell() * 17,
1731 daysBox.
top() + qRound(
1732 double( minsToStart * daysBox.
height() ) /
double( maxdays * 24 * 60 ) ), 14, 0 );
1734 daysBox.
top() + qRound(
1735 double( minsToEnd * daysBox.
height() ) /
double( maxdays * 24 * 60 ) ) );
1737 newxstartcont = qMax( newxstartcont, eventBox.
right() );
1739 xstartcont = newxstartcont;
1743 for (
int d=0; d<daysinmonth; ++d ) {
1746 QRect dayBox( xstartcont, daysBox.
top() + qRound( dayheight * d ), 0, 0 );
1748 dayBox.setBottom( daysBox.
top() + qRound( dayheight * ( d + 1 ) ) );
1749 printEventString( p, dayBox, txt, Qt::AlignTop | Qt::AlignLeft | Qt::TextWrapAnywhere );
1758 bool weeknumbers,
bool recurDaily,
1759 bool recurWeekly,
bool singleLineLimit,
1761 bool includeDescription,
1762 bool excludeConfidential,
1763 bool excludePrivate,
1769 QDate monthFirst( monthDate );
1773 monthDate = monthDate.
addDays(-weekdayCol);
1779 int rows = ( weekdayCol + qd.
daysInMonth() - 1 ) / 7 + 1;
1780 double cellHeight = ( box.
height() - yoffset ) / ( 1. * rows );
1781 double cellWidth = ( box.
width() - xoffset ) / 7.;
1785 int coledges[8], rowedges[8];
1786 for (
int i = 0; i <= 7; ++i ) {
1787 rowedges[i] = int( box.
top() + yoffset + i * cellHeight );
1788 coledges[i] = int( box.
left() + xoffset + i * cellWidth );
1791 if ( weeknumbers ) {
1796 QDate weekDate( monthDate );
1797 for (
int row = 0; row<rows; ++row ) {
1800 coledges[0] - 3 - box.
left(), rowedges[row + 1] - rowedges[row] );
1802 weekDate = weekDate.
addDays( 7 );
1807 QRect daysOfWeekBox( box );
1810 drawDaysOfWeek( p, monthDate, monthDate.addDays( 6 ), daysOfWeekBox );
1813 bool darkbg =
false;
1814 for (
int row = 0; row < rows; ++row ) {
1815 for (
int col = 0; col < 7; ++col ) {
1817 if ( ( monthDate < monthFirst ) || ( monthDate > monthLast ) ) {
1821 QRect dayBox( coledges[col], rowedges[row],
1822 coledges[col + 1] - coledges[col], rowedges[row + 1] - rowedges[row] );
1823 drawDayBox( p, monthDate, fromTime, toTime, dayBox,
false,
1824 recurDaily, recurWeekly, singleLineLimit, showNoteLines,
1825 includeDescription, excludeConfidential, excludePrivate );
1830 monthDate = monthDate.addDays(1);
1837 int x,
int &y,
int width,
1838 int pageHeight,
bool richTextEntry,
1840 bool connectSubTodos )
1844 QRect textrect( 0, 0, width, -1 );
1845 int flags = Qt::AlignLeft;
1849 for (
int currentLine = 0; currentLine < lines.
count(); currentLine++ ) {
1851 KWordWrap *ww = KWordWrap::formatText( fm, textrect, flags, lines[currentLine] );
1856 for (
int lineCount = 0; lineCount < textLine.
count(); lineCount++ ) {
1857 if ( y >= pageHeight ) {
1858 if ( connectSubTodos ) {
1859 for (
int i = 0; i < startPoints.
size(); ++i ) {
1860 TodoParentStart *rct;
1861 rct = startPoints.
at( i );
1862 int start = rct->mRect.bottom() + 1;
1863 int center = rct->mRect.left() + ( rct->mRect.width() / 2 );
1865 if ( !rct->mSamePage ) {
1868 if ( rct->mHasLine ) {
1869 p.
drawLine( center, start, center, to );
1871 rct->mSamePage =
false;
1878 p.
drawText( x, y, textLine[lineCount] );
1884 KCalCore::TodoSortField sortField,
1885 KCalCore::SortDirection sortDir,
1886 bool connectSubTodos,
bool strikeoutCompleted,
1887 bool desc,
int posPriority,
int posSummary,
1888 int posDueDt,
int posPercentComplete,
1889 int level,
int x,
int &y,
int width,
1890 int pageHeight,
const KCalCore::Todo::List &todoList,
1891 TodoParentStart *r,
bool excludeConfidential,
1892 bool excludePrivate )
1895 const KLocale *local = KGlobal::locale();
1897 TodoParentStart startpt;
1902 startPoints.
clear();
1908 int rhs = posPercentComplete;
1916 int left = posSummary + ( level * 10 );
1920 bool showPriority = posPriority >= 0;
1921 int lhs = posPriority;
1923 lhs = r->mRect.right() + 1;
1926 outStr.
setNum( todo->priority() );
1927 rect = p.
boundingRect( lhs, y + 10, 5, -1, Qt::AlignCenter, outStr );
1935 if ( todo->isCompleted() ) {
1940 lhs = rect.
right() + 3;
1943 if ( todo->priority() > 0 && showPriority ) {
1944 p.
drawText( rect, Qt::AlignCenter, outStr );
1946 startpt.mRect = rect;
1949 if ( r && level > 0 && connectSubTodos ) {
1951 int center( r->mRect.left() + ( r->mRect.width() / 2 ) );
1952 int to( rect.
top() + ( rect.
height() / 2 ) );
1953 int endx( rect.
left() );
1954 p.
drawLine( center, to, endx, to );
1955 if ( r->mSamePage ) {
1956 bottom = r->mRect.bottom() + 1;
1960 p.
drawLine( center, bottom, center, to );
1964 outStr = todo->summary();
1966 -1, Qt::TextWordWrap, outStr );
1971 if ( todo->isCompleted() && strikeoutCompleted ) {
1975 p.
drawText( rect, Qt::TextWordWrap, outStr, &newrect );
1978 if ( todo->hasDueDate() && posDueDt >= 0 ) {
1979 outStr = local->formatDate( todo->dtDue().toLocalZone().date(), KLocale::ShortDate );
1981 Qt::AlignTop | Qt::AlignLeft, outStr );
1982 p.
drawText( rect, Qt::AlignTop | Qt::AlignLeft, outStr );
1986 bool showPercentComplete = posPercentComplete >= 0;
1987 if ( showPercentComplete ) {
1991 int progress = (int)( ( lwidth * todo->percentComplete() ) / 100.0 + 0.5 );
1994 p.
drawRect( posPercentComplete, y+3, lwidth, lheight );
1995 if ( progress > 0 ) {
1997 p.
drawRect( posPercentComplete, y+3, progress, lheight );
2001 outStr = i18n(
"%1%", todo->percentComplete() );
2002 rect = p.
boundingRect( posPercentComplete+lwidth+3, y, x + width, -1,
2003 Qt::AlignTop | Qt::AlignLeft, outStr );
2004 p.
drawText( rect, Qt::AlignTop | Qt::AlignLeft, outStr );
2010 KCalCore::Todo::List t;
2011 KCalCore::Incidence::List relations =
mCalendar->childIncidences( todo->uid() );
2013 foreach (
const KCalCore::Incidence::Ptr &incidence, relations ) {
2018 KCalCore::Todo::Ptr subtodo = incidence.dynamicCast<KCalCore::Todo>();
2019 if ( !subtodo )
continue;
2020 #ifdef AKONADI_PORT_DISABLED
2021 if ( subtodo && todoList.contains( subtodo ) ) {
2023 bool subtodoOk =
false;
2025 foreach (
const KCalCore::Todo::Ptr &tt, todoList ) {
2026 if ( tt == subtodo ) {
2034 if ( ( excludeConfidential &&
2035 subtodo->secrecy() == KCalCore::Incidence::SecrecyConfidential ) ||
2037 subtodo->secrecy() == KCalCore::Incidence::SecrecyPrivate ) ) {
2040 t.append( subtodo );
2045 startpt.mHasLine = ( relations.size() > 0 );
2046 startPoints.
append( &startpt );
2049 if ( !todo->description().isEmpty() && desc ) {
2050 y = newrect.
bottom() + 5;
2052 width - ( left + 10 - x ), pageHeight,
2053 todo->descriptionIsRich(),
2054 startPoints, connectSubTodos );
2060 #ifdef AKONADI_PORT_DISABLED
2061 KCalCore::Todo::List sl =
mCalendar->sortTodos( &t, sortField, sortDir );
2063 KCalCore::Todo::List tl;
2064 foreach (
const KCalCore::Todo::Ptr &todo, t ) {
2067 KCalCore::Todo::List sl =
mCalendar->sortTodos( tl, sortField, sortDir );
2071 foreach (
const KCalCore::Todo::Ptr &isl, sl ) {
2073 if ( ++subcount == sl.size() ) {
2074 startpt.mHasLine =
false;
2076 drawTodo( count, isl, p, sortField, sortDir,
2077 connectSubTodos, strikeoutCompleted,
2078 desc, posPriority, posSummary, posDueDt, posPercentComplete,
2079 level+1, x, y, width, pageHeight, todoList, &startpt,
2080 excludeConfidential, excludePrivate );
2087 int w = weekday + 7 - KGlobal::locale()->weekStartDay();
2092 int x,
int &y,
int width,
2093 int pageHeight,
bool richTextEntry )
2097 QRect textrect( 0, 0, width, -1 );
2098 int flags = Qt::AlignLeft;
2102 for (
int currentLine = 0; currentLine < lines.
count(); currentLine++ ) {
2104 KWordWrap *ww = KWordWrap::formatText( fm, textrect, flags, lines[currentLine] );
2108 for (
int lineCount = 0; lineCount < textLine.
count(); lineCount++ ) {
2109 if ( y >= pageHeight ) {
2114 p.
drawText( x, y, textLine[lineCount] );
2120 int x,
int &y,
int width,
int pageHeight )
2125 QString dateText( KGlobal::locale()->formatDate( journal->dtStart().toLocalZone().date(),
2126 KLocale::LongDate ) );
2128 if ( journal->summary().isEmpty() ) {
2129 headerText = dateText;
2131 headerText = i18nc(
"Description - date",
"%1 - %2", journal->summary(), dateText );
2135 if ( rect.
bottom() > pageHeight ) {
2139 rect = p.
boundingRect( x, y, width, -1, Qt::TextWordWrap, headerText );
2142 p.
drawText( rect, Qt::TextWordWrap, headerText, &newrect );
2145 y = newrect.
bottom() + 4;
2147 p.
drawLine( x + 3, y, x + width - 6, y );
2149 if ( !( journal->organizer()->fullName().isEmpty() ) ) {
2150 drawTextLines( p, i18n(
"Person: %1", journal->organizer()->fullName() ),
2151 x, y, width, pageHeight,
false );
2154 if ( !( journal->description().isEmpty() ) ) {
2155 drawTextLines( p, journal->description(), x, y, width, pageHeight,
2156 journal->descriptionIsRich() );
2164 int width,
int height )
2169 QPen pen( Qt::black, 4 );
2174 title = i18nc(
"Date range: Month dayStart - dayEnd",
"%1 %2 - %3",
2175 mCalSys->monthName( fd.
month(), KCalendarSystem::LongName ),
2176 mCalSys->formatDate( fd, KLocale::Day, KLocale::LongNumber ),
2177 mCalSys->formatDate( td, KLocale::Day, KLocale::LongNumber ) );
2179 title = i18nc(
"Date range: monthStart dayStart - monthEnd dayEnd",
"%1 %2 - %3 %4",
2180 mCalSys->monthName( fd.
month(), KCalendarSystem::LongName ),
2181 mCalSys->formatDate( fd, KLocale::Day, KLocale::LongNumber ),
2182 mCalSys->monthName( td.
month(), KCalendarSystem::LongName ),
2183 mCalSys->formatDate( td, KLocale::Day, KLocale::LongNumber ) );
2187 if ( height < 60 ) {
2194 p.
drawText( 0, 0, width, lineSpacing,
2195 Qt::AlignRight | Qt::AlignTop, title );
2200 p.
drawLine( 300, lineSpacing, width, lineSpacing );
2203 if ( height < 60 ) {
2210 p.
drawText( 0, lineSpacing, width, lineSpacing,
2211 Qt::AlignRight | Qt::AlignTop, title );
2219 int linePos = box.
y();
2220 int startPos = startY;
2222 while ( linePos < startPos ) {
2223 linePos += lineHeight;
2227 while ( linePos < box.
bottom() ) {
2230 linePos += lineHeight;
int daysTo(const QDate &d) const
void drawContents(QPainter *p, const QRectF &rect)
CalPrintPluginBase()
Constructor.
void setPointSize(int pointSize)
void setViewport(const QRect &rectangle)
void setPageSize(const QSizeF &size)
void truncate(int position)
const QBrush & background() const
void fillRect(const QRectF &rectangle, const QBrush &brush)
int drawFooter(QPainter &p, const QRect &box)
Draw a page footer containing the printing date and possibly other things, like a page number...
void drawMonth(QPainter &p, const QDate &dt, const QRect &box, int maxdays=-1, int subDailyFlags=TimeBoxes, int holidaysFlags=Text, bool excludeConfidential=false, bool excludePrivate=false)
Draw a vertical representation of the month containing the date dt.
void doLoadConfig()
Load complete config.
void setHeaderHeight(const int height)
void drawDaysOfWeek(QPainter &p, const QDate &fromDate, const QDate &toDate, const QRect &box)
Draw a horizontal bar with the weekday names of the given date range in the given area of the painter...
void setBackground(const QBrush &brush)
static void drawShadedBox(QPainter &p, int linewidth, const QBrush &brush, const QRect &rect)
Draw a shaded box with given width at the given coordinates.
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 insertHtml(const QString &html)
void doSaveConfig()
Save complete config.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
const QFont & font() const
void setBorderWidth(const int border)
const T & at(int i) const
QPoint bottomRight() const
QColor categoryColor(const QString &cat) const
QPoint bottomLeft() const
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule)
int headerHeight() const
Returns the height of the page header.
void drawDayBox(QPainter &p, const QDate &qd, const QTime &fromTime, const QTime &toTime, const QRect &box, bool fullDate=false, bool printRecurDaily=true, bool printRecurWeekly=true, bool singleLineLimit=true, bool showNoteLines=false, bool includeDescription=false, bool excludeDescription=true, bool excludePrivate=true)
Draw the box containing a list of all events of the given day (with their times, of course)...
int drawAllDayBox(QPainter &p, const KCalCore::Event::List &eventList, const QDate &qd, bool expandable, const QRect &box, bool excludeConfidential, bool excludePrivate)
Draw the all-day box for the agenda print view (the box on top which doesn't have a time on the time ...
QString join(const QString &separator) const
void drawLine(const QLineF &line)
void addSpacing(int size)
CALENDARSUPPORT_EXPORT KCalCore::Incidence::Ptr incidence(const Akonadi::Item &item)
returns the incidence from an akonadi item, or a null pointer if the item has no such payload ...
int weekNumber(int *yearNumber) const
#define EVENT_BORDER_WIDTH
static int weekdayColumn(int weekday)
Determines the column of the given weekday ( 1=Monday, 7=Sunday ), taking the start of the week setti...
const KCalendarSystem * calendarSystem()
void setPoint(int index, int x, int y)
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.
void drawNoteLines(QPainter &p, const QRect &box, int startY)
Draws dotted lines for notes in a box.
void drawTextLines(QPainter &p, const QString &entry, int x, int &y, int width, int pageHeight, bool richTextEntry)
Draws text lines splitting on page boundaries.
CALENDARSUPPORT_EXPORT KCalCore::Todo::Ptr todo(const Akonadi::Item &item)
returns the todo from an akonadi item, or a null pointer if the item has no such payload ...
const KCalendarSystem * mCalSys
const QColor & color() const
void setPadding(const int margin)
void setCalendarSystem(const KCalendarSystem *calsys)
virtual void loadConfig()=0
Load print format configuration from config file.
virtual QString groupName()=0
Returns KConfig group name where store settings.
void drawRect(const QRectF &rectangle)
virtual QSizeF documentSize() const =0
static QList< CellItem * > placeItem(QList< CellItem * > cells, CellItem *placeItem)
Place item placeItem into stripe containing items cells in a way that items don't overlap...
#define LANDSCAPE_HEADER_HEIGHT
void setFont(const QFont &font)
QString number(int n, int base)
int count(const T &value) const
void setPrintFooter(bool printFooter)
#define PORTRAIT_HEADER_HEIGHT
void append(const T &value)
virtual QString info() const =0
Returns long description of print format.
bool useColors() const
HELPER FUNCTIONS.
QRectF boundingRect(const QRectF &rectangle, int flags, const QString &text)
QDate addMonths(int nmonths) const
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).
void setPen(const QColor &color)
virtual void saveConfig()=0
Write print format configuration to config file.
void insertText(const QString &text)
void setMargin(const int margin)
int removeAll(const T &value)
virtual ~CalPrintPluginBase()
Akonadi::ETMCalendar::Ptr mCalendar
QPrinter::Orientation orientation() const
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
QTime addSecs(int s) const
void setDate(const QDate &date)
QAbstractTextDocumentLayout * documentLayout() const
void setBrush(const QBrush &brush)
void drawText(const QPointF &position, const QString &text)
void drawSplitHeaderRight(QPainter &p, const QDate &fd, const QDate &td, const QDate &cd, int width, int height)
void drawSmallMonth(QPainter &p, const QDate &qd, const QRect &box)
Draw a small calendar with the days of a month into the given area.
CALENDARSUPPORT_EXPORT QStringList categories(const KCalCore::Incidence::List &incidences)
static void drawBox(QPainter &p, int linewidth, const QRect &rect)
Draw a box with given width at the given coordinates.
void setFooterHeight(const int height)
static KCalPrefs * instance()
Get instance of KCalPrefs.
void setSubHeaderHeight(const int height)
virtual QString description()=0
Returns short description of print format.
static QString cleanStr(const QString &instr)
void drawDaysOfWeekBox(QPainter &p, const QDate &qd, const QRect &box)
Draw a single weekday name in a box inside the given area of the painter.
void setPlainText(const QString &text)
void drawIncidence(QPainter &p, const QRect &dayBox, const QString &time, const QString &summary, const QString &description, int &textY, bool singleLineLimit, bool includeDescription, bool richDescription)
void setDefaultFont(const QFont &font)
const QBrush & brush() const
void drawAgendaItem(PrintCellItem *item, QPainter &p, const KDateTime &startPrintDate, const KDateTime &endPrintDate, float minlen, const QRect &box, bool includeDescription, bool excludeTime)
int width(const QString &text, int len) const
bool contains(const T &value) const
void drawVerticalBox(QPainter &p, int linewidth, const QRect &box, const QString &str, int flags=-1)
Draw an event box with vertical text.
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.
void showEventBox(QPainter &p, int linewidth, const QRect &box, const KCalCore::Incidence::Ptr &incidence, const QString &str, int flags=-1)
Print the box for the given event with the given string.
Base class for Calendar printing classes.
bool setDate(int year, int month, int day)
QString & replace(int position, int n, QChar after)
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.
QDateTime currentDateTime()
virtual void print(QPainter &p, int width, int height)=0
Actually do the printing.
virtual void doPrint(QPrinter *printer)
Start printing.
void addStretch(int stretch)
QDateTime dayBegins() const
void setRect(int x, int y, int width, int height)
void printEventString(QPainter &p, const QRect &box, const QString &str, int flags=-1)
Print the given string (event summary) in the given rectangle.
QString & setNum(short n, int base)
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 excludeConfidential, bool excludePrivate, const QList< QDate > &workDays)
Draw the agenda box for the day print style (the box showing all events of that day).
QFontMetrics fontMetrics() const
void setHeight(int height)
QColor categoryBgColor(const KCalCore::Incidence::Ptr &incidence) const
int footerHeight() const
Returns the height of the page footer.
QTextDocumentFragment fromHtml(const QString &text)
QString toPlainText() const
void adjust(int dx1, int dy1, int dx2, int dy2)
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...
QStringList split(const QString &sep, const QString &str, bool allowEmptyEntries)
#define LANDSCAPE_FOOTER_HEIGHT
void setStrikeOut(bool enable)
void translate(const QPointF &offset)
void setHtml(const QString &html)
QString fromLatin1(const char *str, int size)
int subHeaderHeight() const
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.
CALENDARSUPPORT_EXPORT QList< QDate > workDays(const QDate &start, const QDate &end)
Returns a list containing work days between start and .
QDate addDays(int ndays) const
CALENDARSUPPORT_EXPORT KCalCore::Journal::Ptr journal(const Akonadi::Item &item)
returns the journal from an akonadi item, or a null pointer if the item has no such payload ...
CALENDARSUPPORT_EXPORT KCalCore::Event::Ptr event(const Akonadi::Item &item)
returns the event from an akonadi item, or a null pointer if the item has no such payload ...
QString toPlainText(const QString &htmlText)
const_iterator constEnd() const
const_iterator constBegin() const
void setColorMode(ColorMode newColorMode)
void drawJournal(const KCalCore::Journal::Ptr &journal, QPainter &p, int x, int &y, int width, int pageHeight)
Draws single journal item.
CALENDARSUPPORT_EXPORT QStringList holiday(const QDate &date)
Returns a list of holidays that occur at.
void setUseColors(bool useColors)
Orientation orientation() const
bool begin(QPaintDevice *device)
CALENDARSUPPORT_EXPORT KCalCore::Todo::List todos(const QMimeData *mimeData, const KDateTime::Spec &timeSpec)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QPrinter * mPrinter
The printer object.
void drawSubHeaderBox(QPainter &p, const QString &str, const QRect &box)
Draw a subheader box with a shaded background and the given string.
int secsTo(const QTime &t) const
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...
#define PORTRAIT_FOOTER_HEIGHT
void drawTodoLines(QPainter &p, const QString &entry, int x, int &y, int width, int pageHeight, bool richTextEntry, QList< TodoParentStart * > &startPoints, bool connectSubTodos)