From 00a5629d8de18bc1a5dfb6e2526c03b4b021c903 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 3 Sep 2020 18:42:30 +0200 Subject: Remove deprecated QPrinter and QPagedPaintDevice APIs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adjusting the QPrinter test case - some use cases no longer exist, or are already tested in QPageSize and QPageLayout tests. Adjust examples and manual tests. Change-Id: I01cbc65f3d8031aea2dac86dd942126ba708b111 Reviewed-by: Tor Arne Vestbø Reviewed-by: Qt CI Bot --- tests/manual/dialogs/printdialogpanel.cpp | 139 +----------------------------- 1 file changed, 2 insertions(+), 137 deletions(-) (limited to 'tests/manual/dialogs/printdialogpanel.cpp') diff --git a/tests/manual/dialogs/printdialogpanel.cpp b/tests/manual/dialogs/printdialogpanel.cpp index 7f834399e4..29dc33285b 100644 --- a/tests/manual/dialogs/printdialogpanel.cpp +++ b/tests/manual/dialogs/printdialogpanel.cpp @@ -53,10 +53,7 @@ #include #include #include - -#if QT_VERSION >= 0x050000 -# include -#endif +#include const FlagData printerModeComboData[] = { @@ -65,42 +62,6 @@ const FlagData printerModeComboData[] = {"HighResolution", QPrinter::HighResolution} }; -#if QT_VERSION < 0x050300 -const FlagData pageSizeComboData[] = -{ - {"A4", QPrinter::A4}, - {"B5", QPrinter::B5}, - {"Letter", QPrinter::Letter}, - {"Legal", QPrinter::Legal}, - {"Executive", QPrinter::Executive}, - {"A0", QPrinter::A0}, - {"A1", QPrinter::A1}, - {"A2", QPrinter::A2}, - {"A3", QPrinter::A3}, - {"A5", QPrinter::A5}, - {"A6", QPrinter::A6}, - {"A7", QPrinter::A7}, - {"A8", QPrinter::A8}, - {"A9", QPrinter::A9}, - {"B0", QPrinter::B0}, - {"B1", QPrinter::B1}, - {"B10", QPrinter::B10}, - {"B2", QPrinter::B2}, - {"B3", QPrinter::B3}, - {"B4", QPrinter::B4}, - {"B6", QPrinter::B6}, - {"B7", QPrinter::B7}, - {"B8", QPrinter::B8}, - {"B9", QPrinter::B9}, - {"C5E", QPrinter::C5E}, - {"Comm10E", QPrinter::Comm10E}, - {"DLE", QPrinter::DLE}, - {"Folio", QPrinter::Folio}, - {"Ledger", QPrinter::Ledger}, - {"Tabloid", QPrinter::Tabloid}, - {"Custom", QPrinter::Custom} -}; -#endif const FlagData printRangeComboData[] = { @@ -197,9 +158,7 @@ QTextStream &operator<<(QTextStream &s, const QRectF &rect) QTextStream &operator<<(QTextStream &s, const QPrinter &printer) { s << '"' << printer.printerName() << "\"\nPaper #" <= 0x050000 << " \"" << printer.paperName() << '"' -#endif << (printer.orientation() == QPrinter::Portrait ? ", Portrait" : ", Landscape"); if (printer.fullPage()) s << ", full page"; @@ -208,9 +167,7 @@ QTextStream &operator<<(QTextStream &s, const QPrinter &printer) << printer.paperSize(QPrinter::Millimeter) << "mm " << "\n " << printer.paperSize(QPrinter::DevicePixel) << "device pt " << printer.paperSize(QPrinter::Inch) << "inch " -#if QT_VERSION >= 0x050000 << "\nPagedPaintDevSize: " << printer.pageSizeMM() << "mm" -#endif << "\nLogical resolution : " << printer.logicalDpiX() << ',' << printer.logicalDpiY() << "DPI" << "\nPhysical resolution: " << printer.physicalDpiX() << ',' << printer.physicalDpiY() << "DPI" << "\nPaperRect: " << printer.paperRect(QPrinter::Point) << "pt " @@ -290,9 +247,7 @@ static bool print(QPrinter *printer, QString *errorMessage) QString msg; QTextStream str(&msg); str << "Qt "<< QT_VERSION_STR; -#if QT_VERSION >= 0x050000 str << ' ' << QGuiApplication::platformName(); -#endif str << ' ' << QDateTime::currentDateTime().toString() << "\nFont: " << font.family() << ' ' << font.pointSize() << '\n' << *printer; @@ -346,10 +301,6 @@ public slots: PrintDialogPanel::PrintDialogPanel(QWidget *parent) : QWidget(parent), m_blockSignals(true) { -#if QT_VERSION < 0x050300 - m_printerLayout.setOutputFormat(QPrinter::PdfFormat); -#endif - m_panel.setupUi(this); // Setup the Create box @@ -360,14 +311,10 @@ PrintDialogPanel::PrintDialogPanel(QWidget *parent) // Setup the Page Layout box populateCombo(m_panel.m_unitsCombo, unitsComboData, sizeof(unitsComboData)/sizeof(FlagData)); connect(m_panel.m_unitsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(unitsChanged())); -#if QT_VERSION >= 0x050300 for (int i = QPageSize::A4; i < QPageSize::LastPageSize; ++i) { QPageSize::PageSizeId id = QPageSize::PageSizeId(i); m_panel.m_pageSizeCombo->addItem(QPageSize::name(id), QVariant(id)); } -#else - populateCombo(m_panel.m_pageSizeCombo, pageSizeComboData, sizeof(pageSizeComboData)/sizeof(FlagData)); -#endif connect(m_panel.m_pageSizeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(pageSizeChanged())); connect(m_panel.m_pageWidth, SIGNAL(valueChanged(double)), this, SLOT(pageDimensionsChanged())); connect(m_panel.m_pageHeight, SIGNAL(valueChanged(double)), this, SLOT(pageDimensionsChanged())); @@ -382,13 +329,8 @@ PrintDialogPanel::PrintDialogPanel(QWidget *parent) // Setup the Print Job box m_panel.m_printerCombo->addItem(tr("Print to PDF"), QVariant("PdfFormat")); -#if QT_VERSION >= 0x050300 foreach (const QString &name, QPrinterInfo::availablePrinterNames()) m_panel.m_printerCombo->addItem(name, QVariant(name)); -#else - foreach (const QPrinterInfo &printer, QPrinterInfo::availablePrinters()) - m_panel.m_printerCombo->addItem(printer.printerName(), QVariant(printer.printerName())); -#endif connect(m_panel.m_printerCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(printerChanged())); populateCombo(m_panel.m_printRangeCombo, printRangeComboData, sizeof(printRangeComboData)/sizeof(FlagData)); populateCombo(m_panel.m_pageOrderCombo, pageOrderComboData, sizeof(pageOrderComboData)/sizeof(FlagData)); @@ -462,19 +404,7 @@ void PrintDialogPanel::applySettings(QPrinter *printer) const printer->setColorMode(comboBoxValue(m_panel.m_colorModeCombo)); printer->setResolution(m_panel.m_resolution->value()); -#if QT_VERSION >= 0x050300 printer->setPageLayout(m_pageLayout); -#else - if (m_printerLayout.pageSize() == QPrinter::Custom) - printer->setPaperSize(customPageSize(), m_units); - else - printer->setPageSize(m_printerLayout.pageSize()); - printer->setOrientation(m_printerLayout.orientation()); - printer->setFullPage(m_printerLayout.fullPage()); - double left, top, right, bottom; - m_printerLayout.getPageMargins(&left, &top, &right, &bottom, m_units); - printer->setPageMargins(left, top, right, bottom, m_units); -#endif } // Retrieve the settings from the QPrinter @@ -508,26 +438,13 @@ void PrintDialogPanel::retrieveSettings(const QPrinter *printer) m_panel.availPaperSourceLabel->setText(QLatin1String("N/A")); #endif -#if QT_VERSION >= 0x050300 m_pageLayout = printer->pageLayout(); -#else - if (printer->pageSize() == QPrinter::Custom) - m_printerLayout.setPaperSize(customPageSize(), m_units); - else - m_printerLayout.setPageSize(printer->pageSize()); - m_printerLayout.setOrientation(printer->orientation()); - m_printerLayout.setFullPage(printer->fullPage()); - double left, top, right, bottom; - printer->getPageMargins(&left, &top, &right, &bottom, m_units); - m_printerLayout.setPageMargins(left, top, right, bottom, m_units); -#endif updatePageLayoutWidgets(); } void PrintDialogPanel::updatePageLayoutWidgets() { m_blockSignals = true; -#if QT_VERSION >= 0x050300 setComboBoxValue(m_panel.m_unitsCombo, m_pageLayout.units()); setComboBoxValue(m_panel.m_pageSizeCombo, m_pageLayout.pageSize().id()); QSizeF sizef = m_pageLayout.pageSize().size(QPageSize::Unit(m_pageLayout.units())); @@ -539,24 +456,7 @@ void PrintDialogPanel::updatePageLayoutWidgets() m_panel.m_bottomMargin->setValue(m_pageLayout.margins().bottom()); setComboBoxValue(m_panel.m_layoutModeCombo, m_pageLayout.mode()); QRectF rectf = m_pageLayout.paintRect(); -#else - setComboBoxValue(m_panel.m_unitsCombo, m_units); - setComboBoxValue(m_panel.m_pageSizeCombo, m_printerLayout.pageSize()); - QSizeF sizef = m_printerLayout.paperSize(m_units); - bool custom = (m_printerLayout.pageSize() == QPrinter::Custom); - setComboBoxValue(m_panel.m_orientationCombo, m_printerLayout.orientation()); - double left, top, right, bottom; - m_printerLayout.getPageMargins(&left, &top, &right, &bottom, m_units); - m_panel.m_leftMargin->setValue(left); - m_panel.m_topMargin->setValue(top); - m_panel.m_rightMargin->setValue(right); - m_panel.m_bottomMargin->setValue(bottom); - if (m_printerLayout.fullPage()) - setComboBoxValue(m_panel.m_layoutModeCombo, QPageLayout::FullPageMode); - else - setComboBoxValue(m_panel.m_layoutModeCombo, QPageLayout::StandardMode); - QRectF rectf = m_printerLayout.pageRect(m_units); -#endif + m_panel.m_pageWidth->setValue(sizef.width()); m_panel.m_pageHeight->setValue(sizef.height()); m_panel.m_pageWidth->setEnabled(custom); @@ -603,11 +503,7 @@ void PrintDialogPanel::unitsChanged() { if (m_blockSignals) return; -#if QT_VERSION >= 0x050300 m_pageLayout.setUnits(comboBoxValue(m_panel.m_unitsCombo)); -#else - m_units = comboBoxValue(m_panel.m_unitsCombo); -#endif updatePageLayoutWidgets(); } @@ -615,7 +511,6 @@ void PrintDialogPanel::pageSizeChanged() { if (m_blockSignals) return; -#if QT_VERSION >= 0x050300 const QPageSize::PageSizeId pageSizeId = comboBoxValue(m_panel.m_pageSizeCombo); QPageSize pageSize; if (pageSizeId == QPageSize::Custom) @@ -623,13 +518,6 @@ void PrintDialogPanel::pageSizeChanged() else pageSize = QPageSize(pageSizeId); m_pageLayout.setPageSize(pageSize); -#else - const QPrinter::PageSize pageSize = comboBoxValue(m_panel.m_pageSizeCombo); - if (pageSize == QPrinter::Custom) - m_printerLayout.setPaperSize(QSizeF(200, 200), m_units); - else - m_printerLayout.setPageSize(pageSize); -#endif updatePageLayoutWidgets(); } @@ -637,11 +525,7 @@ void PrintDialogPanel::pageDimensionsChanged() { if (m_blockSignals) return; -#if QT_VERSION >= 0x050300 m_pageLayout.setPageSize(QPageSize(customPageSize(), QPageSize::Unit(m_pageLayout.units()))); -#else - m_printerLayout.setPaperSize(customPageSize(), m_units); -#endif updatePageLayoutWidgets(); } @@ -649,11 +533,7 @@ void PrintDialogPanel::orientationChanged() { if (m_blockSignals) return; -#if QT_VERSION >= 0x050300 m_pageLayout.setOrientation(comboBoxValue(m_panel.m_orientationCombo)); -#else - m_printerLayout.setOrientation(comboBoxValue(m_panel.m_orientationCombo)); -#endif updatePageLayoutWidgets(); } @@ -661,14 +541,8 @@ void PrintDialogPanel::marginsChanged() { if (m_blockSignals) return; -#if QT_VERSION >= 0x050300 m_pageLayout.setMargins(QMarginsF(m_panel.m_leftMargin->value(), m_panel.m_topMargin->value(), m_panel.m_rightMargin->value(), m_panel.m_bottomMargin->value())); -#else - m_printerLayout.setPageMargins(m_panel.m_leftMargin->value(), m_panel.m_topMargin->value(), - m_panel.m_rightMargin->value(), m_panel.m_bottomMargin->value(), - m_units); -#endif updatePageLayoutWidgets(); } @@ -676,12 +550,7 @@ void PrintDialogPanel::layoutModeChanged() { if (m_blockSignals) return; -#if QT_VERSION >= 0x050300 m_pageLayout.setMode(comboBoxValue(m_panel.m_layoutModeCombo)); -#else - bool fullPage = (comboBoxValue(m_panel.m_layoutModeCombo) == QPageLayout::FullPageMode); - m_printerLayout.setFullPage(fullPage); -#endif updatePageLayoutWidgets(); } @@ -709,11 +578,7 @@ void PrintDialogPanel::showPreviewDialog() { applySettings(m_printer.data()); PrintPreviewDialog dialog(m_printer.data(), this); -#if QT_VERSION >= 0x050000 const QSize availableSize = screen()->availableSize(); -#else - const QSize availableSize = QApplication::desktop()->availableGeometry().size(); -#endif dialog.resize(availableSize * 4/ 5); if (dialog.exec() == QDialog::Accepted) retrieveSettings(m_printer.data()); -- cgit v1.2.3