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>
This commit is contained in:
parent
e936c2a9a2
commit
56fbcfd2b7
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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)));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user