* @brief Duplicates the source with the given @p sourceId. */
| 1598 | * @brief Duplicates the source with the given @p sourceId. |
| 1599 | */ |
| 1600 | void DataModel::ProjectModel::duplicateSource(int sourceId) |
| 1601 | { |
| 1602 | #ifndef BUILD_COMMERCIAL |
| 1603 | (void)sourceId; |
| 1604 | return; |
| 1605 | #else |
| 1606 | if (sourceId < 0 || sourceId >= static_cast<int>(m_sources.size())) |
| 1607 | return; |
| 1608 | |
| 1609 | DataModel::Source copy = m_sources[sourceId]; |
| 1610 | copy.sourceId = static_cast<int>(m_sources.size()); |
| 1611 | copy.connectionSettings = QJsonObject(); |
| 1612 | |
| 1613 | QStringList existingTitles; |
| 1614 | existingTitles.reserve(static_cast<int>(m_sources.size())); |
| 1615 | for (const auto& s : m_sources) |
| 1616 | existingTitles.append(s.title); |
| 1617 | |
| 1618 | copy.title = nextDuplicateTitle(m_sources[sourceId].title, existingTitles); |
| 1619 | |
| 1620 | m_sources.push_back(copy); |
| 1621 | setModified(true); |
| 1622 | Q_EMIT sourcesChanged(); |
| 1623 | Q_EMIT sourceStructureChanged(); |
| 1624 | Q_EMIT sourceAdded(copy.sourceId); |
| 1625 | #endif |
| 1626 | } |
| 1627 | |
| 1628 | /** |
| 1629 | * @brief Updates the source with the given @p sourceId. |
nothing calls this directly
no test coverage detected