MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / remapLayoutKeysAfterReorder

Method remapLayoutKeysAfterReorder

app/src/DataModel/ProjectModel.cpp:3971–3996  ·  view source on GitHub ↗

* @brief Rewrites every layout:N widgetSettings entry to use the new groupId. */

Source from the content-addressed store, hash-verified

3969 * @brief Rewrites every layout:N widgetSettings entry to use the new groupId.
3970 */
3971void DataModel::ProjectModel::remapLayoutKeysAfterReorder(const std::vector<int>& oldToNewGid)
3972{
3973 if (m_widgetSettings.isEmpty())
3974 return;
3975
3976 const QString prefix = QStringLiteral("layout:");
3977 QMap<int, QJsonObject> snapshot;
3978
3979 for (const auto& key : m_widgetSettings.keys()) {
3980 if (!key.startsWith(prefix))
3981 continue;
3982
3983 bool ok = false;
3984 const int id = key.mid(prefix.length()).toInt(&ok);
3985 if (!ok || id < 0 || static_cast<size_t>(id) >= oldToNewGid.size())
3986 continue;
3987
3988 snapshot.insert(id, m_widgetSettings.value(key).toObject());
3989 m_widgetSettings.remove(key);
3990 }
3991
3992 for (auto it = snapshot.constBegin(); it != snapshot.constEnd(); ++it) {
3993 const int newId = oldToNewGid[static_cast<size_t>(it.key())];
3994 m_widgetSettings.insert(Keys::layoutKey(newId), it.value());
3995 }
3996}
3997
3998/**
3999 * @brief Renames per-group auto workspaces (PerGroupStart + groupId) so they

Callers

nothing calls this directly

Calls 8

layoutKeyFunction · 0.85
isEmptyMethod · 0.80
keysMethod · 0.80
lengthMethod · 0.80
keyMethod · 0.80
sizeMethod · 0.45
valueMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected