* @brief Patches title, icon, and/or description on the workspace with the given ID. */
| 5146 | * @brief Patches title, icon, and/or description on the workspace with the given ID. |
| 5147 | */ |
| 5148 | void DataModel::ProjectModel::updateWorkspace(int workspaceId, |
| 5149 | const QString& title, |
| 5150 | const QString& icon, |
| 5151 | const QString& description, |
| 5152 | bool setTitle, |
| 5153 | bool setIcon, |
| 5154 | bool setDescription) |
| 5155 | { |
| 5156 | if (AppState::instance().operationMode() != SerialStudio::ProjectFile) |
| 5157 | return; |
| 5158 | |
| 5159 | if (!m_customizeWorkspaces) |
| 5160 | setCustomizeWorkspaces(true); |
| 5161 | |
| 5162 | for (auto& ws : m_workspaces) { |
| 5163 | if (ws.workspaceId == workspaceId) { |
| 5164 | if (setTitle) |
| 5165 | ws.title = title.simplified(); |
| 5166 | |
| 5167 | if (setIcon) |
| 5168 | ws.icon = SerialStudio::normalizeIconPath(icon); |
| 5169 | |
| 5170 | if (setDescription) |
| 5171 | ws.description = description; |
| 5172 | |
| 5173 | setModified(true); |
| 5174 | Q_EMIT editorWorkspacesChanged(); |
| 5175 | Q_EMIT activeWorkspacesChanged(); |
| 5176 | return; |
| 5177 | } |
| 5178 | } |
| 5179 | } |
| 5180 | |
| 5181 | /** |
| 5182 | * @brief Reorders user-defined workspaces (id >= UserStart) by the given id |