Utils: FilePathify RemoveFileDialog

Change-Id: I3402fb7b44ec556d7de79d42b3ddcb606048780d
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-08-17 10:09:43 +02:00
parent 0416e15612
commit fd0f6fd5e6
5 changed files with 11 additions and 9 deletions

View File

@@ -26,16 +26,16 @@
#include "removefiledialog.h" #include "removefiledialog.h"
#include "ui_removefiledialog.h" #include "ui_removefiledialog.h"
#include <QDir> #include <utils/filepath.h>
namespace Utils { namespace Utils {
RemoveFileDialog::RemoveFileDialog(const QString &filePath, QWidget *parent) : RemoveFileDialog::RemoveFileDialog(const FilePath &filePath, QWidget *parent) :
QDialog(parent), QDialog(parent),
m_ui(new Ui::RemoveFileDialog) m_ui(new Ui::RemoveFileDialog)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->fileNameLabel->setText(QDir::toNativeSeparators(filePath)); m_ui->fileNameLabel->setText(filePath.toUserOutput());
// TODO // TODO
m_ui->removeVCCheckBox->setVisible(false); m_ui->removeVCCheckBox->setVisible(false);

View File

@@ -31,6 +31,7 @@
namespace Utils { namespace Utils {
class FilePath;
namespace Ui { class RemoveFileDialog; } namespace Ui { class RemoveFileDialog; }
class QTCREATOR_UTILS_EXPORT RemoveFileDialog : public QDialog class QTCREATOR_UTILS_EXPORT RemoveFileDialog : public QDialog
@@ -38,7 +39,7 @@ class QTCREATOR_UTILS_EXPORT RemoveFileDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit RemoveFileDialog(const QString &filePath, QWidget *parent = nullptr); explicit RemoveFileDialog(const FilePath &filePath, QWidget *parent = nullptr);
~RemoveFileDialog() override; ~RemoveFileDialog() override;
void setDeleteFileVisible(bool visible); void setDeleteFileVisible(bool visible);

View File

@@ -541,8 +541,8 @@ void FolderNavigationWidget::removeCurrentItem()
const QModelIndex current = m_sortProxyModel->mapToSource(m_listView->currentIndex()); const QModelIndex current = m_sortProxyModel->mapToSource(m_listView->currentIndex());
if (!current.isValid() || m_fileSystemModel->isDir(current)) if (!current.isValid() || m_fileSystemModel->isDir(current))
return; return;
const Utils::FilePath filePath = Utils::FilePath::fromString(m_fileSystemModel->filePath(current)); const FilePath filePath = FilePath::fromString(m_fileSystemModel->filePath(current));
Utils::RemoveFileDialog dialog(filePath.toString(), Core::ICore::dialogParent()); RemoveFileDialog dialog(filePath, Core::ICore::dialogParent());
dialog.setDeleteFileVisible(false); dialog.setDeleteFileVisible(false);
if (dialog.exec() == QDialog::Accepted) { if (dialog.exec() == QDialog::Accepted) {
const QVector<FolderNode *> folderNodes = removableFolderNodes(filePath); const QVector<FolderNode *> folderNodes = removableFolderNodes(filePath);

View File

@@ -3668,7 +3668,7 @@ void ProjectExplorerPluginPrivate::removeProject()
return; return;
ProjectNode *projectNode = node->managingProject(); ProjectNode *projectNode = node->managingProject();
if (projectNode) { if (projectNode) {
RemoveFileDialog removeFileDialog(node->filePath().toString(), ICore::dialogParent()); RemoveFileDialog removeFileDialog(node->filePath(), ICore::dialogParent());
removeFileDialog.setDeleteFileVisible(false); removeFileDialog.setDeleteFileVisible(false);
if (removeFileDialog.exec() == QDialog::Accepted) if (removeFileDialog.exec() == QDialog::Accepted)
projectNode->removeSubProject(node->filePath()); projectNode->removeSubProject(node->filePath());
@@ -3745,7 +3745,7 @@ void ProjectExplorerPluginPrivate::removeFile()
for (const Node * const n : ProjectTree::siblingsWithSameBaseName(currentNode)) for (const Node * const n : ProjectTree::siblingsWithSameBaseName(currentNode))
siblings << qMakePair(n, n->filePath()); siblings << qMakePair(n, n->filePath());
RemoveFileDialog removeFileDialog(filePath.toString(), ICore::dialogParent()); RemoveFileDialog removeFileDialog(filePath, ICore::dialogParent());
if (removeFileDialog.exec() != QDialog::Accepted) if (removeFileDialog.exec() != QDialog::Accepted)
return; return;

View File

@@ -1257,7 +1257,8 @@ EntryBackup * RelativeResourceModel::removeEntry(const QModelIndex &index)
deleteItem(index); deleteItem(index);
return new FileEntryBackup(*this, prefixIndex.row(), index.row(), fileNameBackup, aliasBackup); return new FileEntryBackup(*this, prefixIndex.row(), index.row(), fileNameBackup, aliasBackup);
} }
Utils::RemoveFileDialog removeFileDialog(fileNameBackup, Core::ICore::dialogParent()); Utils::RemoveFileDialog removeFileDialog(Utils::FilePath::fromString(fileNameBackup),
Core::ICore::dialogParent());
if (removeFileDialog.exec() == QDialog::Accepted) { if (removeFileDialog.exec() == QDialog::Accepted) {
deleteItem(index); deleteItem(index);
Core::FileUtils::removeFiles({Utils::FilePath::fromString(fileNameBackup)}, Core::FileUtils::removeFiles({Utils::FilePath::fromString(fileNameBackup)},