diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp
index 6ff953d2..c66d5949 100644
--- a/src/timeline/CommunitiesModel.cpp
+++ b/src/timeline/CommunitiesModel.cpp
@@ -214,7 +214,13 @@ CommunitiesModel::toggleTagId(QString tagId)
if (tagId.startsWith("tag:")) {
auto idx = tags_.indexOf(tagId.mid(4));
if (idx != -1)
- emit dataChanged(index(idx), index(idx), {Hidden});
+ emit dataChanged(index(idx + 1 + spaceOrder_.size()),
+ index(idx + 1 + spaceOrder_.size()),
+ {Hidden});
+ } else if (tagId.startsWith("space:")) {
+ auto idx = spaceOrder_.indexOf(tagId.mid(6));
+ if (idx != -1)
+ emit dataChanged(index(idx + 1), index(idx + 1), {Hidden});
}
emit hiddenTagsChanged();
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp
index 3b6ad54a..0d9ec66b 100644
--- a/src/timeline/RoomlistModel.cpp
+++ b/src/timeline/RoomlistModel.cpp
@@ -51,6 +51,7 @@ RoomlistModel::roleNames() const
{IsInvite, "isInvite"},
{IsSpace, "isSpace"},
{Tags, "tags"},
+ {ParentSpaces, "parentSpaces"},
};
}
@@ -93,6 +94,14 @@ RoomlistModel::data(const QModelIndex &index, int role) const
list.push_back(QString::fromStdString(t));
return list;
}
+ case Roles::ParentSpaces: {
+ auto parents =
+ cache::client()->getParentRoomIds(roomid.toStdString());
+ QStringList list;
+ for (const auto &t : parents)
+ list.push_back(QString::fromStdString(t));
+ return list;
+ }
default:
return {};
}
@@ -122,6 +131,14 @@ RoomlistModel::data(const QModelIndex &index, int role) const
return false;
case Roles::Tags:
return QStringList();
+ case Roles::ParentSpaces: {
+ auto parents =
+ cache::client()->getParentRoomIds(roomid.toStdString());
+ QStringList list;
+ for (const auto &t : parents)
+ list.push_back(QString::fromStdString(t));
+ return list;
+ }
default:
return {};
}
@@ -514,6 +531,14 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
for (const auto &t : tags)
if (hiddenTags.contains(t))
return false;
+ } else if (!hiddenSpaces.empty()) {
+ auto parents =
+ sourceModel()
+ ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::ParentSpaces)
+ .toStringList();
+ for (const auto &t : parents)
+ if (hiddenSpaces.contains(t))
+ return false;
}
return true;
@@ -528,30 +553,35 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
for (const auto &t : tags)
if (t != filterStr && hiddenTags.contains(t))
return false;
+ } else if (!hiddenSpaces.empty()) {
+ auto parents =
+ sourceModel()
+ ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::ParentSpaces)
+ .toStringList();
+ for (const auto &t : parents)
+ if (hiddenSpaces.contains(t))
+ return false;
}
return true;
} else if (filterType == FilterBy::Space) {
- auto roomid = sourceModel()
- ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::RoomId)
- .toString();
+ auto parents =
+ sourceModel()
+ ->data(sourceModel()->index(sourceRow, 0), RoomlistModel::ParentSpaces)
+ .toStringList();
auto tags = sourceModel()
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::Tags)
.toStringList();
- auto contains = [](const std::vector<std::string> &v, const std::string &str) {
- for (const auto &e : v)
- if (e == str)
- return true;
- return false;
- };
- auto parents = cache::client()->getParentRoomIds(roomid.toStdString());
-
- if (!contains(parents, filterStr.toStdString()))
+ if (!parents.contains(filterStr))
return false;
else if (!hiddenTags.empty()) {
for (const auto &t : tags)
if (hiddenTags.contains(t))
return false;
+ } else if (!hiddenSpaces.empty()) {
+ for (const auto &t : parents)
+ if (hiddenSpaces.contains(t))
+ return false;
}
return true;
} else {
diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h
index 5f8b8bd8..d6cbb462 100644
--- a/src/timeline/RoomlistModel.h
+++ b/src/timeline/RoomlistModel.h
@@ -38,6 +38,7 @@ public:
IsInvite,
IsSpace,
Tags,
+ ParentSpaces,
};
RoomlistModel(TimelineViewManager *parent = nullptr);
|