]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
GIT_SILENT made messages (after extraction)
[dolphin.git] / src / dolphinviewcontainer.cpp
index 1a608669f6f0eca23dfe902538d6d4cbf39a18e4..5520bf794ab5f3272eebacce89090788531a409e 100644 (file)
@@ -30,7 +30,6 @@
 #include <KProtocolManager>
 #include <KShell>
 #include <KUrlComboBox>
-#include <KUrlNavigator>
 
 #include <QDropEvent>
 #include <QLoggingCategory>
@@ -197,6 +196,17 @@ DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
         }
     });
 
+    KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
+    connect(placesModel, &KFilePlacesModel::dataChanged,
+            this, &DolphinViewContainer::slotPlacesModelChanged);
+    connect(placesModel, &KFilePlacesModel::rowsInserted,
+            this, &DolphinViewContainer::slotPlacesModelChanged);
+    connect(placesModel, &KFilePlacesModel::rowsRemoved,
+            this, &DolphinViewContainer::slotPlacesModelChanged);
+
+    connect(this, &DolphinViewContainer::searchModeEnabledChanged,
+            this, &DolphinViewContainer::captionChanged);
+
     // Initialize kactivities resource instance
 
 #ifdef HAVE_KACTIVITIES
@@ -476,7 +486,8 @@ QString DolphinViewContainer::caption() const
     }
 
     KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
-    const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, QUrl(url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?")), 1, Qt::MatchRegExp);
+    const QString pattern = url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?");
+    const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, QRegularExpression::anchoredPattern(pattern), 1, Qt::MatchRegularExpression);
 
     if (!matchedPlaces.isEmpty()) {
         return placesModel->text(matchedPlaces.first());
@@ -791,6 +802,13 @@ void DolphinViewContainer::showErrorMessage(const QString& msg)
     showMessage(msg, Error);
 }
 
+void DolphinViewContainer::slotPlacesModelChanged()
+{
+    if (!GeneralSettings::showFullPathInTitlebar() && !isSearchModeEnabled()) {
+        Q_EMIT captionChanged();
+    }
+}
+
 bool DolphinViewContainer::isSearchUrl(const QUrl& url) const
 {
     return url.scheme().contains(QLatin1String("search"));