From fd0f6fd5e666aa05650a13feaf0fc3439b1a22f0 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 17 Aug 2021 10:09:43 +0200 Subject: [PATCH] Utils: FilePathify RemoveFileDialog Change-Id: I3402fb7b44ec556d7de79d42b3ddcb606048780d Reviewed-by: David Schulz --- src/libs/utils/removefiledialog.cpp | 6 +++--- src/libs/utils/removefiledialog.h | 3 ++- src/plugins/projectexplorer/foldernavigationwidget.cpp | 4 ++-- src/plugins/projectexplorer/projectexplorer.cpp | 4 ++-- src/plugins/resourceeditor/qrceditor/resourcefile.cpp | 3 ++- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libs/utils/removefiledialog.cpp b/src/libs/utils/removefiledialog.cpp index 0d2208cff86..4bc4fa24dad 100644 --- a/src/libs/utils/removefiledialog.cpp +++ b/src/libs/utils/removefiledialog.cpp @@ -26,16 +26,16 @@ #include "removefiledialog.h" #include "ui_removefiledialog.h" -#include +#include namespace Utils { -RemoveFileDialog::RemoveFileDialog(const QString &filePath, QWidget *parent) : +RemoveFileDialog::RemoveFileDialog(const FilePath &filePath, QWidget *parent) : QDialog(parent), m_ui(new Ui::RemoveFileDialog) { m_ui->setupUi(this); - m_ui->fileNameLabel->setText(QDir::toNativeSeparators(filePath)); + m_ui->fileNameLabel->setText(filePath.toUserOutput()); // TODO m_ui->removeVCCheckBox->setVisible(false); diff --git a/src/libs/utils/removefiledialog.h b/src/libs/utils/removefiledialog.h index 42802233147..e361230d88b 100644 --- a/src/libs/utils/removefiledialog.h +++ b/src/libs/utils/removefiledialog.h @@ -31,6 +31,7 @@ namespace Utils { +class FilePath; namespace Ui { class RemoveFileDialog; } class QTCREATOR_UTILS_EXPORT RemoveFileDialog : public QDialog @@ -38,7 +39,7 @@ class QTCREATOR_UTILS_EXPORT RemoveFileDialog : public QDialog Q_OBJECT public: - explicit RemoveFileDialog(const QString &filePath, QWidget *parent = nullptr); + explicit RemoveFileDialog(const FilePath &filePath, QWidget *parent = nullptr); ~RemoveFileDialog() override; void setDeleteFileVisible(bool visible); diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp index d990d0196fd..cfaf75a772c 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp @@ -541,8 +541,8 @@ void FolderNavigationWidget::removeCurrentItem() const QModelIndex current = m_sortProxyModel->mapToSource(m_listView->currentIndex()); if (!current.isValid() || m_fileSystemModel->isDir(current)) return; - const Utils::FilePath filePath = Utils::FilePath::fromString(m_fileSystemModel->filePath(current)); - Utils::RemoveFileDialog dialog(filePath.toString(), Core::ICore::dialogParent()); + const FilePath filePath = FilePath::fromString(m_fileSystemModel->filePath(current)); + RemoveFileDialog dialog(filePath, Core::ICore::dialogParent()); dialog.setDeleteFileVisible(false); if (dialog.exec() == QDialog::Accepted) { const QVector folderNodes = removableFolderNodes(filePath); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 59dc31de0c1..5a6ff29745a 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -3668,7 +3668,7 @@ void ProjectExplorerPluginPrivate::removeProject() return; ProjectNode *projectNode = node->managingProject(); if (projectNode) { - RemoveFileDialog removeFileDialog(node->filePath().toString(), ICore::dialogParent()); + RemoveFileDialog removeFileDialog(node->filePath(), ICore::dialogParent()); removeFileDialog.setDeleteFileVisible(false); if (removeFileDialog.exec() == QDialog::Accepted) projectNode->removeSubProject(node->filePath()); @@ -3745,7 +3745,7 @@ void ProjectExplorerPluginPrivate::removeFile() for (const Node * const n : ProjectTree::siblingsWithSameBaseName(currentNode)) siblings << qMakePair(n, n->filePath()); - RemoveFileDialog removeFileDialog(filePath.toString(), ICore::dialogParent()); + RemoveFileDialog removeFileDialog(filePath, ICore::dialogParent()); if (removeFileDialog.exec() != QDialog::Accepted) return; diff --git a/src/plugins/resourceeditor/qrceditor/resourcefile.cpp b/src/plugins/resourceeditor/qrceditor/resourcefile.cpp index 4399e52f994..34aed64b882 100644 --- a/src/plugins/resourceeditor/qrceditor/resourcefile.cpp +++ b/src/plugins/resourceeditor/qrceditor/resourcefile.cpp @@ -1257,7 +1257,8 @@ EntryBackup * RelativeResourceModel::removeEntry(const QModelIndex &index) deleteItem(index); 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) { deleteItem(index); Core::FileUtils::removeFiles({Utils::FilePath::fromString(fileNameBackup)},