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 <christian.kandeler@qt.io>
This commit is contained in:
Cristian Adam
2024-06-21 11:27:53 +02:00
parent 739b4fc5f4
commit 92761ad293

View File

@@ -284,8 +284,9 @@ bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int rol
QTC_ASSERT(node, return false);
std::vector<std::tuple<Node *, FilePath, FilePath>> 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: