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 "ui_removefiledialog.h"
#include <QDir>
#include <utils/filepath.h>
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);

View File

@@ -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);

View File

@@ -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<FolderNode *> folderNodes = removableFolderNodes(filePath);

View File

@@ -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;

View File

@@ -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)},