24 #include <calendarsupport/kcalprefs.h>
25 #include <calendarsupport/utils.h>
27 #include <KCalendarSystem>
29 #include <KSystemTimeZones>
31 #include <QAbstractTextDocumentLayout>
33 #include <QTextCursor>
34 #include <QTextDocument>
35 #include <QTextDocumentFragment>
37 #include <boost/concept_check.hpp>
40 using namespace PimPrint::Calendar;
65 class PimPrint::Calendar::CalPrintBase::Private
97 KCalCore::Calendar::Ptr mCalendar;
98 KCalendarSystem *mCalSystem;
101 int mSubHeaderHeight;
106 int mItemBoxBorderWidth;
109 InfoOptions mInfoOptions;
110 TypeOptions mTypeOptions;
111 RangeOptions mRangeOptions;
112 ExtraOptions mExtraOptions;
131 void CalPrintBase::init(
QPrinter *printer)
const
138 d->mPrinter = printer;
142 d->mPainter.begin(d->mPrinter);
148 d->mPainter.setViewport(margin, margin,
149 d->mPainter.viewport().width() - 2 * margin,
150 d->mPainter.viewport().height() - 2 * margin);
157 void CalPrintBase::finish()
const
165 d->mPrinter = printer;
175 d->mCalendar = calendar;
185 d->mCalSystem = calSystem;
190 return d->mCalSystem;
195 d->mPrintStyle = style;
200 return d->mPrintStyle;
205 d->mPageHeight = height;
210 if (d->mPageHeight >= 0) {
211 return d->mPageHeight;
212 }
else if (!d->mUseLandscape) {
221 d->mPageWidth = width;
226 if (d->mPageWidth >= 0) {
227 return d->mPageWidth;
228 }
else if (d->mUseLandscape) {
242 return d->mUseLandscape;
257 d->mHeaderHeight = height;
262 if (d->mHeaderHeight >= 0) {
263 return d->mHeaderHeight;
264 }
else if (!d->mUseLandscape) {
273 d->mSubHeaderHeight = height;
278 return d->mSubHeaderHeight;
283 d->mFooterHeight = height;
288 if (!d->mPrintFooter) {
292 if (d->mFooterHeight >= 0) {
293 return d->mFooterHeight;
294 }
else if (!d->mUseLandscape) {
318 return d->mBoxBorderWidth;
323 return d->mItemBoxBorderWidth;
328 return d->mTimeLineWidth;
333 d->mInfoOptions = flags;
338 return d->mInfoOptions;
343 d->mTypeOptions = flags;
348 return d->mTypeOptions;
353 d->mRangeOptions = flags;
358 return d->mRangeOptions;
363 d->mExtraOptions = flags;
368 return d->mExtraOptions;
376 if (linewidth >= 0) {
377 pen.setWidth(linewidth);
396 const QString &str,
int flags)
const
399 newbox.
adjust(3, 1, -1, -1);
401 (Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap) : flags, str);
405 const KCalCore::Incidence::Ptr &incidence,
406 const QString &str,
int flags)
const
410 QColor bgColor(categoryBgColor(incidence));
411 if (d->mUseColor & bgColor.isValid()) {
417 if (d->mUseColor && bgColor.isValid()) {
418 p.
setPen(getTextColor(bgColor));
427 const QString &str,
int flags)
const
432 drawItemBox(p, linewidth, rotatedBox, KCalCore::Incidence::Ptr(), str,
433 (flags == -1) ? Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine : flags);
438 void CalPrintBase::drawSmallMonth(
QPainter &p,
const QDate &date,
const QRect &box)
const
441 int month = date.
month();
444 QDate monthDate2(monthDate.addDays(-weekdayCol));
446 double cellWidth = double(box.
width()) /
double(7);
447 int rownr = 3 + (date.
daysInMonth() + weekdayCol - 1) / 7;
449 double cellHeight = (box.
height() - 5) / rownr;
452 p.
setFont(
QFont(
"sans-serif",
int(cellHeight - 2), QFont::Normal));
458 titleBox.setHeight(
int(cellHeight + 1));
459 p.
drawText(titleBox, Qt::AlignTop | Qt::AlignHCenter, calSys->monthName(date));
464 wdayBox.setTop(
int(box.
top() + 3 + cellHeight));
465 wdayBox.setHeight(
int(2 * cellHeight) -
int(cellHeight));
468 for (
int col = 0; col < 7; ++col) {
470 wdayBox.setLeft(
int(box.
left() + col * cellWidth));
471 wdayBox.setRight(
int(box.
left() + (col + 1) * cellWidth));
472 p.
drawText(wdayBox, Qt::AlignCenter, tmpStr);
473 monthDate2 = monthDate2.addDays(1);
478 int calStartY = wdayBox.bottom() + 2;
480 monthDate = monthDate.addDays(-weekdayCol);
482 for (
int row = 0; row < (rownr - 2); row++) {
483 for (
int col = 0; col < 7; col++) {
484 if (monthDate.month() == month) {
485 QRect dayRect(
int(box.
left() + col * cellWidth),
486 int(calStartY + row * cellHeight), 0, 0);
487 dayRect.
setRight(
int(box.
left() + (col + 1) * cellWidth));
488 dayRect.setBottom(
int(calStartY + (row + 1) * cellHeight));
491 monthDate = monthDate.addDays(1);
499 const QDate &leftMonth,
const QDate &rightMonth,
501 const QColor &backColor)
const
504 int smallMonthWidth = (allbox.
width() / 4) - 10;
505 if (smallMonthWidth > 100) {
506 smallMonthWidth = 100;
510 QRect textRect(allbox);
514 QFont newFont(
"sans-serif", (textRect.
height() < 60) ? 16 : 18, QFont::Bold);
518 p.
boundingRect(textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, title);
520 int h = boundingR.
height();
521 if (h > allbox.
height()) {
538 const QRect rightMonthBox(box.
right() - 10 - smallMonthWidth, box.
top(),
539 smallMonthWidth, box.
height());
540 drawSmallMonth(p,
QDate(rightMonth.
year(), rightMonth.
month(), 1), rightMonthBox);
541 textRect.
setRight(rightMonthBox.left());
545 smallMonthWidth, box.
height());
546 drawSmallMonth(p,
QDate(leftMonth.
year(), leftMonth.
month(), 1), leftMonthBox);
547 textRect.
setLeft(leftMonthBox.right());
552 p.
drawText(textRect, Qt::AlignCenter | Qt::AlignVCenter | Qt::TextWordWrap, title);
564 p.
drawText(box, Qt::AlignCenter | Qt::AlignVCenter, str);
576 p.
drawText(footbox, Qt::AlignCenter | Qt::AlignVCenter | Qt::TextSingleLine,
577 i18nc(
"print date: formatted-datetime",
"printed: %1", dateStr));
585 const QRect &box)
const
589 int totalsecs = startTime.
secsTo(endTime);
590 float minlen = (float)box.
height() * 60. / (float)totalsecs;
591 float cellHeight = (60. * (float)minlen);
592 float currY = box.
top();
594 int xcenter = box.
left() + box.
width() / 2;
596 QTime curTime(startTime);
597 if (startTime.
minute() > 30) {
598 curTime =
QTime(startTime.
hour() + 1, 0, 0);
599 }
else if (startTime.
minute() > 0) {
600 curTime =
QTime(startTime.
hour(), 30, 0);
601 float yy = currY + minlen * (float)startTime.
secsTo(curTime) / 60.;
603 curTime =
QTime(startTime.
hour() + 1, 0, 0);
605 currY += (float(startTime.
secsTo(curTime) * minlen) / 60.);
607 while (curTime < endTime) {
609 int newY = (int)(currY + cellHeight / 2.);
611 if (newY < box.
bottom()) {
614 if (!KGlobal::locale()->use12Clock()) {
618 if (cellHeight > 30) {
624 box.
width() / 2 - 2, (int)cellHeight,
625 Qt::AlignTop | Qt::AlignRight, numStr);
628 p.
drawText(xcenter + 4, (
int)currY + 2,
629 box.
width() / 2 + 2, (int)(cellHeight / 2) - 3,
630 Qt::AlignTop | Qt::AlignLeft,
"00");
634 numStr = KGlobal::locale()->formatTime(time);
636 if (box.
width() < 60) {
641 p.
drawText(box.
left() + 2, (int)currY + 2, box.
width() - 4, (int)cellHeight / 2 - 3,
642 Qt::AlignTop | Qt::AlignLeft, numStr);
647 if (curTime.
secsTo(endTime) > 3600) {
648 curTime = curTime.
addSecs(3600);
658 bool expandAll)
const
660 QTime myStartTime = startTime;
661 QTime myEndTime = endTime;
663 QDate curDate(startDate);
664 KDateTime::Spec timeSpec = KSystemTimeZones::local();
665 while (curDate <= endDate) {
666 KCalCore::Event::List eventList =
printCalendar()->events(curDate, timeSpec);
667 Q_FOREACH (
const KCalCore::Event::Ptr &
event, eventList) {
669 if (event->allDay()) {
672 if (event->dtStart().time() < myStartTime) {
673 myStartTime =
event->dtStart().time();
675 if (event->dtEnd().time() > myEndTime) {
676 myEndTime =
event->dtEnd().time();
684 int alldayHeight = (int)(3600. * box.
height() / (myStartTime.
secsTo(myEndTime) + 3600.));
697 QDate curDate(startDate);
698 KDateTime::Spec timeSpec = KSystemTimeZones::local();
700 double cellWidth = double(dowBox.
width()) /
double(startDate.
daysTo(endDate) + 1);
701 const QList<QDate> workDays = CalendarSupport::workDays(startDate, endDate);
702 while (curDate <= endDate) {
703 QRect allDayBox(dowBox.
left() + int(i * cellWidth),
705 int((i + 1) * cellWidth) - int(i * cellWidth),
707 QRect dayBox(allDayBox);
708 dayBox.setTop(tlBox.
top());
709 dayBox.setBottom(box.
bottom());
710 KCalCore::Event::List eventList =
712 KCalCore::EventSortStartDate,
713 KCalCore::SortDirectionAscending);
715 alldayHeight = drawAllDayBox(p, allDayBox, curDate, eventList);
717 drawAgendaDayBox(p, dayBox, curDate, eventList, myStartTime, myEndTime, workDays);
727 const KCalCore::Event::List &eventList,
728 const QTime &startTime,
729 const QTime &endTime,
732 QTime myFromTime, myToTime;
734 myFromTime = startTime;
736 myFromTime =
QTime(0, 0, 0);
741 myToTime =
QTime(23, 59, 59);
757 Q_FOREACH (
const KCalCore::Event::Ptr &
event, eventList) {
759 if ((!printConf && event->secrecy() == KCalCore::Incidence::SecrecyConfidential) ||
760 (!printPrivate && event->secrecy() == KCalCore::Incidence::SecrecyPrivate)) {
764 if (event->allDay()) {
767 if (event->dtStart().time() < myFromTime) {
768 myFromTime =
event->dtStart().time();
770 if (event->dtEnd().time() > myToTime) {
771 myToTime =
event->dtEnd().time();
777 int totalsecs = myFromTime.
secsTo(myToTime);
778 float minlen = box.
height() * 60. / totalsecs;
779 float cellHeight = 60. * minlen;
780 float currY = box.
top();
784 currY += myFromTime.
secsTo(curTime) * minlen / 60;
786 while (curTime < myToTime && curTime.
isValid()) {
787 if (currY > box.
top()) {
790 currY += cellHeight / 2;
791 if ((currY > box.
top()) && (currY < box.
bottom())) {
799 if (curTime.
secsTo(myToTime) > 3600) {
800 curTime = curTime.
addSecs(3600);
804 currY += cellHeight / 2;
807 KDateTime startPrintDate = KDateTime(date, myFromTime);
808 KDateTime endPrintDate = KDateTime(date, myToTime);
815 Q_FOREACH (
const KCalCore::Event::Ptr &
event, eventList) {
816 if (event->allDay()) {
836 drawAgendaItem(placeItem, p, startPrintDate, endPrintDate, minlen, box);
841 const KDateTime &startPrintDate,
842 const KDateTime &endPrintDate,
843 float minlen,
const QRect &box)
const
845 KCalCore::Event::Ptr
event = item->
event();
848 KDateTime startTime = item->
start();
849 KDateTime endTime = item->
end();
850 if ((startTime < endPrintDate && endTime > startPrintDate) ||
851 (endTime > startPrintDate && startTime < endPrintDate)) {
852 if (startTime < startPrintDate) {
853 startTime = startPrintDate;
855 if (endTime > endPrintDate) {
856 endTime = endPrintDate;
859 int currentX = box.
left() + item->
subCell() * currentWidth;
861 int(box.
top() + startPrintDate.secsTo(startTime) * minlen / 60.);
863 int(box.
top() + startPrintDate.secsTo(endTime) * minlen / 60.) - currentYPos;
865 QRect eventBox(currentX, currentYPos, currentWidth, currentHeight);
868 if (
event->location().isEmpty()) {
871 str = i18nc(
"summary, location",
"%1, %2",
876 if (
event->location().isEmpty()) {
877 str = i18nc(
"starttime - endtime summary",
879 KGlobal::locale()->formatTime(item->
start().toLocalZone().time()),
880 KGlobal::locale()->formatTime(item->
end().toLocalZone().time()),
883 str = i18nc(
"starttime - endtime summary, location",
885 KGlobal::locale()->formatTime(item->
start().toLocalZone().time()),
886 KGlobal::locale()->formatTime(item->
end().toLocalZone().time()),
892 !
event->description().isEmpty()) {
894 if (
event->descriptionIsRich()) {
897 str +=
event->description();
902 if (eventBox.
height() < 24) {
903 if (eventBox.
height() < 12) {
904 if (eventBox.
height() < 8) {
920 void CalPrintBase::drawDaysOfWeekBox(
QPainter &p,
const QRect &box,
const QDate &date)
const
927 const QDate &fromDate,
const QDate &toDate)
const
929 double cellWidth = double(box.
width()) /
double(fromDate.
daysTo(toDate) + 1);
930 QDate cellDate(fromDate);
934 while (cellDate <= toDate) {
936 dateBox.
setRight(box.
left() + int((i + 1) * cellWidth));
937 drawDaysOfWeekBox(p, dateBox, cellDate);
938 cellDate = cellDate.addDays(1);
943 int CalPrintBase::drawAllDayBox(
QPainter &p,
const QRect &box,
944 const QDate &date,
const KCalCore::Event::List &eventList,
945 bool expandAll)
const
947 KCalCore::Event::List::Iterator it;
948 int offset = box.
top();
951 KCalCore::Event::List evList = eventList;
952 KCalCore::Event::Ptr hd = holidayEvent(date);
963 while (it != evList.end()) {
964 KCalCore::Event::Ptr currEvent = *it;
965 if ((!printConf && currEvent->secrecy() == KCalCore::Incidence::SecrecyConfidential) ||
966 (!printPrivate && currEvent->secrecy() == KCalCore::Incidence::SecrecyPrivate)) {
969 if (currEvent && currEvent->allDay()) {
973 eventBox.setTop(offset);
980 multiDayStr += currEvent->summary();
982 it = evList.erase(it);
998 ret = offset - box.
top();
999 eventBox.setBottom(ret);
1005 void CalPrintBase::drawDayIncidence(
QPainter &p,
const QRect &dayBox,
1010 bool richDescription)
const
1012 kDebug() <<
"summary =" << summary;
1014 int flags = Qt::AlignLeft | Qt::OpaqueMode;
1016 const int borderWidth = p.
pen().
width() + 1;
1022 int summaryWidth = time.
isEmpty() ? 0 : timeBound.
width() + 3;
1023 QRect summaryBound =
QRect(dayBox.
x() + borderWidth + summaryWidth,
1024 dayBox.
y() + textY + 1,
1025 dayBox.
width() - summaryWidth - (borderWidth * 2),
1026 dayBox.
height() - textY);
1028 QString summaryText = summary;
1030 bool boxOverflow =
false;
1032 const bool includeDescription =
infoOptions().testFlag(
1036 if (includeDescription && !descText.
isEmpty()) {
1037 summaryText +=
", " + descText;
1040 int textBoxHeight = (totalHeight > (dayBox.
height() - textY)) ?
1041 dayBox.
height() - textY :
1044 QRect lineRect(dayBox.
x() + borderWidth, dayBox.
y() + textY,
1045 dayBox.
width() - (borderWidth * 2), textBoxHeight);
1048 p.
drawText(timeBound, flags, time);
1050 p.
drawText(summaryBound, flags, summaryText);
1054 if (richDescription) {
1056 textCursor.insertText(summaryText);
1057 if (includeDescription && !description.
isEmpty()) {
1058 textCursor.insertText(
"\n");
1059 textCursor.insertHtml(description);
1062 textCursor.insertText(summaryText);
1063 if (includeDescription && !descText.
isEmpty()) {
1064 textCursor.insertText(
"\n");
1065 textCursor.insertText(descText);
1077 clipBox.setHeight(summaryBound.
height());
1081 QRect backBox(timeBound.
x(), timeBound.
y(),
1082 dayBox.
width() - (borderWidth * 2), clipBox.height());
1090 p.
drawText(timeBound, flags, time);
1104 textY += summaryBound.
height();
1109 int x = dayBox.
x() + dayBox.
width();
1110 int y = dayBox.
y() + dayBox.
height();
1111 poly.setPoint(0, x - 10, y);
1112 poly.setPoint(1, x, y - 10);
1113 poly.setPoint(2, x, y);
1122 void CalPrintBase::drawNoteLines(
QPainter &p,
const QRect &box,
int startY)
const
1125 int linePos = box.
y();
1126 int startPos = startY;
1128 while (linePos < startPos) {
1129 linePos += lineHeight;
1133 while (linePos < box.
bottom()) {
1136 linePos += lineHeight;
1144 const QTime &startTime,
const QTime &endTime,
1145 bool fullDate)
const
1148 const KLocale *local = KGlobal::locale();
1150 QTime myStartTime, myEndTime;
1152 myStartTime = startTime;
1154 myStartTime =
QTime(0, 0, 0);
1157 myEndTime = endTime;
1159 myEndTime =
QTime(23, 59, 59);
1163 dayNumStr = i18nc(
"weekday, shortmonthname daynumber",
1164 "%1, %2 <numid>%3</numid>",
1172 QRect subHeaderBox(box);
1177 QString hstring(holidayString(date));
1180 QRect headerTextBox(subHeaderBox);
1181 headerTextBox.setLeft(subHeaderBox.
left() + 5);
1182 headerTextBox.setRight(subHeaderBox.
right() - 5);
1186 p.
drawText(headerTextBox, Qt::AlignLeft | Qt::AlignVCenter, hstring);
1190 p.
drawText(headerTextBox, Qt::AlignRight | Qt::AlignVCenter, dayNumStr);
1192 const KCalCore::Event::List eventList =
1194 KCalCore::EventSortStartDate,
1195 KCalCore::SortDirectionAscending);
1211 unsigned int visibleEventsCounter = 0;
1212 Q_FOREACH (
const KCalCore::Event::Ptr &currEvent, eventList) {
1213 Q_ASSERT(currEvent);
1214 if (!currEvent->allDay()) {
1215 if (currEvent->dtEnd().toLocalZone().time() <= myStartTime ||
1216 currEvent->dtStart().toLocalZone().time() > myEndTime) {
1220 if ((!printRecurDaily && currEvent->recurrenceType() == KCalCore::Recurrence::rDaily) ||
1221 (!printRecurWeekly && currEvent->recurrenceType() == KCalCore::Recurrence::rWeekly)) {
1224 if ((!printConf && currEvent->secrecy() == KCalCore::Incidence::SecrecyConfidential) ||
1225 (!printPrivate && currEvent->secrecy() == KCalCore::Incidence::SecrecyPrivate)) {
1228 if (currEvent->allDay() || currEvent->isMultiDay()) {
1231 timeText = local->formatTime(currEvent->dtStart().toLocalZone().time()) +
' ';
1234 setColorsByIncidenceCategory(p, currEvent);
1235 QString summaryStr = currEvent->summary();
1236 if (!currEvent->location().isEmpty()) {
1237 summaryStr = i18nc(
"summary, location",
1238 "%1, %2", summaryStr, currEvent->location());
1240 drawDayIncidence(p, box, timeText,
1241 summaryStr, currEvent->description(),
1242 textY, currEvent->descriptionIsRich());
1244 visibleEventsCounter++;
1246 if (textY >= box.
height()) {
1247 const QChar downArrow(0x21e3);
1249 const unsigned int invisibleIncidences =
1250 (eventList.count() - visibleEventsCounter) +
printCalendar()->todos(date).count();
1251 if (invisibleIncidences > 0) {
1258 box.
bottom() - msgRect.height() - 2,
1259 msgRect.width(), msgRect.height());
1263 p.
drawText(msgRect, Qt::AlignLeft, warningMsg);
1270 if (textY < box.
height()) {
1271 KCalCore::Todo::List todoList =
printCalendar()->todos(date);
1272 Q_FOREACH (
const KCalCore::Todo::Ptr &todo, todoList) {
1273 if (!todo->allDay()) {
1274 if ((todo->hasDueDate() && todo->dtDue().toLocalZone().time() <= myStartTime) ||
1275 (todo->hasStartDate() && todo->dtStart().toLocalZone().time() > myEndTime)) {
1279 if ((!printRecurDaily && todo->recurrenceType() == KCalCore::Recurrence::rDaily) ||
1280 (!printRecurWeekly && todo->recurrenceType() == KCalCore::Recurrence::rWeekly)) {
1283 if ((!printConf && todo->secrecy() == KCalCore::Incidence::SecrecyConfidential) ||
1284 (!printPrivate && todo->secrecy() == KCalCore::Incidence::SecrecyPrivate)) {
1287 if (todo->hasStartDate() && !todo->allDay()) {
1289 KGlobal::locale()->formatTime(todo->dtStart().toLocalZone().time()) +
' ';
1294 setColorsByIncidenceCategory(p, todo);
1295 QString summaryStr = todo->summary();
1296 if (!todo->location().isEmpty()) {
1297 summaryStr = i18nc(
"summary, location",
1298 "%1, %2", summaryStr, todo->location());
1302 if (todo->hasDueDate()) {
1303 if (!todo->allDay()) {
1304 str = i18nc(
"to-do summary (Due: datetime)",
"%1 (Due: %2)",
1306 KGlobal::locale()->formatDateTime(todo->dtDue().toLocalZone()));
1308 str = i18nc(
"to-do summary (Due: date)",
"%1 (Due: %2)",
1310 KGlobal::locale()->formatDate(
1311 todo->dtDue().toLocalZone().date(), KLocale::ShortDate));
1316 drawDayIncidence(p, box, timeText,
1317 i18n(
"To-do: %1", str), todo->description(),
1318 textY, todo->descriptionIsRich());
1323 drawNoteLines(p, box, box.
y() + textY);
1332 int w = weekday + 7 - KGlobal::locale()->weekStartDay();
1339 return ret.
replace(
'\n',
' ');
1347 QColor CalPrintBase::getTextColor(
const QColor &c)
const
1349 double luminance = (c.
red() * 0.299) + (c.
green() * 0.587) + (c.
blue() * 0.114);
1350 return (luminance > 128.0) ?
QColor(0, 0, 0) :
QColor(255, 255, 255);
1356 return CalendarSupport::KCalPrefs::instance()->unsetCategoryColor();
1362 bgColor = CalendarSupport::KCalPrefs::instance()->unsetCategoryColor();
1364 bgColor = CalendarSupport::KCalPrefs::instance()->categoryColor(cat);
1369 QColor CalPrintBase::categoryBgColor(
const KCalCore::Incidence::Ptr &incidence)
const
1372 QColor backColor = categoryColor(incidence->categories());
1373 if (incidence->type() == KCalCore::Incidence::TypeTodo) {
1374 if ((incidence.staticCast<KCalCore::Todo>())->isOverdue()) {
1376 backColor =
QColor(255, 100, 100);
1385 void CalPrintBase::setColorsByIncidenceCategory(
QPainter &p,
1386 const KCalCore::Incidence::Ptr &incidence)
const
1388 QColor bgColor = categoryBgColor(incidence);
1392 QColor tColor(getTextColor(bgColor));
1393 if (tColor.isValid()) {
1398 QString CalPrintBase::holidayString(
const QDate &date)
const
1401 return lst.
join(i18nc(
"@item:intext delimiter for joining holiday names",
","));
1404 KCalCore::Event::Ptr CalPrintBase::holidayEvent(
const QDate &date)
const
1406 QString hstring(holidayString(date));
1407 if (hstring.isEmpty()) {
1408 return KCalCore::Event::Ptr();
1411 KCalCore::Event::Ptr holiday(
new KCalCore::Event);
1412 holiday->setSummary(hstring);
1413 holiday->setCategories(i18n(
"Holiday"));
1415 KDateTime kdt(date,
QTime(), KSystemTimeZones::local());
1416 holiday->setDtStart(kdt);
1417 holiday->setDtEnd(kdt);
1418 holiday->setAllDay(
true);
CalPrintBase(QPrinter *printer)
Constructor.
int daysTo(const QDate &d) const
void drawContents(QPainter *p, const QRectF &rect)
void setPrintStyle(const Style style)
Sets the printing Style.
void setPageSize(const QSizeF &size)
void setExtraOptions(ExtraOptions flags)
Sets extra options for printing.
static int sSubHeaderHeight
void drawBox(QPainter &p, const int linewidth, const QRect &box) const
Draws a box with given width at the given coordinates.
const QBrush & background() const
Style printStyle() const
Returns the current printing Style.
void setPadding(const int padding)
Sets the padding margin.
QPrinter * thePrinter() const
Returns a pointer to the currently set QPrinter.
KCalendarSystem * calendarSystem() const
Returns a pointer to the currently set calendar system.
void drawAgendaDayBox(QPainter &p, const QRect &box, const QDate &date, const KCalCore::Event::List &eventList, const QTime &startTime, const QTime &endTime, const QList< QDate > &workDays) const
Draws the agenda box.
const QFont & font() const
TypeOptions typeOptions() const
Returns the current type option flags.
ExtraOptions extraOptions() const
Returns the current extra option flags.
int itemBoxBorderWidth() const
Returns the width of item box borders.
void setHeaderHeight(const int height)
Sets the height of the page header.
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule)
int pageWidth() const
Returns the current printed page width.
void drawTimeTable(QPainter &p, const QRect &box, const QDate &startDate, const QDate &endDate, const QTime &startTime, const QTime &endTime, bool expandAll=false) const
Draws the timetable view of the given time range from startDate to endDate.
static int sPortraitPageHeight
QString join(const QString &separator) const
void drawLine(const QLineF &line)
void drawVerticalBox(QPainter &p, const int linewidth, const QRect &box, const QString &str, int flags=-1) const
Draws an event box with vertical text.
void setPageWidth(const int width) const
Sets the printed page width.
int weekdayColumn(int weekday) const
Determines the column of the given weekday (1=Monday, 7=Sunday), taking the start of the week setting...
int timeLineWidth() const
Returns the width of timelines.
virtual bool event(QEvent *e)
RangeOptions rangeOptions() const
Returns the current time-range option flags.
void setSubHeaderHeight(const int height)
Sets the height of the page sub-header.
void drawRect(const QRectF &rectangle)
void setCalendarSystem(KCalendarSystem *calSystem)
Sets the calendar system to use when printing.
virtual QSizeF documentSize() const =0
QRect boundingRect(QChar ch) const
void setFont(const QFont &font)
QString number(int n, int base)
void drawItemString(QPainter &p, const QRect &box, const QString &str, int flags=-1) const
Draws the given string (incidence summary) in the given rectangle.
void append(const T &value)
QRectF boundingRect(const QRectF &rectangle, int flags, const QString &text)
int margins() const
Returns the size of the page margins.
int boxBorderWidth() const
Returns the width of box borders.
void setPen(const QColor &color)
static int sLandscapeFooterHeight
void setFooterHeight(const int height)
Sets the height of the page footer.
void drawShadedBox(QPainter &p, const int linewidth, const QBrush &brush, const QRect &box) const
Draws a shaded box with given width at the given coordinates.
InfoOptions infoOptions() const
Returns the current information option flags.
int drawFooter(QPainter &p, const QRect &box) const
Draws a page footer containing the printing date and possibly other things, like a page number...
QTime addSecs(int s) const
QAbstractTextDocumentLayout * documentLayout() const
void setBrush(const QBrush &brush)
KCalCore::Calendar::Ptr printCalendar() const
Returns a pointer to the currently set print calendar.
void drawText(const QPointF &position, const QString &text)
void drawTimeLine(QPainter &p, const QTime &startTime, const QTime &endTime, const QRect &box) const
Draws a (vertical) time scale from time startTime to endTime inside the given area of the painter...
static int sPortraitFooterHeight
int padding() const
Returns the current padding margin.
void setUseLandscape(const bool landscape)
Sets the printed page orientation to landscape.
const QBrush & brush() const
void setRangeOptions(RangeOptions flags)
Sets time-range options for printing.
int headerHeight() const
Returns the current height of the page header.
static int sBoxBorderWidth
bool contains(const T &value) const
static int sLandscapeHeaderHeight
static int sTimeLineWidth
void setPrintCalendar(const KCalCore::Calendar::Ptr &calendar)
Sets the calendar containing the data to print.
void setInfoOptions(InfoOptions flags)
Sets information options for printing.
int drawHeader(QPainter &p, const QRect &box, const QString &title, const QDate &leftMonth=QDate(), const QDate &rightMonth=QDate(), const bool expand=false, const QColor &backColor=QColor()) const
Draws the gray header bar of the printout to the QPainter.
int footerHeight() const
Returns the current height of the page footer.
QString & replace(int position, int n, QChar after)
QDateTime currentDateTime()
void drawDayBox(QPainter &p, const QRect &box, const QDate &date, const QTime &startTime, const QTime &endTime, bool fullDate=false) const
Draws the box containing a list of all events and to-dos of the given day.
static int sLandscapePageHeight
void drawDaysOfWeek(QPainter &p, const QRect &box, const QDate &fromDate, const QDate &toDate) const
Draws a horizontal bar with the weekday names of the given date range in the given area of the painte...
bool useLandscape() const
Returns if the current printed page orientation is landscape.
void drawSubHeader(QPainter &p, const QRect &box, const QString &str) const
Draws a subheader with a shaded background and the specified string.
void setRect(int x, int y, int width, int height)
QString & setNum(short n, int base)
QFontMetrics fontMetrics() const
void setHeight(int height)
void setTypeOptions(TypeOptions flags)
Sets type options for printing.
QTextDocumentFragment fromHtml(const QString &text)
QString toPlainText() const
void adjust(int dx1, int dy1, int dx2, int dy2)
int subHeaderHeight() const
Returns the current height of the page sub-header.
void setPageHeight(const int height) const
Sets the printed page height.
void translate(const QPointF &offset)
int pageHeight() const
Returns the current printed page height.
QString toPlainText(const QString &htmlText) const
Converts possible rich text to plain text.
QString cleanString(const QString &str) const
Cleans a string of newlines and other characters that shouldn't be printed.
static int sPortraitHeaderHeight
QDate addDays(int ndays) const
~CalPrintBase()
Destructor.
const_iterator constEnd() const
const_iterator constBegin() const
void setColorMode(ColorMode newColorMode)
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...
KCalCore::Event::Ptr event() const
void setColor(const QColor &color)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
static int sItemBoxBorderWidth
int secsTo(const QTime &t) const
void drawItemBox(QPainter &p, int linewidth, const QRect &box, const KCalCore::Incidence::Ptr &incidence, const QString &str, int flags=-1) const
Draws the box for the specified item with the given string.
void setUseColor(const bool useColor)
Sets if a color print is desired.
void setThePrinter(QPrinter *printer)
Sets the QPrinter.
bool useColor() const
Returns if a color printing is currently set.
void drawAgendaItem(PrintCellItem *item, QPainter &p, const KDateTime &startPrintDate, const KDateTime &endPrintDate, float minlen, const QRect &box) const