renaming utility: Show better info for confliciting targets

Conflicts are handles well but so far the user just got "can not
be renamed". Now the conflicting item is returned.
This commit is contained in:
Martchus 2019-02-13 21:42:29 +01:00
parent 1401b13f7f
commit e9ded173f1
1 changed files with 9 additions and 3 deletions

View File

@ -308,8 +308,14 @@ void RenamingEngine::executeScriptForItem(const QFileInfo &fileInfo, FileSystemI
if (!newRelativeDirectory.isEmpty()) {
FileSystemItem *const counterpartParent = item->root()->makeChildAvailable(newRelativeDirectory);
const QString &counterpartName = newName.isEmpty() ? item->name() : newName;
if (counterpartParent->findChild(counterpartName, item)) {
item->setNote(tr("name is already used at new location"));
if (const auto *const conflictingItem = counterpartParent->findChild(counterpartName, item)) {
QString conflictingName;
if (const auto *const conflictingCounterpart = conflictingItem->counterpart()) {
conflictingCounterpart->relativePath(conflictingName);
} else {
conflictingName = conflictingItem->currentName();
}
item->setNote(tr("name is already used at new location by '%1'").arg(conflictingName));
item->setErrorOccured(true);
} else {
auto *const counterpart = new FileSystemItem(ItemStatus::New, item->type(), counterpartName, counterpartParent);
@ -333,7 +339,7 @@ void RenamingEngine::executeScriptForItem(const QFileInfo &fileInfo, FileSystemI
} else {
item->setNote(tr("will be moved"));
}
} else {
} else if (item->note().isEmpty()) {
item->setNote(tr("can not be renamed"));
}
break;