Warning, file /office/calligra/libs/main/KoPrintJob.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007 Thomas Zander <zander@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef KOPRINTJOB_H
0021 #define KOPRINTJOB_H
0022 
0023 #include <QObject>
0024 #include <QList>
0025 #include <QAbstractPrintDialog>
0026 #include <QPrinter>
0027 
0028 #include "komain_export.h"
0029 
0030 class QWidget;
0031 
0032 /**
0033  * A print job is an interface that the KoView uses to create an application-specific
0034  * class that can take care of printing.
0035  * The printjob should be able to print again after a print job has been completed,
0036  * using the same QPrinter to allow the user to alter settings on the QPrinter and
0037  * call print again.
0038  * The printjob can thus see startPrinting() called more than once, and the implementation
0039  * of that signal should honor the removePolicy passed to it.
0040  */
0041 class KOMAIN_EXPORT KoPrintJob : public QObject
0042 {
0043     Q_OBJECT
0044 public:
0045     /**
0046      * Constructor.
0047      * @param parent the parent qobject that is passed for memory management purposes.
0048      */
0049     explicit KoPrintJob(QObject *parent = 0);
0050     ~KoPrintJob() override;
0051 
0052     /// A policy to allow the printjob to delete itself after its done printing.
0053     enum RemovePolicy {
0054         DeleteWhenDone, ///< Delete the job when its done with printing.
0055         DoNotDelete     ///< Keep the job around so it can be started again.
0056     };
0057 
0058     /// Returns the printer that is used for this print job so others can alter the details of the print-job.
0059     virtual QPrinter &printer() = 0;
0060     /// If this print job is used in combination with a printdialog the option widgets this method
0061     /// returns will be shown in the print dialog.
0062     virtual QList<QWidget*> createOptionWidgets() const = 0;
0063 
0064     virtual int documentFirstPage() const {
0065         return 1;
0066     }
0067     virtual int documentLastPage() const {
0068         return 1;
0069     }
0070     virtual int documentCurrentPage() const {
0071         return 1;
0072     }
0073 
0074     virtual QAbstractPrintDialog::PrintDialogOptions printDialogOptions() const;
0075 
0076     /**
0077      *@brief Check if the painter can print to the printer
0078      *@returns true if the print job can print to the given printer
0079      */
0080     virtual bool canPrint();
0081 
0082 public Q_SLOTS:
0083     /**
0084      * This is called every time the job should be executed.
0085      * When called the document should be printed a new painter using the printer
0086      * of this printJob in order to honor the settings the user made on the printer.
0087      * canPrint() should be called before startPrinting to check if the painter can print
0088      * to the printer
0089      * @param removePolicy a policy that should be honored so the caller can make sure
0090      *   this job doesn't leak memory after being used.
0091      */
0092     virtual void startPrinting(RemovePolicy removePolicy = DoNotDelete);
0093 };
0094 
0095 #endif