Index: src/views/dolphinview.h =================================================================== --- src/views/dolphinview.h +++ src/views/dolphinview.h @@ -576,6 +576,7 @@ void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); void slotModelChanged(KItemModelBase* current, KItemModelBase* previous); void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons); + void slotRenameDialogRenamingFinished(const QList& urls); /* * Is called when new items get pasted or dropped. @@ -760,6 +761,14 @@ */ QUrl viewPropertiesUrl() const; + /** + * Clears the selection and updates current item and selection according to the parameters + * + * @param current URL to be set as current + * @param selected list of selected items + */ + void forceUrlsSelection(const QUrl& current, const QList& selected); + private: void updatePalette(); Index: src/views/dolphinview.cpp =================================================================== --- src/views/dolphinview.cpp +++ src/views/dolphinview.cpp @@ -635,6 +635,9 @@ this, &DolphinView::slotRoleEditingFinished); } else { RenameDialog* dialog = new RenameDialog(this, items); + + connect(dialog, &RenameDialog::renamingFinished, this, &DolphinView::slotRenameDialogRenamingFinished); + dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); dialog->raise(); @@ -1308,9 +1311,7 @@ void DolphinView::observeCreatedItem(const QUrl& url) { if (m_active) { - clearSelection(); - markUrlAsCurrent(url); - markUrlsAsSelected({url}); + forceUrlsSelection(url, {url}); } } @@ -1541,6 +1542,8 @@ KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job); job->uiDelegate()->setAutoErrorHandlingEnabled(true); + forceUrlsSelection(newUrl, {newUrl}); + if (!newNameExistsAlready) { // Only connect the result signal if there is no item with the new name // in the model yet, see bug 328262. @@ -1747,3 +1750,16 @@ url.setPath(m_viewPropertiesContext); return url; } + +void DolphinView::slotRenameDialogRenamingFinished(const QList& urls) +{ + forceUrlsSelection(urls.first(), urls); +} + +void DolphinView::forceUrlsSelection(const QUrl& current, const QList& selected) +{ + clearSelection(); + m_clearSelectionBeforeSelectingNewItems = true; + markUrlAsCurrent(current); + markUrlsAsSelected(selected); +} Index: src/views/renamedialog.h =================================================================== --- src/views/renamedialog.h +++ src/views/renamedialog.h @@ -41,6 +41,9 @@ explicit RenameDialog(QWidget* parent, const KFileItemList& items); virtual ~RenameDialog(); +signals: + void renamingFinished(const QList& urls); + private slots: void slotAccepted(); void slotTextChanged(const QString& newName); @@ -63,6 +66,7 @@ private: bool m_renameOneItem; + QList m_renamedItems; QString m_newName; QLineEdit* m_lineEdit; KFileItemList m_items; Index: src/views/renamedialog.cpp =================================================================== --- src/views/renamedialog.cpp +++ src/views/renamedialog.cpp @@ -162,6 +162,11 @@ KIO::Job * job = KIO::moveAs(oldUrl, newUrl, KIO::HideProgressInfo); KJobWidgets::setWindow(job, widget); KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job); + + if (!job->error()) { + m_renamedItems << newUrl; + } + job->uiDelegate()->setAutoErrorHandlingEnabled(true); } @@ -223,6 +228,10 @@ renameItem(item, newName); } } + + if (!m_items.empty()) { + emit renamingFinished(m_renamedItems); + } } QString RenameDialog::indexedName(const QString& name, int index, const QChar& indexPlaceHolder) @@ -242,5 +251,4 @@ newName.replace(placeHolderStart, minIndexLength, indexString); return newName; -} - +} \ No newline at end of file