Vcs: Add "bulk delete" feature to API

... and use it to improve the user experience when removing several files
at once from a project.

Fixes: QTCREATORBUG-24385
Change-Id: I8e8c39ee9dc0046f1715a5143a7649fab06e5ad8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Christian Kandeler
2020-09-03 17:51:23 +02:00
parent e504d96934
commit 3b415f5ebd
5 changed files with 85 additions and 30 deletions

View File

@@ -157,20 +157,28 @@ QString FileUtils::msgTerminalWithAction()
}
void FileUtils::removeFile(const QString &filePath, bool deleteFromFS)
{
removeFiles({FilePath::fromString(filePath)}, deleteFromFS);
}
void FileUtils::removeFiles(const FilePaths &filePaths, bool deleteFromFS)
{
// remove from version control
VcsManager::promptToDelete(filePath);
VcsManager::promptToDelete(filePaths);
if (!deleteFromFS)
return;
// remove from file system
if (deleteFromFS) {
QFile file(filePath);
if (file.exists()) {
// could have been deleted by vc
if (!file.remove())
QMessageBox::warning(ICore::dialogParent(),
QApplication::translate("Core::Internal", "Deleting File Failed"),
QApplication::translate("Core::Internal", "Could not delete file %1.").arg(filePath));
for (const FilePath &fp : filePaths) {
QFile file(fp.toString());
if (!file.exists()) // could have been deleted by vc
continue;
if (!file.remove()) {
MessageManager::write(QCoreApplication::translate(
"Core::Internal",
"Failed to remove file \"%1\")1.").
arg(fp.toUserOutput()), MessageManager::ModeSwitch);
}
}
}