From 8186bd628f701744a528d83c22346abcd6c46384 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 7 Sep 2020 10:59:58 +0200 Subject: Remove obsolete APIs and comments from QAbstractPrintDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merging QAbstractPrintDialog with QPrintDialog, as proposed in the removed comment, seems to have little value, given that the platform specific implementations rely on the current abstraction. Adjust examples and tests; with the QAbstractPrintDialog test now testing the QPrintDialog::options API, the corresponding test function can be removed from the QPrinter test. Change-Id: Ia8906627898332e8590ea9b27e3d71dfcc6e8d71 Reviewed-by: Tor Arne Vestbø --- src/printsupport/dialogs/qprintdialog_unix.cpp | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/printsupport/dialogs/qprintdialog_unix.cpp') diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index 60e177f3e8..847edf2c49 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -209,7 +209,7 @@ public: QUnixPrintWidget * const parent; QPrintPropertiesDialog *propertiesDialog; Ui::QPrintWidget widget; - QAbstractPrintDialog * q; + QPrintDialog * q; QPrinter *printer; QPrintDevice m_currentPrintDevice; @@ -805,7 +805,7 @@ void QPrintDialogPrivate::setupPrinter() p->setPrintRange(QPrinter::CurrentPage); p->setFromTo(0,0); } else if (options.printRange->isChecked()) { - if (q->isOptionEnabled(QPrintDialog::PrintPageRange)) { + if (q->testOption(QPrintDialog::PrintPageRange)) { p->setPrintRange(QPrinter::PageRange); p->setFromTo(options.from->value(), qMax(options.from->value(), options.to->value())); } else { @@ -829,7 +829,7 @@ void QPrintDialogPrivate::setupPrinter() if (p->printRange() == QPrinter::AllPages || p->printRange() == QPrinter::PageRange) { //If the application is selecting pages and the first page number is even then need to adjust the odd-even accordingly QCUPSSupport::PageSet pageSet = qvariant_cast(options.pageSetCombo->itemData(options.pageSetCombo->currentIndex())); - if (q->isOptionEnabled(QPrintDialog::PrintPageRange) + if (q->testOption(QPrintDialog::PrintPageRange) && p->printRange() == QPrinter::PageRange && (q->fromPage() % 2 == 0)) { @@ -849,7 +849,7 @@ void QPrintDialogPrivate::setupPrinter() // server-side page range, since we set the page range on the printer to 0-0/AllPages above, // we need to take the values directly from the widget as q->fromPage() will return 0 - if (!q->isOptionEnabled(QPrintDialog::PrintPageRange) && options.printRange->isChecked()) + if (!q->testOption(QPrintDialog::PrintPageRange) && options.printRange->isChecked()) QCUPSSupport::setPageRange(p, options.from->value(), qMax(options.from->value(), options.to->value())); } #endif @@ -898,19 +898,19 @@ void QPrintDialogPrivate::_q_checkFields() void QPrintDialogPrivate::updateWidgets() { Q_Q(QPrintDialog); - options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) || - q->isOptionEnabled(QPrintDialog::PrintSelection) || - q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); + options.gbPrintRange->setVisible(q->testOption(QPrintDialog::PrintPageRange) || + q->testOption(QPrintDialog::PrintSelection) || + q->testOption(QPrintDialog::PrintCurrentPage)); - options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange)); - options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection)); - options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage)); - options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies)); + options.printRange->setEnabled(q->testOption(QPrintDialog::PrintPageRange)); + options.printSelection->setVisible(q->testOption(QPrintDialog::PrintSelection)); + options.printCurrentPage->setVisible(q->testOption(QPrintDialog::PrintCurrentPage)); + options.collate->setVisible(q->testOption(QPrintDialog::PrintCollateCopies)); #if QT_CONFIG(cups) // Don't display Page Set if only Selection or Current Page are enabled - if (!q->isOptionEnabled(QPrintDialog::PrintPageRange) - && (q->isOptionEnabled(QPrintDialog::PrintSelection) || q->isOptionEnabled(QPrintDialog::PrintCurrentPage))) { + if (!q->testOption(QPrintDialog::PrintPageRange) + && (q->testOption(QPrintDialog::PrintSelection) || q->testOption(QPrintDialog::PrintCurrentPage))) { options.pageSetCombo->setVisible(false); options.pageSetLabel->setVisible(false); } else { @@ -918,7 +918,7 @@ void QPrintDialogPrivate::updateWidgets() options.pageSetLabel->setVisible(true); } - if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)) { + if (!q->testOption(QPrintDialog::PrintPageRange)) { // If we can do CUPS server side pages selection, // display the page range widgets options.gbPrintRange->setVisible(true); @@ -940,7 +940,7 @@ void QPrintDialogPrivate::updateWidgets() options.pageSetCombo->setEnabled(true); break; case QPrintDialog::CurrentPage: - if (q->isOptionEnabled(QPrintDialog::PrintCurrentPage)) { + if (q->testOption(QPrintDialog::PrintCurrentPage)) { options.printCurrentPage->setChecked(true); options.pageSetCombo->setEnabled(false); } @@ -1066,7 +1066,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter * { q = nullptr; if (parent) - q = qobject_cast (parent->parent()); + q = qobject_cast (parent->parent()); widget.setupUi(parent); @@ -1104,7 +1104,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter * void QUnixPrintWidgetPrivate::updateWidget() { - const bool printToFile = q == nullptr || q->isOptionEnabled(QPrintDialog::PrintToFile); + const bool printToFile = q == nullptr || q->testOption(QPrintDialog::PrintToFile); if (printToFile && !filePrintersAdded) { if (widget.printers->count()) widget.printers->insertSeparator(widget.printers->count()); @@ -1131,7 +1131,7 @@ void QUnixPrintWidgetPrivate::updateWidget() widget.lOutput->setVisible(printToFile); widget.fileBrowser->setVisible(printToFile); - widget.properties->setVisible(q->isOptionEnabled(QAbstractPrintDialog::PrintShowPageSize)); + widget.properties->setVisible(q->testOption(QAbstractPrintDialog::PrintShowPageSize)); } QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate() @@ -1278,7 +1278,7 @@ void QUnixPrintWidgetPrivate::setupPrinterProperties() QPrinter::OutputFormat outputFormat; QString printerName; - if (q->isOptionEnabled(QPrintDialog::PrintToFile) + if (q->testOption(QPrintDialog::PrintToFile) && (widget.printers->currentIndex() == widget.printers->count() - 1)) {// PDF outputFormat = QPrinter::PdfFormat; } else { -- cgit v1.2.3