CMakePM: Allow project files to be removed in project view

Removal of a project file is done as a rename with an empty filename.

Fixes: QTCREATORBUG-25922
Change-Id: I4443d4a31723eb1ac93f02bad633bcfaf99a9573
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Cristian Adam
2023-04-24 20:28:10 +02:00
parent 54af6bd5b3
commit 411b2e05b8
2 changed files with 163 additions and 89 deletions

View File

@@ -48,6 +48,11 @@ public:
bool addFiles(ProjectExplorer::Node *context,
const Utils::FilePaths &filePaths, Utils::FilePaths *) final;
ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *context,
const Utils::FilePaths &filePaths,
Utils::FilePaths *notRemoved
= nullptr) final;
bool canRenameFile(ProjectExplorer::Node *context,
const Utils::FilePath &oldFilePath,
const Utils::FilePath &newFilePath) final;
@@ -192,6 +197,16 @@ private:
void runCTest();
struct ProjectFileArgumentPosition
{
cmListFileArgument argumentPosition;
Utils::FilePath cmakeFile;
QString relativeFileName;
bool fromGlobbing = false;
};
std::optional<ProjectFileArgumentPosition> projectFileArgumentPosition(
const QString &targetName, const QString &fileName);
ProjectExplorer::TreeScanner m_treeScanner;
std::shared_ptr<ProjectExplorer::FolderNode> m_allFiles;
QHash<QString, bool> m_mimeBinaryCache;
@@ -208,14 +223,7 @@ private:
QList<CMakeBuildTarget> m_buildTargets;
QSet<CMakeFileInfo> m_cmakeFiles;
struct FileToBeRenamed
{
cmListFileArgument argumentPosition;
Utils::FilePath cmakeFile;
QString oldRelativeFileName;
bool fromGlobbing = false;
};
QHash<QString, FileToBeRenamed> m_filesToBeRenamed;
QHash<QString, ProjectFileArgumentPosition> m_filesToBeRenamed;
// Parsing state:
BuildDirParameters m_parameters;