citra_qt: Update the multiplayer dialogs when game list is repopulated
The multiplayer state object and dialogs hold a (modified) game list model, but it isn't updated when the actual game list changes. This updates the multiplayer dialogs with the new game list when it got repopulated.
This commit is contained in:
parent
4a9ea65e49
commit
40ad54c5c7
|
@ -421,6 +421,8 @@ void GameList::DonePopulating(QStringList watch_list) {
|
||||||
if (childrenTotal > 0) {
|
if (childrenTotal > 0) {
|
||||||
search_field->setFocus();
|
search_field->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit PopulatingCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::PopupContextMenu(const QPoint& menu_location) {
|
void GameList::PopupContextMenu(const QPoint& menu_location) {
|
||||||
|
|
|
@ -76,6 +76,7 @@ signals:
|
||||||
void OpenDirectory(QString directory);
|
void OpenDirectory(QString directory);
|
||||||
void AddDirectory();
|
void AddDirectory();
|
||||||
void ShowList(bool show);
|
void ShowList(bool show);
|
||||||
|
void PopulatingCompleted();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onItemExpanded(const QModelIndex& item);
|
void onItemExpanded(const QModelIndex& item);
|
||||||
|
|
|
@ -506,6 +506,8 @@ void GMainWindow::ConnectWidgetEvents() {
|
||||||
connect(game_list_placeholder, &GameListPlaceholder::AddDirectory, this,
|
connect(game_list_placeholder, &GameListPlaceholder::AddDirectory, this,
|
||||||
&GMainWindow::OnGameListAddDirectory);
|
&GMainWindow::OnGameListAddDirectory);
|
||||||
connect(game_list, &GameList::ShowList, this, &GMainWindow::OnGameListShowList);
|
connect(game_list, &GameList::ShowList, this, &GMainWindow::OnGameListShowList);
|
||||||
|
connect(game_list, &GameList::PopulatingCompleted,
|
||||||
|
[this] { multiplayer_state->UpdateGameList(game_list->GetModel()); });
|
||||||
|
|
||||||
connect(this, &GMainWindow::EmulationStarting, render_window,
|
connect(this, &GMainWindow::EmulationStarting, render_window,
|
||||||
&GRenderWindow::OnEmulationStarting);
|
&GRenderWindow::OnEmulationStarting);
|
||||||
|
|
|
@ -41,13 +41,7 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
||||||
|
|
||||||
// Create a proxy to the game list to display the list of preferred games
|
// Create a proxy to the game list to display the list of preferred games
|
||||||
game_list = new QStandardItemModel;
|
game_list = new QStandardItemModel;
|
||||||
|
UpdateGameList(list);
|
||||||
for (int i = 0; i < list->rowCount(); i++) {
|
|
||||||
auto parent = list->item(i, 0);
|
|
||||||
for (int j = 0; j < parent->rowCount(); j++) {
|
|
||||||
game_list->appendRow(parent->child(j)->clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy = new ComboBoxProxyModel;
|
proxy = new ComboBoxProxyModel;
|
||||||
proxy->setSourceModel(game_list);
|
proxy->setSourceModel(game_list);
|
||||||
|
@ -79,6 +73,16 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
||||||
|
|
||||||
HostRoomWindow::~HostRoomWindow() = default;
|
HostRoomWindow::~HostRoomWindow() = default;
|
||||||
|
|
||||||
|
void HostRoomWindow::UpdateGameList(QStandardItemModel* list) {
|
||||||
|
game_list->clear();
|
||||||
|
for (int i = 0; i < list->rowCount(); i++) {
|
||||||
|
auto parent = list->item(i, 0);
|
||||||
|
for (int j = 0; j < parent->rowCount(); j++) {
|
||||||
|
game_list->appendRow(parent->child(j)->clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void HostRoomWindow::RetranslateUi() {
|
void HostRoomWindow::RetranslateUi() {
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,11 @@ public:
|
||||||
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
||||||
~HostRoomWindow();
|
~HostRoomWindow();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the dialog with a new game list model.
|
||||||
|
* This model should be the original model of the game list.
|
||||||
|
*/
|
||||||
|
void UpdateGameList(QStandardItemModel* list);
|
||||||
void RetranslateUi();
|
void RetranslateUi();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -35,13 +35,7 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
||||||
|
|
||||||
// Create a proxy to the game list to get the list of games owned
|
// Create a proxy to the game list to get the list of games owned
|
||||||
game_list = new QStandardItemModel;
|
game_list = new QStandardItemModel;
|
||||||
|
UpdateGameList(list);
|
||||||
for (int i = 0; i < list->rowCount(); i++) {
|
|
||||||
auto parent = list->item(i, 0);
|
|
||||||
for (int j = 0; j < parent->rowCount(); j++) {
|
|
||||||
game_list->appendRow(parent->child(j)->clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy = new LobbyFilterProxyModel(this, game_list);
|
proxy = new LobbyFilterProxyModel(this, game_list);
|
||||||
proxy->setSourceModel(model);
|
proxy->setSourceModel(model);
|
||||||
|
@ -88,6 +82,18 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
||||||
RefreshLobby();
|
RefreshLobby();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lobby::UpdateGameList(QStandardItemModel* list) {
|
||||||
|
game_list->clear();
|
||||||
|
for (int i = 0; i < list->rowCount(); i++) {
|
||||||
|
auto parent = list->item(i, 0);
|
||||||
|
for (int j = 0; j < parent->rowCount(); j++) {
|
||||||
|
game_list->appendRow(parent->child(j)->clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (proxy)
|
||||||
|
proxy->UpdateGameList(game_list);
|
||||||
|
}
|
||||||
|
|
||||||
void Lobby::RetranslateUi() {
|
void Lobby::RetranslateUi() {
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
}
|
}
|
||||||
|
@ -260,6 +266,10 @@ void Lobby::OnRefreshLobby() {
|
||||||
LobbyFilterProxyModel::LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list)
|
LobbyFilterProxyModel::LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list)
|
||||||
: QSortFilterProxyModel(parent), game_list(list) {}
|
: QSortFilterProxyModel(parent), game_list(list) {}
|
||||||
|
|
||||||
|
void LobbyFilterProxyModel::UpdateGameList(QStandardItemModel* list) {
|
||||||
|
game_list = list;
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,11 @@ public:
|
||||||
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
||||||
~Lobby() = default;
|
~Lobby() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the lobby with a new game list model.
|
||||||
|
* This model should be the original model of the game list.
|
||||||
|
*/
|
||||||
|
void UpdateGameList(QStandardItemModel* list);
|
||||||
void RetranslateUi();
|
void RetranslateUi();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -76,9 +81,9 @@ private:
|
||||||
*/
|
*/
|
||||||
QString PasswordPrompt();
|
QString PasswordPrompt();
|
||||||
|
|
||||||
QStandardItemModel* model;
|
QStandardItemModel* model{};
|
||||||
QStandardItemModel* game_list;
|
QStandardItemModel* game_list{};
|
||||||
LobbyFilterProxyModel* proxy;
|
LobbyFilterProxyModel* proxy{};
|
||||||
|
|
||||||
QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher;
|
QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher;
|
||||||
std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
|
std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
|
||||||
|
@ -95,6 +100,13 @@ class LobbyFilterProxyModel : public QSortFilterProxyModel {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list);
|
explicit LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the filter with a new game list model.
|
||||||
|
* This model should be the processed one created by the Lobby.
|
||||||
|
*/
|
||||||
|
void UpdateGameList(QStandardItemModel* list);
|
||||||
|
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
|
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
|
||||||
void sort(int column, Qt::SortOrder order) override;
|
void sort(int column, Qt::SortOrder order) override;
|
||||||
|
|
||||||
|
|
|
@ -286,3 +286,13 @@ bool MultiplayerState::IsHostingPublicRoom() const {
|
||||||
void MultiplayerState::UpdateCredentials() {
|
void MultiplayerState::UpdateCredentials() {
|
||||||
announce_multiplayer_session->UpdateCredentials();
|
announce_multiplayer_session->UpdateCredentials();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiplayerState::UpdateGameList(QStandardItemModel* game_list) {
|
||||||
|
game_list_model = game_list;
|
||||||
|
if (lobby) {
|
||||||
|
lobby->UpdateGameList(game_list);
|
||||||
|
}
|
||||||
|
if (host_room) {
|
||||||
|
host_room->UpdateGameList(game_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -46,6 +46,12 @@ public:
|
||||||
|
|
||||||
void UpdateCredentials();
|
void UpdateCredentials();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the multiplayer dialogs with a new game list model.
|
||||||
|
* This model should be the original model of the game list.
|
||||||
|
*/
|
||||||
|
void UpdateGameList(QStandardItemModel* game_list);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnNetworkStateChanged(const Network::RoomMember::State& state);
|
void OnNetworkStateChanged(const Network::RoomMember::State& state);
|
||||||
void OnNetworkError(const Network::RoomMember::Error& error);
|
void OnNetworkError(const Network::RoomMember::Error& error);
|
||||||
|
|
Loading…
Reference in New Issue