From 3749b5552729b434655ddc950b120bb14fe888c7 Mon Sep 17 00:00:00 2001 From: Gregor Mi Date: Thu, 21 Sep 2017 15:41:26 +0200 Subject: Select child folder when navigating to a parent folder Whenever the dolphin view is initialized to show the contents of a new URL (e.g. "/home/x/test") it will be checked if the new URL is a parent of the previous displayed URL (e.g. "/home/x/test/documents/aaa"). If the check is successful, then the common child (in this example: "/home/x/test/documents/") folder item will be selected and scrolled into view. REVIEW: 123253 BUG: 377392 CCBUG: 335616 --- src/dolphinviewcontainer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/dolphinviewcontainer.cpp') diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 198879f37..d83016610 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -41,6 +42,7 @@ #endif #include "global.h" +#include "dolphindebug.h" #include "dolphin_generalsettings.h" #include "filterbar/filterbar.h" #include "search/dolphinsearchbox.h" @@ -134,6 +136,8 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) : this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged); connect(m_urlNavigator, &KUrlNavigator::urlChanged, this, &DolphinViewContainer::slotUrlNavigatorLocationChanged); + connect(m_urlNavigator, &KUrlNavigator::urlSelectionRequested, + this, &DolphinViewContainer::slotUrlSelectionRequested); connect(m_urlNavigator, &KUrlNavigator::returnPressed, this, &DolphinViewContainer::slotReturnPressed); connect(m_urlNavigator, &KUrlNavigator::urlsDropped, this, [=](const QUrl &destination, QDropEvent *event) { @@ -600,6 +604,13 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url) } } +void DolphinViewContainer::slotUrlSelectionRequested(const QUrl& url) +{ + qCDebug(DolphinDebug) << "slotUrlSelectionRequested: " << url; + m_view->markUrlsAsSelected({url}); + m_view->markUrlAsCurrent(url); // makes the item scroll into view +} + void DolphinViewContainer::redirect(const QUrl& oldUrl, const QUrl& newUrl) { Q_UNUSED(oldUrl); -- cgit v1.3