]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placespanel.cpp
fix padding in places view
[dolphin.git] / src / panels / places / placespanel.cpp
index ef174946b216d28565a8a6a3dc3e11a25ff8c771..d49ad39ec49fd59e7960641765930f5fa99b623e 100644 (file)
@@ -34,6 +34,7 @@
 #include <KMountPoint>
 #include <KPropertiesDialog>
 
+#include <QActionGroup>
 #include <QGraphicsSceneDragDropEvent>
 #include <QIcon>
 #include <QMenu>
@@ -77,7 +78,7 @@ bool PlacesPanel::urlChanged()
     }
 
     if (m_controller) {
-        selectClosestItem();
+        selectItem();
     }
 
     return true;
@@ -139,7 +140,7 @@ void PlacesPanel::showEvent(QShowEvent* event)
         layout->setContentsMargins(0, 0, 0, 0);
         layout->addWidget(container);
 
-        selectClosestItem();
+        selectItem();
     }
 
     Panel::showEvent(event);
@@ -293,7 +294,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
         }
     }
 
-    selectClosestItem();
+    selectItem();
 }
 
 void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos)
@@ -361,7 +362,7 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos)
         }
     }
 
-    selectClosestItem();
+    selectItem();
 }
 
 QAction *PlacesPanel::buildGroupContextMenu(QMenu *menu, int index)
@@ -529,13 +530,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)