GameListModel instance ownership transferred back to the GameList instance. The GameListModel instance will be passed as a constructor parameter where needed.

This commit is contained in:
Christian Aguilera
2019-01-17 22:28:07 +00:00
parent 0d02e70d4a
commit 5b757024c4
11 changed files with 69 additions and 71 deletions

View File

@ -21,7 +21,6 @@
#include "Core/Config/NetplaySettings.h"
#include "Core/NetPlayProto.h"
#include "DolphinQt/GameList/GameListModel.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/QtUtils/UTF8CodePointCountValidator.h"
#include "DolphinQt/Settings.h"
@ -29,8 +28,8 @@
#include "UICommon/GameFile.h"
#include "UICommon/NetPlayIndex.h"
NetPlaySetupDialog::NetPlaySetupDialog(QWidget* parent)
: QDialog(parent), m_game_list_model(Settings::Instance().GetGameListModel())
NetPlaySetupDialog::NetPlaySetupDialog(const GameListModel& game_list_model, QWidget* parent)
: QDialog(parent), m_game_list_model(game_list_model)
{
setWindowTitle(tr("NetPlay Setup"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
@ -359,12 +358,12 @@ void NetPlaySetupDialog::PopulateGameList()
QSignalBlocker blocker(m_host_games);
m_host_games->clear();
for (int i = 0; i < m_game_list_model->rowCount(QModelIndex()); i++)
for (int i = 0; i < m_game_list_model.rowCount(QModelIndex()); i++)
{
std::shared_ptr<const UICommon::GameFile> game = m_game_list_model->GetGameFile(i);
std::shared_ptr<const UICommon::GameFile> game = m_game_list_model.GetGameFile(i);
auto* item =
new QListWidgetItem(QString::fromStdString(m_game_list_model->GetNetPlayName(*game)));
new QListWidgetItem(QString::fromStdString(m_game_list_model.GetNetPlayName(*game)));
item->setData(Qt::UserRole, QVariant::fromValue(std::move(game)));
m_host_games->addItem(item);
}