CalendarSupport

calprintdefaultplugins.h
1/*
2 SPDX-FileCopyrightText: 1998 Preston Brown <pbrown@kde.org>
3 SPDX-FileCopyrightText: 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
4 SPDX-FileCopyrightText: 2008 Ron Goodheart <rong.dev@gmail.com>
5 SPDX-FileCopyrightText: 2012-2013 Allen Winter <winter@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
8*/
9#pragma once
10
11#include "calendarsupport_export.h"
12#include "calprintpluginbase.h"
13
14#include "ui_calprintdayconfig_base.h"
15#include "ui_calprintincidenceconfig_base.h"
16#include "ui_calprintmonthconfig_base.h"
17#include "ui_calprinttodoconfig_base.h"
18#include "ui_calprintweekconfig_base.h"
19
20#include <KLocalizedString>
21
22namespace CalendarSupport
23{
24class CALENDARSUPPORT_EXPORT CalPrintIncidence : public CalPrintPluginBase
25{
26public:
27 CalPrintIncidence();
28 ~CalPrintIncidence() override;
29 [[nodiscard]] QString groupName() const override
30 {
31 return QStringLiteral("Print incidence");
32 }
33
34 [[nodiscard]] QString description() const override
35 {
36 return i18n("Print &incidence");
37 }
38
39 [[nodiscard]] QString info() const override
40 {
41 return i18n("Prints an incidence on one page");
42 }
43
44 [[nodiscard]] int sortID() const override
45 {
46 return CalPrinterBase::Incidence;
47 }
48
49 // Enable the Print Incidence option only if there are selected incidences.
50 [[nodiscard]] bool enabled() const override
51 {
52 return !mSelectedIncidences.isEmpty();
53 }
54
55 QWidget *createConfigWidget(QWidget *) override;
56 [[nodiscard]] QPageLayout::Orientation defaultOrientation() const override
57 {
59 }
60
61public:
62 void print(QPainter &p, int width, int height) override;
63 void readSettingsWidget() override;
64 void setSettingsWidget() override;
65 void doLoadConfig() override;
66 void doSaveConfig() override;
67
68protected:
69 int printCaptionAndText(QPainter &p, QRect box, const QString &caption, const QString &text, const QFont &captionFont, const QFont &textFont);
70
71 bool mShowOptions;
72 bool mShowSubitemsNotes;
73 bool mShowAttendees;
74 bool mShowAttachments;
75};
76
77class CalPrintTimetable : public CalPrintPluginBase
78{
79public:
80 CalPrintTimetable();
81 ~CalPrintTimetable() override;
82 void doLoadConfig() override;
83 void doSaveConfig() override;
84
85protected:
86 /**
87 Draw the all-day box for the agenda print view (the box on top which
88 doesn't have a time on the time scale associated).
89
90 Obeys configuration options #mExcludeConfidential, #mExcludePrivate, #mIncludeCategories.
91 @param p QPainter of the printout
92 @param eventList The list of all-day events that are supposed to be printed
93 inside this box
94 @param qd The date of the currently printed day
95 @param box coordinates of the all day box.
96 @param workDays List of workDays
97 */
98 void drawAllDayBox(QPainter &p, const KCalendarCore::Event::List &eventList, QDate qd, QRect box, const QList<QDate> &workDays);
99
100 /**
101 Draw the timetable view of the given time range from fromDate to toDate.
102 On the left side the time scale is printed (using drawTimeLine), then each
103 day gets one column (printed using drawAgendaDayBox),
104 and the events are displayed as boxes (like in korganizer's day/week view).
105 The first cell of each column contains the all-day events (using
106 drawAllDayBox with expandable=false).
107
108 Obeys configuration options #mExcludeConfidential, #mExcludePrivate,
109 #mIncludeAllEvents, #mIncludeCategories, #mIncludeDescription, #mStartTime, #mEndTime.
110 @param p QPainter of the printout
111 @param fromDate First day to be included in the page
112 @param toDate Last day to be included in the page
113 @param box coordinates of the time table.
114 */
115 void drawTimeTable(QPainter &p, QDate fromDate, QDate toDate, QRect box);
116
117 QTime mStartTime, mEndTime; /**< Earliest and latest times of day to print. */
118 bool mSingleLineLimit; /**< Should all fields be printed on the same line? */
119 bool mIncludeTodos; /**< Should to-dos be printed? */
120 bool mIncludeDescription; /**< Should incidence descriptions be printed? */
121 bool mIncludeCategories; /**< Should incidence tags be printed? */
122 bool mIncludeAllEvents; /**< If events occur outside the start/end times, should the times be adjusted? */
123 bool mExcludeTime; /**< Should incidence times of day be printed? */
124};
125
126class CalPrintDay : public CalPrintTimetable
127{
128public:
129 CalPrintDay();
130 ~CalPrintDay() override;
131 [[nodiscard]] QString groupName() const override
132 {
133 return QStringLiteral("Print day");
134 }
135
136 [[nodiscard]] QString description() const override
137 {
138 return i18n("Print da&y");
139 }
140
141 [[nodiscard]] QString info() const override
142 {
143 return i18n("Prints all events of a single day on one page");
144 }
145
146 [[nodiscard]] int sortID() const override
147 {
148 return CalPrinterBase::Day;
149 }
150
151 [[nodiscard]] bool enabled() const override
152 {
153 return true;
154 }
155
156 QWidget *createConfigWidget(QWidget *) override;
157
158 void print(QPainter &p, int width, int height) override;
159 void readSettingsWidget() override;
160 void setSettingsWidget() override;
161 void doLoadConfig() override;
162 void doSaveConfig() override;
163 void setDateRange(const QDate &from, const QDate &to) override;
164
165protected:
166 enum eDayPrintType {
167 Filofax = 0,
168 Timetable,
169 SingleTimetable
170 } mDayPrintType;
171
172 /**
173 Draw the (filofax) table for a bunch of days, using drawDayBox.
174
175 Obeys configuration options #mExcludeConfidential, #mExcludePrivate, #mShowNoteLines, #mUseColors,
176 #mFromDate, #mToDate, #mStartTime, #mEndTime, #mSingleLineLimit,
177 #mIncludeDescription, #mIncludeCategories.
178 @param p QPainter of the printout
179 @param box coordinates of the week box.
180 */
181 void drawDays(QPainter &p, QRect box);
182};
183
184class CalPrintWeek : public CalPrintTimetable
185{
186public:
187 CalPrintWeek();
188 ~CalPrintWeek() override;
189
190 [[nodiscard]] QString groupName() const override
191 {
192 return QStringLiteral("Print week");
193 }
194
195 [[nodiscard]] QString description() const override
196 {
197 return i18n("Print &week");
198 }
199
200 [[nodiscard]] QString info() const override
201 {
202 return i18n("Prints all events of one week on one page");
203 }
204
205 [[nodiscard]] int sortID() const override
206 {
207 return CalPrinterBase::Week;
208 }
209
210 [[nodiscard]] bool enabled() const override
211 {
212 return true;
213 }
214
215 QWidget *createConfigWidget(QWidget *) override;
216
217 /**
218 Returns the default orientation for the eWeekPrintType.
219 */
220 QPageLayout::Orientation defaultOrientation() const override;
221
222 void print(QPainter &p, int width, int height) override;
223 void readSettingsWidget() override;
224 void setSettingsWidget() override;
225 void doLoadConfig() override;
226 void doSaveConfig() override;
227 void setDateRange(const QDate &from, const QDate &to) override;
228
229protected:
230 enum eWeekPrintType {
231 Filofax = 0,
232 Timetable,
233 SplitWeek
234 } mWeekPrintType;
235
236 /**
237 Draw the week (filofax) table of the week containing the date qd. The first
238 three days of the week will be shown in the first column (using drawDayBox),
239 the remaining four in the second column, where the last two days of the week
240 (typically Saturday and Sunday) only get half the height of the other day boxes.
241
242 Obeys configuration options #mExcludeConfidential, #mExcludePrivate, #mShowNoteLines, #mUseColors,
243 #mStartTime, #mEndTime, #mSingleLineLimit, #mIncludeDescription, #mIncludeCategories.
244 @param p QPainter of the printout
245 @param qd Arbitrary date within the week to be printed.
246 @param box coordinates of the week box.
247 */
248 void drawWeek(QPainter &p, QDate qd, QRect box);
249};
250
251class CalPrintMonth : public CalPrintPluginBase
252{
253public:
254 CalPrintMonth();
255 ~CalPrintMonth() override;
256 QString groupName() const override
257 {
258 return QStringLiteral("Print month");
259 }
260
261 QString description() const override
262 {
263 return i18n("Print mont&h");
264 }
265
266 QString info() const override
267 {
268 return i18n("Prints all events of one month on one page");
269 }
270
271 int sortID() const override
272 {
273 return CalPrinterBase::Month;
274 }
275
276 bool enabled() const override
277 {
278 return true;
279 }
280
281 QWidget *createConfigWidget(QWidget *) override;
282 QPageLayout::Orientation defaultOrientation() const override
283 {
285 }
286
287public:
288 void print(QPainter &p, int width, int height) override;
289 void readSettingsWidget() override;
290 void setSettingsWidget() override;
291 void doLoadConfig() override;
292 void doSaveConfig() override;
293 void setDateRange(const QDate &from, const QDate &to) override;
294
295protected:
296 bool mWeekNumbers;
297 bool mRecurDaily;
298 bool mRecurWeekly;
299 bool mIncludeTodos;
300 bool mSingleLineLimit;
301 bool mIncludeDescription;
302 bool mIncludeCategories;
303};
304
305class CalPrintTodos : public CalPrintPluginBase
306{
307public:
308 CalPrintTodos();
309 ~CalPrintTodos() override;
310
311 QString groupName() const override
312 {
313 return QStringLiteral("Print to-dos");
314 }
315
316 QString description() const override
317 {
318 return i18n("Print to-&dos");
319 }
320
321 QString info() const override
322 {
323 return i18n("Prints all to-dos in a (tree-like) list");
324 }
325
326 int sortID() const override
327 {
328 return CalPrinterBase::Todolist;
329 }
330
331 bool enabled() const override
332 {
333 return true;
334 }
335
336 QWidget *createConfigWidget(QWidget *) override;
337
338public:
339 void print(QPainter &p, int width, int height) override;
340 void readSettingsWidget() override;
341 void setSettingsWidget() override;
342 void doLoadConfig() override;
343 void doSaveConfig() override;
344
345protected:
346 QString mPageTitle;
347
348 enum eTodoPrintType {
349 TodosAll = 0,
350 TodosUnfinished,
351 TodosDueRange
352 } mTodoPrintType;
353
354 enum eTodoSortField {
355 TodoFieldSummary = 0,
356 TodoFieldStartDate,
357 TodoFieldDueDate,
358 TodoFieldPriority,
359 TodoFieldPercentComplete,
360 TodoFieldCategories,
361 TodoFieldUnset
362 } mTodoSortField;
363
364 enum eTodoSortDirection {
365 TodoDirectionAscending = 0,
366 TodoDirectionDescending,
367 TodoDirectionUnset
368 } mTodoSortDirection;
369
370 bool mIncludeDescription;
371 bool mIncludePriority;
372 bool mIncludeCategories;
373 bool mIncludeStartDate;
374 bool mIncludeDueDate;
375 bool mIncludePercentComplete;
376 bool mConnectSubTodos;
377 bool mStrikeOutCompleted;
378 bool mSortField;
379 bool mSortDirection;
380};
381
382class CalPrintIncidenceConfig : public QWidget, public Ui::CalPrintIncidenceConfig_Base
383{
385public:
386 explicit CalPrintIncidenceConfig(QWidget *parent)
387 : QWidget(parent)
388 {
389 setupUi(this);
390 }
391};
392
393class CalPrintDayConfig : public QWidget, public Ui::CalPrintDayConfig_Base
394{
396public:
397 explicit CalPrintDayConfig(QWidget *parent)
398 : QWidget(parent)
399 {
400 setupUi(this);
401 }
402};
403
404class CalPrintWeekConfig : public QWidget, public Ui::CalPrintWeekConfig_Base
405{
407public:
408 explicit CalPrintWeekConfig(QWidget *parent)
409 : QWidget(parent)
410 {
411 setupUi(this);
412 }
413};
414
415class CalPrintMonthConfig : public QWidget, public Ui::CalPrintMonthConfig_Base
416{
418public:
419 explicit CalPrintMonthConfig(QWidget *parent)
420 : QWidget(parent)
421 {
422 setupUi(this);
423 }
424};
425
426class CalPrintTodoConfig : public QWidget, public Ui::CalPrintTodoConfig_Base
427{
429public:
430 explicit CalPrintTodoConfig(QWidget *parent)
431 : QWidget(parent)
432 {
433 setupUi(this);
434 }
435};
436}
QString i18n(const char *text, const TYPE &arg...)
const QList< QKeySequence > & print()
Q_OBJECTQ_OBJECT
QObject * parent() const const
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.