]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Places panel: highlight place only when it is displayed
authorMéven Car <meven29@gmail.com>
Tue, 17 Nov 2020 20:11:03 +0000 (21:11 +0100)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Mon, 23 Nov 2020 00:02:59 +0000 (00:02 +0000)
BUG: 156678
FIXED-IN: 20.12

src/panels/places/placespanel.cpp
src/panels/places/placespanel.h

index ef174946b216d28565a8a6a3dc3e11a25ff8c771..4d50fe5f8021eb44540ed07b23e46a914ee4977d 100644 (file)
@@ -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)
index fe4f46ba6c449a4eb9f33c62e3def09ccf107fef..67b484c652bdef2db5c3d7bc325e515602c51b04 100644 (file)
@@ -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);