Fix theme chooser failing to filter themes by name
authorWuzzy <Wuzzy2@mail.ru>
Mon, 19 Mar 2018 18:58:49 +0100
changeset 13262 7d7eb27dab31
parent 13261 0cfa8f6a4e80
child 13263 66dd7b5f7d33
Fix theme chooser failing to filter themes by name
QTfrontend/model/ThemeFilterProxyModel.cpp
QTfrontend/ui/widget/themeprompt.cpp
--- a/QTfrontend/model/ThemeFilterProxyModel.cpp	Mon Mar 19 16:07:08 2018 +0100
+++ b/QTfrontend/model/ThemeFilterProxyModel.cpp	Mon Mar 19 18:58:49 2018 +0100
@@ -38,10 +38,20 @@
         QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
         bool isDLC = index.data(ThemeModel::IsDlcRole).toBool();
         bool isHidden = index.data(ThemeModel::IsHiddenRole).toBool();
-        return (
+        if(
             ((isFilteringDLC && !isDLC) || !isFilteringDLC) &&
-            ((isFilteringHidden && !isHidden) || !isFilteringHidden));
-
+            ((isFilteringHidden && !isHidden) || !isFilteringHidden))
+        {
+            if(!filterRegExp().isEmpty())
+            {
+                // Also check regular expression set by the theme chooser search
+                QString name = index.data(ThemeModel::ActualNameRole).toString();
+                int index = filterRegExp().indexIn(name);
+                return index != -1;
+            }
+            else
+                return true;
+        }
     }
     else
     {
--- a/QTfrontend/ui/widget/themeprompt.cpp	Mon Mar 19 16:07:08 2018 +0100
+++ b/QTfrontend/ui/widget/themeprompt.cpp	Mon Mar 19 18:58:49 2018 +0100
@@ -73,6 +73,8 @@
     filterModel = themeModel->withoutHidden();
     // Custom filter extension
     filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
+    // Reset search field
+    filterModel->setFilterFixedString(QString());
 
     // Grid
     QGridLayout * dialogLayout = new QGridLayout(this);