┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/dolphinview.cpp
diff options
context:
space:
mode:
authorEmirald Mateli <[email protected]>2017-09-17 11:07:44 +0200
committerElvis Angelaccio <[email protected]>2017-09-17 11:12:46 +0200
commit478f404b8abf924a0e3e21bbf1dd49aefbe47672 (patch)
treea8321872b1126a91f873e40ccf539b2419b471dc /src/views/dolphinview.cpp
parentcdd002c57cde0480e6e02c7942e9b92af9d0a3e7 (diff)
Keep renamed file(s) in view
When renaming a file, if its new name causes it to scroll out of view, Dolphin will not scroll to the location of the new file. This patch aims to address that. This affects all view modes. CCBUG: 354330 Test Plan: 1. Have many files in a directory (or several files, just zoom in a lot) 2. Rename a file so that it will move out of view Differential Revision: https://phabricator.kde.org/D6312
Diffstat (limited to 'src/views/dolphinview.cpp')
-rw-r--r--src/views/dolphinview.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 5fcec9241..2ca51f52d 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -635,6 +635,9 @@ void DolphinView::renameSelectedItems()
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 @@ QUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh
void DolphinView::observeCreatedItem(const QUrl& url)
{
if (m_active) {
- clearSelection();
- markUrlAsCurrent(url);
- markUrlsAsSelected({url});
+ forceUrlsSelection(url, {url});
}
}
@@ -1541,6 +1542,8 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
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 @@ QUrl DolphinView::viewPropertiesUrl() const
url.setPath(m_viewPropertiesContext);
return url;
}
+
+void DolphinView::slotRenameDialogRenamingFinished(const QList<QUrl>& urls)
+{
+ forceUrlsSelection(urls.first(), urls);
+}
+
+void DolphinView::forceUrlsSelection(const QUrl& current, const QList<QUrl>& selected)
+{
+ clearSelection();
+ m_clearSelectionBeforeSelectingNewItems = true;
+ markUrlAsCurrent(current);
+ markUrlsAsSelected(selected);
+}