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

Method moveTableToFolder

app/src/DataModel/ProjectModel.cpp:6626–6647  ·  view source on GitHub ↗

* @brief Files a table into folder @p parentFolderId; rejects a leaf-name collision in the target. */

Source from the content-addressed store, hash-verified

6624 * @brief Files a table into folder @p parentFolderId; rejects a leaf-name collision in the target.
6625 */
6626void DataModel::ProjectModel::moveTableToFolder(const QString& tablePath, int parentFolderId)
6627{
6628 if (parentFolderId != -1 && !folderExists(m_tableFolders, parentFolderId))
6629 return;
6630
6631 const int idx = findTableIndexByPath(tablePath);
6632 if (idx < 0)
6633 return;
6634
6635 auto& table = m_tables[static_cast<size_t>(idx)];
6636 if (table.parentFolderId == parentFolderId)
6637 return;
6638
6639 for (size_t i = 0; i < m_tables.size(); ++i)
6640 if (static_cast<int>(i) != idx && m_tables[i].parentFolderId == parentFolderId
6641 && m_tables[i].name == table.name)
6642 return;
6643
6644 table.parentFolderId = parentFolderId;
6645 setModified(true);
6646 Q_EMIT tablesChanged();
6647}
6648
6649/**
6650 * @brief Re-parents a table folder, rejecting a cyclic move into its own subtree.

Callers

nothing calls this directly

Calls 2

folderExistsFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected