* @brief Builds the folder hierarchy under the Workspaces root (folders first, then workspaces). */
| 1875 | * @brief Builds the folder hierarchy under the Workspaces root (folders first, then workspaces). |
| 1876 | */ |
| 1877 | void DataModel::ProjectEditor::buildWorkspaceFolderTree(QStandardItem* wsRoot, |
| 1878 | const QString& pathPrefix, |
| 1879 | QHash<QString, bool>& expandedStates) |
| 1880 | { |
| 1881 | Q_ASSERT(wsRoot != nullptr); |
| 1882 | |
| 1883 | const auto& folders = DataModel::ProjectModel::instance().editorWorkspaceFolders(); |
| 1884 | const auto& workspaces = DataModel::ProjectModel::instance().editorWorkspaces(); |
| 1885 | |
| 1886 | QHash<int, QStandardItem*> folderItems; |
| 1887 | for (const auto& f : folders) { |
| 1888 | auto* item = new QStandardItem(f.title); |
| 1889 | item->setData(f.title, TreeViewText); |
| 1890 | item->setData(QStringLiteral("qrc:/icons/project-editor/treeview/folder.svg"), TreeViewIcon); |
| 1891 | item->setData(-1, TreeViewFrameIndex); |
| 1892 | item->setData(KindWorkspaceFolder, TreeItemKind); |
| 1893 | item->setData(f.folderId, TreeItemId); |
| 1894 | item->setData(f.parentFolderId, TreeItemParentId); |
| 1895 | |
| 1896 | const QString fPath = pathPrefix + QStringLiteral("/") + folderDisplayPath(folders, f.folderId); |
| 1897 | restoreExpandedStateMap(item, expandedStates, fPath); |
| 1898 | folderItems.insert(f.folderId, item); |
| 1899 | } |
| 1900 | |
| 1901 | for (const auto& f : folders) { |
| 1902 | auto* item = folderItems.value(f.folderId); |
| 1903 | QStandardItem* parent = (f.parentFolderId != -1 && folderItems.contains(f.parentFolderId)) |
| 1904 | ? folderItems.value(f.parentFolderId) |
| 1905 | : wsRoot; |
| 1906 | parent->appendRow(item); |
| 1907 | m_workspaceFolderItems.insert(item, f.folderId); |
| 1908 | } |
| 1909 | |
| 1910 | for (const auto& ws : workspaces) { |
| 1911 | auto* wsItem = createWorkspaceItem(ws); |
| 1912 | QStandardItem* parent = (ws.parentFolderId != -1 && folderItems.contains(ws.parentFolderId)) |
| 1913 | ? folderItems.value(ws.parentFolderId) |
| 1914 | : wsRoot; |
| 1915 | parent->appendRow(wsItem); |
| 1916 | m_workspaceItems.insert(wsItem, ws.workspaceId); |
| 1917 | } |
| 1918 | } |
| 1919 | |
| 1920 | /** |
| 1921 | * @brief Appends the "Workspaces" subtree, filtered by the current search query. |
nothing calls this directly
no test coverage detected