X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ada16756d69c012c089733f6ce4e9271f84ccca6..43ea7052e15b1cb917bcc6cd2bd3a8046179e45c:/src/dolphinviewcontainer.cpp diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 585610550..98b812497 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -396,10 +396,7 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled) m_searchBox->setVisible(enabled); m_navigatorWidget->setVisible(!enabled); - if (enabled) { - const QUrl& locationUrl = m_urlNavigator->locationUrl(); - m_searchBox->fromSearchUrl(locationUrl); - } else { + if (!enabled) { m_view->setViewPropertiesContext(QString()); // Restore the URL for the URL navigator. If Dolphin has been @@ -412,6 +409,8 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled) } m_searchModeEnabled = enabled; + + emit searchModeEnabledChanged(enabled); } bool DolphinViewContainer::isSearchModeEnabled() const @@ -426,7 +425,7 @@ QString DolphinViewContainer::placesText() const if (isSearchModeEnabled()) { text = i18n("Search for %1 in %2", m_searchBox->text(), m_searchBox->searchPath().fileName()); } else { - text = url().fileName(); + text = url().adjusted(QUrl::StripTrailingSlash).fileName(); if (text.isEmpty()) { text = url().host(); } @@ -454,7 +453,7 @@ QString DolphinViewContainer::caption() const } KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel(); - const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, url(), 1, Qt::MatchExactly); + const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, QUrl(url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?")), 1, Qt::MatchRegExp); if (!matchedPlaces.isEmpty()) { return placesModel->text(matchedPlaces.first()); @@ -674,11 +673,15 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url) slotReturnPressed(); if (KProtocolManager::supportsListing(url)) { - setSearchModeEnabled(isSearchUrl(url)); + const bool searchUrl = isSearchUrl(url); + if (searchUrl) { + m_searchBox->fromSearchUrl(url); + } + setSearchModeEnabled(searchUrl); m_view->setUrl(url); tryRestoreViewState(); - if (m_autoGrabFocus && isActive() && !isSearchUrl(url)) { + if (m_autoGrabFocus && isActive() && !searchUrl) { // When an URL has been entered, the view should get the focus. // The focus must be requested asynchronously, as changing the URL might create // a new view widget. @@ -697,7 +700,7 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl& url) app = browser; if (app.startsWith('!')) { // a literal command has been configured, remove the '!' prefix - app = app.mid(1); + app.remove(0, 1); } } } else { @@ -785,7 +788,7 @@ void DolphinViewContainer::showErrorMessage(const QString& msg) bool DolphinViewContainer::isSearchUrl(const QUrl& url) const { - return url.scheme().contains(QStringLiteral("search")); + return url.scheme().contains(QLatin1String("search")); } void DolphinViewContainer::saveViewState()