summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-06-20 13:30:35 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-06-25 11:35:26 +0200
commitf8dfc726255df415aaeb9339b20f83cd265ee303 (patch)
tree04006a7333e0e7ecdca2a5e20cf5381d695014f0 /src/timeline
parentDon't spam key requests directly after startup (diff)
downloadnheko-f8dfc726255df415aaeb9339b20f83cd265ee303.tar.xz
Fix spaces showing up with world filter
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/RoomlistModel.cpp69
1 files changed, 44 insertions, 25 deletions
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp
index a44959fc..7f59b112 100644
--- a/src/timeline/RoomlistModel.cpp
+++ b/src/timeline/RoomlistModel.cpp
@@ -531,6 +531,12 @@ bool
 FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) const
 {
         if (filterType == FilterBy::Nothing) {
+                if (sourceModel()
+                      ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::IsSpace)
+                      .toBool()) {
+                        return false;
+                }
+
                 if (!hiddenTags.empty()) {
                         auto tags =
                           sourceModel()
@@ -540,7 +546,9 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
                         for (const auto &t : tags)
                                 if (hiddenTags.contains(t))
                                         return false;
-                } else if (!hiddenSpaces.empty()) {
+                }
+
+                if (!hiddenSpaces.empty()) {
                         auto parents =
                           sourceModel()
                             ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::ParentSpaces)
@@ -548,25 +556,30 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
                         for (const auto &t : parents)
                                 if (hiddenSpaces.contains(t))
                                         return false;
-                } else if (sourceModel()
-                             ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::IsSpace)
-                             .toBool()) {
-                        return false;
                 }
 
                 return true;
         } else if (filterType == FilterBy::Tag) {
+                if (sourceModel()
+                      ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::IsSpace)
+                      .toBool()) {
+                        return false;
+                }
+
                 auto tags = sourceModel()
                               ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::Tags)
                               .toStringList();
 
                 if (!tags.contains(filterStr))
                         return false;
-                else if (!hiddenTags.empty()) {
+
+                if (!hiddenTags.empty()) {
                         for (const auto &t : tags)
                                 if (t != filterStr && hiddenTags.contains(t))
                                         return false;
-                } else if (!hiddenSpaces.empty()) {
+                }
+
+                if (!hiddenSpaces.empty()) {
                         auto parents =
                           sourceModel()
                             ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::ParentSpaces)
@@ -574,41 +587,47 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
                         for (const auto &t : parents)
                                 if (hiddenSpaces.contains(t))
                                         return false;
-                } else if (sourceModel()
-                             ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::IsSpace)
-                             .toBool()) {
-                        return false;
                 }
+
                 return true;
         } else if (filterType == FilterBy::Space) {
+                if (filterStr == sourceModel()
+                                   ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::RoomId)
+                                   .toString())
+                        return true;
+
                 auto parents =
                   sourceModel()
                     ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::ParentSpaces)
                     .toStringList();
-                auto tags = sourceModel()
-                              ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::Tags)
-                              .toStringList();
 
-                if (filterStr == sourceModel()
-                                   ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::RoomId)
-                                   .toString())
-                        return true;
-                else if (!parents.contains(filterStr))
+                if (!parents.contains(filterStr))
                         return false;
-                else if (!hiddenTags.empty()) {
+
+                if (!hiddenTags.empty()) {
+                        auto tags =
+                          sourceModel()
+                            ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::Tags)
+                            .toStringList();
+
                         for (const auto &t : tags)
                                 if (hiddenTags.contains(t))
                                         return false;
-                } else if (!hiddenSpaces.empty()) {
+                }
+
+                if (!hiddenSpaces.empty()) {
                         for (const auto &t : parents)
                                 if (hiddenSpaces.contains(t))
                                         return false;
-                } else if (sourceModel()
-                             ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::IsSpace)
-                             .toBool() &&
-                           !parents.contains(filterStr)) {
+                }
+
+                if (sourceModel()
+                      ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::IsSpace)
+                      .toBool() &&
+                    !parents.contains(filterStr)) {
                         return false;
                 }
+
                 return true;
         } else {
                 return true;