MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / renameTable

Method renameTable

app/src/DataModel/ProjectModel.cpp:5300–5318  ·  view source on GitHub ↗

* @brief Renames a table's leaf name (no-op if the new leaf collides within the same folder). */

Source from the content-addressed store, hash-verified

5298 * @brief Renames a table's leaf name (no-op if the new leaf collides within the same folder).
5299 */
5300void 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.

Callers 1

tableRenameMethod · 0.80

Calls 3

isEmptyMethod · 0.80
removeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected