Changeset View
Changeset View
Standalone View
Standalone View
src/printing/calprintpluginbase.cpp
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | |||||
76 | 76 | | |||
77 | /****************************************************************** | 77 | /****************************************************************** | ||
78 | ** The Print item ** | 78 | ** The Print item ** | ||
79 | ******************************************************************/ | 79 | ******************************************************************/ | ||
80 | 80 | | |||
81 | class PrintCellItem : public CellItem | 81 | class PrintCellItem : public CellItem | ||
82 | { | 82 | { | ||
83 | public: | 83 | public: | ||
84 | PrintCellItem(const KCalCore::Event::Ptr &event, const QDateTime &start, const QDateTime &end) | 84 | PrintCellItem(const KCalendarCore::Event::Ptr &event, const QDateTime &start, const QDateTime &end) | ||
85 | : mEvent(event) | 85 | : mEvent(event) | ||
86 | , mStart(start) | 86 | , mStart(start) | ||
87 | , mEnd(end) | 87 | , mEnd(end) | ||
88 | { | 88 | { | ||
89 | } | 89 | } | ||
90 | 90 | | |||
91 | KCalCore::Event::Ptr event() const | 91 | KCalendarCore::Event::Ptr event() const | ||
92 | { | 92 | { | ||
93 | return mEvent; | 93 | return mEvent; | ||
94 | } | 94 | } | ||
95 | 95 | | |||
96 | QString label() const override | 96 | QString label() const override | ||
97 | { | 97 | { | ||
98 | return mEvent->summary(); | 98 | return mEvent->summary(); | ||
99 | } | 99 | } | ||
Show All 12 Lines | 111 | /** Calculate the start and end date/time of the recurrence that | |||
112 | happens on the given day */ | 112 | happens on the given day */ | ||
113 | bool overlaps(CellItem *o) const override | 113 | bool overlaps(CellItem *o) const override | ||
114 | { | 114 | { | ||
115 | PrintCellItem *other = static_cast<PrintCellItem *>(o); | 115 | PrintCellItem *other = static_cast<PrintCellItem *>(o); | ||
116 | return !(other->start() >= end() || other->end() <= start()); | 116 | return !(other->start() >= end() || other->end() <= start()); | ||
117 | } | 117 | } | ||
118 | 118 | | |||
119 | private: | 119 | private: | ||
120 | KCalCore::Event::Ptr mEvent; | 120 | KCalendarCore::Event::Ptr mEvent; | ||
121 | QDateTime mStart, mEnd; | 121 | QDateTime mStart, mEnd; | ||
122 | }; | 122 | }; | ||
123 | 123 | | |||
124 | /****************************************************************** | 124 | /****************************************************************** | ||
125 | ** The Print plugin ** | 125 | ** The Print plugin ** | ||
126 | ******************************************************************/ | 126 | ******************************************************************/ | ||
127 | 127 | | |||
128 | CalPrintPluginBase::CalPrintPluginBase() | 128 | CalPrintPluginBase::CalPrintPluginBase() | ||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | 263 | { | |||
265 | QDateTime dayBegins = KCalPrefs::instance()->dayBegins(); | 265 | QDateTime dayBegins = KCalPrefs::instance()->dayBegins(); | ||
266 | if (dayBegins.isValid()) { | 266 | if (dayBegins.isValid()) { | ||
267 | start = dayBegins.time(); | 267 | start = dayBegins.time(); | ||
268 | } | 268 | } | ||
269 | return start; | 269 | return start; | ||
270 | } | 270 | } | ||
271 | 271 | | |||
272 | void CalPrintPluginBase::setColorsByIncidenceCategory(QPainter &p, | 272 | void CalPrintPluginBase::setColorsByIncidenceCategory(QPainter &p, | ||
273 | const KCalCore::Incidence::Ptr &incidence) | 273 | const KCalendarCore::Incidence::Ptr &incidence) | ||
274 | const | 274 | const | ||
275 | { | 275 | { | ||
276 | QColor bgColor = categoryBgColor(incidence); | 276 | QColor bgColor = categoryBgColor(incidence); | ||
277 | if (bgColor.isValid()) { | 277 | if (bgColor.isValid()) { | ||
278 | p.setBrush(bgColor); | 278 | p.setBrush(bgColor); | ||
279 | } | 279 | } | ||
280 | QColor tColor(getTextColor(bgColor)); | 280 | QColor tColor(getTextColor(bgColor)); | ||
281 | if (tColor.isValid()) { | 281 | if (tColor.isValid()) { | ||
Show All 12 Lines | 287 | { | |||
294 | if (cat.isEmpty()) { | 294 | if (cat.isEmpty()) { | ||
295 | bgColor = KCalPrefs::instance()->unsetCategoryColor(); | 295 | bgColor = KCalPrefs::instance()->unsetCategoryColor(); | ||
296 | } else { | 296 | } else { | ||
297 | bgColor = KCalPrefs::instance()->categoryColor(cat); | 297 | bgColor = KCalPrefs::instance()->categoryColor(cat); | ||
298 | } | 298 | } | ||
299 | return bgColor; | 299 | return bgColor; | ||
300 | } | 300 | } | ||
301 | 301 | | |||
302 | QColor CalPrintPluginBase::categoryBgColor(const KCalCore::Incidence::Ptr &incidence) const | 302 | QColor CalPrintPluginBase::categoryBgColor(const KCalendarCore::Incidence::Ptr &incidence) const | ||
303 | { | 303 | { | ||
304 | if (incidence) { | 304 | if (incidence) { | ||
305 | QColor backColor = categoryColor(incidence->categories()); | 305 | QColor backColor = categoryColor(incidence->categories()); | ||
306 | if (incidence->type() == KCalCore::Incidence::TypeTodo) { | 306 | if (incidence->type() == KCalendarCore::Incidence::TypeTodo) { | ||
307 | if ((incidence.staticCast<KCalCore::Todo>())->isOverdue()) { | 307 | if ((incidence.staticCast<KCalendarCore::Todo>())->isOverdue()) { | ||
308 | backColor = QColor(255, 100, 100); //was KOPrefs::instance()->todoOverdueColor(); | 308 | backColor = QColor(255, 100, 100); //was KOPrefs::instance()->todoOverdueColor(); | ||
309 | } | 309 | } | ||
310 | } | 310 | } | ||
311 | return backColor; | 311 | return backColor; | ||
312 | } else { | 312 | } else { | ||
313 | return QColor(); | 313 | return QColor(); | ||
314 | } | 314 | } | ||
315 | } | 315 | } | ||
316 | 316 | | |||
317 | QString CalPrintPluginBase::holidayString(const QDate &date) const | 317 | QString CalPrintPluginBase::holidayString(const QDate &date) const | ||
318 | { | 318 | { | ||
319 | QStringList lst = holiday(date); | 319 | QStringList lst = holiday(date); | ||
320 | return lst.join(i18nc("@item:intext delimiter for joining holiday names", ",")); | 320 | return lst.join(i18nc("@item:intext delimiter for joining holiday names", ",")); | ||
321 | } | 321 | } | ||
322 | 322 | | |||
323 | KCalCore::Event::Ptr CalPrintPluginBase::holidayEvent(const QDate &date) const | 323 | KCalendarCore::Event::Ptr CalPrintPluginBase::holidayEvent(const QDate &date) const | ||
324 | { | 324 | { | ||
325 | QString hstring(holidayString(date)); | 325 | QString hstring(holidayString(date)); | ||
326 | if (hstring.isEmpty()) { | 326 | if (hstring.isEmpty()) { | ||
327 | return KCalCore::Event::Ptr(); | 327 | return KCalendarCore::Event::Ptr(); | ||
328 | } | 328 | } | ||
329 | 329 | | |||
330 | KCalCore::Event::Ptr holiday(new KCalCore::Event); | 330 | KCalendarCore::Event::Ptr holiday(new KCalendarCore::Event); | ||
331 | holiday->setSummary(hstring); | 331 | holiday->setSummary(hstring); | ||
332 | holiday->setCategories(i18n("Holiday")); | 332 | holiday->setCategories(i18n("Holiday")); | ||
333 | 333 | | |||
334 | QDateTime kdt(date, QTime(0, 0), Qt::LocalTime); | 334 | QDateTime kdt(date, QTime(0, 0), Qt::LocalTime); | ||
335 | holiday->setDtStart(kdt); | 335 | holiday->setDtStart(kdt); | ||
336 | holiday->setDtEnd(kdt); | 336 | holiday->setDtEnd(kdt); | ||
337 | holiday->setAllDay(true); | 337 | holiday->setAllDay(true); | ||
338 | 338 | | |||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | |||||
444 | { | 444 | { | ||
445 | QRect newbox(box); | 445 | QRect newbox(box); | ||
446 | newbox.adjust(3, 1, -1, -1); | 446 | newbox.adjust(3, 1, -1, -1); | ||
447 | p.drawText(newbox, (flags == -1) | 447 | p.drawText(newbox, (flags == -1) | ||
448 | ? (Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap) : flags, str); | 448 | ? (Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap) : flags, str); | ||
449 | } | 449 | } | ||
450 | 450 | | |||
451 | void CalPrintPluginBase::showEventBox(QPainter &p, int linewidth, const QRect &box, | 451 | void CalPrintPluginBase::showEventBox(QPainter &p, int linewidth, const QRect &box, | ||
452 | const KCalCore::Incidence::Ptr &incidence, const QString &str, | 452 | const KCalendarCore::Incidence::Ptr &incidence, const QString &str, | ||
453 | int flags) | 453 | int flags) | ||
454 | { | 454 | { | ||
455 | QPen oldpen(p.pen()); | 455 | QPen oldpen(p.pen()); | ||
456 | QBrush oldbrush(p.brush()); | 456 | QBrush oldbrush(p.brush()); | ||
457 | QColor bgColor(categoryBgColor(incidence)); | 457 | QColor bgColor(categoryBgColor(incidence)); | ||
458 | if (mUseColors && bgColor.isValid()) { | 458 | if (mUseColors && bgColor.isValid()) { | ||
459 | p.setBrush(bgColor); | 459 | p.setBrush(bgColor); | ||
460 | } else { | 460 | } else { | ||
Show All 18 Lines | |||||
479 | } | 479 | } | ||
480 | 480 | | |||
481 | void CalPrintPluginBase::drawVerticalBox(QPainter &p, int linewidth, const QRect &box, | 481 | void CalPrintPluginBase::drawVerticalBox(QPainter &p, int linewidth, const QRect &box, | ||
482 | const QString &str, int flags) | 482 | const QString &str, int flags) | ||
483 | { | 483 | { | ||
484 | p.save(); | 484 | p.save(); | ||
485 | p.rotate(-90); | 485 | p.rotate(-90); | ||
486 | QRect rotatedBox(-box.top() - box.height(), box.left(), box.height(), box.width()); | 486 | QRect rotatedBox(-box.top() - box.height(), box.left(), box.height(), box.width()); | ||
487 | showEventBox(p, linewidth, rotatedBox, KCalCore::Incidence::Ptr(), str, | 487 | showEventBox(p, linewidth, rotatedBox, KCalendarCore::Incidence::Ptr(), str, | ||
488 | (flags == -1) ? Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine : flags); | 488 | (flags == -1) ? Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine : flags); | ||
489 | 489 | | |||
490 | p.restore(); | 490 | p.restore(); | ||
491 | } | 491 | } | ||
492 | 492 | | |||
493 | /* | 493 | /* | ||
494 | * Return value: If expand, bottom of the printed box, otherwise vertical end | 494 | * Return value: If expand, bottom of the printed box, otherwise vertical end | ||
495 | * of the printed contents inside the box. | 495 | * of the printed contents inside the box. | ||
▲ Show 20 Lines • Show All 313 Lines • ▼ Show 20 Line(s) | |||||
809 | } | 809 | } | ||
810 | 810 | | |||
811 | /** | 811 | /** | ||
812 | prints the all-day box for the agenda print view. if expandable is set, | 812 | prints the all-day box for the agenda print view. if expandable is set, | ||
813 | height is the cell height of a single cell, and the returned height will | 813 | height is the cell height of a single cell, and the returned height will | ||
814 | be the total height used for the all-day events. If !expandable, only one | 814 | be the total height used for the all-day events. If !expandable, only one | ||
815 | cell will be used, and multiple events are concatenated using ", ". | 815 | cell will be used, and multiple events are concatenated using ", ". | ||
816 | */ | 816 | */ | ||
817 | int CalPrintPluginBase::drawAllDayBox(QPainter &p, const KCalCore::Event::List &eventList_, | 817 | int CalPrintPluginBase::drawAllDayBox(QPainter &p, const KCalendarCore::Event::List &eventList_, | ||
818 | const QDate &qd, bool expandable, const QRect &box, | 818 | const QDate &qd, bool expandable, const QRect &box, | ||
819 | bool excludeConfidential, bool excludePrivate) | 819 | bool excludeConfidential, bool excludePrivate) | ||
820 | { | 820 | { | ||
821 | KCalCore::Event::List::Iterator it; | 821 | KCalendarCore::Event::List::Iterator it; | ||
822 | int offset = box.top(); | 822 | int offset = box.top(); | ||
823 | QString multiDayStr; | 823 | QString multiDayStr; | ||
824 | 824 | | |||
825 | KCalCore::Event::List eventList = eventList_; | 825 | KCalendarCore::Event::List eventList = eventList_; | ||
826 | KCalCore::Event::Ptr hd = holidayEvent(qd); | 826 | KCalendarCore::Event::Ptr hd = holidayEvent(qd); | ||
827 | if (hd) { | 827 | if (hd) { | ||
828 | eventList.prepend(hd); | 828 | eventList.prepend(hd); | ||
829 | } | 829 | } | ||
830 | 830 | | |||
831 | it = eventList.begin(); | 831 | it = eventList.begin(); | ||
832 | while (it != eventList.end()) { | 832 | while (it != eventList.end()) { | ||
833 | KCalCore::Event::Ptr currEvent = *it; | 833 | KCalendarCore::Event::Ptr currEvent = *it; | ||
834 | if ((excludeConfidential | 834 | if ((excludeConfidential | ||
835 | && currEvent->secrecy() == KCalCore::Incidence::SecrecyConfidential) | 835 | && currEvent->secrecy() == KCalendarCore::Incidence::SecrecyConfidential) | ||
836 | || (excludePrivate && currEvent->secrecy() == KCalCore::Incidence::SecrecyPrivate)) { | 836 | || (excludePrivate && currEvent->secrecy() == KCalendarCore::Incidence::SecrecyPrivate)) { | ||
837 | continue; | 837 | continue; | ||
838 | } | 838 | } | ||
839 | if (currEvent && currEvent->allDay()) { | 839 | if (currEvent && currEvent->allDay()) { | ||
840 | // set the colors according to the categories | 840 | // set the colors according to the categories | ||
841 | if (expandable) { | 841 | if (expandable) { | ||
842 | QRect eventBox(box); | 842 | QRect eventBox(box); | ||
843 | eventBox.setTop(offset); | 843 | eventBox.setTop(offset); | ||
844 | showEventBox(p, EVENT_BORDER_WIDTH, eventBox, currEvent, currEvent->summary()); | 844 | showEventBox(p, EVENT_BORDER_WIDTH, eventBox, currEvent, currEvent->summary()); | ||
Show All 22 Lines | |||||
867 | } else { | 867 | } else { | ||
868 | ret = offset - box.top(); | 868 | ret = offset - box.top(); | ||
869 | eventBox.setBottom(ret); | 869 | eventBox.setBottom(ret); | ||
870 | drawBox(p, BOX_BORDER_WIDTH, eventBox); | 870 | drawBox(p, BOX_BORDER_WIDTH, eventBox); | ||
871 | } | 871 | } | ||
872 | return ret; | 872 | return ret; | ||
873 | } | 873 | } | ||
874 | 874 | | |||
875 | void CalPrintPluginBase::drawAgendaDayBox(QPainter &p, const KCalCore::Event::List &events, | 875 | void CalPrintPluginBase::drawAgendaDayBox(QPainter &p, const KCalendarCore::Event::List &events, | ||
876 | const QDate &qd, bool expandable, const QTime &fromTime, | 876 | const QDate &qd, bool expandable, const QTime &fromTime, | ||
877 | const QTime &toTime, const QRect &oldbox, | 877 | const QTime &toTime, const QRect &oldbox, | ||
878 | bool includeDescription, bool excludeTime, | 878 | bool includeDescription, bool excludeTime, | ||
879 | bool excludeConfidential, bool excludePrivate, | 879 | bool excludeConfidential, bool excludePrivate, | ||
880 | const QList<QDate> &workDays) | 880 | const QList<QDate> &workDays) | ||
881 | { | 881 | { | ||
882 | QTime myFromTime, myToTime; | 882 | QTime myFromTime, myToTime; | ||
883 | if (fromTime.isValid()) { | 883 | if (fromTime.isValid()) { | ||
Show All 13 Lines | 896 | } else { | |||
897 | drawBox(p, BOX_BORDER_WIDTH, oldbox); | 897 | drawBox(p, BOX_BORDER_WIDTH, oldbox); | ||
898 | } | 898 | } | ||
899 | QRect box(oldbox); | 899 | QRect box(oldbox); | ||
900 | // Account for the border with and cut away that margin from the interior | 900 | // Account for the border with and cut away that margin from the interior | ||
901 | // box.setRight( box.right()-BOX_BORDER_WIDTH ); | 901 | // box.setRight( box.right()-BOX_BORDER_WIDTH ); | ||
902 | 902 | | |||
903 | if (expandable) { | 903 | if (expandable) { | ||
904 | // Adapt start/end times to include complete events | 904 | // Adapt start/end times to include complete events | ||
905 | for (const KCalCore::Event::Ptr &event : qAsConst(events)) { | 905 | for (const KCalendarCore::Event::Ptr &event : qAsConst(events)) { | ||
906 | Q_ASSERT(event); | 906 | Q_ASSERT(event); | ||
907 | if ((excludeConfidential | 907 | if ((excludeConfidential | ||
908 | && event->secrecy() == KCalCore::Incidence::SecrecyConfidential) | 908 | && event->secrecy() == KCalendarCore::Incidence::SecrecyConfidential) | ||
909 | || (excludePrivate && event->secrecy() == KCalCore::Incidence::SecrecyPrivate)) { | 909 | || (excludePrivate && event->secrecy() == KCalendarCore::Incidence::SecrecyPrivate)) { | ||
910 | continue; | 910 | continue; | ||
911 | } | 911 | } | ||
912 | // skip items without times so that we do not adjust for all day items | 912 | // skip items without times so that we do not adjust for all day items | ||
913 | if (event->allDay()) { | 913 | if (event->allDay()) { | ||
914 | continue; | 914 | continue; | ||
915 | } | 915 | } | ||
916 | if (event->dtStart().time() < myFromTime) { | 916 | if (event->dtStart().time() < myFromTime) { | ||
917 | myFromTime = event->dtStart().time(); | 917 | myFromTime = event->dtStart().time(); | ||
Show All 37 Lines | |||||
955 | QDateTime startPrintDate = QDateTime(qd, myFromTime); | 955 | QDateTime startPrintDate = QDateTime(qd, myFromTime); | ||
956 | QDateTime endPrintDate = QDateTime(qd, myToTime); | 956 | QDateTime endPrintDate = QDateTime(qd, myToTime); | ||
957 | 957 | | |||
958 | // Calculate horizontal positions and widths of events taking into account | 958 | // Calculate horizontal positions and widths of events taking into account | ||
959 | // overlapping events | 959 | // overlapping events | ||
960 | 960 | | |||
961 | QList<CellItem *> cells; | 961 | QList<CellItem *> cells; | ||
962 | 962 | | |||
963 | for (const KCalCore::Event::Ptr &event : qAsConst(events)) { | 963 | for (const KCalendarCore::Event::Ptr &event : qAsConst(events)) { | ||
964 | if (event->allDay()) { | 964 | if (event->allDay()) { | ||
965 | continue; | 965 | continue; | ||
966 | } | 966 | } | ||
967 | QList<QDateTime> times = event->startDateTimesForDate(qd, QTimeZone::systemTimeZone()); | 967 | QList<QDateTime> times = event->startDateTimesForDate(qd, QTimeZone::systemTimeZone()); | ||
968 | cells.reserve(times.count()); | 968 | cells.reserve(times.count()); | ||
969 | for (auto it = times.constBegin(); it != times.constEnd(); ++it) { | 969 | for (auto it = times.constBegin(); it != times.constEnd(); ++it) { | ||
970 | cells.append(new PrintCellItem(event, (*it).toLocalTime(), | 970 | cells.append(new PrintCellItem(event, (*it).toLocalTime(), | ||
971 | event->endDateForStart(*it).toLocalTime())); | 971 | event->endDateForStart(*it).toLocalTime())); | ||
Show All 14 Lines | |||||
986 | } | 986 | } | ||
987 | } | 987 | } | ||
988 | 988 | | |||
989 | void CalPrintPluginBase::drawAgendaItem(PrintCellItem *item, QPainter &p, | 989 | void CalPrintPluginBase::drawAgendaItem(PrintCellItem *item, QPainter &p, | ||
990 | const QDateTime &startPrintDate, | 990 | const QDateTime &startPrintDate, | ||
991 | const QDateTime &endPrintDate, float minlen, | 991 | const QDateTime &endPrintDate, float minlen, | ||
992 | const QRect &box, bool includeDescription, bool excludeTime) | 992 | const QRect &box, bool includeDescription, bool excludeTime) | ||
993 | { | 993 | { | ||
994 | KCalCore::Event::Ptr event = item->event(); | 994 | KCalendarCore::Event::Ptr event = item->event(); | ||
995 | 995 | | |||
996 | // start/end of print area for event | 996 | // start/end of print area for event | ||
997 | QDateTime startTime = item->start(); | 997 | QDateTime startTime = item->start(); | ||
998 | QDateTime endTime = item->end(); | 998 | QDateTime endTime = item->end(); | ||
999 | if ((startTime < endPrintDate && endTime > startPrintDate) | 999 | if ((startTime < endPrintDate && endTime > startPrintDate) | ||
1000 | || (endTime > startPrintDate && startTime < endPrintDate)) { | 1000 | || (endTime > startPrintDate && startTime < endPrintDate)) { | ||
1001 | if (startTime < startPrintDate) { | 1001 | if (startTime < startPrintDate) { | ||
1002 | startTime = startPrintDate; | 1002 | startTime = startPrintDate; | ||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 1072 | { | |||
1108 | headerTextBox.setRight(subHeaderBox.right() - 5); | 1108 | headerTextBox.setRight(subHeaderBox.right() - 5); | ||
1109 | if (!hstring.isEmpty()) { | 1109 | if (!hstring.isEmpty()) { | ||
1110 | p.setFont(QFont(QStringLiteral("sans-serif"), 8, QFont::Bold, true)); | 1110 | p.setFont(QFont(QStringLiteral("sans-serif"), 8, QFont::Bold, true)); | ||
1111 | p.drawText(headerTextBox, Qt::AlignLeft | Qt::AlignVCenter, hstring); | 1111 | p.drawText(headerTextBox, Qt::AlignLeft | Qt::AlignVCenter, hstring); | ||
1112 | } | 1112 | } | ||
1113 | p.setFont(QFont(QStringLiteral("sans-serif"), 10, QFont::Bold)); | 1113 | p.setFont(QFont(QStringLiteral("sans-serif"), 10, QFont::Bold)); | ||
1114 | p.drawText(headerTextBox, Qt::AlignRight | Qt::AlignVCenter, dayNumStr); | 1114 | p.drawText(headerTextBox, Qt::AlignRight | Qt::AlignVCenter, dayNumStr); | ||
1115 | 1115 | | |||
1116 | const KCalCore::Event::List eventList | 1116 | const KCalendarCore::Event::List eventList | ||
1117 | = mCalendar->events(qd, QTimeZone::systemTimeZone(), | 1117 | = mCalendar->events(qd, QTimeZone::systemTimeZone(), | ||
1118 | KCalCore::EventSortStartDate, | 1118 | KCalendarCore::EventSortStartDate, | ||
1119 | KCalCore::SortDirectionAscending); | 1119 | KCalendarCore::SortDirectionAscending); | ||
1120 | 1120 | | |||
1121 | QString timeText; | 1121 | QString timeText; | ||
1122 | p.setFont(QFont(QStringLiteral("sans-serif"), 7)); | 1122 | p.setFont(QFont(QStringLiteral("sans-serif"), 7)); | ||
1123 | 1123 | | |||
1124 | int textY = mSubHeaderHeight; // gives the relative y-coord of the next printed entry | 1124 | int textY = mSubHeaderHeight; // gives the relative y-coord of the next printed entry | ||
1125 | unsigned int visibleEventsCounter = 0; | 1125 | unsigned int visibleEventsCounter = 0; | ||
1126 | for (const KCalCore::Event::Ptr &currEvent : qAsConst(eventList)) { | 1126 | for (const KCalendarCore::Event::Ptr &currEvent : qAsConst(eventList)) { | ||
1127 | Q_ASSERT(currEvent); | 1127 | Q_ASSERT(currEvent); | ||
1128 | if (!currEvent->allDay()) { | 1128 | if (!currEvent->allDay()) { | ||
1129 | if (currEvent->dtEnd().toLocalTime().time() <= myFromTime | 1129 | if (currEvent->dtEnd().toLocalTime().time() <= myFromTime | ||
1130 | || currEvent->dtStart().toLocalTime().time() > myToTime) { | 1130 | || currEvent->dtStart().toLocalTime().time() > myToTime) { | ||
1131 | continue; | 1131 | continue; | ||
1132 | } | 1132 | } | ||
1133 | } | 1133 | } | ||
1134 | if ((!printRecurDaily && currEvent->recurrenceType() == KCalCore::Recurrence::rDaily) | 1134 | if ((!printRecurDaily && currEvent->recurrenceType() == KCalendarCore::Recurrence::rDaily) | ||
1135 | || (!printRecurWeekly | 1135 | || (!printRecurWeekly | ||
1136 | && currEvent->recurrenceType() == KCalCore::Recurrence::rWeekly)) { | 1136 | && currEvent->recurrenceType() == KCalendarCore::Recurrence::rWeekly)) { | ||
1137 | continue; | 1137 | continue; | ||
1138 | } | 1138 | } | ||
1139 | if ((excludeConfidential | 1139 | if ((excludeConfidential | ||
1140 | && currEvent->secrecy() == KCalCore::Incidence::SecrecyConfidential) | 1140 | && currEvent->secrecy() == KCalendarCore::Incidence::SecrecyConfidential) | ||
1141 | || (excludePrivate && currEvent->secrecy() == KCalCore::Incidence::SecrecyPrivate)) { | 1141 | || (excludePrivate && currEvent->secrecy() == KCalendarCore::Incidence::SecrecyPrivate)) { | ||
1142 | continue; | 1142 | continue; | ||
1143 | } | 1143 | } | ||
1144 | if (currEvent->allDay() || currEvent->isMultiDay()) { | 1144 | if (currEvent->allDay() || currEvent->isMultiDay()) { | ||
1145 | timeText.clear(); | 1145 | timeText.clear(); | ||
1146 | } else { | 1146 | } else { | ||
1147 | timeText = local.toString( | 1147 | timeText = local.toString( | ||
1148 | currEvent->dtStart().toLocalTime().time(), QLocale::ShortFormat) + QLatin1Char(' '); | 1148 | currEvent->dtStart().toLocalTime().time(), QLocale::ShortFormat) + QLatin1Char(' '); | ||
1149 | } | 1149 | } | ||
Show All 31 Lines | 1169 | if (invisibleIncidences > 0) { | |||
1181 | p.drawText(msgRect, Qt::AlignLeft, warningMsg); | 1181 | p.drawText(msgRect, Qt::AlignLeft, warningMsg); | ||
1182 | p.restore(); | 1182 | p.restore(); | ||
1183 | } | 1183 | } | ||
1184 | break; | 1184 | break; | ||
1185 | } | 1185 | } | ||
1186 | } | 1186 | } | ||
1187 | 1187 | | |||
1188 | if (textY < box.height()) { | 1188 | if (textY < box.height()) { | ||
1189 | KCalCore::Todo::List todos = mCalendar->todos(qd); | 1189 | KCalendarCore::Todo::List todos = mCalendar->todos(qd); | ||
1190 | for (const KCalCore::Todo::Ptr &todo : qAsConst(todos)) { | 1190 | for (const KCalendarCore::Todo::Ptr &todo : qAsConst(todos)) { | ||
1191 | if (!todo->allDay()) { | 1191 | if (!todo->allDay()) { | ||
1192 | if ((todo->hasDueDate() && todo->dtDue().toLocalTime().time() <= myFromTime) | 1192 | if ((todo->hasDueDate() && todo->dtDue().toLocalTime().time() <= myFromTime) | ||
1193 | || (todo->hasStartDate() && todo->dtStart().toLocalTime().time() > myToTime)) { | 1193 | || (todo->hasStartDate() && todo->dtStart().toLocalTime().time() > myToTime)) { | ||
1194 | continue; | 1194 | continue; | ||
1195 | } | 1195 | } | ||
1196 | } | 1196 | } | ||
1197 | if ((!printRecurDaily && todo->recurrenceType() == KCalCore::Recurrence::rDaily) | 1197 | if ((!printRecurDaily && todo->recurrenceType() == KCalendarCore::Recurrence::rDaily) | ||
1198 | || (!printRecurWeekly && todo->recurrenceType() == KCalCore::Recurrence::rWeekly)) { | 1198 | || (!printRecurWeekly && todo->recurrenceType() == KCalendarCore::Recurrence::rWeekly)) { | ||
1199 | continue; | 1199 | continue; | ||
1200 | } | 1200 | } | ||
1201 | if ((excludeConfidential && todo->secrecy() == KCalCore::Incidence::SecrecyConfidential) | 1201 | if ((excludeConfidential && todo->secrecy() == KCalendarCore::Incidence::SecrecyConfidential) | ||
1202 | || (excludePrivate && todo->secrecy() == KCalCore::Incidence::SecrecyPrivate)) { | 1202 | || (excludePrivate && todo->secrecy() == KCalendarCore::Incidence::SecrecyPrivate)) { | ||
1203 | continue; | 1203 | continue; | ||
1204 | } | 1204 | } | ||
1205 | if (todo->hasStartDate() && !todo->allDay()) { | 1205 | if (todo->hasStartDate() && !todo->allDay()) { | ||
1206 | timeText = QLocale().toString( | 1206 | timeText = QLocale().toString( | ||
1207 | todo->dtStart().toLocalTime().time(), QLocale::ShortFormat) + QLatin1Char(' '); | 1207 | todo->dtStart().toLocalTime().time(), QLocale::ShortFormat) + QLatin1Char(' '); | ||
1208 | } else { | 1208 | } else { | ||
1209 | timeText.clear(); | 1209 | timeText.clear(); | ||
1210 | } | 1210 | } | ||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Line(s) | 1436 | void CalPrintPluginBase::drawTimeTable(QPainter &p, const QDate &fromDate, const QDate &toDate, | |||
1438 | const QRect &box, bool includeDescription, bool excludeTime, | 1438 | const QRect &box, bool includeDescription, bool excludeTime, | ||
1439 | bool excludeConfidential, bool excludePrivate) | 1439 | bool excludeConfidential, bool excludePrivate) | ||
1440 | { | 1440 | { | ||
1441 | QTime myFromTime = fromTime; | 1441 | QTime myFromTime = fromTime; | ||
1442 | QTime myToTime = toTime; | 1442 | QTime myToTime = toTime; | ||
1443 | if (expandable) { | 1443 | if (expandable) { | ||
1444 | QDate curDate(fromDate); | 1444 | QDate curDate(fromDate); | ||
1445 | while (curDate <= toDate) { | 1445 | while (curDate <= toDate) { | ||
1446 | KCalCore::Event::List eventList | 1446 | KCalendarCore::Event::List eventList | ||
1447 | = mCalendar->events(curDate, QTimeZone::systemTimeZone()); | 1447 | = mCalendar->events(curDate, QTimeZone::systemTimeZone()); | ||
1448 | for (const KCalCore::Event::Ptr &event : qAsConst(eventList)) { | 1448 | for (const KCalendarCore::Event::Ptr &event : qAsConst(eventList)) { | ||
1449 | Q_ASSERT(event); | 1449 | Q_ASSERT(event); | ||
1450 | if (event->allDay()) { | 1450 | if (event->allDay()) { | ||
1451 | continue; | 1451 | continue; | ||
1452 | } | 1452 | } | ||
1453 | if (event->dtStart().time() < myFromTime) { | 1453 | if (event->dtStart().time() < myFromTime) { | ||
1454 | myFromTime = event->dtStart().time(); | 1454 | myFromTime = event->dtStart().time(); | ||
1455 | } | 1455 | } | ||
1456 | if (event->dtEnd().time() > myToTime) { | 1456 | if (event->dtEnd().time() > myToTime) { | ||
Show All 24 Lines | |||||
1481 | double cellWidth = double(dowBox.width()) / double(fromDate.daysTo(toDate) + 1); | 1481 | double cellWidth = double(dowBox.width()) / double(fromDate.daysTo(toDate) + 1); | ||
1482 | const QList<QDate> workDays = CalendarSupport::workDays(fromDate, toDate); | 1482 | const QList<QDate> workDays = CalendarSupport::workDays(fromDate, toDate); | ||
1483 | while (curDate <= toDate) { | 1483 | while (curDate <= toDate) { | ||
1484 | QRect allDayBox(dowBox.left() + int(i *cellWidth), dowBox.bottom() + BOX_BORDER_WIDTH, | 1484 | QRect allDayBox(dowBox.left() + int(i *cellWidth), dowBox.bottom() + BOX_BORDER_WIDTH, | ||
1485 | int((i + 1) * cellWidth) - int(i *cellWidth), alldayHeight); | 1485 | int((i + 1) * cellWidth) - int(i *cellWidth), alldayHeight); | ||
1486 | QRect dayBox(allDayBox); | 1486 | QRect dayBox(allDayBox); | ||
1487 | dayBox.setTop(tlBox.top()); | 1487 | dayBox.setTop(tlBox.top()); | ||
1488 | dayBox.setBottom(box.bottom()); | 1488 | dayBox.setBottom(box.bottom()); | ||
1489 | KCalCore::Event::List eventList = mCalendar->events(curDate, QTimeZone::systemTimeZone(), | 1489 | KCalendarCore::Event::List eventList = mCalendar->events(curDate, QTimeZone::systemTimeZone(), | ||
1490 | KCalCore::EventSortStartDate, | 1490 | KCalendarCore::EventSortStartDate, | ||
1491 | KCalCore::SortDirectionAscending); | 1491 | KCalendarCore::SortDirectionAscending); | ||
1492 | 1492 | | |||
1493 | alldayHeight = drawAllDayBox(p, eventList, curDate, false, allDayBox, | 1493 | alldayHeight = drawAllDayBox(p, eventList, curDate, false, allDayBox, | ||
1494 | excludeConfidential, excludePrivate); | 1494 | excludeConfidential, excludePrivate); | ||
1495 | drawAgendaDayBox(p, eventList, curDate, false, myFromTime, myToTime, | 1495 | drawAgendaDayBox(p, eventList, curDate, false, myFromTime, myToTime, | ||
1496 | dayBox, includeDescription, excludeTime, | 1496 | dayBox, includeDescription, excludeTime, | ||
1497 | excludeConfidential, excludePrivate, workDays); | 1497 | excludeConfidential, excludePrivate, workDays); | ||
1498 | 1498 | | |||
1499 | ++i; | 1499 | ++i; | ||
1500 | curDate = curDate.addDays(1); | 1500 | curDate = curDate.addDays(1); | ||
1501 | } | 1501 | } | ||
1502 | } | 1502 | } | ||
1503 | 1503 | | |||
1504 | class MonthEventStruct | 1504 | class MonthEventStruct | ||
1505 | { | 1505 | { | ||
1506 | public: | 1506 | public: | ||
1507 | MonthEventStruct() : event(nullptr) | 1507 | MonthEventStruct() : event(nullptr) | ||
1508 | { | 1508 | { | ||
1509 | } | 1509 | } | ||
1510 | 1510 | | |||
1511 | MonthEventStruct(const QDateTime &s, const QDateTime &e, const KCalCore::Event::Ptr &ev) | 1511 | MonthEventStruct(const QDateTime &s, const QDateTime &e, const KCalendarCore::Event::Ptr &ev) | ||
1512 | { | 1512 | { | ||
1513 | event = ev; | 1513 | event = ev; | ||
1514 | start = s; | 1514 | start = s; | ||
1515 | end = e; | 1515 | end = e; | ||
1516 | if (event->allDay()) { | 1516 | if (event->allDay()) { | ||
1517 | start = QDateTime(start.date(), QTime(0, 0, 0)); | 1517 | start = QDateTime(start.date(), QTime(0, 0, 0)); | ||
1518 | end = QDateTime(end.date().addDays(1), QTime(0, 0, 0)).addSecs(-1); | 1518 | end = QDateTime(end.date().addDays(1), QTime(0, 0, 0)).addSecs(-1); | ||
1519 | } | 1519 | } | ||
1520 | } | 1520 | } | ||
1521 | 1521 | | |||
1522 | bool operator <(const MonthEventStruct &mes) | 1522 | bool operator <(const MonthEventStruct &mes) | ||
1523 | { | 1523 | { | ||
1524 | return start < mes.start; | 1524 | return start < mes.start; | ||
1525 | } | 1525 | } | ||
1526 | 1526 | | |||
1527 | QDateTime start; | 1527 | QDateTime start; | ||
1528 | QDateTime end; | 1528 | QDateTime end; | ||
1529 | KCalCore::Event::Ptr event; | 1529 | KCalendarCore::Event::Ptr event; | ||
1530 | }; | 1530 | }; | ||
1531 | 1531 | | |||
1532 | void CalPrintPluginBase::drawMonth(QPainter &p, const QDate &dt, const QRect &box, int maxdays, | 1532 | void CalPrintPluginBase::drawMonth(QPainter &p, const QDate &dt, const QRect &box, int maxdays, | ||
1533 | int subDailyFlags, int holidaysFlags, bool excludeConfidential, | 1533 | int subDailyFlags, int holidaysFlags, bool excludeConfidential, | ||
1534 | bool excludePrivate) | 1534 | bool excludePrivate) | ||
1535 | { | 1535 | { | ||
1536 | p.save(); | 1536 | p.save(); | ||
1537 | QRect subheaderBox(box); | 1537 | QRect subheaderBox(box); | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | |||||
1593 | } | 1593 | } | ||
1594 | p.setBrush(oldbrush); | 1594 | p.setBrush(oldbrush); | ||
1595 | int xstartcont = box.left() + dayNrWidth + 5; | 1595 | int xstartcont = box.left() + dayNrWidth + 5; | ||
1596 | 1596 | | |||
1597 | QDate start(dt.year(), dt.month(), 1); | 1597 | QDate start(dt.year(), dt.month(), 1); | ||
1598 | QDate end = start.addMonths(1); | 1598 | QDate end = start.addMonths(1); | ||
1599 | end = end.addDays(-1); | 1599 | end = end.addDays(-1); | ||
1600 | 1600 | | |||
1601 | const KCalCore::Event::List events = mCalendar->events(start, end); | 1601 | const KCalendarCore::Event::List events = mCalendar->events(start, end); | ||
1602 | QMap<int, QStringList> textEvents; | 1602 | QMap<int, QStringList> textEvents; | ||
1603 | QList<CellItem *> timeboxItems; | 1603 | QList<CellItem *> timeboxItems; | ||
1604 | 1604 | | |||
1605 | // 1) For multi-day events, show boxes spanning several cells, use CellItem | 1605 | // 1) For multi-day events, show boxes spanning several cells, use CellItem | ||
1606 | // print the summary vertically | 1606 | // print the summary vertically | ||
1607 | // 2) For sub-day events, print the concated summaries into the remaining | 1607 | // 2) For sub-day events, print the concated summaries into the remaining | ||
1608 | // space of the box (optional, depending on the given flags) | 1608 | // space of the box (optional, depending on the given flags) | ||
1609 | // 3) Draw some kind of timeline showing free and busy times | 1609 | // 3) Draw some kind of timeline showing free and busy times | ||
1610 | 1610 | | |||
1611 | // Holidays | 1611 | // Holidays | ||
1612 | QList<KCalCore::Event::Ptr> holidays; | 1612 | QList<KCalendarCore::Event::Ptr> holidays; | ||
1613 | for (QDate d(start); d <= end; d = d.addDays(1)) { | 1613 | for (QDate d(start); d <= end; d = d.addDays(1)) { | ||
1614 | KCalCore::Event::Ptr e = holidayEvent(d); | 1614 | KCalendarCore::Event::Ptr e = holidayEvent(d); | ||
1615 | if (e) { | 1615 | if (e) { | ||
1616 | holidays.append(e); | 1616 | holidays.append(e); | ||
1617 | if (holidaysFlags & TimeBoxes) { | 1617 | if (holidaysFlags & TimeBoxes) { | ||
1618 | timeboxItems.append(new PrintCellItem(e, QDateTime(d, QTime(0, 0, 0)), | 1618 | timeboxItems.append(new PrintCellItem(e, QDateTime(d, QTime(0, 0, 0)), | ||
1619 | QDateTime(d.addDays(1), QTime(0, 0, 0)))); | 1619 | QDateTime(d.addDays(1), QTime(0, 0, 0)))); | ||
1620 | } | 1620 | } | ||
1621 | if (holidaysFlags & Text) { | 1621 | if (holidaysFlags & Text) { | ||
1622 | textEvents[d.day()] << e->summary(); | 1622 | textEvents[d.day()] << e->summary(); | ||
1623 | } | 1623 | } | ||
1624 | } | 1624 | } | ||
1625 | } | 1625 | } | ||
1626 | 1626 | | |||
1627 | QList<MonthEventStruct> monthentries; | 1627 | QList<MonthEventStruct> monthentries; | ||
1628 | 1628 | | |||
1629 | for (const KCalCore::Event::Ptr &e : qAsConst(events)) { | 1629 | for (const KCalendarCore::Event::Ptr &e : qAsConst(events)) { | ||
1630 | if (!e) { | 1630 | if (!e) { | ||
1631 | continue; | 1631 | continue; | ||
1632 | } | 1632 | } | ||
1633 | if ((excludeConfidential && e->secrecy() == KCalCore::Incidence::SecrecyConfidential) | 1633 | if ((excludeConfidential && e->secrecy() == KCalendarCore::Incidence::SecrecyConfidential) | ||
1634 | || (excludePrivate && e->secrecy() == KCalCore::Incidence::SecrecyPrivate)) { | 1634 | || (excludePrivate && e->secrecy() == KCalendarCore::Incidence::SecrecyPrivate)) { | ||
1635 | continue; | 1635 | continue; | ||
1636 | } | 1636 | } | ||
1637 | if (e->recurs()) { | 1637 | if (e->recurs()) { | ||
1638 | if (e->recursOn(start, QTimeZone::systemTimeZone())) { | 1638 | if (e->recursOn(start, QTimeZone::systemTimeZone())) { | ||
1639 | // This occurrence has possibly started before the beginning of the | 1639 | // This occurrence has possibly started before the beginning of the | ||
1640 | // month, so obtain the start date before the beginning of the month | 1640 | // month, so obtain the start date before the beginning of the month | ||
1641 | QList<QDateTime> starttimes = e->startDateTimesForDate(start, | 1641 | QList<QDateTime> starttimes = e->startDateTimesForDate(start, | ||
1642 | QTimeZone::systemTimeZone()); | 1642 | QTimeZone::systemTimeZone()); | ||
1643 | for (auto it = starttimes.constBegin(); it != starttimes.constEnd(); ++it) { | 1643 | for (auto it = starttimes.constBegin(); it != starttimes.constEnd(); ++it) { | ||
1644 | monthentries.append(MonthEventStruct((*it).toLocalTime(), | 1644 | monthentries.append(MonthEventStruct((*it).toLocalTime(), | ||
1645 | e->endDateForStart(*it).toLocalTime(), e)); | 1645 | e->endDateForStart(*it).toLocalTime(), e)); | ||
1646 | } | 1646 | } | ||
1647 | } | 1647 | } | ||
1648 | // Loop through all remaining days of the month and check if the event | 1648 | // Loop through all remaining days of the month and check if the event | ||
1649 | // begins on that day (don't use Event::recursOn, as that will | 1649 | // begins on that day (don't use Event::recursOn, as that will | ||
1650 | // also return events that have started earlier. These start dates | 1650 | // also return events that have started earlier. These start dates | ||
1651 | // however, have already been treated! | 1651 | // however, have already been treated! | ||
1652 | KCalCore::Recurrence *recur = e->recurrence(); | 1652 | KCalendarCore::Recurrence *recur = e->recurrence(); | ||
1653 | QDate d1(start.addDays(1)); | 1653 | QDate d1(start.addDays(1)); | ||
1654 | while (d1 <= end) { | 1654 | while (d1 <= end) { | ||
1655 | if (recur->recursOn(d1, QTimeZone::systemTimeZone())) { | 1655 | if (recur->recursOn(d1, QTimeZone::systemTimeZone())) { | ||
1656 | KCalCore::TimeList times(recur->recurTimesOn(d1, QTimeZone::systemTimeZone())); | 1656 | KCalendarCore::TimeList times(recur->recurTimesOn(d1, QTimeZone::systemTimeZone())); | ||
1657 | for (KCalCore::TimeList::ConstIterator it = times.constBegin(); | 1657 | for (KCalendarCore::TimeList::ConstIterator it = times.constBegin(); | ||
1658 | it != times.constEnd(); ++it) { | 1658 | it != times.constEnd(); ++it) { | ||
1659 | QDateTime d1start(d1, *it, Qt::LocalTime); | 1659 | QDateTime d1start(d1, *it, Qt::LocalTime); | ||
1660 | monthentries.append( | 1660 | monthentries.append( | ||
1661 | MonthEventStruct(d1start, | 1661 | MonthEventStruct(d1start, | ||
1662 | e->endDateForStart(d1start).toLocalTime(), e)); | 1662 | e->endDateForStart(d1start).toLocalTime(), e)); | ||
1663 | 1663 | | |||
1664 | } | 1664 | } | ||
1665 | } | 1665 | } | ||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Line(s) | 1841 | if (y >= pageHeight) { | |||
1859 | mPrinter->newPage(); | 1859 | mPrinter->newPage(); | ||
1860 | } | 1860 | } | ||
1861 | y += fm.height(); | 1861 | y += fm.height(); | ||
1862 | p.drawText(x, y, textLine[lineCount]); | 1862 | p.drawText(x, y, textLine[lineCount]); | ||
1863 | } | 1863 | } | ||
1864 | } | 1864 | } | ||
1865 | } | 1865 | } | ||
1866 | 1866 | | |||
1867 | void CalPrintPluginBase::drawTodo(int &count, const KCalCore::Todo::Ptr &todo, QPainter &p, | 1867 | void CalPrintPluginBase::drawTodo(int &count, const KCalendarCore::Todo::Ptr &todo, QPainter &p, | ||
1868 | KCalCore::TodoSortField sortField, | 1868 | KCalendarCore::TodoSortField sortField, | ||
1869 | KCalCore::SortDirection sortDir, bool connectSubTodos, | 1869 | KCalendarCore::SortDirection sortDir, bool connectSubTodos, | ||
1870 | bool strikeoutCompleted, bool desc, int posPriority, | 1870 | bool strikeoutCompleted, bool desc, int posPriority, | ||
1871 | int posSummary, int posDueDt, int posPercentComplete, int level, | 1871 | int posSummary, int posDueDt, int posPercentComplete, int level, | ||
1872 | int x, int &y, int width, int pageHeight, | 1872 | int x, int &y, int width, int pageHeight, | ||
1873 | const KCalCore::Todo::List &todoList, TodoParentStart *r, | 1873 | const KCalendarCore::Todo::List &todoList, TodoParentStart *r, | ||
1874 | bool excludeConfidential, bool excludePrivate) | 1874 | bool excludeConfidential, bool excludePrivate) | ||
1875 | { | 1875 | { | ||
1876 | QString outStr; | 1876 | QString outStr; | ||
1877 | const auto local = QLocale::system(); | 1877 | const auto local = QLocale::system(); | ||
1878 | QRect rect; | 1878 | QRect rect; | ||
1879 | TodoParentStart startpt; | 1879 | TodoParentStart startpt; | ||
1880 | // This list keeps all starting points of the parent to-dos so the connection | 1880 | // This list keeps all starting points of the parent to-dos so the connection | ||
1881 | // lines of the tree can easily be drawn (needed if a new page is started) | 1881 | // lines of the tree can easily be drawn (needed if a new page is started) | ||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 1969 | if (showPercentComplete) { | |||
1984 | rect = p.boundingRect(posPercentComplete + lwidth + 3, y, x + width, -1, | 1984 | rect = p.boundingRect(posPercentComplete + lwidth + 3, y, x + width, -1, | ||
1985 | Qt::AlignTop | Qt::AlignLeft, outStr); | 1985 | Qt::AlignTop | Qt::AlignLeft, outStr); | ||
1986 | p.drawText(rect, Qt::AlignTop | Qt::AlignLeft, outStr); | 1986 | p.drawText(rect, Qt::AlignTop | Qt::AlignLeft, outStr); | ||
1987 | } | 1987 | } | ||
1988 | 1988 | | |||
1989 | y += 10; | 1989 | y += 10; | ||
1990 | 1990 | | |||
1991 | // Make a list of all the sub-to-dos related to this to-do. | 1991 | // Make a list of all the sub-to-dos related to this to-do. | ||
1992 | KCalCore::Todo::List t; | 1992 | KCalendarCore::Todo::List t; | ||
1993 | const KCalCore::Incidence::List relations = mCalendar->childIncidences(todo->uid()); | 1993 | const KCalendarCore::Incidence::List relations = mCalendar->childIncidences(todo->uid()); | ||
1994 | 1994 | | |||
1995 | for (const KCalCore::Incidence::Ptr &incidence : relations) { | 1995 | for (const KCalendarCore::Incidence::Ptr &incidence : relations) { | ||
1996 | // In the future, to-dos might also be related to events | 1996 | // In the future, to-dos might also be related to events | ||
1997 | // Manually check if the sub-to-do is in the list of to-dos to print | 1997 | // Manually check if the sub-to-do is in the list of to-dos to print | ||
1998 | // The problem is that relations() does not apply filters, so | 1998 | // The problem is that relations() does not apply filters, so | ||
1999 | // we need to compare manually with the complete filtered list! | 1999 | // we need to compare manually with the complete filtered list! | ||
2000 | KCalCore::Todo::Ptr subtodo = incidence.dynamicCast<KCalCore::Todo>(); | 2000 | KCalendarCore::Todo::Ptr subtodo = incidence.dynamicCast<KCalendarCore::Todo>(); | ||
2001 | if (!subtodo) { | 2001 | if (!subtodo) { | ||
2002 | continue; | 2002 | continue; | ||
2003 | } | 2003 | } | ||
2004 | #ifdef AKONADI_PORT_DISABLED | 2004 | #ifdef AKONADI_PORT_DISABLED | ||
2005 | if (subtodo && todoList.contains(subtodo)) { | 2005 | if (subtodo && todoList.contains(subtodo)) { | ||
2006 | #else | 2006 | #else | ||
2007 | bool subtodoOk = false; | 2007 | bool subtodoOk = false; | ||
2008 | if (subtodo) { | 2008 | if (subtodo) { | ||
2009 | for (const KCalCore::Todo::Ptr &tt : qAsConst(todoList)) { | 2009 | for (const KCalendarCore::Todo::Ptr &tt : qAsConst(todoList)) { | ||
2010 | if (tt == subtodo) { | 2010 | if (tt == subtodo) { | ||
2011 | subtodoOk = true; | 2011 | subtodoOk = true; | ||
2012 | break; | 2012 | break; | ||
2013 | } | 2013 | } | ||
2014 | } | 2014 | } | ||
2015 | } | 2015 | } | ||
2016 | if (subtodoOk) { | 2016 | if (subtodoOk) { | ||
2017 | #endif | 2017 | #endif | ||
2018 | if ((excludeConfidential | 2018 | if ((excludeConfidential | ||
2019 | && subtodo->secrecy() == KCalCore::Incidence::SecrecyConfidential) | 2019 | && subtodo->secrecy() == KCalendarCore::Incidence::SecrecyConfidential) | ||
2020 | || (excludePrivate | 2020 | || (excludePrivate | ||
2021 | && subtodo->secrecy() == KCalCore::Incidence::SecrecyPrivate)) { | 2021 | && subtodo->secrecy() == KCalendarCore::Incidence::SecrecyPrivate)) { | ||
2022 | continue; | 2022 | continue; | ||
2023 | } | 2023 | } | ||
2024 | t.append(subtodo); | 2024 | t.append(subtodo); | ||
2025 | } | 2025 | } | ||
2026 | } | 2026 | } | ||
2027 | 2027 | | |||
2028 | // has sub-todos? | 2028 | // has sub-todos? | ||
2029 | startpt.mHasLine = (relations.size() > 0); | 2029 | startpt.mHasLine = (relations.size() > 0); | ||
2030 | startPoints.append(&startpt); | 2030 | startPoints.append(&startpt); | ||
2031 | 2031 | | |||
2032 | // description | 2032 | // description | ||
2033 | if (!todo->description().isEmpty() && desc) { | 2033 | if (!todo->description().isEmpty() && desc) { | ||
2034 | y = newrect.bottom() + 5; | 2034 | y = newrect.bottom() + 5; | ||
2035 | drawTodoLines(p, todo->description(), left, y, | 2035 | drawTodoLines(p, todo->description(), left, y, | ||
2036 | width - (left + 10 - x), pageHeight, | 2036 | width - (left + 10 - x), pageHeight, | ||
2037 | todo->descriptionIsRich(), | 2037 | todo->descriptionIsRich(), | ||
2038 | startPoints, connectSubTodos); | 2038 | startPoints, connectSubTodos); | ||
2039 | } else { | 2039 | } else { | ||
2040 | y += 10; | 2040 | y += 10; | ||
2041 | } | 2041 | } | ||
2042 | 2042 | | |||
2043 | // Sort the sub-to-dos and print them | 2043 | // Sort the sub-to-dos and print them | ||
2044 | #ifdef AKONADI_PORT_DISABLED | 2044 | #ifdef AKONADI_PORT_DISABLED | ||
2045 | KCalCore::Todo::List sl = mCalendar->sortTodos(&t, sortField, sortDir); | 2045 | KCalendarCore::Todo::List sl = mCalendar->sortTodos(&t, sortField, sortDir); | ||
2046 | #else | 2046 | #else | ||
2047 | KCalCore::Todo::List tl; | 2047 | KCalendarCore::Todo::List tl; | ||
2048 | tl.reserve(t.count()); | 2048 | tl.reserve(t.count()); | ||
2049 | for (const KCalCore::Todo::Ptr &todo : qAsConst(t)) { | 2049 | for (const KCalendarCore::Todo::Ptr &todo : qAsConst(t)) { | ||
2050 | tl.append(todo); | 2050 | tl.append(todo); | ||
2051 | } | 2051 | } | ||
2052 | KCalCore::Todo::List sl = mCalendar->sortTodos(tl, sortField, sortDir); | 2052 | KCalendarCore::Todo::List sl = mCalendar->sortTodos(tl, sortField, sortDir); | ||
2053 | #endif | 2053 | #endif | ||
2054 | 2054 | | |||
2055 | int subcount = 0; | 2055 | int subcount = 0; | ||
2056 | for (const KCalCore::Todo::Ptr &isl : qAsConst(sl)) { | 2056 | for (const KCalendarCore::Todo::Ptr &isl : qAsConst(sl)) { | ||
2057 | count++; | 2057 | count++; | ||
2058 | if (++subcount == sl.size()) { | 2058 | if (++subcount == sl.size()) { | ||
2059 | startpt.mHasLine = false; | 2059 | startpt.mHasLine = false; | ||
2060 | } | 2060 | } | ||
2061 | drawTodo(count, isl, p, sortField, sortDir, | 2061 | drawTodo(count, isl, p, sortField, sortDir, | ||
2062 | connectSubTodos, strikeoutCompleted, | 2062 | connectSubTodos, strikeoutCompleted, | ||
2063 | desc, posPriority, posSummary, posDueDt, posPercentComplete, | 2063 | desc, posPriority, posSummary, posDueDt, posPercentComplete, | ||
2064 | level + 1, x, y, width, pageHeight, todoList, &startpt, | 2064 | level + 1, x, y, width, pageHeight, todoList, &startpt, | ||
Show All 29 Lines | 2092 | if (y >= pageHeight) { | |||
2094 | mPrinter->newPage(); | 2094 | mPrinter->newPage(); | ||
2095 | } | 2095 | } | ||
2096 | y += fm.height(); | 2096 | y += fm.height(); | ||
2097 | p.drawText(x, y, textLine[lineCount]); | 2097 | p.drawText(x, y, textLine[lineCount]); | ||
2098 | } | 2098 | } | ||
2099 | } | 2099 | } | ||
2100 | } | 2100 | } | ||
2101 | 2101 | | |||
2102 | void CalPrintPluginBase::drawJournal(const KCalCore::Journal::Ptr &journal, QPainter &p, int x, | 2102 | void CalPrintPluginBase::drawJournal(const KCalendarCore::Journal::Ptr &journal, QPainter &p, int x, | ||
2103 | int &y, int width, int pageHeight) | 2103 | int &y, int width, int pageHeight) | ||
2104 | { | 2104 | { | ||
2105 | QFont oldFont(p.font()); | 2105 | QFont oldFont(p.font()); | ||
2106 | p.setFont(QFont(QStringLiteral("sans-serif"), 15)); | 2106 | p.setFont(QFont(QStringLiteral("sans-serif"), 15)); | ||
2107 | QString headerText; | 2107 | QString headerText; | ||
2108 | QString dateText(QLocale::system().toString(journal->dtStart().toLocalTime().date(), | 2108 | QString dateText(QLocale::system().toString(journal->dtStart().toLocalTime().date(), | ||
2109 | QLocale::LongFormat)); | 2109 | QLocale::LongFormat)); | ||
2110 | 2110 | | |||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |