diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-02 21:39:34 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-08 11:49:54 +0100 |
commit | b14b1c99f8d122c7988cd6e59b0f3fef15923da4 (patch) | |
tree | c876d2428f7be32a73a1d066fa2d703b59708a1e /src/printsupport/kernel/qprinter.cpp | |
parent | 8bf36025f5602e3067448941ee4d0ccca3928a40 (diff) |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/printsupport/kernel/qprinter.cpp')
-rw-r--r-- | src/printsupport/kernel/qprinter.cpp | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index ec5b868ea5..d320accad0 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -49,7 +49,6 @@ #include "qlist.h" #include <qcoreapplication.h> #include <qfileinfo.h> -#include <QtGui/qrangecollection.h> #include <private/qpagedpaintdevice_p.h> @@ -1393,12 +1392,12 @@ void QPrinter::setPrinterSelectionOption(const QString &option) \note If fromPage() and toPage() both return 0, this indicates that \e{the whole document will be printed}. - \sa setFromTo(), toPage(), rangeCollection() + \sa setFromTo(), toPage(), pageRanges() */ int QPrinter::fromPage() const { - return d->rangeCollection->firstPage(); + return d->pageRanges.firstPage(); } /*! @@ -1417,12 +1416,12 @@ int QPrinter::fromPage() const The programmer is responsible for reading this setting and printing accordingly. - \sa setFromTo(), fromPage(), rangeCollection() + \sa setFromTo(), fromPage(), pageRanges() */ int QPrinter::toPage() const { - return d->rangeCollection->lastPage(); + return d->pageRanges.lastPage(); } /*! @@ -1439,25 +1438,13 @@ int QPrinter::toPage() const This function is mostly used to set a default value that the user can override in the print dialog when you call setup(). - \sa fromPage(), toPage(), rangeCollection() + \sa fromPage(), toPage(), pageRanges() */ void QPrinter::setFromTo(int from, int to) { - d->rangeCollection->clear(); - d->rangeCollection->addRange(from, to); -} - -/*! - \since 6.0 - - Returns the range collection associated with this device. - - \sa QRangeCollection, fromPage(), toPage() -*/ -QRangeCollection *QPrinter::rangeCollection() -{ - return d->rangeCollection; + d->pageRanges.clear(); + d->pageRanges.addRange(from, to); } /*! |