]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placespanel.cpp
Add missing includes
[dolphin.git] / src / panels / places / placespanel.cpp
index 66770ee865edba216d0b561970fb8d7f411fc70a..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)
@@ -486,7 +487,7 @@ void PlacesPanel::slotStorageSetupDone(int index, bool success)
 void PlacesPanel::slotShowTooltip()
 {
     const QUrl url = m_model->data(m_hoveredIndex).value("url").value<QUrl>();
-    const QString text = url.isLocalFile() ? url.path() : url.toString();
+    const QString text = url.toDisplayString(QUrl::PreferLocalFile);
     QToolTip::showText(m_hoverPos, text);
 }
 
@@ -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)