QtPrintSupport - Cleanup QPrintDialog header

Move QUnixPrintWidget from the header to the UNIX implementation as
it is not used anywhere else and doesn't need to be exported.

Make the private slots only compile under UNIX, remove the Mac and Win
stubs for them as unneeded.

Add some documentation to the UNIX dialog

Change-Id: I8f30504285df877e17ac8eeace875f666f43d94d
Reviewed-by: Teemu Katajisto <teemu.katajisto@digia.com>
Reviewed-by: John Layt <jlayt@kde.org>
This commit is contained in:
John Layt 2012-05-14 21:27:25 +01:00 committed by Qt by Nokia
parent 9ae3ec470c
commit c8b1f7c859
5 changed files with 156 additions and 76 deletions

View File

@ -55,28 +55,6 @@ class QPrintDialogPrivate;
class QPushButton;
class QPrinter;
#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
class QUnixPrintWidgetPrivate;
class Q_PRINTSUPPORT_EXPORT QUnixPrintWidget : public QWidget
{
Q_OBJECT
public:
explicit QUnixPrintWidget(QPrinter *printer, QWidget *parent = 0);
~QUnixPrintWidget();
void updatePrinter();
private:
friend class QPrintDialogPrivate;
friend class QUnixPrintWidgetPrivate;
QUnixPrintWidgetPrivate *d;
Q_PRIVATE_SLOT(d, void _q_printerChanged(int))
Q_PRIVATE_SLOT(d, void _q_btnBrowseClicked())
Q_PRIVATE_SLOT(d, void _q_btnPropertiesClicked())
};
#endif
class Q_PRINTSUPPORT_EXPORT QPrintDialog : public QAbstractPrintDialog
{
Q_OBJECT
@ -129,14 +107,14 @@ Q_SIGNALS:
void accepted(QPrinter *printer);
private:
Q_PRIVATE_SLOT(d_func(), void _q_chbPrintLastFirstToggled(bool))
#if defined (Q_OS_UNIX) && !defined(Q_OS_MAC)
Q_PRIVATE_SLOT(d_func(), void _q_chbPrintLastFirstToggled(bool))
Q_PRIVATE_SLOT(d_func(), void _q_collapseOrExpandDialog())
#endif
# if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_MESSAGEBOX)
# if !defined(QT_NO_MESSAGEBOX)
Q_PRIVATE_SLOT(d_func(), void _q_checkFields())
# endif
# endif // QT_NO_MESSAGEBOX
friend class QUnixPrintWidget;
# endif // Q_OS_UNIX
};
#endif // QT_NO_PRINTDIALOG

View File

@ -67,17 +67,6 @@ public:
inline QPrintDialog *printDialog() { return q_func(); }
inline void _q_printToFileChanged(int) {}
inline void _q_rbPrintRangeToggled(bool) {}
inline void _q_printerChanged(int) {}
#ifndef QT_NO_MESSAGEBOX
inline void _q_checkFields() {}
#endif
inline void _q_chbPrintLastFirstToggled(bool) {}
inline void _q_paperSizeChanged(int) {}
inline void _q_btnBrowseClicked() {}
inline void _q_btnPropertiesClicked() {}
NSPrintInfo *printInfo;
NSPrintPanel *printPanel;
};

View File

@ -68,6 +68,44 @@
# include <private/qprintengine_pdf_p.h>
#endif
/*
Print dialog class declarations
QPrintDialog: The main Print Dialog, nothing really held here.
QUnixPrintWidget:
QUnixPrintWidgetPrivate: The real Unix Print Dialog implementation.
Directly includes the upper half of the Print Dialog
containing the Printer Selection widgets and
Properties button.
Embeds the Properties pop-up dialog from
QPrintPropertiesDialog
Embeds the lower half from separate widget class
QPrintDialogPrivate
Layout in qprintwidget.ui
QPrintDialogPrivate: The lower half of the Print Dialog containing the
Copies and Options tabs that expands when the
Options button is selected.
Layout in qprintsettingsoutput.ui
QPrintPropertiesDialog: Dialog displayed when clicking on Properties button to
allow editing of Page and Advanced tabs.
Layout in qprintpropertieswidget.ui
QPPDOptionsModel: Holds the PPD Options for the printer.
QPPDOptionsEditor: Edits the PPD Options for the printer.
*/
QT_BEGIN_NAMESPACE
class QOptionTreeItem;
@ -104,38 +142,24 @@ private:
#endif
};
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
class QUnixPrintWidgetPrivate;
class QUnixPrintWidget : public QWidget
{
Q_DECLARE_PUBLIC(QPrintDialog)
Q_DECLARE_TR_FUNCTIONS(QPrintDialog)
Q_OBJECT
public:
QPrintDialogPrivate();
~QPrintDialogPrivate();
explicit QUnixPrintWidget(QPrinter *printer, QWidget *parent = 0);
~QUnixPrintWidget();
void updatePrinter();
void init();
/// copy printer properties to the widget
void applyPrinterProperties(QPrinter *p);
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
void selectPrinter(QCUPSSupport *cups);
#endif
void _q_chbPrintLastFirstToggled(bool);
#ifndef QT_NO_MESSAGEBOX
void _q_checkFields();
#endif
void _q_collapseOrExpandDialog();
void setupPrinter();
void updateWidgets();
virtual void setTabs(const QList<QWidget*> &tabs);
Ui::QPrintSettingsOutput options;
QUnixPrintWidget *top;
QWidget *bottom;
QDialogButtonBox *buttons;
QPushButton *collapseButton;
private:
friend class QPrintDialogPrivate;
friend class QUnixPrintWidgetPrivate;
QUnixPrintWidgetPrivate *d;
Q_PRIVATE_SLOT(d, void _q_printerChanged(int))
Q_PRIVATE_SLOT(d, void _q_btnBrowseClicked())
Q_PRIVATE_SLOT(d, void _q_btnPropertiesClicked())
};
class QUnixPrintWidgetPrivate
@ -176,6 +200,40 @@ private:
#endif
};
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
{
Q_DECLARE_PUBLIC(QPrintDialog)
Q_DECLARE_TR_FUNCTIONS(QPrintDialog)
public:
QPrintDialogPrivate();
~QPrintDialogPrivate();
void init();
/// copy printer properties to the widget
void applyPrinterProperties(QPrinter *p);
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
void selectPrinter(QCUPSSupport *cups);
#endif
void _q_chbPrintLastFirstToggled(bool);
#ifndef QT_NO_MESSAGEBOX
void _q_checkFields();
#endif
void _q_collapseOrExpandDialog();
void setupPrinter();
void updateWidgets();
virtual void setTabs(const QList<QWidget*> &tabs);
Ui::QPrintSettingsOutput options;
QUnixPrintWidget *top;
QWidget *bottom;
QDialogButtonBox *buttons;
QPushButton *collapseButton;
};
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
class QOptionTreeItem
{
@ -248,7 +306,17 @@ private slots:
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*
QPrintPropertiesDialog
Dialog displayed when clicking on Properties button to allow editing of Page
and Advanced tabs.
*/
QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent)
: QDialog(parent)
@ -365,6 +433,18 @@ void QPrintPropertiesDialog::addItemToOptions(QOptionTreeItem *parent, QList<con
}
#endif
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*
QPrintDialogPrivate
The lower half of the Print Dialog containing the Copies and Options
tabs that expands when the Options button is selected.
*/
QPrintDialogPrivate::QPrintDialogPrivate()
: top(0), bottom(0), buttons(0), collapseButton(0)
{
@ -578,6 +658,15 @@ void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups)
#endif
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*
QPrintDialog
The main Print Dialog.
*/
QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
: QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent)
@ -622,6 +711,17 @@ void QPrintDialog::accept()
QDialog::accept();
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*
QUnixPrintWidget && QUnixPrintWidgetPrivate
The upper half of the Print Dialog containing the Printer Selection widgets
*/
#if defined (Q_OS_UNIX)
/*! \internal
@ -957,7 +1057,6 @@ void QUnixPrintWidgetPrivate::setupPrinter()
#endif
}
/*! \internal
*/
QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent)
@ -983,6 +1082,16 @@ void QUnixPrintWidget::updatePrinter()
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*
QPPDOptionsModel
Holds the PPD Options for the printer.
*/
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
QPPDOptionsModel::QPPDOptionsModel(QCUPSSupport *c, QObject *parent)
@ -1170,6 +1279,15 @@ QVariant QPPDOptionsModel::headerData(int section, Qt::Orientation, int role) co
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/*
QPPDOptionsEditor
Edits the PPD Options for the printer.
*/
QWidget* QPPDOptionsEditor::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex& index) const
{
@ -1223,6 +1341,9 @@ void QPPDOptionsEditor::cbChanged(int)
*/
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#endif // !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
#endif // defined (Q_OS_UNIX)

View File

@ -72,13 +72,6 @@ public:
{
}
inline void _q_printToFileChanged(int) {}
inline void _q_rbPrintRangeToggled(bool) {}
inline void _q_printerChanged(int) {}
inline void _q_chbPrintLastFirstToggled(bool) {}
inline void _q_paperSizeChanged(int) {}
inline void _q_btnBrowseClicked() {}
inline void _q_btnPropertiesClicked() {}
int openWindowsPrintDialogModally();
QWin32PrintEnginePrivate *ep;

View File

@ -606,7 +606,6 @@ QT_CLASS_LIB(QFontDialog, QtWidgets, qfontdialog.h)
QT_CLASS_LIB(QInputDialog, QtWidgets, qinputdialog.h)
QT_CLASS_LIB(QMessageBox, QtWidgets, qmessagebox.h)
QT_CLASS_LIB(QPageSetupDialog, QtWidgets, qpagesetupdialog.h)
QT_CLASS_LIB(QUnixPrintWidget, QtWidgets, qprintdialog.h)
QT_CLASS_LIB(QPrintDialog, QtWidgets, qprintdialog.h)
QT_CLASS_LIB(QPrintPreviewDialog, QtWidgets, qprintpreviewdialog.h)
QT_CLASS_LIB(QProgressDialog, QtWidgets, qprogressdialog.h)