* @brief Rewrites every layout:N widgetSettings entry to use the new groupId. */
| 3969 | * @brief Rewrites every layout:N widgetSettings entry to use the new groupId. |
| 3970 | */ |
| 3971 | void 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 |