File indexing completed on 2025-01-05 04:47:41
0001 /* 0002 SPDX-FileCopyrightText: 1998 Preston Brown <pbrown@kde.org> 0003 SPDX-FileCopyrightText: 2003 Reinhold Kainhofer <reinhold@kainhofer.com> 0004 SPDX-FileCopyrightText: 2008 Ron Goodheart <rong.dev@gmail.com> 0005 SPDX-FileCopyrightText: 2012-2013 Allen Winter <winter@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0008 */ 0009 #pragma once 0010 0011 #include "calendarsupport_export.h" 0012 #include "calprintpluginbase.h" 0013 0014 #include "ui_calprintdayconfig_base.h" 0015 #include "ui_calprintincidenceconfig_base.h" 0016 #include "ui_calprintmonthconfig_base.h" 0017 #include "ui_calprinttodoconfig_base.h" 0018 #include "ui_calprintweekconfig_base.h" 0019 0020 #include <KLocalizedString> 0021 0022 namespace CalendarSupport 0023 { 0024 class CALENDARSUPPORT_EXPORT CalPrintIncidence : public CalPrintPluginBase 0025 { 0026 public: 0027 CalPrintIncidence(); 0028 ~CalPrintIncidence() override; 0029 [[nodiscard]] QString groupName() const override 0030 { 0031 return QStringLiteral("Print incidence"); 0032 } 0033 0034 [[nodiscard]] QString description() const override 0035 { 0036 return i18n("Print &incidence"); 0037 } 0038 0039 [[nodiscard]] QString info() const override 0040 { 0041 return i18n("Prints an incidence on one page"); 0042 } 0043 0044 [[nodiscard]] int sortID() const override 0045 { 0046 return CalPrinterBase::Incidence; 0047 } 0048 0049 // Enable the Print Incidence option only if there are selected incidences. 0050 [[nodiscard]] bool enabled() const override 0051 { 0052 return !mSelectedIncidences.isEmpty(); 0053 } 0054 0055 QWidget *createConfigWidget(QWidget *) override; 0056 [[nodiscard]] QPageLayout::Orientation defaultOrientation() const override 0057 { 0058 return QPageLayout::Portrait; 0059 } 0060 0061 public: 0062 void print(QPainter &p, int width, int height) override; 0063 void readSettingsWidget() override; 0064 void setSettingsWidget() override; 0065 void doLoadConfig() override; 0066 void doSaveConfig() override; 0067 0068 protected: 0069 int printCaptionAndText(QPainter &p, QRect box, const QString &caption, const QString &text, const QFont &captionFont, const QFont &textFont); 0070 0071 bool mShowOptions; 0072 bool mShowSubitemsNotes; 0073 bool mShowAttendees; 0074 bool mShowAttachments; 0075 }; 0076 0077 class CalPrintTimetable : public CalPrintPluginBase 0078 { 0079 public: 0080 CalPrintTimetable(); 0081 ~CalPrintTimetable() override; 0082 void doLoadConfig() override; 0083 void doSaveConfig() override; 0084 0085 protected: 0086 /** 0087 Draw the all-day box for the agenda print view (the box on top which 0088 doesn't have a time on the time scale associated). 0089 0090 Obeys configuration options #mExcludeConfidential, #mExcludePrivate, #mIncludeCategories. 0091 @param p QPainter of the printout 0092 @param eventList The list of all-day events that are supposed to be printed 0093 inside this box 0094 @param qd The date of the currently printed day 0095 @param box coordinates of the all day box. 0096 @param workDays List of workDays 0097 */ 0098 void drawAllDayBox(QPainter &p, const KCalendarCore::Event::List &eventList, QDate qd, QRect box, const QList<QDate> &workDays); 0099 0100 /** 0101 Draw the timetable view of the given time range from fromDate to toDate. 0102 On the left side the time scale is printed (using drawTimeLine), then each 0103 day gets one column (printed using drawAgendaDayBox), 0104 and the events are displayed as boxes (like in korganizer's day/week view). 0105 The first cell of each column contains the all-day events (using 0106 drawAllDayBox with expandable=false). 0107 0108 Obeys configuration options #mExcludeConfidential, #mExcludePrivate, 0109 #mIncludeAllEvents, #mIncludeCategories, #mIncludeDescription, #mStartTime, #mEndTime. 0110 @param p QPainter of the printout 0111 @param fromDate First day to be included in the page 0112 @param toDate Last day to be included in the page 0113 @param box coordinates of the time table. 0114 */ 0115 void drawTimeTable(QPainter &p, QDate fromDate, QDate toDate, QRect box); 0116 0117 QTime mStartTime, mEndTime; /**< Earliest and latest times of day to print. */ 0118 bool mSingleLineLimit; /**< Should all fields be printed on the same line? */ 0119 bool mIncludeTodos; /**< Should to-dos be printed? */ 0120 bool mIncludeDescription; /**< Should incidence descriptions be printed? */ 0121 bool mIncludeCategories; /**< Should incidence tags be printed? */ 0122 bool mIncludeAllEvents; /**< If events occur outside the start/end times, should the times be adjusted? */ 0123 bool mExcludeTime; /**< Should incidence times of day be printed? */ 0124 }; 0125 0126 class CalPrintDay : public CalPrintTimetable 0127 { 0128 public: 0129 CalPrintDay(); 0130 ~CalPrintDay() override; 0131 [[nodiscard]] QString groupName() const override 0132 { 0133 return QStringLiteral("Print day"); 0134 } 0135 0136 [[nodiscard]] QString description() const override 0137 { 0138 return i18n("Print da&y"); 0139 } 0140 0141 [[nodiscard]] QString info() const override 0142 { 0143 return i18n("Prints all events of a single day on one page"); 0144 } 0145 0146 [[nodiscard]] int sortID() const override 0147 { 0148 return CalPrinterBase::Day; 0149 } 0150 0151 [[nodiscard]] bool enabled() const override 0152 { 0153 return true; 0154 } 0155 0156 QWidget *createConfigWidget(QWidget *) override; 0157 0158 void print(QPainter &p, int width, int height) override; 0159 void readSettingsWidget() override; 0160 void setSettingsWidget() override; 0161 void doLoadConfig() override; 0162 void doSaveConfig() override; 0163 void setDateRange(const QDate &from, const QDate &to) override; 0164 0165 protected: 0166 enum eDayPrintType { Filofax = 0, Timetable, SingleTimetable } mDayPrintType; 0167 0168 /** 0169 Draw the (filofax) table for a bunch of days, using drawDayBox. 0170 0171 Obeys configuration options #mExcludeConfidential, #mExcludePrivate, #mShowNoteLines, #mUseColors, 0172 #mFromDate, #mToDate, #mStartTime, #mEndTime, #mSingleLineLimit, 0173 #mIncludeDescription, #mIncludeCategories. 0174 @param p QPainter of the printout 0175 @param box coordinates of the week box. 0176 */ 0177 void drawDays(QPainter &p, QRect box); 0178 }; 0179 0180 class CalPrintWeek : public CalPrintTimetable 0181 { 0182 public: 0183 CalPrintWeek(); 0184 ~CalPrintWeek() override; 0185 0186 QString groupName() const override 0187 { 0188 return QStringLiteral("Print week"); 0189 } 0190 0191 QString description() const override 0192 { 0193 return i18n("Print &week"); 0194 } 0195 0196 QString info() const override 0197 { 0198 return i18n("Prints all events of one week on one page"); 0199 } 0200 0201 int sortID() const override 0202 { 0203 return CalPrinterBase::Week; 0204 } 0205 0206 bool enabled() const override 0207 { 0208 return true; 0209 } 0210 0211 QWidget *createConfigWidget(QWidget *) override; 0212 0213 /** 0214 Returns the default orientation for the eWeekPrintType. 0215 */ 0216 QPageLayout::Orientation defaultOrientation() const override; 0217 0218 void print(QPainter &p, int width, int height) override; 0219 void readSettingsWidget() override; 0220 void setSettingsWidget() override; 0221 void doLoadConfig() override; 0222 void doSaveConfig() override; 0223 void setDateRange(const QDate &from, const QDate &to) override; 0224 0225 protected: 0226 enum eWeekPrintType { Filofax = 0, Timetable, SplitWeek } mWeekPrintType; 0227 0228 /** 0229 Draw the week (filofax) table of the week containing the date qd. The first 0230 three days of the week will be shown in the first column (using drawDayBox), 0231 the remaining four in the second column, where the last two days of the week 0232 (typically Saturday and Sunday) only get half the height of the other day boxes. 0233 0234 Obeys configuration options #mExcludeConfidential, #mExcludePrivate, #mShowNoteLines, #mUseColors, 0235 #mStartTime, #mEndTime, #mSingleLineLimit, #mIncludeDescription, #mIncludeCategories. 0236 @param p QPainter of the printout 0237 @param qd Arbitrary date within the week to be printed. 0238 @param box coordinates of the week box. 0239 */ 0240 void drawWeek(QPainter &p, QDate qd, QRect box); 0241 }; 0242 0243 class CalPrintMonth : public CalPrintPluginBase 0244 { 0245 public: 0246 CalPrintMonth(); 0247 ~CalPrintMonth() override; 0248 QString groupName() const override 0249 { 0250 return QStringLiteral("Print month"); 0251 } 0252 0253 QString description() const override 0254 { 0255 return i18n("Print mont&h"); 0256 } 0257 0258 QString info() const override 0259 { 0260 return i18n("Prints all events of one month on one page"); 0261 } 0262 0263 int sortID() const override 0264 { 0265 return CalPrinterBase::Month; 0266 } 0267 0268 bool enabled() const override 0269 { 0270 return true; 0271 } 0272 0273 QWidget *createConfigWidget(QWidget *) override; 0274 QPageLayout::Orientation defaultOrientation() const override 0275 { 0276 return QPageLayout::Landscape; 0277 } 0278 0279 public: 0280 void print(QPainter &p, int width, int height) override; 0281 void readSettingsWidget() override; 0282 void setSettingsWidget() override; 0283 void doLoadConfig() override; 0284 void doSaveConfig() override; 0285 void setDateRange(const QDate &from, const QDate &to) override; 0286 0287 protected: 0288 bool mWeekNumbers; 0289 bool mRecurDaily; 0290 bool mRecurWeekly; 0291 bool mIncludeTodos; 0292 bool mSingleLineLimit; 0293 bool mIncludeDescription; 0294 bool mIncludeCategories; 0295 }; 0296 0297 class CalPrintTodos : public CalPrintPluginBase 0298 { 0299 public: 0300 CalPrintTodos(); 0301 ~CalPrintTodos() override; 0302 0303 QString groupName() const override 0304 { 0305 return QStringLiteral("Print to-dos"); 0306 } 0307 0308 QString description() const override 0309 { 0310 return i18n("Print to-&dos"); 0311 } 0312 0313 QString info() const override 0314 { 0315 return i18n("Prints all to-dos in a (tree-like) list"); 0316 } 0317 0318 int sortID() const override 0319 { 0320 return CalPrinterBase::Todolist; 0321 } 0322 0323 bool enabled() const override 0324 { 0325 return true; 0326 } 0327 0328 QWidget *createConfigWidget(QWidget *) override; 0329 0330 public: 0331 void print(QPainter &p, int width, int height) override; 0332 void readSettingsWidget() override; 0333 void setSettingsWidget() override; 0334 void doLoadConfig() override; 0335 void doSaveConfig() override; 0336 0337 protected: 0338 QString mPageTitle; 0339 0340 enum eTodoPrintType { TodosAll = 0, TodosUnfinished, TodosDueRange } mTodoPrintType; 0341 0342 enum eTodoSortField { 0343 TodoFieldSummary = 0, 0344 TodoFieldStartDate, 0345 TodoFieldDueDate, 0346 TodoFieldPriority, 0347 TodoFieldPercentComplete, 0348 TodoFieldCategories, 0349 TodoFieldUnset 0350 } mTodoSortField; 0351 0352 enum eTodoSortDirection { TodoDirectionAscending = 0, TodoDirectionDescending, TodoDirectionUnset } mTodoSortDirection; 0353 0354 bool mIncludeDescription; 0355 bool mIncludePriority; 0356 bool mIncludeCategories; 0357 bool mIncludeStartDate; 0358 bool mIncludeDueDate; 0359 bool mIncludePercentComplete; 0360 bool mConnectSubTodos; 0361 bool mStrikeOutCompleted; 0362 bool mSortField; 0363 bool mSortDirection; 0364 }; 0365 0366 class CalPrintIncidenceConfig : public QWidget, public Ui::CalPrintIncidenceConfig_Base 0367 { 0368 Q_OBJECT 0369 public: 0370 explicit CalPrintIncidenceConfig(QWidget *parent) 0371 : QWidget(parent) 0372 { 0373 setupUi(this); 0374 } 0375 }; 0376 0377 class CalPrintDayConfig : public QWidget, public Ui::CalPrintDayConfig_Base 0378 { 0379 Q_OBJECT 0380 public: 0381 explicit CalPrintDayConfig(QWidget *parent) 0382 : QWidget(parent) 0383 { 0384 setupUi(this); 0385 } 0386 }; 0387 0388 class CalPrintWeekConfig : public QWidget, public Ui::CalPrintWeekConfig_Base 0389 { 0390 Q_OBJECT 0391 public: 0392 explicit CalPrintWeekConfig(QWidget *parent) 0393 : QWidget(parent) 0394 { 0395 setupUi(this); 0396 } 0397 }; 0398 0399 class CalPrintMonthConfig : public QWidget, public Ui::CalPrintMonthConfig_Base 0400 { 0401 Q_OBJECT 0402 public: 0403 explicit CalPrintMonthConfig(QWidget *parent) 0404 : QWidget(parent) 0405 { 0406 setupUi(this); 0407 } 0408 }; 0409 0410 class CalPrintTodoConfig : public QWidget, public Ui::CalPrintTodoConfig_Base 0411 { 0412 Q_OBJECT 0413 public: 0414 explicit CalPrintTodoConfig(QWidget *parent) 0415 : QWidget(parent) 0416 { 0417 setupUi(this); 0418 } 0419 }; 0420 }