Accept arrays as enum descriptions in qmltypes files

We don't use the values at all and they are hard to determine
statically. Qt >= 5.15 will generated arrays instead of objects.

Change-Id: I3b3bbd427c49e649ca3f9cef51c89b32e830eb66
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Ulf Hermann
2019-08-29 10:38:36 +02:00
parent 1bf23a6c74
commit b5b1367b0b
4 changed files with 29 additions and 41 deletions

View File

@@ -44,8 +44,8 @@ QString FakeMetaEnum::name() const
void FakeMetaEnum::setName(const QString &name)
{ m_name = name; }
void FakeMetaEnum::addKey(const QString &key, int value)
{ m_keys.append(key); m_values.append(value); }
void FakeMetaEnum::addKey(const QString &key)
{ m_keys.append(key); }
QString FakeMetaEnum::key(int index) const
{ return m_keys.at(index); }
@@ -71,10 +71,6 @@ void FakeMetaEnum::addToHash(QCryptographicHash &hash) const
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
hash.addData(reinterpret_cast<const char *>(key.constData()), len * sizeof(QChar));
}
len = m_values.size();
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
foreach (int value, m_values)
hash.addData(reinterpret_cast<const char *>(&value), sizeof(value));
}
QString FakeMetaEnum::describe(int baseIndent) const
@@ -82,16 +78,14 @@ QString FakeMetaEnum::describe(int baseIndent) const
QString newLine = QString::fromLatin1("\n") + QString::fromLatin1(" ").repeated(baseIndent);
QString res = QLatin1String("Enum ");
res += name();
res += QLatin1String(":{");
res += QLatin1String(": [");
for (int i = 0; i < keyCount(); ++i) {
res += newLine;
res += QLatin1String(" ");
res += key(i);
res += QLatin1String(": ");
res += QString::number(m_values.value(i, -1));
}
res += newLine;
res += QLatin1Char('}');
res += QLatin1Char(']');
return res;
}