]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix regex porting regression
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 4 Jul 2021 20:15:17 +0000 (22:15 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 4 Jul 2021 20:15:17 +0000 (22:15 +0200)
QAbstractItemModel::match() under the hood uses QRegExp::exactMatch(),
so with QRegularExpression we need to use anchoredPattern() on the pattern.

Regression spotted by a failing dolphinmainwindowtest.

src/dolphinviewcontainer.cpp

index b92e8b6ef80fad31942d10f19bec2789cdb3961d..dc7cacff4a5be105e330e4b747c1ae823c095493 100644 (file)
@@ -476,7 +476,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::MatchRegularExpression);
+    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());