forked from qt-creator/qt-creator
ProjectExplorer: Handle project file list globally
Handle the generation of the list of files in a project globally, based on the project tree. Creator now has the concept of TreeManagers which can enrich the project tree with additional data (e.g. the files found in a resource file), which the project does not necessarily know about. So use that tree to find the files that belong to a project instead of implementing similar features in each project. Change-Id: Ia375a914a1f2c0adaa427f9eda834eec2db07f68 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Marco Benelli <marco.benelli@qt.io>
This commit is contained in:
@@ -101,12 +101,6 @@ QString AutotoolsProject::defaultBuildDirectory(const QString &projectPath)
|
|||||||
return QFileInfo(projectPath).absolutePath();
|
return QFileInfo(projectPath).absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AutotoolsProject::files(FilesMode fileMode) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(fileMode);
|
|
||||||
return m_files;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function, is called at the very beginning, to
|
// This function, is called at the very beginning, to
|
||||||
// restore the settings if there are some stored.
|
// restore the settings if there are some stored.
|
||||||
Project::RestoreResult AutotoolsProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
Project::RestoreResult AutotoolsProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
||||||
|
@@ -58,7 +58,6 @@ public:
|
|||||||
~AutotoolsProject() override;
|
~AutotoolsProject() override;
|
||||||
|
|
||||||
QString displayName() const override;
|
QString displayName() const override;
|
||||||
QStringList files(FilesMode fileMode) const override;
|
|
||||||
static QString defaultBuildDirectory(const QString &projectPath);
|
static QString defaultBuildDirectory(const QString &projectPath);
|
||||||
QStringList buildTargets() const;
|
QStringList buildTargets() const;
|
||||||
|
|
||||||
|
@@ -306,21 +306,6 @@ QString CMakeProject::displayName() const
|
|||||||
return root ? root->displayName() : projectDirectory().fileName();
|
return root ? root->displayName() : projectDirectory().fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CMakeProject::files(FilesMode fileMode) const
|
|
||||||
{
|
|
||||||
QStringList result;
|
|
||||||
if (ProjectNode *rpn = rootProjectNode()) {
|
|
||||||
rpn->forEachNode([&](const FileNode *fn) {
|
|
||||||
const bool isGenerated = fn->isGenerated();
|
|
||||||
if ((fileMode & Project::SourceFiles) && !isGenerated)
|
|
||||||
result.append(fn->filePath().toString());
|
|
||||||
if ((fileMode & Project::GeneratedFiles) && isGenerated)
|
|
||||||
result.append(fn->filePath().toString());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Project::RestoreResult CMakeProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
Project::RestoreResult CMakeProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
||||||
{
|
{
|
||||||
RestoreResult result = Project::fromMap(map, errorMessage);
|
RestoreResult result = Project::fromMap(map, errorMessage);
|
||||||
|
@@ -88,7 +88,6 @@ public:
|
|||||||
|
|
||||||
QString displayName() const final;
|
QString displayName() const final;
|
||||||
|
|
||||||
QStringList files(FilesMode fileMode) const final;
|
|
||||||
QStringList buildTargetTitles(bool runnable = false) const;
|
QStringList buildTargetTitles(bool runnable = false) const;
|
||||||
bool hasBuildTarget(const QString &title) const;
|
bool hasBuildTarget(const QString &title) const;
|
||||||
|
|
||||||
|
@@ -45,8 +45,6 @@ public:
|
|||||||
|
|
||||||
QString displayName() const override { return m_name; }
|
QString displayName() const override { return m_name; }
|
||||||
|
|
||||||
QStringList files(FilesMode fileMode) const override { Q_UNUSED(fileMode); return QStringList(); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
};
|
};
|
||||||
|
@@ -249,9 +249,6 @@ void GenericProject::parseProject(RefreshOptions options)
|
|||||||
// TODO: Possibly load some configuration from the project file
|
// TODO: Possibly load some configuration from the project file
|
||||||
//QSettings projectInfo(m_fileName, QSettings::IniFormat);
|
//QSettings projectInfo(m_fileName, QSettings::IniFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options & Files)
|
|
||||||
emit fileListChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericProject::refresh(RefreshOptions options)
|
void GenericProject::refresh(RefreshOptions options)
|
||||||
@@ -261,7 +258,7 @@ void GenericProject::refresh(RefreshOptions options)
|
|||||||
if (options & Files) {
|
if (options & Files) {
|
||||||
auto newRoot = new GenericProjectNode(this);
|
auto newRoot = new GenericProjectNode(this);
|
||||||
|
|
||||||
for (const QString &f : files()) {
|
for (const QString &f : m_files) {
|
||||||
FileType fileType = FileType::Source; // ### FIXME
|
FileType fileType = FileType::Source; // ### FIXME
|
||||||
if (f.endsWith(".qrc"))
|
if (f.endsWith(".qrc"))
|
||||||
fileType = FileType::Resource;
|
fileType = FileType::Resource;
|
||||||
@@ -364,7 +361,7 @@ void GenericProject::refreshCppCodeModel()
|
|||||||
rpp.setQtVersion(activeQtVersion);
|
rpp.setQtVersion(activeQtVersion);
|
||||||
rpp.setIncludePaths(projectIncludePaths());
|
rpp.setIncludePaths(projectIncludePaths());
|
||||||
rpp.setConfigFileName(configFileName());
|
rpp.setConfigFileName(configFileName());
|
||||||
rpp.setFiles(files());
|
rpp.setFiles(m_files);
|
||||||
|
|
||||||
const CppTools::ProjectUpdateInfo projectInfoUpdate(this, cToolChain, cxxToolChain, k, {rpp});
|
const CppTools::ProjectUpdateInfo projectInfoUpdate(this, cToolChain, cxxToolChain, k, {rpp});
|
||||||
m_cppCodeModelUpdater->update(projectInfoUpdate);
|
m_cppCodeModelUpdater->update(projectInfoUpdate);
|
||||||
@@ -397,22 +394,11 @@ QStringList GenericProject::projectIncludePaths() const
|
|||||||
return m_projectIncludePaths;
|
return m_projectIncludePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList GenericProject::files() const
|
|
||||||
{
|
|
||||||
return m_files;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString GenericProject::displayName() const
|
QString GenericProject::displayName() const
|
||||||
{
|
{
|
||||||
return projectFilePath().toFileInfo().completeBaseName();
|
return projectFilePath().toFileInfo().completeBaseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList GenericProject::files(FilesMode fileMode) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(fileMode);
|
|
||||||
return m_files;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList GenericProject::buildTargets() const
|
QStringList GenericProject::buildTargets() const
|
||||||
{
|
{
|
||||||
const QStringList targets = { "all", "clean" };
|
const QStringList targets = { "all", "clean" };
|
||||||
|
@@ -57,8 +57,6 @@ public:
|
|||||||
|
|
||||||
QString displayName() const override;
|
QString displayName() const override;
|
||||||
|
|
||||||
QStringList files(FilesMode fileMode) const override;
|
|
||||||
|
|
||||||
QStringList buildTargets() const;
|
QStringList buildTargets() const;
|
||||||
|
|
||||||
bool addFiles(const QStringList &filePaths);
|
bool addFiles(const QStringList &filePaths);
|
||||||
@@ -75,7 +73,6 @@ public:
|
|||||||
void refresh(RefreshOptions options);
|
void refresh(RefreshOptions options);
|
||||||
|
|
||||||
QStringList projectIncludePaths() const;
|
QStringList projectIncludePaths() const;
|
||||||
QStringList files() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
|
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
|
||||||
|
@@ -87,7 +87,8 @@ void GenericProjectPlugin::editFiles()
|
|||||||
if (!genericProject)
|
if (!genericProject)
|
||||||
return;
|
return;
|
||||||
SelectableFilesDialogEditFiles sfd(genericProject->projectDirectory(),
|
SelectableFilesDialogEditFiles sfd(genericProject->projectDirectory(),
|
||||||
Utils::transform(genericProject->files(), [](const QString &f) { return Utils::FileName::fromString(f); }),
|
Utils::transform(genericProject->files(Project::AllFiles),
|
||||||
|
[](const QString &f) { return Utils::FileName::fromString(f); }),
|
||||||
ICore::mainWindow());
|
ICore::mainWindow());
|
||||||
if (sfd.exec() == QDialog::Accepted)
|
if (sfd.exec() == QDialog::Accepted)
|
||||||
genericProject->setFiles(Utils::transform(sfd.selectedFiles(), &Utils::FileName::toString));
|
genericProject->setFiles(Utils::transform(sfd.selectedFiles(), &Utils::FileName::toString));
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/kit.h>
|
#include <projectexplorer/kit.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
@@ -73,11 +74,6 @@ QString NimProject::displayName() const
|
|||||||
return projectFilePath().toFileInfo().completeBaseName();
|
return projectFilePath().toFileInfo().completeBaseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList NimProject::files(FilesMode) const
|
|
||||||
{
|
|
||||||
return m_files;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NimProject::needsConfiguration() const
|
bool NimProject::needsConfiguration() const
|
||||||
{
|
{
|
||||||
return targets().empty();
|
return targets().empty();
|
||||||
@@ -133,7 +129,7 @@ void NimProject::collectProjectFiles()
|
|||||||
|
|
||||||
void NimProject::updateProject()
|
void NimProject::updateProject()
|
||||||
{
|
{
|
||||||
QStringList oldFiles = m_files;
|
const QStringList oldFiles = m_files;
|
||||||
m_files.clear();
|
m_files.clear();
|
||||||
|
|
||||||
QList<FileNode *> fileNodes = Utils::filtered(m_futureWatcher.future().result(),
|
QList<FileNode *> fileNodes = Utils::filtered(m_futureWatcher.future().result(),
|
||||||
@@ -158,9 +154,6 @@ void NimProject::updateProject()
|
|||||||
newRoot->setDisplayName(displayName());
|
newRoot->setDisplayName(displayName());
|
||||||
newRoot->addNestedNodes(fileNodes);
|
newRoot->addNestedNodes(fileNodes);
|
||||||
setRootProjectNode(newRoot);
|
setRootProjectNode(newRoot);
|
||||||
|
|
||||||
emit fileListChanged();
|
|
||||||
|
|
||||||
emit parsingFinished();
|
emit parsingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,12 +175,10 @@ bool NimProject::supportsKit(Kit *k, QString *errorMessage) const
|
|||||||
|
|
||||||
FileNameList NimProject::nimFiles() const
|
FileNameList NimProject::nimFiles() const
|
||||||
{
|
{
|
||||||
FileNameList result;
|
const QStringList nim = files(AllFiles, [](const ProjectExplorer::FileNode *fn) {
|
||||||
rootProjectNode()->forEachNode([&](FileNode *file) {
|
return fn->filePath().endsWith(".nim");
|
||||||
if (file->displayName().endsWith(QLatin1String(".nim")))
|
|
||||||
result.append(file->filePath());
|
|
||||||
});
|
});
|
||||||
return result;
|
return Utils::transform(nim, [](const QString &fp) { return Utils::FileName::fromString(fp); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap NimProject::toMap() const
|
QVariantMap NimProject::toMap() const
|
||||||
@@ -203,4 +194,4 @@ Project::RestoreResult NimProject::fromMap(const QVariantMap &map, QString *erro
|
|||||||
return Project::fromMap(map, errorMessage);
|
return Project::fromMap(map, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace Nim
|
||||||
|
@@ -42,7 +42,6 @@ public:
|
|||||||
explicit NimProject(const Utils::FileName &fileName);
|
explicit NimProject(const Utils::FileName &fileName);
|
||||||
|
|
||||||
QString displayName() const override;
|
QString displayName() const override;
|
||||||
QStringList files(FilesMode) const override;
|
|
||||||
bool needsConfiguration() const override;
|
bool needsConfiguration() const override;
|
||||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
||||||
Utils::FileNameList nimFiles() const;
|
Utils::FileNameList nimFiles() const;
|
||||||
|
@@ -476,6 +476,7 @@ void Project::setRootProjectNode(ProjectNode *root)
|
|||||||
if (root)
|
if (root)
|
||||||
root->setParentFolderNode(&d->m_containerNode);
|
root->setParentFolderNode(&d->m_containerNode);
|
||||||
ProjectTree::emitSubtreeChanged(root);
|
ProjectTree::emitSubtreeChanged(root);
|
||||||
|
emit fileListChanged();
|
||||||
|
|
||||||
delete oldNode;
|
delete oldNode;
|
||||||
}
|
}
|
||||||
@@ -524,6 +525,25 @@ Project::RestoreResult Project::restoreSettings(QString *errorMessage)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList Project::files(Project::FilesMode fileMode,
|
||||||
|
const std::function<bool (const FileNode *)> &filter) const
|
||||||
|
{
|
||||||
|
QStringList result;
|
||||||
|
|
||||||
|
if (!rootProjectNode())
|
||||||
|
return result;
|
||||||
|
|
||||||
|
rootProjectNode()->forEachNode([&](const FileNode *fn) {
|
||||||
|
if (filter && !filter(fn))
|
||||||
|
return;
|
||||||
|
if ((fileMode == AllFiles)
|
||||||
|
|| (fileMode == SourceFiles && !fn->isGenerated())
|
||||||
|
|| (fileMode == GeneratedFiles && fn->isGenerated()))
|
||||||
|
result.append(fn->filePath().toString());
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Serializes all data into a QVariantMap.
|
Serializes all data into a QVariantMap.
|
||||||
|
@@ -36,6 +36,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IDocument;
|
class IDocument;
|
||||||
class Context;
|
class Context;
|
||||||
@@ -47,6 +49,7 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
class BuildInfo;
|
class BuildInfo;
|
||||||
class EditorConfiguration;
|
class EditorConfiguration;
|
||||||
|
class FileNode;
|
||||||
class NamedWidget;
|
class NamedWidget;
|
||||||
class ProjectImporter;
|
class ProjectImporter;
|
||||||
class ProjectNode;
|
class ProjectNode;
|
||||||
@@ -112,7 +115,8 @@ public:
|
|||||||
GeneratedFiles = 0x2,
|
GeneratedFiles = 0x2,
|
||||||
AllFiles = SourceFiles | GeneratedFiles
|
AllFiles = SourceFiles | GeneratedFiles
|
||||||
};
|
};
|
||||||
virtual QStringList files(FilesMode fileMode) const = 0;
|
virtual QStringList files(FilesMode fileMode,
|
||||||
|
const std::function<bool(const FileNode *)> &filter = {}) const;
|
||||||
virtual QStringList filesGeneratedFrom(const QString &sourceFile) const;
|
virtual QStringList filesGeneratedFrom(const QString &sourceFile) const;
|
||||||
|
|
||||||
static QString makeUnique(const QString &preferredName, const QStringList &usedNames);
|
static QString makeUnique(const QString &preferredName, const QStringList &usedNames);
|
||||||
|
@@ -96,9 +96,6 @@ public:
|
|||||||
|
|
||||||
QString displayName() const override;
|
QString displayName() const override;
|
||||||
|
|
||||||
QStringList files(FilesMode) const override { return m_files; }
|
|
||||||
QStringList files() const { return m_files; }
|
|
||||||
|
|
||||||
bool addFiles(const QStringList &filePaths);
|
bool addFiles(const QStringList &filePaths);
|
||||||
bool removeFiles(const QStringList &filePaths);
|
bool removeFiles(const QStringList &filePaths);
|
||||||
bool setFiles(const QStringList &filePaths);
|
bool setFiles(const QStringList &filePaths);
|
||||||
@@ -356,7 +353,7 @@ public:
|
|||||||
|
|
||||||
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
||||||
QList<Core::Id> allIds;
|
QList<Core::Id> allIds;
|
||||||
foreach (const QString &file, project->files())
|
foreach (const QString &file, project->files(ProjectExplorer::Project::AllFiles))
|
||||||
allIds.append(idFromScript(file));
|
allIds.append(idFromScript(file));
|
||||||
return allIds;
|
return allIds;
|
||||||
}
|
}
|
||||||
@@ -371,7 +368,7 @@ public:
|
|||||||
if (!canHandle(parent))
|
if (!canHandle(parent))
|
||||||
return false;
|
return false;
|
||||||
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
||||||
return project->files().contains(scriptFromId(id));
|
return project->files(ProjectExplorer::Project::AllFiles).contains(scriptFromId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canRestore(Target *parent, const QVariantMap &map) const override
|
bool canRestore(Target *parent, const QVariantMap &map) const override
|
||||||
@@ -533,7 +530,6 @@ void PythonProject::parseProject()
|
|||||||
m_rawFileList = readLines(projectFilePath().toString());
|
m_rawFileList = readLines(projectFilePath().toString());
|
||||||
m_rawFileList << projectFilePath().fileName();
|
m_rawFileList << projectFilePath().fileName();
|
||||||
m_files = processEntries(m_rawFileList, &m_rawListEntries);
|
m_files = processEntries(m_rawFileList, &m_rawListEntries);
|
||||||
emit fileListChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -175,58 +175,6 @@ void QbsProject::projectLoaded()
|
|||||||
m_parsingDelay.start(0);
|
m_parsingDelay.start(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void collectFilesForProject(const qbs::ProjectData &project, Project::FilesMode mode,
|
|
||||||
QSet<QString> &result)
|
|
||||||
{
|
|
||||||
if (mode & Project::SourceFiles)
|
|
||||||
result.insert(project.location().filePath());
|
|
||||||
|
|
||||||
foreach (const qbs::ProductData &prd, project.products()) {
|
|
||||||
if (mode & Project::SourceFiles) {
|
|
||||||
foreach (const qbs::GroupData &grp, prd.groups()) {
|
|
||||||
foreach (const QString &file, grp.allFilePaths())
|
|
||||||
result.insert(file);
|
|
||||||
result.insert(grp.location().filePath());
|
|
||||||
}
|
|
||||||
result.insert(prd.location().filePath());
|
|
||||||
}
|
|
||||||
if (mode & Project::GeneratedFiles) {
|
|
||||||
foreach (const qbs::ProductData &prd, project.products()) {
|
|
||||||
foreach (const qbs::ArtifactData &artifact, prd.generatedArtifacts()) {
|
|
||||||
// A list of human-readable file types that we can reasonably expect
|
|
||||||
// to get generated during a build. Extend as needed.
|
|
||||||
static const QSet<QString> sourceTags = {
|
|
||||||
QLatin1String("c"), QLatin1String("cpp"), QLatin1String("hpp"),
|
|
||||||
QLatin1String("objc"), QLatin1String("objcpp"),
|
|
||||||
QLatin1String("c_pch_src"), QLatin1String("cpp_pch_src"),
|
|
||||||
QLatin1String("objc_pch_src"), QLatin1String("objcpp_pch_src"),
|
|
||||||
QLatin1String("asm"), QLatin1String("asm_cpp"),
|
|
||||||
QLatin1String("linkerscript"),
|
|
||||||
QLatin1String("qrc"), QLatin1String("java.java")
|
|
||||||
};
|
|
||||||
if (artifact.fileTags().toSet().intersects(sourceTags))
|
|
||||||
result.insert(artifact.filePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (const qbs::ProjectData &subProject, project.subProjects())
|
|
||||||
collectFilesForProject(subProject, mode, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList QbsProject::files(Project::FilesMode fileMode) const
|
|
||||||
{
|
|
||||||
qCDebug(qbsPmLog) << Q_FUNC_INFO << fileMode << m_qbsProject.isValid() << isParsing();
|
|
||||||
if (!m_qbsProject.isValid() || isParsing())
|
|
||||||
return QStringList();
|
|
||||||
QSet<QString> result;
|
|
||||||
collectFilesForProject(m_projectData, fileMode, result);
|
|
||||||
result.unite(m_qbsProject.buildSystemFiles());
|
|
||||||
qCDebug(qbsPmLog) << "file count:" << result.count();
|
|
||||||
return result.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList QbsProject::filesGeneratedFrom(const QString &sourceFile) const
|
QStringList QbsProject::filesGeneratedFrom(const QString &sourceFile) const
|
||||||
{
|
{
|
||||||
QStringList generated;
|
QStringList generated;
|
||||||
@@ -312,7 +260,6 @@ bool QbsProject::addFilesToProduct(const QStringList &filePaths,
|
|||||||
if (notAdded->count() != filePaths.count()) {
|
if (notAdded->count() != filePaths.count()) {
|
||||||
m_projectData = m_qbsProject.projectData();
|
m_projectData = m_qbsProject.projectData();
|
||||||
setRootProjectNode(Internal::QbsNodeTreeBuilder::buildTree(this));
|
setRootProjectNode(Internal::QbsNodeTreeBuilder::buildTree(this));
|
||||||
emit fileListChanged();
|
|
||||||
}
|
}
|
||||||
return notAdded->isEmpty();
|
return notAdded->isEmpty();
|
||||||
}
|
}
|
||||||
|
@@ -64,7 +64,6 @@ public:
|
|||||||
QString displayName() const override;
|
QString displayName() const override;
|
||||||
QbsRootProjectNode *rootProjectNode() const override;
|
QbsRootProjectNode *rootProjectNode() const override;
|
||||||
|
|
||||||
QStringList files(FilesMode fileMode) const override;
|
|
||||||
QStringList filesGeneratedFrom(const QString &sourceFile) const override;
|
QStringList filesGeneratedFrom(const QString &sourceFile) const override;
|
||||||
|
|
||||||
bool isProjectEditable() const;
|
bool isProjectEditable() const;
|
||||||
|
@@ -191,7 +191,6 @@ static QList<QmakeProject *> s_projects;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
QmakeProject::QmakeProject(const FileName &fileName) :
|
QmakeProject::QmakeProject(const FileName &fileName) :
|
||||||
m_projectFiles(new QmakeProjectFiles),
|
|
||||||
m_qmakeVfs(new QMakeVfs),
|
m_qmakeVfs(new QMakeVfs),
|
||||||
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
|
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater(this))
|
||||||
{
|
{
|
||||||
@@ -230,7 +229,6 @@ QmakeProject::~QmakeProject()
|
|||||||
setRootProjectNode(nullptr);
|
setRootProjectNode(nullptr);
|
||||||
m_rootProFile.reset();
|
m_rootProFile.reset();
|
||||||
|
|
||||||
delete m_projectFiles;
|
|
||||||
m_cancelEvaluate = true;
|
m_cancelEvaluate = true;
|
||||||
Q_ASSERT(m_qmakeGlobalsRefCnt == 0);
|
Q_ASSERT(m_qmakeGlobalsRefCnt == 0);
|
||||||
delete m_qmakeVfs;
|
delete m_qmakeVfs;
|
||||||
@@ -241,32 +239,6 @@ QmakeProFile *QmakeProject::rootProFile() const
|
|||||||
return m_rootProFile.get();
|
return m_rootProFile.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeProject::updateFileList()
|
|
||||||
{
|
|
||||||
QmakeProjectFiles files;
|
|
||||||
rootProjectNode()->forEachNode([&](FileNode *fileNode) {
|
|
||||||
const int type = static_cast<int>(fileNode->fileType());
|
|
||||||
QStringList &targetList = fileNode->isGenerated() ? files.generatedFiles[type] : files.files[type];
|
|
||||||
targetList.push_back(fileNode->filePath().toString());
|
|
||||||
}, [&](FolderNode *folderNode) {
|
|
||||||
if (ProjectNode *projectNode = folderNode->asProjectNode())
|
|
||||||
files.proFiles.append(projectNode->filePath().toString());
|
|
||||||
if (dynamic_cast<ResourceEditor::ResourceTopLevelNode *>(folderNode))
|
|
||||||
files.files[static_cast<int>(FileType::Resource)].push_back(folderNode->filePath().toString());
|
|
||||||
});
|
|
||||||
|
|
||||||
for (QStringList &f : files.files)
|
|
||||||
f.removeDuplicates();
|
|
||||||
for (QStringList &f : files.generatedFiles)
|
|
||||||
f.removeDuplicates();
|
|
||||||
files.proFiles.removeDuplicates();
|
|
||||||
|
|
||||||
if (files != *m_projectFiles) {
|
|
||||||
*m_projectFiles = files;
|
|
||||||
emit fileListChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Project::RestoreResult QmakeProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
Project::RestoreResult QmakeProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
||||||
{
|
{
|
||||||
RestoreResult result = Project::fromMap(map, errorMessage);
|
RestoreResult result = Project::fromMap(map, errorMessage);
|
||||||
@@ -576,7 +548,6 @@ void QmakeProject::decrementPendingEvaluateFutures()
|
|||||||
setAllBuildConfigurationsEnabled(true);
|
setAllBuildConfigurationsEnabled(true);
|
||||||
|
|
||||||
m_asyncUpdateState = Base;
|
m_asyncUpdateState = Base;
|
||||||
updateFileList();
|
|
||||||
updateCodeModels();
|
updateCodeModels();
|
||||||
updateBuildSystemData();
|
updateBuildSystemData();
|
||||||
if (activeTarget())
|
if (activeTarget())
|
||||||
@@ -639,21 +610,6 @@ QString QmakeProject::displayName() const
|
|||||||
return projectFilePath().toFileInfo().completeBaseName();
|
return projectFilePath().toFileInfo().completeBaseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QmakeProject::files(FilesMode fileMode) const
|
|
||||||
{
|
|
||||||
QStringList files;
|
|
||||||
for (int i = 0; i < static_cast<int>(FileType::FileTypeSize); ++i) {
|
|
||||||
if (fileMode & SourceFiles)
|
|
||||||
files += m_projectFiles->files[i];
|
|
||||||
if (fileMode & GeneratedFiles)
|
|
||||||
files += m_projectFiles->generatedFiles[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
files.removeDuplicates();
|
|
||||||
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the folder that contains a file with a certain name (recurse down)
|
// Find the folder that contains a file with a certain name (recurse down)
|
||||||
static FolderNode *folderOf(FolderNode *in, const FileName &fileName)
|
static FolderNode *folderOf(FolderNode *in, const FileName &fileName)
|
||||||
{
|
{
|
||||||
@@ -1086,10 +1042,8 @@ void CentralizedFolderWatcher::delayedFolderChanged(const QString &folder)
|
|||||||
m_recursiveWatchedFolders += tmp;
|
m_recursiveWatchedFolders += tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newOrRemovedFiles) {
|
if (newOrRemovedFiles)
|
||||||
m_project->updateFileList();
|
|
||||||
m_project->updateCodeModels();
|
m_project->updateCodeModels();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmakeProject::needsConfiguration() const
|
bool QmakeProject::needsConfiguration() const
|
||||||
|
@@ -73,7 +73,6 @@ public:
|
|||||||
bool validParse(const Utils::FileName &proFilePath) const;
|
bool validParse(const Utils::FileName &proFilePath) const;
|
||||||
bool parseInProgress(const Utils::FileName &proFilePath) const;
|
bool parseInProgress(const Utils::FileName &proFilePath) const;
|
||||||
|
|
||||||
virtual QStringList files(FilesMode fileMode) const final;
|
|
||||||
virtual QStringList filesGeneratedFrom(const QString &file) const final;
|
virtual QStringList filesGeneratedFrom(const QString &file) const final;
|
||||||
|
|
||||||
enum Parsing {ExactParse, ExactAndCumulativeParse };
|
enum Parsing {ExactParse, ExactAndCumulativeParse };
|
||||||
@@ -109,8 +108,6 @@ public:
|
|||||||
/// \internal
|
/// \internal
|
||||||
bool wasEvaluateCanceled();
|
bool wasEvaluateCanceled();
|
||||||
|
|
||||||
// For QmakeProFileNode after a on disk change
|
|
||||||
void updateFileList();
|
|
||||||
void updateCodeModels();
|
void updateCodeModels();
|
||||||
|
|
||||||
void watchFolders(const QStringList &l, QmakePriFile *file);
|
void watchFolders(const QStringList &l, QmakePriFile *file);
|
||||||
@@ -188,9 +185,6 @@ private:
|
|||||||
|
|
||||||
std::unique_ptr<QmakeProFile> m_rootProFile;
|
std::unique_ptr<QmakeProFile> m_rootProFile;
|
||||||
|
|
||||||
// cached lists of all of files
|
|
||||||
Internal::QmakeProjectFiles *m_projectFiles = nullptr;
|
|
||||||
|
|
||||||
QMakeVfs *m_qmakeVfs = nullptr;
|
QMakeVfs *m_qmakeVfs = nullptr;
|
||||||
|
|
||||||
// cached data during project rescan
|
// cached data during project rescan
|
||||||
|
@@ -168,9 +168,6 @@ void QmlProject::parseProject(RefreshOptions options)
|
|||||||
if (options & Configuration) {
|
if (options & Configuration) {
|
||||||
// update configuration
|
// update configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options & Files)
|
|
||||||
emit fileListChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProject::refresh(RefreshOptions options)
|
void QmlProject::refresh(RefreshOptions options)
|
||||||
@@ -195,16 +192,6 @@ void QmlProject::refresh(RefreshOptions options)
|
|||||||
emit parsingFinished();
|
emit parsingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QmlProject::files() const
|
|
||||||
{
|
|
||||||
QStringList files;
|
|
||||||
if (m_projectItem)
|
|
||||||
files = m_projectItem.data()->files();
|
|
||||||
else
|
|
||||||
files = m_files;
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QmlProject::mainFile() const
|
QString QmlProject::mainFile() const
|
||||||
{
|
{
|
||||||
if (m_projectItem)
|
if (m_projectItem)
|
||||||
@@ -296,11 +283,6 @@ Internal::QmlProjectNode *QmlProject::rootProjectNode() const
|
|||||||
return static_cast<Internal::QmlProjectNode *>(Project::rootProjectNode());
|
return static_cast<Internal::QmlProjectNode *>(Project::rootProjectNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QmlProject::files(FilesMode) const
|
|
||||||
{
|
|
||||||
return files();
|
|
||||||
}
|
|
||||||
|
|
||||||
Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
||||||
{
|
{
|
||||||
RestoreResult result = Project::fromMap(map, errorMessage);
|
RestoreResult result = Project::fromMap(map, errorMessage);
|
||||||
@@ -371,9 +353,12 @@ Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *erro
|
|||||||
|
|
||||||
void QmlProject::generateProjectTree()
|
void QmlProject::generateProjectTree()
|
||||||
{
|
{
|
||||||
|
if (!m_projectItem)
|
||||||
|
return;
|
||||||
|
|
||||||
auto newRoot = new Internal::QmlProjectNode(this);
|
auto newRoot = new Internal::QmlProjectNode(this);
|
||||||
|
|
||||||
for (const QString &f : files()) {
|
for (const QString &f : m_projectItem.data()->files()) {
|
||||||
FileType fileType = FileType::Source; // ### FIXME
|
FileType fileType = FileType::Source; // ### FIXME
|
||||||
if (f == projectFilePath().toString())
|
if (f == projectFilePath().toString())
|
||||||
fileType = FileType::Project;
|
fileType = FileType::Project;
|
||||||
|
@@ -51,7 +51,6 @@ public:
|
|||||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const override;
|
||||||
|
|
||||||
Internal::QmlProjectNode *rootProjectNode() const override;
|
Internal::QmlProjectNode *rootProjectNode() const override;
|
||||||
QStringList files(FilesMode fileMode) const override;
|
|
||||||
|
|
||||||
bool validProjectFile() const;
|
bool validProjectFile() const;
|
||||||
|
|
||||||
@@ -66,7 +65,6 @@ public:
|
|||||||
void refresh(RefreshOptions options);
|
void refresh(RefreshOptions options);
|
||||||
|
|
||||||
QDir projectDir() const;
|
QDir projectDir() const;
|
||||||
QStringList files() const;
|
|
||||||
QString mainFile() const;
|
QString mainFile() const;
|
||||||
QStringList customImportPaths() const;
|
QStringList customImportPaths() const;
|
||||||
|
|
||||||
@@ -92,10 +90,7 @@ private:
|
|||||||
void parseProject(RefreshOptions options);
|
void parseProject(RefreshOptions options);
|
||||||
|
|
||||||
QmlImport m_defaultImport;
|
QmlImport m_defaultImport;
|
||||||
ProjectExplorer::Target *m_activeTarget = 0;
|
ProjectExplorer::Target *m_activeTarget = nullptr;
|
||||||
|
|
||||||
// plain format
|
|
||||||
QStringList m_files;
|
|
||||||
|
|
||||||
QPointer<QmlProjectItem> m_projectItem;
|
QPointer<QmlProjectItem> m_projectItem;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user