mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-15 08:40:06 +00:00
Fix Lobby filtering with player list
* Make double clicking the player list open the correct room * Fix an issue where filtering with search broke the whos playing list
This commit is contained in:
parent
1f6791431d
commit
62257e0d79
@ -56,8 +56,7 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
|||||||
connect(ui->games_owned, &QCheckBox::stateChanged, proxy,
|
connect(ui->games_owned, &QCheckBox::stateChanged, proxy,
|
||||||
&LobbyFilterProxyModel::SetFilterOwned);
|
&LobbyFilterProxyModel::SetFilterOwned);
|
||||||
connect(ui->hide_full, &QCheckBox::stateChanged, proxy, &LobbyFilterProxyModel::SetFilterFull);
|
connect(ui->hide_full, &QCheckBox::stateChanged, proxy, &LobbyFilterProxyModel::SetFilterFull);
|
||||||
connect(ui->search, &QLineEdit::textChanged, proxy,
|
connect(ui->search, &QLineEdit::textChanged, proxy, &LobbyFilterProxyModel::SetFilterSearch);
|
||||||
&LobbyFilterProxyModel::setFilterFixedString);
|
|
||||||
connect(ui->room_list, &QTreeView::doubleClicked, this, &Lobby::OnJoinRoom);
|
connect(ui->room_list, &QTreeView::doubleClicked, this, &Lobby::OnJoinRoom);
|
||||||
connect(ui->room_list, &QTreeView::clicked, this, &Lobby::OnExpandRoom);
|
connect(ui->room_list, &QTreeView::clicked, this, &Lobby::OnExpandRoom);
|
||||||
|
|
||||||
@ -86,7 +85,12 @@ void Lobby::OnExpandRoom(const QModelIndex& index) {
|
|||||||
auto member_list = proxy->data(member_index, LobbyItemMemberList::MemberListRole).toList();
|
auto member_list = proxy->data(member_index, LobbyItemMemberList::MemberListRole).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::OnJoinRoom(const QModelIndex& index) {
|
void Lobby::OnJoinRoom(const QModelIndex& source) {
|
||||||
|
QModelIndex index = source;
|
||||||
|
// If the user double clicks on a child row (aka the player list) then use the parent instead
|
||||||
|
if (source.parent() != QModelIndex()) {
|
||||||
|
index = source.parent();
|
||||||
|
}
|
||||||
if (!ui->nickname->hasAcceptableInput()) {
|
if (!ui->nickname->hasAcceptableInput()) {
|
||||||
NetworkMessage::ShowError(NetworkMessage::USERNAME_NOT_VALID);
|
NetworkMessage::ShowError(NetworkMessage::USERNAME_NOT_VALID);
|
||||||
return;
|
return;
|
||||||
@ -213,6 +217,11 @@ LobbyFilterProxyModel::LobbyFilterProxyModel(QWidget* parent, QStandardItemModel
|
|||||||
bool LobbyFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const {
|
bool LobbyFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const {
|
||||||
// Prioritize filters by fastest to compute
|
// Prioritize filters by fastest to compute
|
||||||
|
|
||||||
|
// pass over any child rows (aka row that shows the players in the room)
|
||||||
|
if (sourceParent != QModelIndex()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
@ -226,23 +235,22 @@ bool LobbyFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// filter by search parameters
|
// filter by search parameters
|
||||||
auto search_param = filterRegExp();
|
if (!filter_search.isEmpty()) {
|
||||||
if (!search_param.isEmpty()) {
|
|
||||||
QModelIndex game_name = sourceModel()->index(sourceRow, Column::GAME_NAME, sourceParent);
|
QModelIndex game_name = sourceModel()->index(sourceRow, Column::GAME_NAME, sourceParent);
|
||||||
QModelIndex room_name = sourceModel()->index(sourceRow, Column::ROOM_NAME, sourceParent);
|
QModelIndex room_name = sourceModel()->index(sourceRow, Column::ROOM_NAME, sourceParent);
|
||||||
QModelIndex host_name = sourceModel()->index(sourceRow, Column::HOST, sourceParent);
|
QModelIndex host_name = sourceModel()->index(sourceRow, Column::HOST, sourceParent);
|
||||||
bool preferred_game_match = sourceModel()
|
bool preferred_game_match = sourceModel()
|
||||||
->data(game_name, LobbyItemGame::GameNameRole)
|
->data(game_name, LobbyItemGame::GameNameRole)
|
||||||
.toString()
|
.toString()
|
||||||
.contains(search_param);
|
.contains(filter_search, filterCaseSensitivity());
|
||||||
bool room_name_match = sourceModel()
|
bool room_name_match = sourceModel()
|
||||||
->data(room_name, LobbyItemName::NameRole)
|
->data(room_name, LobbyItemName::NameRole)
|
||||||
.toString()
|
.toString()
|
||||||
.contains(search_param);
|
.contains(filter_search, filterCaseSensitivity());
|
||||||
bool username_match = sourceModel()
|
bool username_match = sourceModel()
|
||||||
->data(host_name, LobbyItemHost::HostUsernameRole)
|
->data(host_name, LobbyItemHost::HostUsernameRole)
|
||||||
.toString()
|
.toString()
|
||||||
.contains(search_param);
|
.contains(filter_search, filterCaseSensitivity());
|
||||||
if (!preferred_game_match && !room_name_match && !username_match) {
|
if (!preferred_game_match && !room_name_match && !username_match) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -289,6 +297,11 @@ void LobbyFilterProxyModel::SetFilterFull(bool filter) {
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LobbyFilterProxyModel::SetFilterSearch(const QString& filter) {
|
||||||
|
filter_search = filter;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
void Lobby::OnConnection() {
|
void Lobby::OnConnection() {
|
||||||
if (auto room_member = Network::GetRoomMember().lock()) {
|
if (auto room_member = Network::GetRoomMember().lock()) {
|
||||||
switch (room_member->GetState()) {
|
switch (room_member->GetState()) {
|
||||||
|
@ -122,9 +122,11 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void SetFilterOwned(bool);
|
void SetFilterOwned(bool);
|
||||||
void SetFilterFull(bool);
|
void SetFilterFull(bool);
|
||||||
|
void SetFilterSearch(const QString&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStandardItemModel* game_list;
|
QStandardItemModel* game_list;
|
||||||
bool filter_owned = false;
|
bool filter_owned = false;
|
||||||
bool filter_full = false;
|
bool filter_full = false;
|
||||||
|
QString filter_search;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user