File 0001-Pass-Qt-MatchExactly-when-calling-QAbstractItemModel.patch of Package plasma5-desktop

From edf0b4ae99c5957667d58dc55fdeac69087331d3 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Thu, 4 Mar 2021 21:52:46 +0100
Subject: [PATCH] Pass Qt::MatchExactly when calling QAbstractItemModel::match
 for strings

It defaults to Qt::MatchStartsWith and thus returns the wrong result.
---
 kcms/colors/colors.cpp                 | 2 +-
 kcms/colors/filterproxymodel.cpp       | 2 +-
 kcms/desktoptheme/filterproxymodel.cpp | 2 +-
 kcms/desktoptheme/themesmodel.cpp      | 2 +-
 kcms/icons/main.cpp                    | 2 +-
 kcms/keys/kglobalshortcutseditor.cpp   | 4 ++--
 kcms/ksplash/kcm.cpp                   | 2 +-
 kcms/lookandfeel/kcm.cpp               | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/kcms/colors/colors.cpp b/kcms/colors/colors.cpp
index dc38a8463..ddde28ba3 100644
--- a/kcms/colors/colors.cpp
+++ b/kcms/colors/colors.cpp
@@ -243,7 +243,7 @@ void KCMColors::installSchemeFile(const QString &path)
 
     m_model->load();
 
-    const auto results = m_model->match(m_model->index(0, 0), ColorsModel::SchemeNameRole, newName);
+    const auto results = m_model->match(m_model->index(0, 0), ColorsModel::SchemeNameRole, newName, 1, Qt::MatchExactly);
     if (!results.isEmpty()) {
         m_model->setSelectedScheme(newName);
     }
diff --git a/kcms/colors/filterproxymodel.cpp b/kcms/colors/filterproxymodel.cpp
index 5b1c3d711..168363bf9 100644
--- a/kcms/colors/filterproxymodel.cpp
+++ b/kcms/colors/filterproxymodel.cpp
@@ -49,7 +49,7 @@ void FilterProxyModel::setSelectedScheme(const QString &scheme)
 int FilterProxyModel::selectedSchemeIndex() const
 {
     // We must search in the source model and then map the index to our proxy model.
-    const auto results = sourceModel()->match(sourceModel()->index(0, 0), ColorsModel::SchemeNameRole, m_selectedScheme);
+    const auto results = sourceModel()->match(sourceModel()->index(0, 0), ColorsModel::SchemeNameRole, m_selectedScheme, 1, Qt::MatchExactly);
 
     if (results.count() == 1) {
         const QModelIndex result = mapFromSource(results.first());
diff --git a/kcms/desktoptheme/filterproxymodel.cpp b/kcms/desktoptheme/filterproxymodel.cpp
index 5f6211863..03a2dffda 100644
--- a/kcms/desktoptheme/filterproxymodel.cpp
+++ b/kcms/desktoptheme/filterproxymodel.cpp
@@ -53,7 +53,7 @@ void FilterProxyModel::setSelectedTheme(const QString &pluginName)
 int FilterProxyModel::selectedThemeIndex() const
 {
     // We must search in the source model and then map the index to our proxy model.
-    const auto results = sourceModel()->match(sourceModel()->index(0, 0), ThemesModel::PluginNameRole, m_selectedTheme);
+    const auto results = sourceModel()->match(sourceModel()->index(0, 0), ThemesModel::PluginNameRole, m_selectedTheme, 1, Qt::MatchExactly);
 
     if (results.count() == 1) {
         const QModelIndex result = mapFromSource(results.first());
diff --git a/kcms/desktoptheme/themesmodel.cpp b/kcms/desktoptheme/themesmodel.cpp
index f2b3fa8dd..fbaec9ba2 100644
--- a/kcms/desktoptheme/themesmodel.cpp
+++ b/kcms/desktoptheme/themesmodel.cpp
@@ -135,7 +135,7 @@ void ThemesModel::setSelectedTheme(const QString &pluginName)
 
 int ThemesModel::pluginIndex(const QString &pluginName) const
 {
-    const auto results = match(index(0, 0), PluginNameRole, pluginName);
+    const auto results = match(index(0, 0), PluginNameRole, pluginName, 1, Qt::MatchExactly);
     if (results.count() == 1) {
         return results.first().row();
     }
diff --git a/kcms/icons/main.cpp b/kcms/icons/main.cpp
index aec4a091a..7e1cdae6d 100644
--- a/kcms/icons/main.cpp
+++ b/kcms/icons/main.cpp
@@ -494,7 +494,7 @@ QPixmap IconModule::getBestIcon(KIconTheme &theme, const QStringList &iconNames,
 
 int IconModule::pluginIndex(const QString &themeName) const
 {
-    const auto results = m_model->match(m_model->index(0, 0), ThemeNameRole, themeName);
+    const auto results = m_model->match(m_model->index(0, 0), ThemeNameRole, themeName, 1, Qt::MatchExactly);
     if (results.count() == 1) {
         return results.first().row();
     }
diff --git a/kcms/keys/kglobalshortcutseditor.cpp b/kcms/keys/kglobalshortcutseditor.cpp
index 5a92e6977..da6ebc3c9 100644
--- a/kcms/keys/kglobalshortcutseditor.cpp
+++ b/kcms/keys/kglobalshortcutseditor.cpp
@@ -406,7 +406,7 @@ void KGlobalShortcutsEditor::activateComponent(const QString &component)
         Q_ASSERT(iter != d->components.end());
         return;
     } else {
-        QModelIndexList results = d->proxyModel->match(d->proxyModel->index(0, 0), Qt::DisplayRole, component);
+        QModelIndexList results = d->proxyModel->match(d->proxyModel->index(0, 0), Qt::DisplayRole, component, 1, Qt::MatchExactly);
         Q_ASSERT(!results.isEmpty());
         if (results.first().isValid()) {
             // Known component. Get it.
@@ -831,7 +831,7 @@ void KGlobalShortcutsEditor::KGlobalShortcutsEditorPrivate::removeComponent(
         if (components.value(text)->uniqueName() == componentUnique)
             {
             // Remove from QComboBox
-            QModelIndexList results = proxyModel->match(proxyModel->index(0, 0), Qt::DisplayRole, text);
+            QModelIndexList results = proxyModel->match(proxyModel->index(0, 0), Qt::DisplayRole, text, 1, Qt::MatchExactly);
             Q_ASSERT(!results.isEmpty());
             model->removeRow(proxyModel->mapToSource(results.first()).row());
 
diff --git a/kcms/ksplash/kcm.cpp b/kcms/ksplash/kcm.cpp
index 389900159..d4f04d4c5 100644
--- a/kcms/ksplash/kcm.cpp
+++ b/kcms/ksplash/kcm.cpp
@@ -132,7 +132,7 @@ void KCMSplashScreen::save()
 
 int KCMSplashScreen::pluginIndex(const QString &pluginName) const
 {
-    const auto results = m_model->match(m_model->index(0, 0), PluginNameRole, pluginName);
+    const auto results = m_model->match(m_model->index(0, 0), PluginNameRole, pluginName, 1, Qt::MatchExactly);
     if (results.count() == 1) {
         return results.first().row();
     }
diff --git a/kcms/lookandfeel/kcm.cpp b/kcms/lookandfeel/kcm.cpp
index 8b0a7a7b9..17f00d662 100644
--- a/kcms/lookandfeel/kcm.cpp
+++ b/kcms/lookandfeel/kcm.cpp
@@ -121,7 +121,7 @@ QStandardItemModel *KCMLookandFeel::lookAndFeelModel() const
 
 int KCMLookandFeel::pluginIndex(const QString &pluginName) const
 {
-    const auto results = m_model->match(m_model->index(0, 0), PluginNameRole, pluginName);
+    const auto results = m_model->match(m_model->index(0, 0), PluginNameRole, pluginName, 1, Qt::MatchExactly);
     if (results.count() == 1) {
         return results.first().row();
     }
-- 
2.25.1

openSUSE Build Service is sponsored by