diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2018-04-26 16:48:12 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2018-05-04 09:03:05 +0000 |
commit | 522492d85d4ef1db119b4fbfa5d33f9166e7a206 (patch) | |
tree | c040f6c3d5799c17d01ae90380a0545fcafdb1d5 /src/plugins/nim | |
parent | bdd2dd371ecd6d6b61f913050f3d1dd130846caa (diff) |
NimProject: Use FolderNode::addNestedNodes that takes unique_ptrs
Change-Id: Ibd8fb90ae38f2f3ae6e522a78c68632b4b2f0c38
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/nim')
-rw-r--r-- | src/plugins/nim/project/nimproject.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/plugins/nim/project/nimproject.cpp b/src/plugins/nim/project/nimproject.cpp index b0d7191c42..99fd84afa2 100644 --- a/src/plugins/nim/project/nimproject.cpp +++ b/src/plugins/nim/project/nimproject.cpp @@ -129,19 +129,21 @@ void NimProject::updateProject() const QStringList oldFiles = m_files; m_files.clear(); - QList<FileNode *> fileNodes = Utils::filtered(m_futureWatcher.future().result(), - [&](const FileNode *fn) { + std::vector<std::unique_ptr<FileNode>> fileNodes + = 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 QString fileName = path.fileName(); - const bool keep = !m_excludedFiles.contains(path.toString()) - && !fileName.endsWith(".nimproject", HostOsInfo::fileNameCaseSensitivity()) - && !fileName.contains(".nimproject.user", HostOsInfo::fileNameCaseSensitivity()); - if (!keep) - delete fn; - return keep; + return m_excludedFiles.contains(path.toString()) + || fileName.endsWith(".nimproject", HostOsInfo::fileNameCaseSensitivity()) + || fileName.contains(".nimproject.user", HostOsInfo::fileNameCaseSensitivity()); }); - 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; }); if (oldFiles == m_files) @@ -149,7 +151,7 @@ void NimProject::updateProject() auto newRoot = std::make_unique<NimProjectNode>(*this, projectDirectory()); newRoot->setDisplayName(displayName()); - newRoot->addNestedNodes(fileNodes); + newRoot->addNestedNodes(std::move(fileNodes)); setRootProjectNode(std::move(newRoot)); emitParsingFinished(true); } |