* @brief Appends a widget reference to the specified workspace. */
| 5822 | * @brief Appends a widget reference to the specified workspace. |
| 5823 | */ |
| 5824 | void DataModel::ProjectModel::addWidgetToWorkspace(int workspaceId, |
| 5825 | int widgetType, |
| 5826 | int groupUniqueId, |
| 5827 | int relativeIndex) |
| 5828 | { |
| 5829 | if (AppState::instance().operationMode() != SerialStudio::ProjectFile) |
| 5830 | return; |
| 5831 | |
| 5832 | if (!m_customizeWorkspaces) |
| 5833 | setCustomizeWorkspaces(true); |
| 5834 | |
| 5835 | for (auto& ws : m_workspaces) { |
| 5836 | if (ws.workspaceId != workspaceId) |
| 5837 | continue; |
| 5838 | |
| 5839 | for (const auto& ref : ws.widgetRefs) |
| 5840 | if (ref.widgetType == widgetType && ref.groupUniqueId == groupUniqueId |
| 5841 | && ref.relativeIndex == relativeIndex) |
| 5842 | return; |
| 5843 | |
| 5844 | DataModel::WidgetRef ref; |
| 5845 | ref.widgetType = widgetType; |
| 5846 | ref.groupUniqueId = groupUniqueId; |
| 5847 | ref.relativeIndex = relativeIndex; |
| 5848 | ws.widgetRefs.push_back(ref); |
| 5849 | |
| 5850 | setModified(true); |
| 5851 | Q_EMIT editorWorkspacesChanged(); |
| 5852 | Q_EMIT activeWorkspacesChanged(); |
| 5853 | return; |
| 5854 | } |
| 5855 | } |
| 5856 | |
| 5857 | /** |
| 5858 | * @brief Removes a widget reference from the specified workspace by index. |
no test coverage detected