From a6bcdf151647ab7a97c9fe1d2c8c8dd2b718244e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 22 Apr 2015 13:50:21 +0200 Subject: Clean up API of QPlatformPrintDevice (QPA). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The class inherited QSharedData, had a non-virtual clone() function and a non-virtual operator==() which compared QPlatformPrintDevice::id(). Derived classes implemented clone() and operator==() comparing ids to no effect. The class does not have any setters modifying its values, so detaching, copying and assigning does not make sense. Remove the inheritance, clone(), and operator==() and make the class a non-copyable base class. Use a QSharedPointer instead of a QSharedDataPointer to store it in QPrintDevice. Remove copy constructors and clone() reimplementations that were never called in implementations. Found while investigating QTBUG-44991. Task-number: QTBUG-44991 Change-Id: Ib79354b37048d04d50d936f1d0ae06c36efaac00 Reviewed-by: Morten Johan Sørvig Reviewed-by: Paul Olav Tvete --- src/printsupport/kernel/qplatformprintdevice.cpp | 5 ----- src/printsupport/kernel/qplatformprintdevice.h | 7 ++----- src/printsupport/kernel/qprintdevice.cpp | 2 +- src/printsupport/kernel/qprintdevice_p.h | 2 +- 4 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src/printsupport') diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp index bd6d81774c..6385f58aa1 100644 --- a/src/printsupport/kernel/qplatformprintdevice.cpp +++ b/src/printsupport/kernel/qplatformprintdevice.cpp @@ -75,11 +75,6 @@ QPlatformPrintDevice::~QPlatformPrintDevice() { } -bool QPlatformPrintDevice::operator==(const QPlatformPrintDevice &other) const -{ - return m_id == other.m_id; -} - QString QPlatformPrintDevice::id() const { return m_id; diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h index 1e21e608ad..8bb87a70f9 100644 --- a/src/printsupport/kernel/qplatformprintdevice.h +++ b/src/printsupport/kernel/qplatformprintdevice.h @@ -55,17 +55,14 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_PRINTER -class Q_PRINTSUPPORT_EXPORT QPlatformPrintDevice : public QSharedData +class Q_PRINTSUPPORT_EXPORT QPlatformPrintDevice { + Q_DISABLE_COPY(QPlatformPrintDevice) public: QPlatformPrintDevice(); explicit QPlatformPrintDevice(const QString &id); virtual ~QPlatformPrintDevice(); - QPlatformPrintDevice *clone(); - - bool operator==(const QPlatformPrintDevice &other) const; - virtual QString id() const; virtual QString name() const; virtual QString location() const; diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp index 7c18b53e09..a640c14483 100644 --- a/src/printsupport/kernel/qprintdevice.cpp +++ b/src/printsupport/kernel/qprintdevice.cpp @@ -73,7 +73,7 @@ QPrintDevice &QPrintDevice::operator=(const QPrintDevice &other) bool QPrintDevice::operator==(const QPrintDevice &other) const { if (d && other.d) - return *d == *other.d; + return d->id() == other.d->id(); return d == other.d; } diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h index ad55cded0e..ddf5595734 100644 --- a/src/printsupport/kernel/qprintdevice_p.h +++ b/src/printsupport/kernel/qprintdevice_p.h @@ -136,7 +136,7 @@ private: friend class QPlatformPrinterSupport; friend class QPlatformPrintDevice; QPrintDevice(QPlatformPrintDevice *dd); - QSharedDataPointer d; + QSharedPointer d; }; Q_DECLARE_SHARED(QPrintDevice) -- cgit v1.2.3 From 2142f09c3d6502056dd5a667d238532e699f276d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 11 May 2015 09:36:17 +0200 Subject: Introduce a version number to QPlatformPrinterSupportFactoryInterface. Append a version number to QPlatformPrinterSupportFactoryInterface_iid as is done for QPlatformIntegrationFactoryInterface. Start with 5.1 since a6bcdf151647ab7a97c9fe1d2c8c8dd2b718244e changes the API in 5.5. Use macro in plugins. Task-number: QTBUG-46009 Change-Id: Ib9d2a02d20b9c4c6ad6c1045a907d69d80e3def4 Reviewed-by: Paul Olav Tvete --- src/printsupport/kernel/qplatformprintplugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/printsupport') diff --git a/src/printsupport/kernel/qplatformprintplugin.h b/src/printsupport/kernel/qplatformprintplugin.h index 279de9b952..ad39bf5a0c 100644 --- a/src/printsupport/kernel/qplatformprintplugin.h +++ b/src/printsupport/kernel/qplatformprintplugin.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE class QPlatformPrinterSupport; -#define QPlatformPrinterSupportFactoryInterface_iid "org.qt-project.QPlatformPrinterSupportFactoryInterface" +#define QPlatformPrinterSupportFactoryInterface_iid "org.qt-project.QPlatformPrinterSupportFactoryInterface.5.1" class Q_PRINTSUPPORT_EXPORT QPlatformPrinterSupportPlugin : public QObject { -- cgit v1.2.3 From ab156fcedd4c2d2856c0b46699c32926288be292 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 17 Apr 2015 08:04:04 +0200 Subject: Use the new non-obsoleted functions for getting the paper details This fixes a problem with the margins not being correctly respected as the functions introduced previously would set a different property to what was being queried in this case. Change-Id: I3458c8e46239276a296d17aa80da7330c85fcf0a Reviewed-by: Friedemann Kleint --- src/printsupport/widgets/qprintpreviewwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/printsupport') diff --git a/src/printsupport/widgets/qprintpreviewwidget.cpp b/src/printsupport/widgets/qprintpreviewwidget.cpp index 208ad5e0f3..7898dc9352 100644 --- a/src/printsupport/widgets/qprintpreviewwidget.cpp +++ b/src/printsupport/widgets/qprintpreviewwidget.cpp @@ -335,8 +335,8 @@ void QPrintPreviewWidgetPrivate::populateScene() pages.clear(); int numPages = pictures.count(); - QSize paperSize = printer->paperRect().size(); - QRect pageRect = printer->pageRect(); + QSize paperSize = printer->pageLayout().fullRectPixels(printer->resolution()).size(); + QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution()); for (int i = 0; i < numPages; i++) { PageItem* item = new PageItem(i+1, pictures.at(i), paperSize, pageRect); -- cgit v1.2.3 From 79be2601225bdb50cab72e2502b7d7f9ee81e94f Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 17 Apr 2015 08:10:10 +0200 Subject: Fix documentation of obsoleted functions to show the right replacement Change-Id: Ib008a5544d68d93e1f96ff6b7504e9a7ea4bb192 Reviewed-by: Friedemann Kleint --- src/printsupport/kernel/qprinter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/printsupport') diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index 8ed2732c1e..d7df796afb 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -1764,7 +1764,7 @@ QRectF QPrinter::paperRect(Unit unit) const } /*! - \obsolete Use pageLayout().paintRect() instead. + \obsolete Use pageLayout().paintRectPixels(resolution()) instead. Returns the page's rectangle; this is usually smaller than the paperRect() since the page normally has margins between its @@ -1781,7 +1781,7 @@ QRect QPrinter::pageRect() const } /*! - \obsolete Use pageLayout().fullPageRect() instead. + \obsolete Use pageLayout().fullRectPixels(resolution()) instead. Returns the paper's rectangle; this is usually larger than the pageRect(). -- cgit v1.2.3