|
|
@ -66,6 +66,7 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
|
|
|
// UI Buttons
|
|
|
|
// UI Buttons
|
|
|
|
connect(ui->refresh_list, &QPushButton::clicked, this, &Lobby::RefreshLobby);
|
|
|
|
connect(ui->refresh_list, &QPushButton::clicked, this, &Lobby::RefreshLobby);
|
|
|
|
connect(ui->games_owned, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterOwned);
|
|
|
|
connect(ui->games_owned, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterOwned);
|
|
|
|
|
|
|
|
connect(ui->hide_empty, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterEmpty);
|
|
|
|
connect(ui->hide_full, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterFull);
|
|
|
|
connect(ui->hide_full, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterFull);
|
|
|
|
connect(ui->search, &QLineEdit::textChanged, proxy, &LobbyFilterProxyModel::SetFilterSearch);
|
|
|
|
connect(ui->search, &QLineEdit::textChanged, proxy, &LobbyFilterProxyModel::SetFilterSearch);
|
|
|
|
connect(ui->room_list, &QTreeView::doubleClicked, this, &Lobby::OnJoinRoom);
|
|
|
|
connect(ui->room_list, &QTreeView::doubleClicked, this, &Lobby::OnJoinRoom);
|
|
|
@ -282,12 +283,22 @@ bool LobbyFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& s
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// filter by empty rooms
|
|
|
|
|
|
|
|
if (filter_empty) {
|
|
|
|
|
|
|
|
QModelIndex member_list = sourceModel()->index(sourceRow, Column::MEMBER, sourceParent);
|
|
|
|
|
|
|
|
const int player_count =
|
|
|
|
|
|
|
|
sourceModel()->data(member_list, LobbyItemMemberList::MemberListRole).toList().size();
|
|
|
|
|
|
|
|
if (player_count == 0) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// filter by filled rooms
|
|
|
|
// filter by filled rooms
|
|
|
|
if (filter_full) {
|
|
|
|
if (filter_full) {
|
|
|
|
QModelIndex member_list = sourceModel()->index(sourceRow, Column::MEMBER, sourceParent);
|
|
|
|
QModelIndex member_list = sourceModel()->index(sourceRow, Column::MEMBER, sourceParent);
|
|
|
|
int player_count =
|
|
|
|
const int player_count =
|
|
|
|
sourceModel()->data(member_list, LobbyItemMemberList::MemberListRole).toList().size();
|
|
|
|
sourceModel()->data(member_list, LobbyItemMemberList::MemberListRole).toList().size();
|
|
|
|
int max_players =
|
|
|
|
const int max_players =
|
|
|
|
sourceModel()->data(member_list, LobbyItemMemberList::MaxPlayerRole).toInt();
|
|
|
|
sourceModel()->data(member_list, LobbyItemMemberList::MaxPlayerRole).toInt();
|
|
|
|
if (player_count >= max_players) {
|
|
|
|
if (player_count >= max_players) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -352,6 +363,11 @@ void LobbyFilterProxyModel::SetFilterOwned(bool filter) {
|
|
|
|
invalidate();
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LobbyFilterProxyModel::SetFilterEmpty(bool filter) {
|
|
|
|
|
|
|
|
filter_empty = filter;
|
|
|
|
|
|
|
|
invalidate();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LobbyFilterProxyModel::SetFilterFull(bool filter) {
|
|
|
|
void LobbyFilterProxyModel::SetFilterFull(bool filter) {
|
|
|
|
filter_full = filter;
|
|
|
|
filter_full = filter;
|
|
|
|
invalidate();
|
|
|
|
invalidate();
|
|
|
|