Hide rooms with custom defined types in quick switcher

This matches the behavior in other room lists. I also tried to normalize
the constructor with SortFilterRoomTreeModel.
This commit is contained in:
Joshua Goins
2026-02-10 20:11:48 -05:00
parent 115d4e7466
commit 847db41fb3
3 changed files with 15 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
#include "sortfilterroomlistmodel.h"
#include "enums/neochatroomtype.h"
#include "neochatconnection.h"
using namespace Qt::StringLiterals;
@@ -14,11 +15,9 @@ SortFilterRoomListModel::SortFilterRoomListModel(RoomListModel *sourceModel, QOb
setSourceModel(sourceModel);
sort(0);
invalidateFilter();
connect(this, &SortFilterRoomListModel::filterTextChanged, this, [this]() {
invalidateFilter();
});
connect(this, &SortFilterRoomListModel::filterTextChanged, this, &SortFilterRoomListModel::invalidateFilter);
connect(this, &SortFilterRoomListModel::sourceModelChanged, this, [this]() {
this->sourceModel()->disconnect(this);
connect(this->sourceModel(), &QAbstractListModel::rowsInserted, this, &SortFilterRoomListModel::invalidateRowsFilter);
connect(this->sourceModel(), &QAbstractListModel::rowsRemoved, this, &SortFilterRoomListModel::invalidateRowsFilter);
});
@@ -44,6 +43,11 @@ bool SortFilterRoomListModel::filterAcceptsRow(int source_row, const QModelIndex
return false;
}
// Hide rooms with defined types, assuming that data-holding rooms have a defined type
if (!sourceModel()->data(index, RoomListModel::RoomTypeRole).toString().isEmpty()) {
return false;
}
return sourceModel()->data(index, RoomListModel::DisplayNameRole).toString().contains(m_filterText, Qt::CaseInsensitive)
&& sourceModel()->data(index, RoomListModel::IsSpaceRole).toBool() == false;
}