summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpagedpaintdevice_p.h
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2014-03-28 10:58:25 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-05 21:47:46 +0200
commitbc46b591b2cb81a5cb0c513aa4139b7e88fa8b06 (patch)
treef419a9eb6c623cd24d57f316edcaec1d4f6c5cd2 /src/gui/painting/qpagedpaintdevice_p.h
parentd84da399649d01ac689e87295f8decc024a4f8e8 (diff)
QPagedPaintDevice - Move QPageLayout methods
The new QPageLayout methods weren't originally added to QPagePaintDevice as no new virtuals can be added, instead static polymorphism was used to add the methods directly in the derived classes QPdfWriter and QPrinter. This however means that classes like QTextDocument with print() methods that take a QPagedPaintDevice are unable to access the QPageLayout methods. To fix this, instead make the QPagedPaintDevicePrivate a virtual class and have QPdfWriter and QPrinter implement derived private classes that are called by the non-virtual QPagedPaintDevice base methods. Change-Id: Ieb6e513b1fa05f5ae76ea1f9156b0b1a053089eb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/gui/painting/qpagedpaintdevice_p.h')
-rw-r--r--src/gui/painting/qpagedpaintdevice_p.h42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/gui/painting/qpagedpaintdevice_p.h b/src/gui/painting/qpagedpaintdevice_p.h
index da58951dc7..2321494779 100644
--- a/src/gui/painting/qpagedpaintdevice_p.h
+++ b/src/gui/painting/qpagedpaintdevice_p.h
@@ -55,8 +55,6 @@
#include <qpagedpaintdevice.h>
-#include "qpagelayout.h"
-
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QPagedPaintDevicePrivate
@@ -71,6 +69,46 @@ public:
{
}
+ virtual ~QPagedPaintDevicePrivate()
+ {
+ }
+
+ // ### Qt6 Remove these and make public class methods virtual
+ virtual bool setPageLayout(const QPageLayout &newPageLayout)
+ {
+ m_pageLayout = newPageLayout;
+ return m_pageLayout.isEquivalentTo(newPageLayout);;
+ }
+
+ virtual bool setPageSize(const QPageSize &pageSize)
+ {
+ m_pageLayout.setPageSize(pageSize);
+ return m_pageLayout.pageSize().isEquivalentTo(pageSize);
+ }
+
+ virtual bool setPageOrientation(QPageLayout::Orientation orientation)
+ {
+ m_pageLayout.setOrientation(orientation);
+ return m_pageLayout.orientation() == orientation;
+ }
+
+ virtual bool setPageMargins(const QMarginsF &margins)
+ {
+ return setPageMargins(margins, m_pageLayout.units());
+ }
+
+ virtual bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
+ {
+ m_pageLayout.setUnits(units);
+ m_pageLayout.setMargins(margins);
+ return m_pageLayout.margins() == margins && m_pageLayout.units() == units;
+ }
+
+ virtual QPageLayout pageLayout() const
+ {
+ return m_pageLayout;
+ }
+
static inline QPagedPaintDevicePrivate *get(QPagedPaintDevice *pd) { return pd->d; }
QPageLayout m_pageLayout;