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 { Filofax = 0, Timetable, SingleTimetable } mDayPrintType;
167
168 /**
169 Draw the (filofax) table for a bunch of days, using drawDayBox.
170
171 Obeys configuration options #mExcludeConfidential, #mExcludePrivate, #mShowNoteLines, #mUseColors,
172 #mFromDate, #mToDate, #mStartTime, #mEndTime, #mSingleLineLimit,
173 #mIncludeDescription, #mIncludeCategories.
174 @param p QPainter of the printout
175 @param box coordinates of the week box.
176 */
177 void drawDays(QPainter &p, QRect box);
178};
179
180class CalPrintWeek : public CalPrintTimetable
181{
182public:
183 CalPrintWeek();
184 ~CalPrintWeek() override;
185
186 [[nodiscard]] QString groupName() const override
187 {
188 return QStringLiteral("Print week");
189 }
190
191 [[nodiscard]] QString description() const override
192 {
193 return i18n("Print &week");
194 }
195
196 [[nodiscard]] QString info() const override
197 {
198 return i18n("Prints all events of one week on one page");
199 }
200
201 [[nodiscard]] int sortID() const override
202 {
203 return CalPrinterBase::Week;
204 }
205
206 [[nodiscard]] bool enabled() const override
207 {
208 return true;
209 }
210
211 QWidget *createConfigWidget(QWidget *) override;
212
213 /**
214 Returns the default orientation for the eWeekPrintType.
215 */
216 QPageLayout::Orientation defaultOrientation() const override;
217
218 void print(QPainter &p, int width, int height) override;
219 void readSettingsWidget() override;
220 void setSettingsWidget() override;
221 void doLoadConfig() override;
222 void doSaveConfig() override;
223 void setDateRange(const QDate &from, const QDate &to) override;
224
225protected:
226 enum eWeekPrintType { Filofax = 0, Timetable, SplitWeek } mWeekPrintType;
227
228 /**
229 Draw the week (filofax) table of the week containing the date qd. The first
230 three days of the week will be shown in the first column (using drawDayBox),
231 the remaining four in the second column, where the last two days of the week
232 (typically Saturday and Sunday) only get half the height of the other day boxes.
233
234 Obeys configuration options #mExcludeConfidential, #mExcludePrivate, #mShowNoteLines, #mUseColors,
235 #mStartTime, #mEndTime, #mSingleLineLimit, #mIncludeDescription, #mIncludeCategories.
236 @param p QPainter of the printout
237 @param qd Arbitrary date within the week to be printed.
238 @param box coordinates of the week box.
239 */
240 void drawWeek(QPainter &p, QDate qd, QRect box);
241};
242
243class CalPrintMonth : public CalPrintPluginBase
244{
245public:
246 CalPrintMonth();
247 ~CalPrintMonth() override;
248 QString groupName() const override
249 {
250 return QStringLiteral("Print month");
251 }
252
253 QString description() const override
254 {
255 return i18n("Print mont&h");
256 }
257
258 QString info() const override
259 {
260 return i18n("Prints all events of one month on one page");
261 }
262
263 int sortID() const override
264 {
265 return CalPrinterBase::Month;
266 }
267
268 bool enabled() const override
269 {
270 return true;
271 }
272
273 QWidget *createConfigWidget(QWidget *) override;
274 QPageLayout::Orientation defaultOrientation() const override
275 {
277 }
278
279public:
280 void print(QPainter &p, int width, int height) override;
281 void readSettingsWidget() override;
282 void setSettingsWidget() override;
283 void doLoadConfig() override;
284 void doSaveConfig() override;
285 void setDateRange(const QDate &from, const QDate &to) override;
286
287protected:
288 bool mWeekNumbers;
289 bool mRecurDaily;
290 bool mRecurWeekly;
291 bool mIncludeTodos;
292 bool mSingleLineLimit;
293 bool mIncludeDescription;
294 bool mIncludeCategories;
295};
296
297class CalPrintTodos : public CalPrintPluginBase
298{
299public:
300 CalPrintTodos();
301 ~CalPrintTodos() override;
302
303 QString groupName() const override
304 {
305 return QStringLiteral("Print to-dos");
306 }
307
308 QString description() const override
309 {
310 return i18n("Print to-&dos");
311 }
312
313 QString info() const override
314 {
315 return i18n("Prints all to-dos in a (tree-like) list");
316 }
317
318 int sortID() const override
319 {
320 return CalPrinterBase::Todolist;
321 }
322
323 bool enabled() const override
324 {
325 return true;
326 }
327
328 QWidget *createConfigWidget(QWidget *) override;
329
330public:
331 void print(QPainter &p, int width, int height) override;
332 void readSettingsWidget() override;
333 void setSettingsWidget() override;
334 void doLoadConfig() override;
335 void doSaveConfig() override;
336
337protected:
338 QString mPageTitle;
339
340 enum eTodoPrintType { TodosAll = 0, TodosUnfinished, TodosDueRange } mTodoPrintType;
341
342 enum eTodoSortField {
343 TodoFieldSummary = 0,
344 TodoFieldStartDate,
345 TodoFieldDueDate,
346 TodoFieldPriority,
347 TodoFieldPercentComplete,
348 TodoFieldCategories,
349 TodoFieldUnset
350 } mTodoSortField;
351
352 enum eTodoSortDirection { TodoDirectionAscending = 0, TodoDirectionDescending, TodoDirectionUnset } mTodoSortDirection;
353
354 bool mIncludeDescription;
355 bool mIncludePriority;
356 bool mIncludeCategories;
357 bool mIncludeStartDate;
358 bool mIncludeDueDate;
359 bool mIncludePercentComplete;
360 bool mConnectSubTodos;
361 bool mStrikeOutCompleted;
362 bool mSortField;
363 bool mSortDirection;
364};
365
366class CalPrintIncidenceConfig : public QWidget, public Ui::CalPrintIncidenceConfig_Base
367{
369public:
370 explicit CalPrintIncidenceConfig(QWidget *parent)
371 : QWidget(parent)
372 {
373 setupUi(this);
374 }
375};
376
377class CalPrintDayConfig : public QWidget, public Ui::CalPrintDayConfig_Base
378{
380public:
381 explicit CalPrintDayConfig(QWidget *parent)
382 : QWidget(parent)
383 {
384 setupUi(this);
385 }
386};
387
388class CalPrintWeekConfig : public QWidget, public Ui::CalPrintWeekConfig_Base
389{
391public:
392 explicit CalPrintWeekConfig(QWidget *parent)
393 : QWidget(parent)
394 {
395 setupUi(this);
396 }
397};
398
399class CalPrintMonthConfig : public QWidget, public Ui::CalPrintMonthConfig_Base
400{
402public:
403 explicit CalPrintMonthConfig(QWidget *parent)
404 : QWidget(parent)
405 {
406 setupUi(this);
407 }
408};
409
410class CalPrintTodoConfig : public QWidget, public Ui::CalPrintTodoConfig_Base
411{
413public:
414 explicit CalPrintTodoConfig(QWidget *parent)
415 : QWidget(parent)
416 {
417 setupUi(this);
418 }
419};
420}
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 Tue Mar 26 2024 11:16:32 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.