* @brief Appends a copy of the currently selected dataset to its parent group. */
| 4282 | * @brief Appends a copy of the currently selected dataset to its parent group. |
| 4283 | */ |
| 4284 | void DataModel::ProjectModel::duplicateCurrentDataset() |
| 4285 | { |
| 4286 | auto dataset = m_selectedDataset; |
| 4287 | |
| 4288 | if (dataset.groupId < 0 || static_cast<size_t>(dataset.groupId) >= m_groups.size()) |
| 4289 | return; |
| 4290 | |
| 4291 | dataset.index = nextDatasetIndex(); |
| 4292 | dataset.datasetId = m_groups[dataset.groupId].datasets.size(); |
| 4293 | dataset.uniqueId = allocateUniqueId(); |
| 4294 | |
| 4295 | const auto& siblings = m_groups[dataset.groupId].datasets; |
| 4296 | QStringList existingTitles; |
| 4297 | existingTitles.reserve(static_cast<int>(siblings.size())); |
| 4298 | for (const auto& d : siblings) |
| 4299 | existingTitles.append(d.title); |
| 4300 | |
| 4301 | dataset.title = nextDuplicateTitle(m_selectedDataset.title, existingTitles); |
| 4302 | |
| 4303 | m_groups[dataset.groupId].datasets.push_back(dataset); |
| 4304 | m_selectedDataset = dataset; |
| 4305 | |
| 4306 | Q_EMIT groupsChanged(); |
| 4307 | Q_EMIT datasetAdded(dataset.groupId, |
| 4308 | static_cast<int>(m_groups[dataset.groupId].datasets.size()) - 1); |
| 4309 | setModified(true); |
| 4310 | } |
| 4311 | |
| 4312 | /** |
| 4313 | * @brief Ensures a compatible group is selected before adding a dataset; honors sourceId scoping. |
nothing calls this directly
no test coverage detected