forked from qt-creator/qt-creator
Nim: Fixed missing update of project files on add and remove
Change-Id: Iadbd5b9b04dcb16f53a16263f94f8f44835e5793 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -48,6 +48,8 @@ const QString C_NIMRUNCONFIGURATION_WORKINGDIRECTORYASPECT_ID = QStringLiteral("
|
|||||||
const QString C_NIMRUNCONFIGURATION_ARGUMENTASPECT_ID = QStringLiteral("Nim.NimRunConfiguration.ArgumentAspect");
|
const QString C_NIMRUNCONFIGURATION_ARGUMENTASPECT_ID = QStringLiteral("Nim.NimRunConfiguration.ArgumentAspect");
|
||||||
const QString C_NIMRUNCONFIGURATION_TERMINALASPECT_ID = QStringLiteral("Nim.NimRunConfiguration.TerminalAspect");
|
const QString C_NIMRUNCONFIGURATION_TERMINALASPECT_ID = QStringLiteral("Nim.NimRunConfiguration.TerminalAspect");
|
||||||
|
|
||||||
|
// NimProject
|
||||||
|
const char C_NIMPROJECT_EXCLUDEDFILES[] = "Nim.NimProjectExcludedFiles";
|
||||||
|
|
||||||
// NimBuildConfiguration
|
// NimBuildConfiguration
|
||||||
const char C_NIMBUILDCONFIGURATION_ID[] = "Nim.NimBuildConfiguration";
|
const char C_NIMBUILDCONFIGURATION_ID[] = "Nim.NimBuildConfiguration";
|
||||||
|
|||||||
@@ -98,6 +98,29 @@ void NimProject::scheduleProjectScan()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NimProject::addFiles(const QStringList &filePaths)
|
||||||
|
{
|
||||||
|
m_excludedFiles = Utils::filtered(m_excludedFiles, [&](const QString &f) { return !filePaths.contains(f); });
|
||||||
|
scheduleProjectScan();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NimProject::removeFiles(const QStringList &filePaths)
|
||||||
|
{
|
||||||
|
m_excludedFiles.append(filePaths);
|
||||||
|
m_excludedFiles = Utils::filteredUnique(m_excludedFiles);
|
||||||
|
scheduleProjectScan();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NimProject::renameFile(const QString &filePath, const QString &newFilePath)
|
||||||
|
{
|
||||||
|
Q_UNUSED(filePath)
|
||||||
|
m_excludedFiles.removeOne(newFilePath);
|
||||||
|
scheduleProjectScan();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void NimProject::collectProjectFiles()
|
void NimProject::collectProjectFiles()
|
||||||
{
|
{
|
||||||
m_lastProjectScan.start();
|
m_lastProjectScan.start();
|
||||||
@@ -116,9 +139,11 @@ void NimProject::updateProject()
|
|||||||
m_files.clear();
|
m_files.clear();
|
||||||
|
|
||||||
QList<FileNode *> fileNodes = Utils::filtered(m_futureWatcher.future().result(),
|
QList<FileNode *> fileNodes = Utils::filtered(m_futureWatcher.future().result(),
|
||||||
[](const FileNode *fn) {
|
[&](const FileNode *fn) {
|
||||||
const QString fileName = fn->filePath().fileName();
|
const FileName path = fn->filePath();
|
||||||
const bool keep = !fileName.endsWith(".nimproject", HostOsInfo::fileNameCaseSensitivity())
|
const QString fileName = path.fileName();
|
||||||
|
const bool keep = !m_excludedFiles.contains(path.toString())
|
||||||
|
&& !fileName.endsWith(".nimproject", HostOsInfo::fileNameCaseSensitivity())
|
||||||
&& !fileName.contains(".nimproject.user", HostOsInfo::fileNameCaseSensitivity());
|
&& !fileName.contains(".nimproject.user", HostOsInfo::fileNameCaseSensitivity());
|
||||||
if (!keep)
|
if (!keep)
|
||||||
delete fn;
|
delete fn;
|
||||||
@@ -162,4 +187,17 @@ FileNameList NimProject::nimFiles() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap NimProject::toMap() const
|
||||||
|
{
|
||||||
|
QVariantMap result = Project::toMap();
|
||||||
|
result[Constants::C_NIMPROJECT_EXCLUDEDFILES] = m_excludedFiles;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Project::RestoreResult NimProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
||||||
|
{
|
||||||
|
m_excludedFiles = map.value(Constants::C_NIMPROJECT_EXCLUDEDFILES).toStringList();
|
||||||
|
return Project::fromMap(map, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,15 +52,23 @@ public:
|
|||||||
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;
|
||||||
void scheduleProjectScan();
|
QVariantMap toMap() const override;
|
||||||
|
|
||||||
|
bool addFiles(const QStringList &filePaths);
|
||||||
|
bool removeFiles(const QStringList &filePaths);
|
||||||
|
bool renameFile(const QString &filePath, const QString &newFilePath);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void scheduleProjectScan();
|
||||||
void collectProjectFiles();
|
void collectProjectFiles();
|
||||||
void updateProject();
|
void updateProject();
|
||||||
|
|
||||||
QStringList m_files;
|
QStringList m_files;
|
||||||
|
QStringList m_excludedFiles;
|
||||||
QFutureWatcher<QList<ProjectExplorer::FileNode *>> m_futureWatcher;
|
QFutureWatcher<QList<ProjectExplorer::FileNode *>> m_futureWatcher;
|
||||||
|
|
||||||
QElapsedTimer m_lastProjectScan;
|
QElapsedTimer m_lastProjectScan;
|
||||||
QTimer m_projectScanTimer;
|
QTimer m_projectScanTimer;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ QList<ProjectAction> NimProjectNode::supportedActions(Node *node) const
|
|||||||
ProjectAction::RemoveFile
|
ProjectAction::RemoveFile
|
||||||
};
|
};
|
||||||
static const QList<ProjectAction> folderActions = { ProjectAction::AddNewFile,
|
static const QList<ProjectAction> folderActions = { ProjectAction::AddNewFile,
|
||||||
ProjectAction::RemoveFile
|
ProjectAction::RemoveFile,
|
||||||
|
ProjectAction::AddExistingFile
|
||||||
};
|
};
|
||||||
switch (node->nodeType()) {
|
switch (node->nodeType()) {
|
||||||
case NodeType::File:
|
case NodeType::File:
|
||||||
@@ -71,28 +72,24 @@ bool NimProjectNode::removeSubProjects(const QStringList &)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NimProjectNode::addFiles(const QStringList &, QStringList *)
|
bool NimProjectNode::addFiles(const QStringList &filePaths, QStringList *)
|
||||||
{
|
{
|
||||||
m_project.scheduleProjectScan();
|
return m_project.addFiles(filePaths);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NimProjectNode::removeFiles(const QStringList &, QStringList *)
|
bool NimProjectNode::removeFiles(const QStringList &filePaths, QStringList *)
|
||||||
{
|
{
|
||||||
m_project.scheduleProjectScan();
|
return m_project.removeFiles(filePaths);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NimProjectNode::deleteFiles(const QStringList &)
|
bool NimProjectNode::deleteFiles(const QStringList &)
|
||||||
{
|
{
|
||||||
m_project.scheduleProjectScan();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NimProjectNode::renameFile(const QString &, const QString &)
|
bool NimProjectNode::renameFile(const QString &filePath, const QString &newFilePath)
|
||||||
{
|
{
|
||||||
m_project.scheduleProjectScan();
|
return m_project.renameFile(filePath, newFilePath);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ public:
|
|||||||
bool canAddSubProject(const QString &) const override;
|
bool canAddSubProject(const QString &) const override;
|
||||||
bool addSubProjects(const QStringList &) override;
|
bool addSubProjects(const QStringList &) override;
|
||||||
bool removeSubProjects(const QStringList &) override;
|
bool removeSubProjects(const QStringList &) override;
|
||||||
bool addFiles(const QStringList &, QStringList *) override;
|
bool addFiles(const QStringList &filePaths, QStringList *) override;
|
||||||
bool removeFiles(const QStringList &, QStringList *) override;
|
bool removeFiles(const QStringList &filePaths, QStringList *) override;
|
||||||
bool deleteFiles(const QStringList &) override;
|
bool deleteFiles(const QStringList &) override;
|
||||||
bool renameFile(const QString &, const QString &) override;
|
bool renameFile(const QString &filePath, const QString &newFilePath) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NimProject &m_project;
|
NimProject &m_project;
|
||||||
|
|||||||
Reference in New Issue
Block a user