Commit a8c2abea authored by Tobias Hunger's avatar Tobias Hunger

CMake: Register files with the locator again

Change-Id: Ib3a42c22bfac18630b968cfd78744c7827ef7fad
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 722707b2
......@@ -37,6 +37,7 @@
#include <projectexplorer/taskhub.h>
#include <utils/algorithm.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/synchronousprocess.h>
......@@ -203,6 +204,11 @@ QList<ProjectExplorer::FileNode *> BuildDirManager::files() const
return m_files;
}
void BuildDirManager::clearFiles()
{
m_files.clear();
}
CMakeConfig BuildDirManager::configuration() const
{
return parseConfiguration();
......@@ -220,8 +226,7 @@ void BuildDirManager::extractData()
m_files.append(new ProjectExplorer::FileNode(topCMake, ProjectExplorer::ProjectFileType, false));
m_watchedFiles.insert(topCMake);
foreach (const QString &file, m_watcher->files())
m_watcher->removePath(file);
m_watcher->removePaths(m_watcher->files());
// Find cbp file
QString cbpFile = CMakeManager::findCbpFile(m_buildDir.toString());
......@@ -250,8 +255,9 @@ void BuildDirManager::extractData()
}
m_watchedFiles = projectFiles;
foreach (const Utils::FileName &f, m_watchedFiles)
m_watcher->addPath(f.toString());
const QStringList toWatch
= Utils::transform(m_watchedFiles.toList(), [](const Utils::FileName &fn) { return fn.toString(); });
m_watcher->addPaths(toWatch);
m_buildTargets = cbpparser.buildTargets();
}
......
......@@ -81,6 +81,7 @@ public:
QString projectName() const;
QList<CMakeBuildTarget> buildTargets() const;
QList<ProjectExplorer::FileNode *> files() const;
void clearFiles();
CMakeConfig configuration() const;
signals:
......
......@@ -256,6 +256,7 @@ void CMakeProject::parseCMakeOutput()
rootProjectNode()->setDisplayName(m_buildDirManager->projectName());
buildTree(static_cast<CMakeProjectNode *>(rootProjectNode()), m_buildDirManager->files());
m_buildDirManager->clearFiles(); // Some of the FileNodes in files() were deleted!
updateApplicationAndDeploymentTargets();
......@@ -449,7 +450,7 @@ bool CMakeProject::hasBuildTarget(const QString &title) const
return Utils::anyOf(buildTargets(), [title](const CMakeBuildTarget &ct) { return ct.title == title; });
}
void CMakeProject::gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list)
void CMakeProject::gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list) const
{
foreach (ProjectExplorer::FolderNode *folder, parent->subFolderNodes())
gatherFileNodes(folder, list);
......@@ -539,8 +540,25 @@ QString CMakeProject::displayName() const
QStringList CMakeProject::files(FilesMode fileMode) const
{
Q_UNUSED(fileMode)
return m_files;
QStringList result;
if (m_buildDirManager) {
QList<FileNode *> nodes;
gatherFileNodes(rootProjectNode(), nodes);
nodes = Utils::filtered(nodes, [fileMode](const FileNode *fn) {
const bool isGenerated = fn->isGenerated();
switch (fileMode)
{
case ProjectExplorer::Project::SourceFiles:
return !isGenerated;
case ProjectExplorer::Project::GeneratedFiles:
return isGenerated;
case ProjectExplorer::Project::AllFiles:
return true;
}
});
result = Utils::transform(nodes, [fileMode](const FileNode* fn) { return fn->filePath().toString(); });
}
return result;
}
Project::RestoreResult CMakeProject::fromMap(const QVariantMap &map, QString *errorMessage)
......@@ -712,7 +730,7 @@ void CMakeProject::createUiCodeModelSupport()
QHash<QString, QString> uiFileHash;
// Find all ui files
foreach (const QString &uiFile, m_files) {
foreach (const QString &uiFile, files(SourceFiles)) {
if (uiFile.endsWith(QLatin1String(".ui")))
uiFileHash.insert(uiFile, uiHeaderFile(uiFile));
}
......
......@@ -139,7 +139,7 @@ private:
void updateRunConfigurations();
void buildTree(Internal::CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list);
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list) const;
ProjectExplorer::FolderNode *findOrCreateFolder(Internal::CMakeProjectNode *rootNode, QString directory);
void createUiCodeModelSupport();
QString uiHeaderFile(const QString &uiFile);
......@@ -151,7 +151,6 @@ private:
Internal::BuildDirManager *m_buildDirManager = 0;
// TODO probably need a CMake specific node structure
QStringList m_files;
QList<CMakeBuildTarget> m_buildTargets;
QFuture<void> m_codeModelFuture;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment