From 54b899f44877d87f6118b1bab02fb67c35d738e8 Mon Sep 17 00:00:00 2001 From: John Layt Date: Sun, 20 May 2012 22:38:28 +0100 Subject: SIC: QtPrintSupport - Remove QAbstractPageSetupDialog QAbstractPageSetupDialog is a completely unnecessary base class that is not really abstract and is used nowhere else. This changes merges its methods into the QPageSetupDialog main class. While technically SIC no-one else uses this so no apps should be affected. Change-Id: I59b1739f1c453c34c25d1664d5d042e7918db316 Reviewed-by: Lars Knoll --- src/printsupport/dialogs/qpagesetupdialog.cpp | 76 +++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 4 deletions(-) (limited to 'src/printsupport/dialogs/qpagesetupdialog.cpp') diff --git a/src/printsupport/dialogs/qpagesetupdialog.cpp b/src/printsupport/dialogs/qpagesetupdialog.cpp index 404d5d9ec2..8488255872 100644 --- a/src/printsupport/dialogs/qpagesetupdialog.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog.cpp @@ -39,7 +39,10 @@ ** ****************************************************************************/ -#include +#include "qpagesetupdialog.h" +#include + +#include #ifndef QT_NO_PRINTDIALOG @@ -74,6 +77,12 @@ QT_BEGIN_NAMESPACE parent as the parent widget. */ +/*! + \fn QPageSetupDialog::~QPageSetupDialog() + + Destroys the page setup dialog. +*/ + /*! \since 4.5 @@ -92,10 +101,33 @@ QT_BEGIN_NAMESPACE constructor. */ -// hack -class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate +QPageSetupDialogPrivate::QPageSetupDialogPrivate(QPrinter *prntr) : printer(0), ownsPrinter(false) { -}; + setPrinter(prntr); + init(); +} + +void QPageSetupDialogPrivate::init() +{ +} + +void QPageSetupDialogPrivate::setPrinter(QPrinter *newPrinter) +{ + if (printer && ownsPrinter) + delete printer; + + if (newPrinter) { + printer = newPrinter; + ownsPrinter = false; + } else { + printer = new QPrinter; + ownsPrinter = true; + } +#ifndef Q_WS_X11 + if (printer->outputFormat() != QPrinter::NativeFormat) + qWarning("QPageSetupDialog: Cannot be used on non-native printers"); +#endif +} /*! \overload @@ -121,6 +153,42 @@ void QPageSetupDialog::open(QObject *receiver, const char *member) */ #endif +QPageSetupDialog::~QPageSetupDialog() +{ + Q_D(QPageSetupDialog); + if (d->ownsPrinter) + delete d->printer; +} + +QPrinter *QPageSetupDialog::printer() +{ + Q_D(QPageSetupDialog); + return d->printer; +} + +/*! + \fn int QPageSetupDialog::exec() + + This virtual function is called to pop up the dialog. It must be + reimplemented in subclasses. +*/ + +/*! + \reimp +*/ +void QPageSetupDialog::done(int result) +{ + Q_D(QPageSetupDialog); + QDialog::done(result); + if (d->receiverToDisconnectOnClose) { + disconnect(this, SIGNAL(accepted()), + d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); + d->receiverToDisconnectOnClose = 0; + } + d->memberToDisconnectOnClose.clear(); + +} + QT_END_NAMESPACE #endif -- cgit v1.2.3