File indexing completed on 2024-10-06 03:31:31
0001 // SPDX-FileCopyrightText: 2002-2010 Peter Hedlund <peter.hedlund@kdemail.net> 0002 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu> 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #pragma once 0006 0007 #include "kwqcardmodel.h" 0008 #include <QObject> 0009 0010 class QPrinter; 0011 class QTextDocument; 0012 0013 class Exporter : public QObject 0014 { 0015 Q_OBJECT 0016 Q_PROPERTY(KWQCardModel *cardModel MEMBER m_cardModel NOTIFY cardModelChanged) 0017 0018 public: 0019 enum PrintStyle { 0020 Flashcard, 0021 List, 0022 Exam, 0023 }; 0024 Q_ENUM(PrintStyle); 0025 0026 Q_INVOKABLE void printPreview(const PrintStyle printStyle); 0027 Q_INVOKABLE void print(const PrintStyle printStyle); 0028 0029 Q_SIGNALS: 0030 void cardModelChanged(); 0031 0032 private: 0033 void printPreviewRequested(QPrinter *printer, const PrintStyle printStyle); 0034 void createPages(QPrinter *printer, QTextDocument *textDoc, bool sendToPrinter, const PrintStyle printStyle); 0035 0036 KWQCardModel *m_cardModel = nullptr; 0037 };