From 92761ad2932c494e027c6ef54d3597b7da312485 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Fri, 21 Jun 2024 11:27:53 +0200 Subject: [PATCH] PE: Allow candidate renaming with sub directories This would allow renaming of: myclass.h myclass.cpp -> my/class.h my/class.cpp Fixes: QTCREATORBUG-30830 Change-Id: Ic7f277e52a52dfe6745023f550072a935295bcac Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/projectmodels.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/projectmodels.cpp b/src/plugins/projectexplorer/projectmodels.cpp index 5f5aa0150e1..b7be5e1546b 100644 --- a/src/plugins/projectexplorer/projectmodels.cpp +++ b/src/plugins/projectexplorer/projectmodels.cpp @@ -284,8 +284,9 @@ bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int rol QTC_ASSERT(node, return false); std::vector> toRename; - const Utils::FilePath orgFilePath = node->filePath(); - const Utils::FilePath newFilePath = orgFilePath.parentDir().pathAppended(value.toString()); + const FilePath orgFilePath = node->filePath(); + const FilePath newFilePath = orgFilePath.parentDir().pathAppended(value.toString()); + const FilePath valuePath = FilePath::fromString(value.toString()); const QFileInfo orgFileInfo = orgFilePath.toFileInfo(); toRename.emplace_back(std::make_tuple(node, orgFilePath, newFilePath)); @@ -309,12 +310,13 @@ bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int rol case QMessageBox::Yes: for (Node * const n : candidateNodes) { QString targetFilePath = orgFileInfo.absolutePath() + '/' - + newFilePath.completeBaseName(); + + valuePath.parentDir().path() + '/' + + valuePath.completeBaseName(); const QString suffix = n->filePath().suffix(); if (!suffix.isEmpty()) targetFilePath.append('.').append(suffix); toRename.emplace_back(std::make_tuple(n, n->filePath(), - FilePath::fromString(targetFilePath))); + FilePath::fromString(targetFilePath).cleanPath())); } break; case QMessageBox::Cancel: