diff options
Diffstat (limited to 'src/printsupport/kernel')
-rw-r--r-- | src/printsupport/kernel/qcups.cpp | 106 | ||||
-rw-r--r-- | src/printsupport/kernel/qcups_p.h | 35 | ||||
-rw-r--r-- | src/printsupport/kernel/qpaintengine_alpha.cpp | 9 | ||||
-rw-r--r-- | src/printsupport/kernel/qplatformprintdevice.cpp | 45 | ||||
-rw-r--r-- | src/printsupport/kernel/qplatformprintdevice.h | 21 | ||||
-rw-r--r-- | src/printsupport/kernel/qprint_p.h | 1 | ||||
-rw-r--r-- | src/printsupport/kernel/qprintdevice.cpp | 31 | ||||
-rw-r--r-- | src/printsupport/kernel/qprintdevice_p.h | 16 | ||||
-rw-r--r-- | src/printsupport/kernel/qprintengine_pdf.cpp | 2 | ||||
-rw-r--r-- | src/printsupport/kernel/qprintengine_pdf_p.h | 16 | ||||
-rw-r--r-- | src/printsupport/kernel/qprintengine_win.cpp | 8 | ||||
-rw-r--r-- | src/printsupport/kernel/qprinter.cpp | 12 | ||||
-rw-r--r-- | src/printsupport/kernel/qprinter.h | 14 | ||||
-rw-r--r-- | src/printsupport/kernel/qprinterinfo.cpp | 2 |
14 files changed, 224 insertions, 94 deletions
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index b9e162abe9..be170ed619 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -43,33 +43,37 @@ QT_BEGIN_NAMESPACE -QStringList QCUPSSupport::cupsOptionsList(QPrinter *printer) +static QStringList cupsOptionsList(QPrinter *printer) Q_DECL_NOTHROW { return printer->printEngine()->property(PPK_CupsOptions).toStringList(); } -void QCUPSSupport::setCupsOptions(QPrinter *printer, const QStringList &cupsOptions) +void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions) Q_DECL_NOTHROW { printer->printEngine()->setProperty(PPK_CupsOptions, QVariant(cupsOptions)); } -void QCUPSSupport::setCupsOption(QStringList &cupsOptions, const QString &option, const QString &value) +void QCUPSSupport::setCupsOption(QPrinter *printer, const QString &option, const QString &value) { + QStringList cupsOptions = cupsOptionsList(printer); if (cupsOptions.contains(option)) { cupsOptions.replace(cupsOptions.indexOf(option) + 1, value); } else { cupsOptions.append(option); cupsOptions.append(value); } + setCupsOptions(printer, cupsOptions); } -void QCUPSSupport::clearCupsOption(QStringList &cupsOptions, const QString &option) +void QCUPSSupport::clearCupsOption(QPrinter *printer, const QString &option) { + QStringList cupsOptions = cupsOptionsList(printer); // ### use const_iterator once QList::erase takes them const QStringList::iterator it = std::find(cupsOptions.begin(), cupsOptions.end(), option); if (it != cupsOptions.end()) { Q_ASSERT(it + 1 < cupsOptions.end()); cupsOptions.erase(it, it+1); + setCupsOptions(printer, cupsOptions); } } @@ -107,32 +111,57 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, return QString(); } +QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString &jobHoldUntil) +{ + if (jobHoldUntil == QLatin1String("indefinite")) { + return { QCUPSSupport::Indefinite, QTime() }; + } else if (jobHoldUntil == QLatin1String("day-time")) { + return { QCUPSSupport::DayTime, QTime() }; + } else if (jobHoldUntil == QLatin1String("night")) { + return { QCUPSSupport::Night, QTime() }; + } else if (jobHoldUntil == QLatin1String("second-shift")) { + return { QCUPSSupport::SecondShift, QTime() }; + } else if (jobHoldUntil == QLatin1String("third-shift")) { + return { QCUPSSupport::ThirdShift, QTime() }; + } else if (jobHoldUntil == QLatin1String("weekend")) { + return { QCUPSSupport::Weekend, QTime() }; + } + + + QTime parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m:s")); + if (!parsedTime.isValid()) + parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m")); + if (parsedTime.isValid()) { + // CUPS time is in UTC, user expects local time, so get the equivalent + QDateTime dateTimeUtc = QDateTime::currentDateTimeUtc(); + dateTimeUtc.setTime(parsedTime); + return { QCUPSSupport::SpecificTime, dateTimeUtc.toLocalTime().time() }; + } + + return { QCUPSSupport::NoHold, QTime() }; +} + + void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, const QTime &holdUntilTime) { - QStringList cupsOptions = cupsOptionsList(printer); const QString jobHoldUntilArgument = jobHoldToString(jobHold, holdUntilTime); if (!jobHoldUntilArgument.isEmpty()) { - setCupsOption(cupsOptions, + setCupsOption(printer, QStringLiteral("job-hold-until"), jobHoldUntilArgument); } else { - clearCupsOption(cupsOptions, QStringLiteral("job-hold-until")); + clearCupsOption(printer, QStringLiteral("job-hold-until")); } - setCupsOptions(printer, cupsOptions); } void QCUPSSupport::setJobBilling(QPrinter *printer, const QString &jobBilling) { - QStringList cupsOptions = cupsOptionsList(printer); - setCupsOption(cupsOptions, QStringLiteral("job-billing"), jobBilling); - setCupsOptions(printer, cupsOptions); + setCupsOption(printer, QStringLiteral("job-billing"), jobBilling); } void QCUPSSupport::setJobPriority(QPrinter *printer, int priority) { - QStringList cupsOptions = cupsOptionsList(printer); - setCupsOption(cupsOptions, QStringLiteral("job-priority"), QString::number(priority)); - setCupsOptions(printer, cupsOptions); + setCupsOption(printer, QStringLiteral("job-priority"), QString::number(priority)); } static inline QString bannerPageToString(const QCUPSSupport::BannerPage bannerPage) @@ -150,19 +179,42 @@ static inline QString bannerPageToString(const QCUPSSupport::BannerPage bannerPa return QString(); } +static inline QCUPSSupport::BannerPage stringToBannerPage(const QString &bannerPage) +{ + if (bannerPage == QLatin1String("none")) return QCUPSSupport::NoBanner; + else if (bannerPage == QLatin1String("standard")) return QCUPSSupport::Standard; + else if (bannerPage == QLatin1String("unclassified")) return QCUPSSupport::Unclassified; + else if (bannerPage == QLatin1String("confidential")) return QCUPSSupport::Confidential; + else if (bannerPage == QLatin1String("classified")) return QCUPSSupport::Classified; + else if (bannerPage == QLatin1String("secret")) return QCUPSSupport::Secret; + else if (bannerPage == QLatin1String("topsecret")) return QCUPSSupport::TopSecret; + + return QCUPSSupport::NoBanner; +} + +QCUPSSupport::JobSheets QCUPSSupport::parseJobSheets(const QString &jobSheets) +{ + JobSheets result; + + const QStringList parts = jobSheets.split(QLatin1Char(',')); + if (parts.count() == 2) { + result.startBannerPage = stringToBannerPage(parts[0]); + result.endBannerPage = stringToBannerPage(parts[1]); + } + + return result; +} + void QCUPSSupport::setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage) { - QStringList cupsOptions = cupsOptionsList(printer); const QString startBanner = bannerPageToString(startBannerPage); const QString endBanner = bannerPageToString(endBannerPage); - setCupsOption(cupsOptions, QStringLiteral("job-sheets"), startBanner + QLatin1Char(',') + endBanner); - setCupsOptions(printer, cupsOptions); + setCupsOption(printer, QStringLiteral("job-sheets"), startBanner + QLatin1Char(',') + endBanner); } void QCUPSSupport::setPageSet(QPrinter *printer, const PageSet pageSet) { - QStringList cupsOptions = cupsOptionsList(printer); QString pageSetString; switch (pageSet) { @@ -177,29 +229,29 @@ void QCUPSSupport::setPageSet(QPrinter *printer, const PageSet pageSet) break; } - setCupsOption(cupsOptions, QStringLiteral("page-set"), pageSetString); - setCupsOptions(printer, cupsOptions); + setCupsOption(printer, QStringLiteral("page-set"), pageSetString); } void QCUPSSupport::setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet, const PagesPerSheetLayout pagesPerSheetLayout) { - QStringList cupsOptions = cupsOptionsList(printer); // WARNING: the following trick (with a [2]-extent) only works as // WARNING: long as there's only one two-digit number in the list // WARNING: and it is the last one (before the "\0")! static const char pagesPerSheetData[][2] = { "1", "2", "4", "6", "9", {'1', '6'}, "\0" }; static const char pageLayoutData[][5] = {"lrtb", "lrbt", "rlbt", "rltb", "btlr", "btrl", "tblr", "tbrl"}; - setCupsOption(cupsOptions, QStringLiteral("number-up"), QLatin1String(pagesPerSheetData[pagesPerSheet])); - setCupsOption(cupsOptions, QStringLiteral("number-up-layout"), QLatin1String(pageLayoutData[pagesPerSheetLayout])); - setCupsOptions(printer, cupsOptions); + setCupsOption(printer, QStringLiteral("number-up"), QLatin1String(pagesPerSheetData[pagesPerSheet])); + setCupsOption(printer, QStringLiteral("number-up-layout"), QLatin1String(pageLayoutData[pagesPerSheetLayout])); } void QCUPSSupport::setPageRange(QPrinter *printer, int pageFrom, int pageTo) { - QStringList cupsOptions = cupsOptionsList(printer); - setCupsOption(cupsOptions, QStringLiteral("page-ranges"), QStringLiteral("%1-%2").arg(pageFrom).arg(pageTo)); - setCupsOptions(printer, cupsOptions); + setPageRange(printer, QStringLiteral("%1-%2").arg(pageFrom).arg(pageTo)); +} + +void QCUPSSupport::setPageRange(QPrinter *printer, const QString &pageRange) +{ + setCupsOption(printer, QStringLiteral("page-ranges"), pageRange); } QT_END_NAMESPACE diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h index 780115e350..da2b087d5b 100644 --- a/src/printsupport/kernel/qcups_p.h +++ b/src/printsupport/kernel/qcups_p.h @@ -67,6 +67,14 @@ QT_BEGIN_NAMESPACE // removed from the dialogs. #define PPK_CupsOptions QPrintEngine::PrintEnginePropertyKey(0xfe00) +#define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase) +#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1) +#define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2) +#define PDPK_CupsJobSheets QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 3) +#define PDPK_CupsJobBilling QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 4) +#define PDPK_CupsJobHoldUntil QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 5) +#define PDPK_PpdChoiceIsInstallableConflict QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 6) + class Q_PRINTSUPPORT_EXPORT QCUPSSupport { public: @@ -122,10 +130,8 @@ public: TopToBottomRightToLeft }; - static QStringList cupsOptionsList(QPrinter *printer); - static void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions); - static void setCupsOption(QStringList &cupsOptions, const QString &option, const QString &value); - static void clearCupsOption(QStringList &cupsOptions, const QString &option); + static void setCupsOption(QPrinter *printer, const QString &option, const QString &value); + static void clearCupsOption(QPrinter *printer, const QString &option); static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, const QTime &holdUntilTime = QTime()); static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString()); @@ -135,6 +141,27 @@ public: static void setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet, const PagesPerSheetLayout pagesPerSheetLayout); static void setPageRange(QPrinter *printer, int pageFrom, int pageTo); + static void setPageRange(QPrinter *printer, const QString &pageRange); + + struct JobSheets + { + JobSheets(BannerPage s = NoBanner, BannerPage e = NoBanner) + : startBannerPage(s), endBannerPage(e) {} + + BannerPage startBannerPage; + BannerPage endBannerPage; + }; + static JobSheets parseJobSheets(const QString &jobSheets); + + struct JobHoldUntilWithTime + { + JobHoldUntilWithTime(JobHoldUntil jh = NoHold, const QTime &t = QTime()) + : jobHold(jh), time(t) {} + + JobHoldUntil jobHold; + QTime time; + }; + static JobHoldUntilWithTime parseJobHoldUntil(const QString &jobHoldUntil); }; Q_DECLARE_TYPEINFO(QCUPSSupport::JobHoldUntil, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(QCUPSSupport::BannerPage, Q_PRIMITIVE_TYPE); diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp index cae5c2f522..410051df2a 100644 --- a/src/printsupport/kernel/qpaintengine_alpha.cpp +++ b/src/printsupport/kernel/qpaintengine_alpha.cpp @@ -306,15 +306,12 @@ void QAlphaPaintEngine::flushAndInit(bool init) d->m_alphargn = d->m_alphargn.intersected(QRect(0, 0, d->m_pdev->width(), d->m_pdev->height())); // just use the bounding rect if it's a complex region.. - QVector<QRect> rects = d->m_alphargn.rects(); - if (rects.size() > 10) { + if (d->m_alphargn.rectCount() > 10) { QRect br = d->m_alphargn.boundingRect(); d->m_alphargn = QRegion(br); - rects.clear(); - rects.append(br); } - d->m_cliprgn = d->m_alphargn; + const auto oldAlphaRegion = d->m_cliprgn = d->m_alphargn; // now replay the QPicture ++d->m_pass; // we are now doing pass #2 @@ -336,7 +333,7 @@ void QAlphaPaintEngine::flushAndInit(bool init) d->resetState(painter()); // fill in the alpha images - for (const auto &rect : qAsConst(rects)) + for (const auto &rect : oldAlphaRegion) d->drawAlphaImage(rect); d->m_alphargn = QRegion(); diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp index e2d4a08de3..8dba402a6e 100644 --- a/src/printsupport/kernel/qplatformprintdevice.cpp +++ b/src/printsupport/kernel/qplatformprintdevice.cpp @@ -167,7 +167,7 @@ QList<QPageSize> QPlatformPrintDevice::supportedPageSizes() const { if (!m_havePageSizes) loadPageSizes(); - return m_pageSizes.toList(); + return m_pageSizes; } QPageSize QPlatformPrintDevice::supportedPageSize(const QPageSize &pageSize) const @@ -293,7 +293,7 @@ QList<int> QPlatformPrintDevice::supportedResolutions() const { if (!m_haveResolutions) loadResolutions(); - return m_resolutions.toList(); + return m_resolutions; } void QPlatformPrintDevice::loadInputSlots() const @@ -313,11 +313,11 @@ QPrint::InputSlot QPlatformPrintDevice::defaultInputSlot() const return input; } -QList<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const +QVector<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const { if (!m_haveInputSlots) loadInputSlots(); - return m_inputSlots.toList(); + return m_inputSlots; } void QPlatformPrintDevice::loadOutputBins() const @@ -337,11 +337,11 @@ QPrint::OutputBin QPlatformPrintDevice::defaultOutputBin() const return output; } -QList<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const +QVector<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const { if (!m_haveOutputBins) loadOutputBins(); - return m_outputBins.toList(); + return m_outputBins; } void QPlatformPrintDevice::loadDuplexModes() const @@ -353,11 +353,11 @@ QPrint::DuplexMode QPlatformPrintDevice::defaultDuplexMode() const return QPrint::DuplexNone; } -QList<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const +QVector<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const { if (!m_haveDuplexModes) loadDuplexModes(); - return m_duplexModes.toList(); + return m_duplexModes; } void QPlatformPrintDevice::loadColorModes() const @@ -369,11 +369,11 @@ QPrint::ColorMode QPlatformPrintDevice::defaultColorMode() const return QPrint::GrayScale; } -QList<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const +QVector<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const { if (!m_haveColorModes) loadColorModes(); - return m_colorModes.toList(); + return m_colorModes; } #ifndef QT_NO_MIMETYPE @@ -381,11 +381,34 @@ void QPlatformPrintDevice::loadMimeTypes() const { } +QVariant QPlatformPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) const +{ + Q_UNUSED(key) + + return QVariant(); +} + +bool QPlatformPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value) +{ + Q_UNUSED(key) + Q_UNUSED(value) + + return false; +} + +bool QPlatformPrintDevice::isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant ¶ms) const +{ + Q_UNUSED(key) + Q_UNUSED(params) + + return false; +} + QList<QMimeType> QPlatformPrintDevice::supportedMimeTypes() const { if (!m_haveMimeTypes) loadMimeTypes(); - return m_mimeTypes.toList(); + return m_mimeTypes; } #endif // QT_NO_MIMETYPE diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h index 44a3a966f4..a988518547 100644 --- a/src/printsupport/kernel/qplatformprintdevice.h +++ b/src/printsupport/kernel/qplatformprintdevice.h @@ -53,11 +53,14 @@ #include <QtPrintSupport/qtprintsupportglobal.h> #include <private/qprint_p.h> +#include <private/qprintdevice_p.h> +#include <QtCore/qvariant.h> #include <QtCore/qvector.h> #include <QtCore/qmimetype.h> #include <QtGui/qpagelayout.h> + QT_BEGIN_NAMESPACE #ifndef QT_NO_PRINTER @@ -107,16 +110,20 @@ public: virtual QList<int> supportedResolutions() const; virtual QPrint::InputSlot defaultInputSlot() const; - virtual QList<QPrint::InputSlot> supportedInputSlots() const; + virtual QVector<QPrint::InputSlot> supportedInputSlots() const; virtual QPrint::OutputBin defaultOutputBin() const; - virtual QList<QPrint::OutputBin> supportedOutputBins() const; + virtual QVector<QPrint::OutputBin> supportedOutputBins() const; virtual QPrint::DuplexMode defaultDuplexMode() const; - virtual QList<QPrint::DuplexMode> supportedDuplexModes() const; + virtual QVector<QPrint::DuplexMode> supportedDuplexModes() const; virtual QPrint::ColorMode defaultColorMode() const; - virtual QList<QPrint::ColorMode> supportedColorModes() const; + virtual QVector<QPrint::ColorMode> supportedColorModes() const; + + virtual QVariant property(QPrintDevice::PrintDevicePropertyKey key) const; + virtual bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value); + virtual bool isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant ¶ms) const; #ifndef QT_NO_MIMETYPE virtual QList<QMimeType> supportedMimeTypes() const; @@ -149,7 +156,7 @@ protected: bool m_supportsCollateCopies; mutable bool m_havePageSizes; - mutable QVector<QPageSize> m_pageSizes; + mutable QList<QPageSize> m_pageSizes; bool m_supportsCustomPageSizes; @@ -157,7 +164,7 @@ protected: QSize m_maximumPhysicalPageSize; mutable bool m_haveResolutions; - mutable QVector<int> m_resolutions; + mutable QList<int> m_resolutions; mutable bool m_haveInputSlots; mutable QVector<QPrint::InputSlot> m_inputSlots; @@ -173,7 +180,7 @@ protected: #ifndef QT_NO_MIMETYPE mutable bool m_haveMimeTypes; - mutable QVector<QMimeType> m_mimeTypes; + mutable QList<QMimeType> m_mimeTypes; #endif }; diff --git a/src/printsupport/kernel/qprint_p.h b/src/printsupport/kernel/qprint_p.h index 280c2d7608..4956775461 100644 --- a/src/printsupport/kernel/qprint_p.h +++ b/src/printsupport/kernel/qprint_p.h @@ -59,6 +59,7 @@ #if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups)) #include <cups/ppd.h> // Use for type defs only, don't want to actually link in main module +Q_DECLARE_METATYPE(ppd_file_t *) #endif QT_BEGIN_NAMESPACE diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp index 26799a6f13..50fc14169d 100644 --- a/src/printsupport/kernel/qprintdevice.cpp +++ b/src/printsupport/kernel/qprintdevice.cpp @@ -210,9 +210,9 @@ QPrint::InputSlot QPrintDevice::defaultInputSlot() const return isValid() ? d->defaultInputSlot() : QPrint::InputSlot(); } -QList<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const +QVector<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const { - return isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>(); + return isValid() ? d->supportedInputSlots() : QVector<QPrint::InputSlot>{}; } QPrint::OutputBin QPrintDevice::defaultOutputBin() const @@ -220,9 +220,9 @@ QPrint::OutputBin QPrintDevice::defaultOutputBin() const return isValid() ? d->defaultOutputBin() : QPrint::OutputBin(); } -QList<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const +QVector<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const { - return isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>(); + return isValid() ? d->supportedOutputBins() : QVector<QPrint::OutputBin>{}; } QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const @@ -230,9 +230,9 @@ QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const return isValid() ? d->defaultDuplexMode() : QPrint::DuplexNone; } -QList<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const +QVector<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const { - return isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>(); + return isValid() ? d->supportedDuplexModes() : QVector<QPrint::DuplexMode>{}; } QPrint::ColorMode QPrintDevice::defaultColorMode() const @@ -240,9 +240,24 @@ QPrint::ColorMode QPrintDevice::defaultColorMode() const return isValid() ? d->defaultColorMode() : QPrint::GrayScale; } -QList<QPrint::ColorMode> QPrintDevice::supportedColorModes() const +QVector<QPrint::ColorMode> QPrintDevice::supportedColorModes() const { - return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>(); + return isValid() ? d->supportedColorModes() : QVector<QPrint::ColorMode>{}; +} + +QVariant QPrintDevice::property(PrintDevicePropertyKey key) const +{ + return isValid() ? d->property(key) : QVariant(); +} + +bool QPrintDevice::setProperty(PrintDevicePropertyKey key, const QVariant &value) +{ + return isValid() ? d->setProperty(key, value) : false; +} + +bool QPrintDevice::isFeatureAvailable(PrintDevicePropertyKey key, const QVariant ¶ms) const +{ + return isValid() ? d->isFeatureAvailable(key, params) : false; } #ifndef QT_NO_MIMETYPE diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h index 1e0d3983e9..562ccd2057 100644 --- a/src/printsupport/kernel/qprintdevice_p.h +++ b/src/printsupport/kernel/qprintdevice_p.h @@ -120,16 +120,24 @@ public: QList<int> supportedResolutions() const; QPrint::InputSlot defaultInputSlot() const; - QList<QPrint::InputSlot> supportedInputSlots() const; + QVector<QPrint::InputSlot> supportedInputSlots() const; QPrint::OutputBin defaultOutputBin() const; - QList<QPrint::OutputBin> supportedOutputBins() const; + QVector<QPrint::OutputBin> supportedOutputBins() const; QPrint::DuplexMode defaultDuplexMode() const; - QList<QPrint::DuplexMode> supportedDuplexModes() const; + QVector<QPrint::DuplexMode> supportedDuplexModes() const; QPrint::ColorMode defaultColorMode() const; - QList<QPrint::ColorMode> supportedColorModes() const; + QVector<QPrint::ColorMode> supportedColorModes() const; + + enum PrintDevicePropertyKey { + PDPK_CustomBase = 0xff00 + }; + + QVariant property(PrintDevicePropertyKey key) const; + bool setProperty(PrintDevicePropertyKey key, const QVariant &value); + bool isFeatureAvailable(PrintDevicePropertyKey key, const QVariant ¶ms) const; #ifndef QT_NO_MIMETYPE QList<QMimeType> supportedMimeTypes() const; diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp index 873e146eec..0230ebddc8 100644 --- a/src/printsupport/kernel/qprintengine_pdf.cpp +++ b/src/printsupport/kernel/qprintengine_pdf.cpp @@ -374,7 +374,7 @@ void QPdfPrintEnginePrivate::closePrintDevice() if (outDevice) { outDevice->close(); if (fd >= 0) - #if defined(Q_OS_WIN) && defined(_MSC_VER) && _MSC_VER >= 1400 + #if defined(Q_OS_WIN) && defined(Q_CC_MSVC) ::_close(fd); #else ::close(fd); diff --git a/src/printsupport/kernel/qprintengine_pdf_p.h b/src/printsupport/kernel/qprintengine_pdf_p.h index e9e81bdf68..bb01a2e9e1 100644 --- a/src/printsupport/kernel/qprintengine_pdf_p.h +++ b/src/printsupport/kernel/qprintengine_pdf_p.h @@ -87,18 +87,18 @@ public: virtual ~QPdfPrintEngine(); // reimplementations QPaintEngine - bool begin(QPaintDevice *pdev) Q_DECL_OVERRIDE; - bool end() Q_DECL_OVERRIDE; + bool begin(QPaintDevice *pdev) override; + bool end() override; // end reimplementations QPaintEngine // reimplementations QPrintEngine - bool abort() Q_DECL_OVERRIDE {return false;} - QPrinter::PrinterState printerState() const Q_DECL_OVERRIDE {return state;} + bool abort() override {return false;} + QPrinter::PrinterState printerState() const override {return state;} - bool newPage() Q_DECL_OVERRIDE; - int metric(QPaintDevice::PaintDeviceMetric) const Q_DECL_OVERRIDE; - virtual void setProperty(PrintEnginePropertyKey key, const QVariant &value) Q_DECL_OVERRIDE; - virtual QVariant property(PrintEnginePropertyKey key) const Q_DECL_OVERRIDE; + bool newPage() override; + int metric(QPaintDevice::PaintDeviceMetric) const override; + virtual void setProperty(PrintEnginePropertyKey key, const QVariant &value) override; + virtual QVariant property(PrintEnginePropertyKey key) const override; // end reimplementations QPrintEngine QPrinter::PrinterState state; diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index b479ecacb1..a943d24cb1 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -1024,7 +1024,7 @@ bool QWin32PrintEnginePrivate::resetDC() return hdc != 0; } -static int indexOfId(const QList<QPrint::InputSlot> &inputSlots, QPrint::InputSlotId id) +static int indexOfId(const QVector<QPrint::InputSlot> &inputSlots, QPrint::InputSlotId id) { for (int i = 0; i < inputSlots.size(); ++i) { if (inputSlots.at(i).id == id) @@ -1033,7 +1033,7 @@ static int indexOfId(const QList<QPrint::InputSlot> &inputSlots, QPrint::InputSl return -1; } -static int indexOfWindowsId(const QList<QPrint::InputSlot> &inputSlots, int windowsId) +static int indexOfWindowsId(const QVector<QPrint::InputSlot> &inputSlots, int windowsId) { for (int i = 0; i < inputSlots.size(); ++i) { if (inputSlots.at(i).windowsId == windowsId) @@ -1210,7 +1210,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant & case PPK_PaperSource: { if (!d->devMode) break; - const QList<QPrint::InputSlot> inputSlots = d->m_printDevice.supportedInputSlots(); + const auto inputSlots = d->m_printDevice.supportedInputSlots(); const int paperSource = value.toInt(); const int index = paperSource >= DMBIN_USER ? indexOfWindowsId(inputSlots, paperSource) : indexOfId(inputSlots, QPrint::InputSlotId(paperSource)); @@ -1465,7 +1465,7 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const if (d->devMode->dmDefaultSource >= DMBIN_USER) { value = int(d->devMode->dmDefaultSource); } else { - const QList<QPrint::InputSlot> inputSlots = d->m_printDevice.supportedInputSlots(); + const auto inputSlots = d->m_printDevice.supportedInputSlots(); const int index = indexOfWindowsId(inputSlots, d->devMode->dmDefaultSource); value = index >= 0 ? inputSlots.at(index).id : QPrint::Auto; } diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index d439fcbbbc..8a2cdcb34f 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -231,7 +231,7 @@ public: virtual ~QPrinterPagedPaintDevicePrivate() {} - bool setPageLayout(const QPageLayout &newPageLayout) Q_DECL_OVERRIDE + bool setPageLayout(const QPageLayout &newPageLayout) override { if (pd->paintEngine->type() != QPaintEngine::Pdf && pd->printEngine->printerState() == QPrinter::Active) { @@ -248,7 +248,7 @@ public: return pageLayout().isEquivalentTo(newPageLayout); } - bool setPageSize(const QPageSize &pageSize) Q_DECL_OVERRIDE + bool setPageSize(const QPageSize &pageSize) override { if (pd->paintEngine->type() != QPaintEngine::Pdf && pd->printEngine->printerState() == QPrinter::Active) { @@ -266,7 +266,7 @@ public: return pageLayout().pageSize().isEquivalentTo(pageSize); } - bool setPageOrientation(QPageLayout::Orientation orientation) Q_DECL_OVERRIDE + bool setPageOrientation(QPageLayout::Orientation orientation) override { // Set the print engine value pd->setProperty(QPrintEngine::PPK_Orientation, orientation); @@ -277,12 +277,12 @@ public: return pageLayout().orientation() == orientation; } - bool setPageMargins(const QMarginsF &margins) Q_DECL_OVERRIDE + bool setPageMargins(const QMarginsF &margins) override { return setPageMargins(margins, pageLayout().units()); } - bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) Q_DECL_OVERRIDE + bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) override { // Try to set print engine margins QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(margins, units); @@ -294,7 +294,7 @@ public: return pageLayout().margins() == margins && pageLayout().units() == units; } - QPageLayout pageLayout() const Q_DECL_OVERRIDE + QPageLayout pageLayout() const override { return pd->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>(); } diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h index bfe2d346ae..28dca78a63 100644 --- a/src/printsupport/kernel/qprinter.h +++ b/src/printsupport/kernel/qprinter.h @@ -72,7 +72,7 @@ public: explicit QPrinter(const QPrinterInfo& printer, PrinterMode mode = ScreenResolution); ~QPrinter(); - int devType() const Q_DECL_OVERRIDE; + int devType() const override; enum Orientation { Portrait, Landscape }; @@ -170,10 +170,10 @@ public: void setOrientation(Orientation); Orientation orientation() const; - void setPageSize(PageSize) Q_DECL_OVERRIDE; + void setPageSize(PageSize) override; PageSize pageSize() const; - void setPageSizeMM(const QSizeF &size) Q_DECL_OVERRIDE; + void setPageSizeMM(const QSizeF &size) override; void setPaperSize(PaperSize); PaperSize paperSize() const; @@ -237,12 +237,12 @@ public: QString printerSelectionOption() const; void setPrinterSelectionOption(const QString &); - bool newPage() Q_DECL_OVERRIDE; + bool newPage() override; bool abort(); PrinterState printerState() const; - QPaintEngine *paintEngine() const Q_DECL_OVERRIDE; + QPaintEngine *paintEngine() const override; QPrintEngine *printEngine() const; void setFromTo(int fromPage, int toPage); @@ -252,13 +252,13 @@ public: void setPrintRange(PrintRange range); PrintRange printRange() const; - void setMargins(const Margins &m) Q_DECL_OVERRIDE; + void setMargins(const Margins &m) override; void setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit); void getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const; protected: - int metric(PaintDeviceMetric) const Q_DECL_OVERRIDE; + int metric(PaintDeviceMetric) const override; void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine); private: diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp index d271e069ad..49a0c9ece4 100644 --- a/src/printsupport/kernel/qprinterinfo.cpp +++ b/src/printsupport/kernel/qprinterinfo.cpp @@ -380,7 +380,7 @@ QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const { Q_D(const QPrinterInfo); QList<QPrinter::DuplexMode> list; - const QList<QPrint::DuplexMode> supportedDuplexModes = d->m_printDevice.supportedDuplexModes(); + const auto supportedDuplexModes = d->m_printDevice.supportedDuplexModes(); list.reserve(supportedDuplexModes.size()); for (QPrint::DuplexMode mode : supportedDuplexModes) list << QPrinter::DuplexMode(mode); |