diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-06-07 23:48:53 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-07-12 06:55:52 +0200 |
commit | 56fbcfd2b78bc62eca953a5cd3af831a8964e9e1 (patch) | |
tree | d0075c54a5de51d41f80f2f7aca006c9a8923595 | |
parent | e936c2a9a29f4ec1767836a268ea398d6ef4aeeb (diff) | |
download | qtbase-56fbcfd2b78bc62eca953a5cd3af831a8964e9e1.tar.gz |
QPdfWriter: replace a QHash with a static_cast
The QHash was mapping equivalent values of different enums to each other.
The enums have the same enumerators, though, so if we take care to keep
the two in sync in the future, we can just static_cast them into each
other via int.
Change-Id: Ie67978604f8c3b9477419bc6029bbb869061e938
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | src/gui/painting/qpagedpaintdevice.h | 1 | ||||
-rw-r--r-- | src/gui/painting/qpdf_p.h | 1 | ||||
-rw-r--r-- | src/gui/painting/qpdfwriter.cpp | 8 |
3 files changed, 3 insertions, 7 deletions
diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h index 1c37c17fa3..21e23e0eb4 100644 --- a/src/gui/painting/qpagedpaintdevice.h +++ b/src/gui/painting/qpagedpaintdevice.h @@ -213,6 +213,7 @@ public: Envelope10 = Comm10E }; + // keep in sync with QPdfEngine::PdfVersion! enum PdfVersion { PdfVersion_1_4, PdfVersion_A1b, PdfVersion_1_6 }; // ### Qt6 Make these virtual diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index e337c61f64..e5649eb9dc 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -168,6 +168,7 @@ class Q_GUI_EXPORT QPdfEngine : public QPaintEngine Q_DECLARE_PRIVATE(QPdfEngine) friend class QPdfWriter; public: + // keep in sync with QPagedPaintDevice::PdfVersion! enum PdfVersion { Version_1_4, diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index 7f18ce42be..bf7e2d3dca 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -170,17 +170,11 @@ void QPdfWriter::setPdfVersion(PdfVersion version) { Q_D(QPdfWriter); - static const QHash<QPdfWriter::PdfVersion, QPdfEngine::PdfVersion> engineMapping { - {QPdfWriter::PdfVersion_1_4, QPdfEngine::Version_1_4}, - {QPdfWriter::PdfVersion_A1b, QPdfEngine::Version_A1b}, - {QPdfWriter::PdfVersion_1_6, QPdfEngine::Version_1_6} - }; - if (d->pdfVersion == version) return; d->pdfVersion = version; - d->engine->setPdfVersion(engineMapping.value(version, QPdfEngine::Version_1_4)); + d->engine->setPdfVersion(static_cast<QPdfEngine::PdfVersion>(static_cast<int>(version))); } /*! |