forked from qt-creator/qt-creator
QmlDesigner: Fix the bug for using QMap::asKeyValueRange
This feature is available for QT_VERSION >= 6.4.0. So a compiler condition is considered to switch the code for different versions. Also, an old unused function has been removed. Change-Id: I470812213cfb00c28fcf062d214895cfcba68d69 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -79,21 +79,6 @@ EType DesignerIconEnums<EType>::value(const QString &keyStr, bool *ok)
|
||||
return static_cast<EType>(metaEnum.keyToValue(keyStr.toLatin1(), ok));
|
||||
}
|
||||
|
||||
Q_GLOBAL_STATIC(QStringList, _iconFontMandatoryKeys);
|
||||
|
||||
const QStringList & iconFontMandatoryKeys()
|
||||
{
|
||||
if (_iconFontMandatoryKeys->isEmpty()) {
|
||||
*_iconFontMandatoryKeys
|
||||
<< DesignerIconEnums<Theme::Icon>::keyName
|
||||
<< DesignerIconEnums<Theme::Color>::keyName
|
||||
<< DesignerIconEnums<QIcon::Mode>::keyName
|
||||
<< DesignerIconEnums<QIcon::State>::keyName
|
||||
<< "size";
|
||||
}
|
||||
return *_iconFontMandatoryKeys;
|
||||
}
|
||||
|
||||
QJsonObject mergeJsons(const QJsonObject &prior, const QJsonObject &joiner)
|
||||
{
|
||||
QJsonObject object = prior;
|
||||
@@ -237,8 +222,17 @@ struct JsonMap<QMap<Key, Value>>
|
||||
static QJsonObject json(const QMap<Key, Value> &map)
|
||||
{
|
||||
QJsonObject output;
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
|
||||
for (const auto &[key, val] : map.asKeyValueRange())
|
||||
output[DesignerIconEnums<Key>::toString(key)] = JsonMap<Value>::json(val);
|
||||
#else
|
||||
const auto mapKeys = map.keys();
|
||||
for (const Key &key : mapKeys) {
|
||||
const Value &val = map.value(key);
|
||||
output[DesignerIconEnums<Key>::toString(key)] = JsonMap<Value>::json(val);
|
||||
}
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -24,14 +24,14 @@ public:
|
||||
QIcon::Mode mode = QIcon::Normal,
|
||||
QIcon::State state = QIcon::Off);
|
||||
|
||||
IconFontHelper();
|
||||
|
||||
static IconFontHelper fromJson(const QJsonObject &jsonObject);
|
||||
QJsonObject toJson() const;
|
||||
Theme::Icon themeIcon() const;
|
||||
Theme::Color themeColor() const;
|
||||
|
||||
private:
|
||||
IconFontHelper();
|
||||
|
||||
Theme::Icon mThemeIcon;
|
||||
Theme::Color mThemeColor;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user