forked from qt-creator/qt-creator
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:
@@ -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:
|
||||
|
Reference in New Issue
Block a user