From b14b1c99f8d122c7988cd6e59b0f3fef15923da4 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 2 Nov 2020 21:39:34 +0100 Subject: Rename QRangeCollection to QPageRanges, make it a proper value type The type is specific about printing, so give it a name in line with QPageLayout and QPageSize. As per API review comment, it's not clear why this type should not be a regular, copyable and movable value type. It stores a list of intervals. Give it value-type semantics, as an implicitly shared class. Convert the parse method into a static factory function. Add a Range type and use it instead of the semantic-free QPair. Move QPrinter getter into QPagedPainteDevice, make it return a copy rather than a pointer, and add a setter. Extend test case to cover all members and more merge cases. Fix bugs found that way. Fixes: QTBUG-88113 Change-Id: If17ea4d410d49f16b097e88b7979db5d72add820 Reviewed-by: Qt CI Bot Reviewed-by: Volker Hilsheimer --- src/gui/painting/qpagedpaintdevice.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/gui/painting/qpagedpaintdevice.cpp') diff --git a/src/gui/painting/qpagedpaintdevice.cpp b/src/gui/painting/qpagedpaintdevice.cpp index 9d09fb6f04..1e32f2c2bc 100644 --- a/src/gui/painting/qpagedpaintdevice.cpp +++ b/src/gui/painting/qpagedpaintdevice.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -42,10 +42,8 @@ QT_BEGIN_NAMESPACE -QPagedPaintDevicePrivate::~QPagedPaintDevicePrivate() -{ - delete rangeCollection; -} + +QPagedPaintDevicePrivate::~QPagedPaintDevicePrivate() = default; /*! \class QPagedPaintDevice @@ -213,4 +211,26 @@ QPageLayout QPagedPaintDevice::pageLayout() const return d->pageLayout(); } +/*! + \since 6.0 + + Returns the page ranges associated with this device. + + \sa QPageRanges, QPrinter::fromPage(), QPrinter::toPage() +*/ +QPageRanges QPagedPaintDevice::pageRanges() const +{ + return d->pageRanges; +} + +/*! + \since 6.0 + + Sets the page ranges for this device to \a ranges. +*/ +void QPagedPaintDevice::setPageRanges(const QPageRanges &ranges) +{ + d->pageRanges = ranges; +} + QT_END_NAMESPACE -- cgit v1.2.3