From: Méven Car Date: Tue, 17 Nov 2020 20:11:03 +0000 (+0100) Subject: Places panel: highlight place only when it is displayed X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/2cd1c07cad5945a5286914c05987e21b53cc3c7f Places panel: highlight place only when it is displayed BUG: 156678 FIXED-IN: 20.12 --- diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index ef174946b..4d50fe5f8 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -77,7 +77,7 @@ bool PlacesPanel::urlChanged() } if (m_controller) { - selectClosestItem(); + selectItem(); } return true; @@ -139,7 +139,7 @@ void PlacesPanel::showEvent(QShowEvent* event) layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(container); - selectClosestItem(); + selectItem(); } Panel::showEvent(event); @@ -293,7 +293,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) } } - selectClosestItem(); + selectItem(); } void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) @@ -361,7 +361,7 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) } } - selectClosestItem(); + selectItem(); } QAction *PlacesPanel::buildGroupContextMenu(QMenu *menu, int index) @@ -529,13 +529,17 @@ void PlacesPanel::editEntry(int index) delete dialog; } -void PlacesPanel::selectClosestItem() +void PlacesPanel::selectItem() { const int index = m_model->closestItem(url()); KItemListSelectionManager* selectionManager = m_controller->selectionManager(); selectionManager->setCurrentItem(index); selectionManager->clearSelection(); - selectionManager->setSelected(index); + + const QUrl closestUrl = m_model->url(index); + if (!closestUrl.path().isEmpty() && url() == closestUrl) { + selectionManager->setSelected(index); + } } void PlacesPanel::triggerItem(int index, Qt::MouseButton button) diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index fe4f46ba6..67b484c65 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -68,10 +68,10 @@ private: void editEntry(int index); /** - * Selects the item that has the closest URL for the URL set + * Selects the item that matches the URL set * for the panel (see Panel::setUrl()). */ - void selectClosestItem(); + void selectItem(); void triggerItem(int index, Qt::MouseButton button);