File indexing completed on 2024-05-19 05:14:35
0001 /* 0002 This file is part of KAddressBook. 0003 SPDX-FileCopyrightText: 1996-2002 Mirko Boehm <mirko@kde.org> 0004 SPDX-FileCopyrightText: Tobias Koenig <tokoe@kde.org> 0005 SPDX-FileCopyrightText: 2009-2024 Laurent Montel <montel@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0008 */ 0009 0010 #pragma once 0011 0012 #include <KAssistantDialog> 0013 0014 namespace KAddressBookImportExport 0015 { 0016 class ContactSelectionWidget; 0017 } 0018 class StylePage; 0019 0020 class QItemSelectionModel; 0021 class QPrinter; 0022 0023 namespace Akonadi 0024 { 0025 class Collection; 0026 } 0027 0028 namespace KABPrinting 0029 { 0030 class PrintProgress; 0031 class PrintStyle; 0032 class PrintStyleFactory; 0033 0034 /** 0035 * The PrintingWizard combines pages common for all print styles 0036 * and those provided by the respective style. 0037 */ 0038 class PrintingWizard : public KAssistantDialog 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 /** 0044 * Creates a new printing wizard. 0045 * 0046 * @param printer The configured printer. 0047 * @param selectionModel The selection model to get the selected contacts from. 0048 * @param parent The parent widget. 0049 */ 0050 PrintingWizard(QPrinter *printer, QItemSelectionModel *selectionModel, QWidget *parent = nullptr); 0051 0052 /** 0053 * Destroys the printing wizard. 0054 */ 0055 ~PrintingWizard() override; 0056 0057 /** 0058 * Sets the default addressbook of the contact selection. 0059 */ 0060 void setDefaultAddressBook(const Akonadi::Collection &addressBook); 0061 0062 /** 0063 * Registers all available printing styles. 0064 */ 0065 void registerStyles(); 0066 0067 /** 0068 * Performs the actual printing. 0069 */ 0070 void print(); 0071 0072 /** 0073 * Returns the printer to use for printing. 0074 */ 0075 QPrinter *printer() const; 0076 0077 /** 0078 * Returns the index of the selected style 0079 */ 0080 int printingStyle() const; 0081 0082 /** 0083 * Returns the sort order of addressBook 0084 */ 0085 int sortOrder() const; 0086 0087 protected Q_SLOTS: 0088 /** 0089 * A print style has been selected. The argument is the index 0090 * in the cbStyle combo and in styles. 0091 */ 0092 void slotStyleSelected(int); 0093 0094 protected: 0095 class PrintStyleDefinition 0096 { 0097 public: 0098 explicit PrintStyleDefinition(PrintStyleFactory *factory = nullptr, PrintStyle *style = nullptr) 0099 : printstyleFactory(factory) 0100 , printStyle(style) 0101 { 0102 } 0103 0104 PrintStyleFactory *printstyleFactory = nullptr; 0105 PrintStyle *printStyle = nullptr; 0106 }; 0107 0108 QList<PrintStyleDefinition *> mPrintStyleDefinition; 0109 QPrinter *mPrinter = nullptr; 0110 PrintStyle *mStyle = nullptr; 0111 PrintProgress *mProgress = nullptr; 0112 0113 StylePage *mStylePage = nullptr; 0114 KAddressBookImportExport::ContactSelectionWidget *mSelectionPage = nullptr; 0115 0116 /** 0117 * Overloaded accept slot. This is used to do the actual 0118 * printing without having the wizard disappearing 0119 * before. What happens is actually up to the print style, 0120 * since it does the printing. It could display a progress 0121 * window, for example (hint, hint). 0122 */ 0123 void accept() override; 0124 0125 private: 0126 void writeConfig(); 0127 void readConfig(); 0128 void loadGrantleeStyle(); 0129 }; 0130 }