forked from qt-creator/qt-creator
NimProject: Use FolderNode::addNestedNodes that takes unique_ptrs
Change-Id: Ibd8fb90ae38f2f3ae6e522a78c68632b4b2f0c38 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -129,19 +129,21 @@ void NimProject::updateProject()
|
|||||||
const QStringList oldFiles = m_files;
|
const QStringList oldFiles = m_files;
|
||||||
m_files.clear();
|
m_files.clear();
|
||||||
|
|
||||||
QList<FileNode *> fileNodes = Utils::filtered(m_futureWatcher.future().result(),
|
std::vector<std::unique_ptr<FileNode>> fileNodes
|
||||||
[&](const FileNode *fn) {
|
= transform<std::vector>(m_futureWatcher.future().result(),
|
||||||
|
[](FileNode *fn) { return std::unique_ptr<FileNode>(fn); });
|
||||||
|
std::remove_if(std::begin(fileNodes), std::end(fileNodes),
|
||||||
|
[this](const std::unique_ptr<FileNode> &fn) {
|
||||||
const FileName path = fn->filePath();
|
const FileName path = fn->filePath();
|
||||||
const QString fileName = path.fileName();
|
const QString fileName = path.fileName();
|
||||||
const bool keep = !m_excludedFiles.contains(path.toString())
|
return m_excludedFiles.contains(path.toString())
|
||||||
&& !fileName.endsWith(".nimproject", HostOsInfo::fileNameCaseSensitivity())
|
|| fileName.endsWith(".nimproject", HostOsInfo::fileNameCaseSensitivity())
|
||||||
&& !fileName.contains(".nimproject.user", HostOsInfo::fileNameCaseSensitivity());
|
|| fileName.contains(".nimproject.user", HostOsInfo::fileNameCaseSensitivity());
|
||||||
if (!keep)
|
|
||||||
delete fn;
|
|
||||||
return keep;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
m_files = Utils::transform(fileNodes, [](const FileNode *fn) { return fn->filePath().toString(); });
|
m_files = transform<QList>(fileNodes, [](const std::unique_ptr<FileNode> &fn) {
|
||||||
|
return fn->filePath().toString();
|
||||||
|
});
|
||||||
Utils::sort(m_files, [](const QString &a, const QString &b) { return a < b; });
|
Utils::sort(m_files, [](const QString &a, const QString &b) { return a < b; });
|
||||||
|
|
||||||
if (oldFiles == m_files)
|
if (oldFiles == m_files)
|
||||||
@@ -149,7 +151,7 @@ void NimProject::updateProject()
|
|||||||
|
|
||||||
auto newRoot = std::make_unique<NimProjectNode>(*this, projectDirectory());
|
auto newRoot = std::make_unique<NimProjectNode>(*this, projectDirectory());
|
||||||
newRoot->setDisplayName(displayName());
|
newRoot->setDisplayName(displayName());
|
||||||
newRoot->addNestedNodes(fileNodes);
|
newRoot->addNestedNodes(std::move(fileNodes));
|
||||||
setRootProjectNode(std::move(newRoot));
|
setRootProjectNode(std::move(newRoot));
|
||||||
emitParsingFinished(true);
|
emitParsingFinished(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user