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/dialogs | |
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/dialogs')
-rw-r--r-- | src/printsupport/dialogs/qprintdialog_unix.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index 847edf2c49..6cd5ccb880 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -59,7 +59,6 @@ #include <QtWidgets/qstyleditemdelegate.h> #include <QtWidgets/qformlayout.h> #include <QtPrintSupport/qprinter.h> -#include <QtGui/qrangecollection.h> #include <qpa/qplatformprintplugin.h> #include <qpa/qplatformprintersupport.h> @@ -818,11 +817,14 @@ void QPrintDialogPrivate::setupPrinter() #if QT_CONFIG(cups) if (options.pagesRadioButton->isChecked()) { - p->setPrintRange(QPrinter::PageRange); - p->rangeCollection()->parse(options.pagesLineEdit->text()); + const QPageRanges ranges = QPageRanges::fromString(options.pagesLineEdit->text()); + if (!ranges.isEmpty()) { + p->setPrintRange(QPrinter::PageRange); + p->setPageRanges(ranges); + } // server-side page filtering - QCUPSSupport::setPageRange(p, p->rangeCollection()->toString()); + QCUPSSupport::setPageRange(p, ranges.toString()); } // page set @@ -1022,7 +1024,7 @@ void QPrintDialog::accept() { Q_D(QPrintDialog); #if QT_CONFIG(cups) - if (d->options.pagesRadioButton->isChecked() && printer()->rangeCollection()->isEmpty()) { + if (d->options.pagesRadioButton->isChecked() && printer()->pageRanges().isEmpty()) { QMessageBox::critical(this, tr("Invalid Pages Definition"), tr("%1 does not follow the correct syntax. Please use ',' to separate " "ranges and pages, '-' to define ranges and make sure ranges do " |