mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-11-30 16:03:05 +00:00
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) {
|
||||
search_field->setFocus();
|
||||
}
|
||||
|
||||
emit PopulatingCompleted();
|
||||
}
|
||||
|
||||
void GameList::PopupContextMenu(const QPoint& menu_location) {
|
||||
|
|
|
@ -76,6 +76,7 @@ signals:
|
|||
void OpenDirectory(QString directory);
|
||||
void AddDirectory();
|
||||
void ShowList(bool show);
|
||||
void PopulatingCompleted();
|
||||
|
||||
private slots:
|
||||
void onItemExpanded(const QModelIndex& item);
|
||||
|
|
|
@ -506,6 +506,8 @@ void GMainWindow::ConnectWidgetEvents() {
|
|||
connect(game_list_placeholder, &GameListPlaceholder::AddDirectory, this,
|
||||
&GMainWindow::OnGameListAddDirectory);
|
||||
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,
|
||||
&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
|
||||
game_list = new QStandardItemModel;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
UpdateGameList(list);
|
||||
|
||||
proxy = new ComboBoxProxyModel;
|
||||
proxy->setSourceModel(game_list);
|
||||
|
@ -79,6 +73,16 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
|||
|
||||
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() {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,11 @@ public:
|
|||
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
||||
~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();
|
||||
|
||||
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
|
||||
game_list = new QStandardItemModel;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
UpdateGameList(list);
|
||||
|
||||
proxy = new LobbyFilterProxyModel(this, game_list);
|
||||
proxy->setSourceModel(model);
|
||||
|
@ -88,6 +82,18 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
|||
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() {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
@ -260,6 +266,10 @@ void Lobby::OnRefreshLobby() {
|
|||
LobbyFilterProxyModel::LobbyFilterProxyModel(QWidget* parent, QStandardItemModel* list)
|
||||
: QSortFilterProxyModel(parent), game_list(list) {}
|
||||
|
||||
void LobbyFilterProxyModel::UpdateGameList(QStandardItemModel* list) {
|
||||
game_list = list;
|
||||
}
|
||||
|
||||
bool LobbyFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const {
|
||||
// Prioritize filters by fastest to compute
|
||||
|
||||
|
|
|
@ -30,6 +30,11 @@ public:
|
|||
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
||||
~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();
|
||||
|
||||
public slots:
|
||||
|
@ -76,9 +81,9 @@ private:
|
|||
*/
|
||||
QString PasswordPrompt();
|
||||
|
||||
QStandardItemModel* model;
|
||||
QStandardItemModel* game_list;
|
||||
LobbyFilterProxyModel* proxy;
|
||||
QStandardItemModel* model{};
|
||||
QStandardItemModel* game_list{};
|
||||
LobbyFilterProxyModel* proxy{};
|
||||
|
||||
QFutureWatcher<AnnounceMultiplayerRoom::RoomList> room_list_watcher;
|
||||
std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
|
||||
|
@ -95,6 +100,13 @@ class LobbyFilterProxyModel : public QSortFilterProxyModel {
|
|||
|
||||
public:
|
||||
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;
|
||||
void sort(int column, Qt::SortOrder order) override;
|
||||
|
||||
|
|
|
@ -286,3 +286,13 @@ bool MultiplayerState::IsHostingPublicRoom() const {
|
|||
void MultiplayerState::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();
|
||||
|
||||
/**
|
||||
* 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:
|
||||
void OnNetworkStateChanged(const Network::RoomMember::State& state);
|
||||
void OnNetworkError(const Network::RoomMember::Error& error);
|
||||
|
|
Loading…
Reference in a new issue