MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / addNestedNodes

Method addNestedNodes

src/plugins/smartut/common/itemnode.cpp:169–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169void FolderNode::addNestedNodes(std::vector<std::unique_ptr<FileNode>> &&files,
170 const QString &workspace,
171 const FolderNodeFactory &factory)
172{
173 using DirWithNodes = std::pair<QString, std::vector<std::unique_ptr<FileNode>>>;
174 std::vector<DirWithNodes> fileNodesPerDir;
175 for (auto &f : files) {
176 if (!f->filePath().startsWith(workspace))
177 continue;
178
179 QFileInfo fileInfo(f->filePath());
180 const QString parentDir = fileInfo.absolutePath();
181 const auto it = std::lower_bound(fileNodesPerDir.begin(), fileNodesPerDir.end(), parentDir,
182 [](const DirWithNodes &nad, const QString &dir) { return nad.first < dir; });
183 if (it != fileNodesPerDir.end() && it->first == parentDir) {
184 it->second.emplace_back(std::move(f));
185 } else {
186 DirWithNodes dirWithNodes;
187 dirWithNodes.first = parentDir;
188 dirWithNodes.second.emplace_back(std::move(f));
189 fileNodesPerDir.insert(it, std::move(dirWithNodes));
190 }
191 }
192
193 for (DirWithNodes &dirWithNodes : fileNodesPerDir) {
194 FolderNode *const folderNode = Utils::recursiveFindOrCreateFolderNode(this, dirWithNodes.first,
195 workspace, factory);
196 for (auto &f : dirWithNodes.second)
197 folderNode->addNode(std::move(f));
198 }
199}
200
201QIcon FolderNode::icon() const
202{

Callers 2

createProjectNodeMethod · 0.80
setProjectListMethod · 0.80

Calls 6

startsWithMethod · 0.80
insertMethod · 0.80
addNodeMethod · 0.80
filePathMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected