forked from qt-creator/qt-creator
CompilerExplorer: Avoid using keys()
Instead, iterate directly over the container. Change-Id: I6a3cb7d623e083663a11389f15b8d51599f338a3 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -136,9 +136,8 @@ struct CompileParameters
|
|||||||
Options &libraries(const QMap<QString, QString> &libraries)
|
Options &libraries(const QMap<QString, QString> &libraries)
|
||||||
{
|
{
|
||||||
Libraries result;
|
Libraries result;
|
||||||
for (const auto &key : libraries.keys()) {
|
for (auto it = libraries.begin(); it != libraries.end(); ++it)
|
||||||
result.add(key, libraries[key]);
|
result.add(it.key(), *it);
|
||||||
}
|
|
||||||
obj["libraries"] = result.array;
|
obj["libraries"] = result.array;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,9 +62,8 @@ bool LibrarySelectionAspect::guiToBuffer()
|
|||||||
QVariantMap toVariantMap(const QMap<QString, QString> &map)
|
QVariantMap toVariantMap(const QMap<QString, QString> &map)
|
||||||
{
|
{
|
||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
for (const auto &key : map.keys())
|
for (auto it = map.begin(); it != map.end(); ++it)
|
||||||
variant.insert(key, map[key]);
|
variant.insert(it.key(), *it);
|
||||||
|
|
||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,10 +85,9 @@ QVariant LibrarySelectionAspect::defaultVariantValue() const
|
|||||||
void LibrarySelectionAspect::setVariantValue(const QVariant &value, Announcement howToAnnounce)
|
void LibrarySelectionAspect::setVariantValue(const QVariant &value, Announcement howToAnnounce)
|
||||||
{
|
{
|
||||||
QMap<QString, QString> map;
|
QMap<QString, QString> map;
|
||||||
Store store = storeFromVariant(value);
|
const Store store = storeFromVariant(value);
|
||||||
for (const auto &key : store.keys())
|
for (auto it = store.begin(); it != store.end(); ++it)
|
||||||
map[stringFromKey(key)] = store[key].toString();
|
map[stringFromKey(it.key())] = it->toString();
|
||||||
|
|
||||||
setValue(map, howToAnnounce);
|
setValue(map, howToAnnounce);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -616,21 +616,21 @@ CompilerWidget *EditorWidget::addCompiler(const std::shared_ptr<SourceSettings>
|
|||||||
|
|
||||||
QVariantMap EditorWidget::windowStateCallback()
|
QVariantMap EditorWidget::windowStateCallback()
|
||||||
{
|
{
|
||||||
auto settings = saveSettings();
|
const auto settings = saveSettings();
|
||||||
QVariantMap result;
|
QVariantMap result;
|
||||||
|
|
||||||
for (const Key &key : settings.keys()) {
|
for (auto it = settings.begin(); it != settings.end(); ++it) {
|
||||||
// QTBUG-116339
|
// QTBUG-116339
|
||||||
if (stringFromKey(key) != "State") {
|
const QString keyString = stringFromKey(it.key());
|
||||||
result.insert(stringFromKey(key), settings.value(key));
|
if (keyString != "State") {
|
||||||
|
result.insert(keyString, *it);
|
||||||
} else {
|
} else {
|
||||||
QVariantMap m;
|
QVariantMap m;
|
||||||
m["type"] = "Base64";
|
m["type"] = "Base64";
|
||||||
m["value"] = settings.value(key).toByteArray().toBase64();
|
m["value"] = it->toByteArray().toBase64();
|
||||||
result.insert(stringFromKey(key), m);
|
result.insert(keyString, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,28 +730,24 @@ void EditorWidget::recreateEditors()
|
|||||||
m_document->settings()->m_sources.forEachItem<SourceSettings>(
|
m_document->settings()->m_sources.forEachItem<SourceSettings>(
|
||||||
[this](const auto &sourceSettings) { addSourceEditor(sourceSettings); });
|
[this](const auto &sourceSettings) { addSourceEditor(sourceSettings); });
|
||||||
|
|
||||||
Store windowState = m_document->settings()->windowState.value();
|
const Store windowState = m_document->settings()->windowState.value();
|
||||||
|
|
||||||
if (!windowState.isEmpty()) {
|
if (windowState.isEmpty())
|
||||||
Store hashMap;
|
return;
|
||||||
for (const auto &key : windowState.keys()) {
|
|
||||||
if (key.view() != "State")
|
Store hashMap;
|
||||||
hashMap.insert(key, windowState.value(key));
|
for (auto it = windowState.begin(); it != windowState.end(); ++it) {
|
||||||
else {
|
const Key key = it.key();
|
||||||
QVariant v = windowState.value(key);
|
const QVariant v = *it;
|
||||||
if (v.userType() == QMetaType::QByteArray) {
|
if (key.view() != "State" || v.userType() == QMetaType::QByteArray) {
|
||||||
hashMap.insert(key, v);
|
hashMap.insert(key, v);
|
||||||
} else if (v.userType() == QMetaType::QVariantMap) {
|
} else if (v.userType() == QMetaType::QVariantMap) {
|
||||||
QVariantMap m = v.toMap();
|
const QVariantMap m = v.toMap();
|
||||||
if (m.value("type") == "Base64") {
|
if (m.value("type") == "Base64")
|
||||||
hashMap.insert(key, QByteArray::fromBase64(m.value("value").toByteArray()));
|
hashMap.insert(key, QByteArray::fromBase64(m.value("value").toByteArray()));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
restoreSettings(hashMap);
|
|
||||||
}
|
}
|
||||||
|
restoreSettings(hashMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWidget::setupHelpWidget()
|
void EditorWidget::setupHelpWidget()
|
||||||
|
|||||||
Reference in New Issue
Block a user