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 <lars.knoll@nokia.com>
This commit is contained in:
John Layt 2012-05-20 22:38:28 +01:00 committed by Qt by Nokia
parent 01864d4854
commit 54b899f448
11 changed files with 133 additions and 276 deletions

2
dist/changes-5.0.0 vendored
View File

@ -291,6 +291,8 @@ information about a particular change.
- QPageSetupDialog has had the PageSetupDialogOption enum and the api to
set and get the enum removed as none of the Options are used any more.
- QAbstractPageSetupDialog has been removed.
****************************************************************************
* General *
****************************************************************************

View File

@ -3,8 +3,7 @@
HEADERS += \
dialogs/qabstractprintdialog.h \
dialogs/qabstractprintdialog_p.h \
dialogs/qabstractpagesetupdialog.h \
dialogs/qabstractpagesetupdialog_p.h \
dialogs/qpagesetupdialog_p.h \
dialogs/qpagesetupdialog.h \
dialogs/qprintdialog.h \
dialogs/qprintpreviewdialog.h
@ -34,7 +33,6 @@ INCLUDEPATH += $$PWD
SOURCES += \
dialogs/qabstractprintdialog.cpp \
dialogs/qabstractpagesetupdialog.cpp \
dialogs/qpagesetupdialog.cpp \
dialogs/qprintpreviewdialog.cpp

View File

@ -1,138 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qabstractpagesetupdialog.h"
#include "qabstractpagesetupdialog_p.h"
#ifndef QT_NO_PRINTDIALOG
#include <QtGui/qguiapplication.h>
#include <QtPrintSupport/qprinter.h>
QT_BEGIN_NAMESPACE
/*!
\internal
\class QAbstractPageSetupDialog
\brief The QAbstractPageSetupDialog class provides a base for
implementations of page setup dialogs.
*/
/*!
Constructs the page setup dialog for the printer \a printer with
\a parent as parent widget.
*/
QAbstractPageSetupDialog::QAbstractPageSetupDialog(QPrinter *printer, QWidget *parent)
: QDialog(*(new QAbstractPageSetupDialogPrivate), parent)
{
Q_D(QAbstractPageSetupDialog);
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
d->setPrinter(printer);
}
/*!
\internal
*/
QAbstractPageSetupDialog::QAbstractPageSetupDialog(QAbstractPageSetupDialogPrivate &ptr,
QPrinter *printer, QWidget *parent)
: QDialog(ptr, parent)
{
Q_D(QAbstractPageSetupDialog);
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
d->setPrinter(printer);
}
QAbstractPageSetupDialog::~QAbstractPageSetupDialog()
{
Q_D(QAbstractPageSetupDialog);
if (d->ownsPrinter)
delete d->printer;
}
/*!
Returns the printer that this page setup dialog is operating on.
*/
QPrinter *QAbstractPageSetupDialog::printer()
{
Q_D(QAbstractPageSetupDialog);
return d->printer;
}
void QAbstractPageSetupDialogPrivate::setPrinter(QPrinter *newPrinter)
{
if (newPrinter) {
printer = newPrinter;
ownsPrinter = false;
} else {
printer = new QPrinter;
ownsPrinter = true;
}
if (printer->outputFormat() != QPrinter::NativeFormat && QGuiApplication::platformName() == QLatin1String("xcb"))
qWarning("QPageSetupDialog: Cannot be used on non-native printers");
}
/*!
\fn int QAbstractPageSetupDialog::exec()
This virtual function is called to pop up the dialog. It must be
reimplemented in subclasses.
*/
/*!
\reimp
*/
void QAbstractPageSetupDialog::done(int result)
{
Q_D(QAbstractPageSetupDialog);
QDialog::done(result);
if (d->receiverToDisconnectOnClose) {
disconnect(this, SIGNAL(accepted()),
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
d->receiverToDisconnectOnClose = 0;
}
d->memberToDisconnectOnClose.clear();
}
QT_END_NAMESPACE
#endif // QT_NO_PRINTDIALOG

View File

@ -1,82 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QABSTRACTPAGESETUPDIALOG_H
#define QABSTRACTPAGESETUPDIALOG_H
#include <QtWidgets/qdialog.h>
#include <QtPrintSupport/qtprintsupportglobal.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#ifndef QT_NO_PRINTDIALOG
class QAbstractPageSetupDialogPrivate;
class QPrinter;
// ### QtPrintNG: merge this class with QPageSetupDialog
class Q_PRINTSUPPORT_EXPORT QAbstractPageSetupDialog : public QDialog
{
Q_DECLARE_PRIVATE(QAbstractPageSetupDialog)
Q_OBJECT
public:
explicit QAbstractPageSetupDialog(QPrinter *printer, QWidget *parent = 0);
QAbstractPageSetupDialog(QAbstractPageSetupDialogPrivate &ptr,
QPrinter *printer, QWidget *parent = 0);
~QAbstractPageSetupDialog();
virtual int exec() = 0;
void done(int result);
QPrinter *printer();
};
#endif // QT_NO_PRINTDIALOG
QT_END_NAMESPACE
QT_END_HEADER
#endif // QABSTRACTPAGESETUPDIALOG_H

View File

@ -39,7 +39,10 @@
**
****************************************************************************/
#include <private/qabstractpagesetupdialog_p.h>
#include "qpagesetupdialog.h"
#include <private/qpagesetupdialog_p.h>
#include <QtPrintSupport/qprinter.h>
#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

View File

@ -42,7 +42,8 @@
#ifndef QPAGESETUPDIALOG_H
#define QPAGESETUPDIALOG_H
#include <QtPrintSupport/qabstractpagesetupdialog.h>
#include <QtWidgets/qdialog.h>
#include <QtPrintSupport/qtprintsupportglobal.h>
QT_BEGIN_HEADER
@ -51,9 +52,10 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_PRINTDIALOG
class QPrinter;
class QPageSetupDialogPrivate;
class Q_PRINTSUPPORT_EXPORT QPageSetupDialog : public QAbstractPageSetupDialog
class Q_PRINTSUPPORT_EXPORT QPageSetupDialog : public QDialog
{
Q_OBJECT
Q_DECLARE_PRIVATE(QPageSetupDialog)
@ -61,6 +63,7 @@ class Q_PRINTSUPPORT_EXPORT QPageSetupDialog : public QAbstractPageSetupDialog
public:
explicit QPageSetupDialog(QPrinter *printer, QWidget *parent = 0);
explicit QPageSetupDialog(QWidget *parent = 0);
virtual ~QPageSetupDialog();
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
virtual void setVisible(bool visible);
@ -76,9 +79,9 @@ public:
#endif
void open(QObject *receiver, const char *member);
#ifdef qdoc
void done(int result);
QPrinter *printer();
#endif
};
#endif // QT_NO_PRINTDIALOG

View File

@ -44,7 +44,7 @@
#include <Cocoa/Cocoa.h>
#include "qpagesetupdialog.h"
#include "qabstractpagesetupdialog_p.h"
#include "qpagesetupdialog_p.h"
#include <qpa/qplatformnativeinterface.h>
#include <QtPrintSupport/qprintengine.h>
@ -93,16 +93,16 @@ QT_USE_NAMESPACE
QT_BEGIN_NAMESPACE
class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate
class QMacPageSetupDialogPrivate : public QPageSetupDialogPrivate
{
Q_DECLARE_PUBLIC(QPageSetupDialog)
public:
QPageSetupDialogPrivate()
: printInfo(0), pageLayout(0)
QMacPageSetupDialogPrivate(QPrinter *printer)
: QPageSetupDialogPrivate(printer), printInfo(0), pageLayout(0)
{ }
~QPageSetupDialogPrivate() {
~QMacPageSetupDialogPrivate() {
}
void openCocoaPageLayout(Qt::WindowModality modality);
@ -112,7 +112,7 @@ public:
NSPageLayout *pageLayout;
};
void QPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality)
void QMacPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality)
{
Q_Q(QPageSetupDialog);
@ -145,7 +145,7 @@ void QPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality)
}
}
void QPageSetupDialogPrivate::closeCocoaPageLayout()
void QMacPageSetupDialogPrivate::closeCocoaPageLayout()
{
[printInfo release];
printInfo = 0;
@ -154,14 +154,16 @@ void QPageSetupDialogPrivate::closeCocoaPageLayout()
}
QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent)
: QDialog(*(new QMacPageSetupDialogPrivate(printer)), parent)
{
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
setAttribute(Qt::WA_DontShowOnScreen);
}
QPageSetupDialog::QPageSetupDialog(QWidget *parent)
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), 0, parent)
: QDialog(*(new QMacPageSetupDialogPrivate(0)), parent)
{
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
setAttribute(Qt::WA_DontShowOnScreen);
}
@ -172,7 +174,7 @@ void QPageSetupDialog::setVisible(bool visible)
if (d->printer->outputFormat() != QPrinter::NativeFormat)
return;
bool isCurrentlyVisible = (d->pageLayout != 0);
bool isCurrentlyVisible = (static_cast <QMacPageSetupDialogPrivate*>(d)->pageLayout != 0);
if (!visible == !isCurrentlyVisible)
return;
@ -184,11 +186,11 @@ void QPageSetupDialog::setVisible(bool visible)
// NSPrintPanels can only be modal, so we must pick a type
modality = parentWidget() ? Qt::WindowModal : Qt::ApplicationModal;
}
d->openCocoaPageLayout(modality);
static_cast <QMacPageSetupDialogPrivate*>(d)->openCocoaPageLayout(modality);
return;
} else {
if (d->pageLayout) {
d->closeCocoaPageLayout();
if (static_cast <QMacPageSetupDialogPrivate*>(d)->pageLayout) {
static_cast <QMacPageSetupDialogPrivate*>(d)->closeCocoaPageLayout();
return;
}
}
@ -204,8 +206,8 @@ int QPageSetupDialog::exec()
QDialog::setVisible(true);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
d->openCocoaPageLayout(Qt::ApplicationModal);
d->closeCocoaPageLayout();
static_cast <QMacPageSetupDialogPrivate*>(d)->openCocoaPageLayout(Qt::ApplicationModal);
static_cast <QMacPageSetupDialogPrivate*>(d)->closeCocoaPageLayout();
[pool release];
QDialog::setVisible(false);

View File

@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef QABSTRACTPAGESETUPDIALOG_P_H
#define QABSTRACTPAGESETUPDIALOG_P_H
#ifndef QPAGESETUPDIALOG_P_H
#define QPAGESETUPDIALOG_P_H
//
// W A R N I N G
@ -66,13 +66,14 @@ QT_BEGIN_NAMESPACE
class QPrinter;
class QAbstractPageSetupDialogPrivate : public QDialogPrivate
class QPageSetupDialogPrivate : public QDialogPrivate
{
Q_DECLARE_PUBLIC(QAbstractPageSetupDialog)
Q_DECLARE_PUBLIC(QPageSetupDialog)
public:
QAbstractPageSetupDialogPrivate() : printer(0), ownsPrinter(false) {}
QPageSetupDialogPrivate(QPrinter *printer);
virtual void init();
void setPrinter(QPrinter *newPrinter);
QPrinter *printer;
@ -85,4 +86,4 @@ QT_END_NAMESPACE
#endif // QT_NO_PRINTDIALOG
#endif // QABSTRACTPAGESETUPDIALOG_P_H
#endif // QPAGESETUPDIALOG_P_H

View File

@ -50,7 +50,7 @@
#include <ui_qpagesetupwidget.h>
#include <QtPrintSupport/qprinter.h>
#include <private/qabstractpagesetupdialog_p.h>
#include <private/qpagesetupdialog_p.h>
#include <private/qprinter_p.h>
#include <private/qprintengine_pdf_p.h>
@ -214,12 +214,13 @@ private:
};
class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate
class QUnixPageSetupDialogPrivate : public QPageSetupDialogPrivate
{
Q_DECLARE_PUBLIC(QPageSetupDialog)
public:
~QPageSetupDialogPrivate();
QUnixPageSetupDialogPrivate(QPrinter *printer);
~QUnixPageSetupDialogPrivate();
void init();
QPageSetupWidget *widget;
@ -228,14 +229,24 @@ public:
#endif
};
QPageSetupDialogPrivate::~QPageSetupDialogPrivate()
QUnixPageSetupDialogPrivate::QUnixPageSetupDialogPrivate(QPrinter *printer) : QPageSetupDialogPrivate(printer)
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
, cups(0)
#endif
{
}
QUnixPageSetupDialogPrivate::~QUnixPageSetupDialogPrivate()
{
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
delete cups;
if (cups) {
delete cups;
cups = 0;
}
#endif
}
void QPageSetupDialogPrivate::init()
void QUnixPageSetupDialogPrivate::init()
{
Q_Q(QPageSetupDialog);
@ -584,30 +595,25 @@ void QPageSetupWidget::setRightMargin(double newValue)
QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent)
: QDialog(*(new QUnixPageSetupDialogPrivate(printer)), parent)
{
Q_D(QPageSetupDialog);
d->init();
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
}
QPageSetupDialog::QPageSetupDialog(QWidget *parent)
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), 0, parent)
: QDialog(*(new QUnixPageSetupDialogPrivate(0)), parent)
{
Q_D(QPageSetupDialog);
d->init();
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
}
/*!
\internal
*/
int QPageSetupDialog::exec()
{
Q_D(QPageSetupDialog);
int ret = QDialog::exec();
if (ret == Accepted)
d->widget->setupPrinter();
static_cast <QUnixPageSetupDialogPrivate*>(d)->widget->setupPrinter();
return ret;
}

View File

@ -45,25 +45,23 @@
#include <qapplication.h>
#include "../kernel/qprintengine_win_p.h"
#include "qabstractpagesetupdialog_p.h"
#include "qpagesetupdialog_p.h"
#include "qprinter.h"
#include <qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE
class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate
{
};
QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent)
: QDialog(*(new QPageSetupDialogPrivate(printer)), parent)
{
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
setAttribute(Qt::WA_DontShowOnScreen);
}
QPageSetupDialog::QPageSetupDialog(QWidget *parent)
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), 0, parent)
: QDialog(*(new QPageSetupDialogPrivate(0)), parent)
{
setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
setAttribute(Qt::WA_DontShowOnScreen);
}

View File

@ -595,7 +595,6 @@ QT_CLASS_LIB(QAccessibleFactoryInterface, QtWidgets, qaccessibleplugin.h)
QT_CLASS_LIB(QAccessiblePlugin, QtWidgets, qaccessibleplugin.h)
QT_CLASS_LIB(QAccessibleWidget, QtWidgets, qaccessiblewidget.h)
QT_CLASS_LIB(QAccessibleWidgetEx, QtWidgets, qaccessiblewidget.h)
QT_CLASS_LIB(QAbstractPageSetupDialog, QtWidgets, qabstractpagesetupdialog.h)
QT_CLASS_LIB(QAbstractPrintDialog, QtWidgets, qabstractprintdialog.h)
QT_CLASS_LIB(QColorDialog, QtWidgets, qcolordialog.h)
QT_CLASS_LIB(QDialog, QtWidgets, qdialog.h)