Enable toggling tags

This commit is contained in:
Nicolas Werner 2021-06-11 14:51:29 +02:00
parent d8c0d4874b
commit 8d2d8dc267
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
8 changed files with 73 additions and 15 deletions

View file

@ -324,6 +324,7 @@ RoomlistModel::initializeRooms()
models.clear();
roomids.clear();
invites.clear();
currentRoom_ = nullptr;
invites = cache::client()->invites();
for (const auto &id : invites.keys())
@ -461,6 +462,22 @@ FilteredRoomlistModel::lessThan(const QModelIndex &left, const QModelIndex &righ
return left.row() < right.row();
}
bool
FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) const
{
if (filterType == FilterBy::Nothing)
return true;
else if (filterType == FilterBy::Tag) {
auto tags = sourceModel()
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::Tags)
.toStringList();
return tags.contains(filterStr);
} else {
return true;
}
}
FilteredRoomlistModel::FilteredRoomlistModel(RoomlistModel *model, QObject *parent)
: QSortFilterProxyModel(parent)
, roomlistmodel(model)