File indexing completed on 2025-01-05 04:47:43

0001 /*
0002   SPDX-FileCopyrightText: 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
0003 
0004   SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0005 */
0006 
0007 #pragma once
0008 
0009 #include "calendarsupport_export.h"
0010 #include "calprintpluginbase.h"
0011 #include "ui_calprintjournalconfig_base.h"
0012 
0013 namespace CalendarSupport
0014 {
0015 class CalPrintJournal : public CalPrintPluginBase
0016 {
0017 public:
0018     CalPrintJournal()
0019         : CalPrintPluginBase()
0020     {
0021     }
0022 
0023     ~CalPrintJournal() override = default;
0024 
0025     [[nodiscard]] QString groupName() const override
0026     {
0027         return QStringLiteral("Print journal");
0028     }
0029 
0030     [[nodiscard]] QString description() const override
0031     {
0032         return i18n("Print &journal");
0033     }
0034 
0035     [[nodiscard]] QString info() const override
0036     {
0037         return i18n("Prints all journals for a given date range");
0038     }
0039 
0040     QWidget *createConfigWidget(QWidget *) override;
0041     [[nodiscard]] int sortID() const override
0042     {
0043         return CalPrinterBase::Journallist;
0044     }
0045 
0046     [[nodiscard]] bool enabled() const override
0047     {
0048         return true;
0049     }
0050 
0051 public:
0052     void print(QPainter &p, int width, int height) override;
0053     void readSettingsWidget() override;
0054     void setSettingsWidget() override;
0055     void doLoadConfig() override;
0056     void doSaveConfig() override;
0057     void setDateRange(const QDate &from, const QDate &to) override;
0058 
0059 protected:
0060     /**
0061       Draws single journal item.
0062 
0063       Obeys configuration options #mExcludeConfidential, #excludePrivate.
0064       @param journal The item to be printed.
0065       @param p QPainter of the printout
0066       @param x x-coordinate of the upper left coordinate of the first item
0067       @param y y-coordinate of the upper left coordinate of the first item
0068       @param width width of the whole list
0069       @param pageHeight Total height allowed for the list on a page. If an item
0070                    would be below that line, a new page is started.
0071     */
0072     void drawJournal(const KCalendarCore::Journal::Ptr &journal, QPainter &p, int x, int &y, int width, int pageHeight);
0073     bool mUseDateRange;
0074 };
0075 
0076 class CalPrintJournalConfig : public QWidget, public Ui::CalPrintJournalConfig_Base
0077 {
0078 public:
0079     explicit CalPrintJournalConfig(QWidget *parent)
0080         : QWidget(parent)
0081     {
0082         setupUi(this);
0083     }
0084 };
0085 }