X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/8276f1e46e3af9c3499ff121ac603cc6cb9032ff..b68abb7d2718709c2a3ed1e92145ed4247b7333b:/src/panels/places/placespanel.cpp diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index 66770ee86..d49ad39ec 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -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(); - 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)