* @brief Renames a table's leaf name (no-op if the new leaf collides within the same folder). */
| 5298 | * @brief Renames a table's leaf name (no-op if the new leaf collides within the same folder). |
| 5299 | */ |
| 5300 | void DataModel::ProjectModel::renameTable(const QString& oldName, const QString& newName) |
| 5301 | { |
| 5302 | const QString n = newName.simplified().remove(QLatin1Char('/')); |
| 5303 | if (n.isEmpty()) |
| 5304 | return; |
| 5305 | |
| 5306 | const int idx = findTableIndexByPath(oldName); |
| 5307 | if (idx < 0) |
| 5308 | return; |
| 5309 | |
| 5310 | const int parent = m_tables[static_cast<size_t>(idx)].parentFolderId; |
| 5311 | for (size_t i = 0; i < m_tables.size(); ++i) |
| 5312 | if (static_cast<int>(i) != idx && m_tables[i].parentFolderId == parent && m_tables[i].name == n) |
| 5313 | return; |
| 5314 | |
| 5315 | m_tables[static_cast<size_t>(idx)].name = n; |
| 5316 | setModified(true); |
| 5317 | Q_EMIT tablesChanged(); |
| 5318 | } |
| 5319 | |
| 5320 | /** |
| 5321 | * @brief Appends a register to @p table with a unique name. |
no test coverage detected