From 21e5da2fe0a3c9450de60b846d2f0836e4455976 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 7 Feb 2018 14:41:53 +0100 Subject: QPagedPainterDevicePrivate: Remove m_pageLayout Having it there is awkward since all the subclasses of QPagedPaintDevice, that is QPdfWriter and QPrinter, have their own m_pageLayout via their private engine classes so we ended up with code like pd->engine->setPageMargins(margins, units); // Set QPagedPaintDevice layout to match the current paint engine layout m_pageLayout = pd->engine->pageLayout(); Now we just use the subclass for it's page layout and all is simpler since we don't need to make sure the two variables are updated to have the same contents. Unfortunately this means that we have to implement a dummy subclass for QPagedPaintDevice(). That constructor doesn't make any sense since QPagedPaintDevice is not really a leaf you want to instantiate, it's there to provide common api for the subclasses and the QPagedPaintDevice(QPagedPaintDevicePrivate *dd) constructor should be used. Since it's a public class we can't remove that constructor and that's why we have that QDummyPagedPaintDevicePrivate. QPageLayout &QPagedPaintDevice::devicePageLayout() is also deprecated now since there's no "device" page layout anymore. Those functions were marked internal and as far as I can see unused outside QPdfWriter/QPrinter so it should be fine. [ChangeLog][QtGui] QPagedPaintDevice constructor has been deprecated since that class is not meant to be used standalone, its two public but internal devicePageLayout() methods are now deprecated. Change-Id: I054601b66afcb7dd662db6247c5ed7820fbee212 Reviewed-by: Frederik Gladhorn --- src/gui/painting/qpdfwriter.cpp | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'src/gui/painting/qpdfwriter.cpp') diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index 2f24c7efcb..e6c5cabd7f 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -83,41 +83,28 @@ public: { // Try to set the paint engine page layout pd->engine->setPageLayout(newPageLayout); - // Set QPagedPaintDevice layout to match the current paint engine layout - m_pageLayout = pd->engine->pageLayout(); - return m_pageLayout.isEquivalentTo(newPageLayout); + return pageLayout().isEquivalentTo(newPageLayout); } bool setPageSize(const QPageSize &pageSize) override { // Try to set the paint engine page size pd->engine->setPageSize(pageSize); - // Set QPagedPaintDevice layout to match the current paint engine layout - m_pageLayout = pd->engine->pageLayout(); - return m_pageLayout.pageSize().isEquivalentTo(pageSize); + return pageLayout().pageSize().isEquivalentTo(pageSize); } bool setPageOrientation(QPageLayout::Orientation orientation) override { // Set the print engine value pd->engine->setPageOrientation(orientation); - // Set QPagedPaintDevice layout to match the current paint engine layout - m_pageLayout = pd->engine->pageLayout(); - return m_pageLayout.orientation() == orientation; - } - - bool setPageMargins(const QMarginsF &margins) override - { - return setPageMargins(margins, pageLayout().units()); + return pageLayout().orientation() == orientation; } bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) override { // Try to set engine margins pd->engine->setPageMargins(margins, units); - // Set QPagedPaintDevice layout to match the current paint engine layout - m_pageLayout = pd->engine->pageLayout(); - return m_pageLayout.margins() == margins && m_pageLayout.units() == units; + return pageLayout().margins() == margins && pageLayout().units() == units; } QPageLayout pageLayout() const override @@ -150,9 +137,6 @@ QPdfWriter::QPdfWriter(const QString &filename) Q_D(QPdfWriter); d->engine->setOutputFilename(filename); - - // Set QPagedPaintDevice layout to match the current paint engine layout - devicePageLayout() = d->engine->pageLayout(); } /*! @@ -165,9 +149,6 @@ QPdfWriter::QPdfWriter(QIODevice *device) Q_D(QPdfWriter); d->engine->d_func()->outDevice = device; - - // Set QPagedPaintDevice layout to match the current paint engine layout - devicePageLayout() = d->engine->pageLayout(); } /*! -- cgit v1.2.3