diff options
author | Wolfgang Müller | 2024-09-20 14:37:33 +0200 |
---|---|---|
committer | Wolfgang Müller | 2024-09-20 14:37:33 +0200 |
commit | 6d9897304ed0fc9aaa6d509272b39bb1bb1e51b5 (patch) | |
tree | d416bfdc0bec2dfeda89b08234b31a546b5f126a | |
parent | f3ddcefff67f889ddc43c5d5c85f5966730ac07d (diff) | |
download | portage-roles-6d9897304ed0fc9aaa6d509272b39bb1bb1e51b5.tar.gz |
desktop-plasma: Add kde-frameworks/kio patch for setUrl() handling
This patch fixes kio's handling of trailing slashes in
KFilePlacesView::setUrl(). Merge request upstream at [1].
[1] https://invent.kde.org/frameworks/kio/-/merge_requests/1723
-rw-r--r-- | desktop-plasma/patches/kde-frameworks/kio/0001-KFilePlacesView-have-setUrl-handle-trailing-slashes-.patch | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/desktop-plasma/patches/kde-frameworks/kio/0001-KFilePlacesView-have-setUrl-handle-trailing-slashes-.patch b/desktop-plasma/patches/kde-frameworks/kio/0001-KFilePlacesView-have-setUrl-handle-trailing-slashes-.patch new file mode 100644 index 0000000..09b3415 --- /dev/null +++ b/desktop-plasma/patches/kde-frameworks/kio/0001-KFilePlacesView-have-setUrl-handle-trailing-slashes-.patch @@ -0,0 +1,91 @@ +From 9140e58ea4ec9034d75fc7a3572cf0789dd4bb32 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Wolfgang=20M=C3=BCller?= <wolf@oriole.systems> +Date: Fri, 20 Sep 2024 09:23:18 +0200 +Subject: [PATCH] KFilePlacesView: have setUrl() handle trailing slashes in + place URLs + +Whilst KFilePlacesView::setUrl() correctly strips its argument when +comparing it to place URLs, it fails to strip the place URL itself. This +means that if a place URL contains a trailing slash, it is not correctly +highlighted in the place view. + +Instead of comparing both QUrl objects directly, use QUrl::matches, +which allows us to pass QUrl::StripTrailingSlash to both. + +Add a test case for this behaviour as well. +--- + autotests/kfileplacesviewtest.cpp | 37 +++++++++++++++++++++++++++++ + src/filewidgets/kfileplacesview.cpp | 2 +- + 2 files changed, 38 insertions(+), 1 deletion(-) + +diff --git a/autotests/kfileplacesviewtest.cpp b/autotests/kfileplacesviewtest.cpp +index 673bec37b..e70979eb3 100644 +--- a/autotests/kfileplacesviewtest.cpp ++++ b/autotests/kfileplacesviewtest.cpp +@@ -34,6 +34,8 @@ private Q_SLOTS: + + void testUrlChanged_data(); + void testUrlChanged(); ++ void testSetUrl_data(); ++ void testSetUrl(); + + private: + QTemporaryDir m_tmpHome; +@@ -100,6 +102,41 @@ void KFilePlacesViewTest::testUrlChanged() + QCOMPARE(args.at(0).toUrl().toString(), expectedUrl); + } + ++void KFilePlacesViewTest::testSetUrl_data() ++{ ++ QTest::addColumn<QUrl>("place"); ++ QTest::addColumn<QUrl>("url"); ++ ++ QString testPath = QString("file://%1/testSetUrl").arg(m_tmpHome.path()); ++ QUrl bareUrl = QUrl(testPath); ++ QUrl trailingUrl = QUrl(testPath.append("/")); ++ ++ QTest::newRow("place-bare-url-bare") << bareUrl << bareUrl; ++ QTest::newRow("place-bare-url-trailing") << bareUrl << trailingUrl; ++ QTest::newRow("place-trailing-url-bare") << trailingUrl << bareUrl; ++ QTest::newRow("place-trailing-url-trailing") << trailingUrl << trailingUrl; ++} ++ ++void KFilePlacesViewTest::testSetUrl() ++{ ++ QFETCH(QUrl, place); ++ QFETCH(QUrl, url); ++ ++ KFilePlacesView pv; ++ KFilePlacesModel pm; ++ pv.setModel(&pm); ++ ++ pm.addPlace("testSetUrl", place); ++ QModelIndex added = pm.closestItem(place); ++ ++ QSignalSpy selectionChangedSpy(pv.selectionModel(), &QItemSelectionModel::selectionChanged); ++ pv.setUrl(url); ++ ++ QVERIFY(!selectionChangedSpy.isEmpty()); ++ const QList<QVariant> args = selectionChangedSpy.takeFirst(); ++ QVERIFY(args.at(0).value<QItemSelection>().indexes().contains(added)); ++} ++ + QTEST_MAIN(KFilePlacesViewTest) + + #include "kfileplacesviewtest.moc" +diff --git a/src/filewidgets/kfileplacesview.cpp b/src/filewidgets/kfileplacesview.cpp +index dd4830353..c8eefde78 100644 +--- a/src/filewidgets/kfileplacesview.cpp ++++ b/src/filewidgets/kfileplacesview.cpp +@@ -1037,7 +1037,7 @@ void KFilePlacesView::setUrl(const QUrl &url) + + d->m_currentUrl = url; + +- if (placesModel->url(index) == url.adjusted(QUrl::StripTrailingSlash)) { ++ if (placesModel->url(index).matches(url, QUrl::StripTrailingSlash)) { + selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect); + } else { + selectionModel()->clear(); +-- +2.46.0 + |