Allow filtering by space
This commit is contained in:
parent
6a7d28d1b5
commit
6bfa6c4c79
5 changed files with 68 additions and 12 deletions
|
|
@ -530,6 +530,30 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
} else if (filterType == FilterBy::Space) {
|
||||
auto roomid = sourceModel()
|
||||
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::RoomId)
|
||||
.toString();
|
||||
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()))
|
||||
return false;
|
||||
else if (!hiddenTags.empty()) {
|
||||
for (const auto &t : tags)
|
||||
if (hiddenTags.contains(t))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue