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

@ -33,7 +33,6 @@
#include "DolphinQt/Config/ARCodeWidget.h" #include "DolphinQt/Config/ARCodeWidget.h"
#include "DolphinQt/Config/GeckoCodeWidget.h" #include "DolphinQt/Config/GeckoCodeWidget.h"
#include "DolphinQt/GameList/GameListModel.h"
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"
constexpr u32 MAX_RESULTS = 50; constexpr u32 MAX_RESULTS = 50;
@ -152,7 +151,8 @@ static bool Compare(T mem_value, T value, CompareType op)
} }
} }
CheatsManager::CheatsManager(QWidget* parent) : QDialog(parent) CheatsManager::CheatsManager(const GameListModel& game_list_model, QWidget* parent)
: QDialog(parent), m_game_list_model(game_list_model)
{ {
setWindowTitle(tr("Cheats Manager")); setWindowTitle(tr("Cheats Manager"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
@ -175,11 +175,9 @@ void CheatsManager::OnStateChanged(Core::State state)
if (state != Core::State::Running && state != Core::State::Paused) if (state != Core::State::Running && state != Core::State::Paused)
return; return;
auto* model = Settings::Instance().GetGameListModel(); for (int i = 0; i < m_game_list_model.rowCount(QModelIndex()); i++)
for (int i = 0; i < model->rowCount(QModelIndex()); i++)
{ {
auto file = model->GetGameFile(i); auto file = m_game_list_model.GetGameFile(i);
if (file->GetGameID() == SConfig::GetInstance().GetGameID()) if (file->GetGameID() == SConfig::GetInstance().GetGameID())
{ {

View File

@ -11,6 +11,7 @@
#include <QDialog> #include <QDialog>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "DolphinQt/GameList/GameListModel.h"
class ARCodeWidget; class ARCodeWidget;
class QComboBox; class QComboBox;
@ -39,7 +40,7 @@ class CheatsManager : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CheatsManager(QWidget* parent = nullptr); explicit CheatsManager(const GameListModel& game_list_model, QWidget* parent = nullptr);
~CheatsManager(); ~CheatsManager();
private: private:
@ -61,6 +62,7 @@ private:
void OnMatchContextMenu(); void OnMatchContextMenu();
void OnWatchItemChanged(QTableWidgetItem* item); void OnWatchItemChanged(QTableWidgetItem* item);
const GameListModel& m_game_list_model;
std::vector<Result> m_results; std::vector<Result> m_results;
std::vector<Result> m_watch; std::vector<Result> m_watch;
std::shared_ptr<const UICommon::GameFile> m_game_file; std::shared_ptr<const UICommon::GameFile> m_game_file;

View File

@ -41,7 +41,6 @@
#include "DolphinQt/Config/PropertiesDialog.h" #include "DolphinQt/Config/PropertiesDialog.h"
#include "DolphinQt/ConvertDialog.h" #include "DolphinQt/ConvertDialog.h"
#include "DolphinQt/GameList/GameListModel.h"
#include "DolphinQt/GameList/GridProxyModel.h" #include "DolphinQt/GameList/GridProxyModel.h"
#include "DolphinQt/GameList/ListProxyModel.h" #include "DolphinQt/GameList/ListProxyModel.h"
#include "DolphinQt/MenuBar.h" #include "DolphinQt/MenuBar.h"
@ -54,27 +53,26 @@
#include "UICommon/GameFile.h" #include "UICommon/GameFile.h"
GameList::GameList(QWidget* parent) : QStackedWidget(parent) GameList::GameList(QWidget* parent) : QStackedWidget(parent), m_model(this)
{ {
m_model = Settings::Instance().GetGameListModel();
m_list_proxy = new ListProxyModel(this); m_list_proxy = new ListProxyModel(this);
m_list_proxy->setSortCaseSensitivity(Qt::CaseInsensitive); m_list_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
m_list_proxy->setSortRole(GameListModel::SORT_ROLE); m_list_proxy->setSortRole(GameListModel::SORT_ROLE);
m_list_proxy->setSourceModel(m_model); m_list_proxy->setSourceModel(&m_model);
m_grid_proxy = new GridProxyModel(this); m_grid_proxy = new GridProxyModel(this);
m_grid_proxy->setSourceModel(m_model); m_grid_proxy->setSourceModel(&m_model);
MakeListView(); MakeListView();
MakeGridView(); MakeGridView();
MakeEmptyView(); MakeEmptyView();
if (Settings::GetQSettings().contains(QStringLiteral("gridview/scale"))) if (Settings::GetQSettings().contains(QStringLiteral("gridview/scale")))
m_model->SetScale(Settings::GetQSettings().value(QStringLiteral("gridview/scale")).toFloat()); m_model.SetScale(Settings::GetQSettings().value(QStringLiteral("gridview/scale")).toFloat());
connect(m_list, &QTableView::doubleClicked, this, &GameList::GameSelected); connect(m_list, &QTableView::doubleClicked, this, &GameList::GameSelected);
connect(m_grid, &QListView::doubleClicked, this, &GameList::GameSelected); connect(m_grid, &QListView::doubleClicked, this, &GameList::GameSelected);
connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange); connect(&m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange); connect(&m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);
addWidget(m_list); addWidget(m_list);
addWidget(m_grid); addWidget(m_grid);
@ -94,7 +92,7 @@ GameList::GameList(QWidget* parent) : QStackedWidget(parent)
void GameList::PurgeCache() void GameList::PurgeCache()
{ {
m_model->PurgeCache(); m_model.PurgeCache();
} }
void GameList::MakeListView() void GameList::MakeListView()
@ -176,7 +174,7 @@ GameList::~GameList()
{ {
Settings::GetQSettings().setValue(QStringLiteral("tableheader/state"), Settings::GetQSettings().setValue(QStringLiteral("tableheader/state"),
m_list->horizontalHeader()->saveState()); m_list->horizontalHeader()->saveState());
Settings::GetQSettings().setValue(QStringLiteral("gridview/scale"), m_model->GetScale()); Settings::GetQSettings().setValue(QStringLiteral("gridview/scale"), m_model.GetScale());
} }
void GameList::UpdateColumnVisibility() void GameList::UpdateColumnVisibility()
@ -368,21 +366,19 @@ void GameList::ShowContextMenu(const QPoint&)
menu->addSeparator(); menu->addSeparator();
auto* model = Settings::Instance().GetGameListModel();
auto* tags_menu = menu->addMenu(tr("Tags")); auto* tags_menu = menu->addMenu(tr("Tags"));
auto path = game->GetFilePath(); auto path = game->GetFilePath();
auto game_tags = model->GetGameTags(path); auto game_tags = m_model.GetGameTags(path);
for (const auto& tag : model->GetAllTags()) for (const auto& tag : m_model.GetAllTags())
{ {
auto* tag_action = tags_menu->addAction(tag); auto* tag_action = tags_menu->addAction(tag);
tag_action->setCheckable(true); tag_action->setCheckable(true);
tag_action->setChecked(game_tags.contains(tag)); tag_action->setChecked(game_tags.contains(tag));
connect(tag_action, &QAction::toggled, [path, tag, model](bool checked) { connect(tag_action, &QAction::toggled, [path, tag, model = &m_model](bool checked) {
if (!checked) if (!checked)
model->RemoveGameTag(path, tag); model->RemoveGameTag(path, tag);
else else
@ -635,7 +631,7 @@ void GameList::DeleteFile()
if (deletion_successful) if (deletion_successful)
{ {
m_model->RemoveGame(game->GetFilePath()); m_model.RemoveGame(game->GetFilePath());
} }
else else
{ {
@ -686,7 +682,7 @@ std::shared_ptr<const UICommon::GameFile> GameList::GetSelectedGame() const
if (sel_model->hasSelection()) if (sel_model->hasSelection())
{ {
QModelIndex model_index = proxy->mapToSource(sel_model->selectedIndexes()[0]); QModelIndex model_index = proxy->mapToSource(sel_model->selectedIndexes()[0]);
return m_model->GetGameFile(model_index.row()); return m_model.GetGameFile(model_index.row());
} }
return {}; return {};
} }
@ -714,7 +710,7 @@ QList<std::shared_ptr<const UICommon::GameFile>> GameList::GetSelectedGames() co
for (const auto& index : index_list) for (const auto& index : index_list)
{ {
QModelIndex model_index = proxy->mapToSource(index); QModelIndex model_index = proxy->mapToSource(index);
selected_list.push_back(m_model->GetGameFile(model_index.row())); selected_list.push_back(m_model.GetGameFile(model_index.row()));
} }
} }
return selected_list; return selected_list;
@ -728,18 +724,18 @@ bool GameList::HasMultipleSelected() const
std::shared_ptr<const UICommon::GameFile> GameList::FindGame(const std::string& path) const std::shared_ptr<const UICommon::GameFile> GameList::FindGame(const std::string& path) const
{ {
return m_model->FindGame(path); return m_model.FindGame(path);
} }
std::shared_ptr<const UICommon::GameFile> std::shared_ptr<const UICommon::GameFile>
GameList::FindSecondDisc(const UICommon::GameFile& game) const GameList::FindSecondDisc(const UICommon::GameFile& game) const
{ {
return m_model->FindSecondDisc(game); return m_model.FindSecondDisc(game);
} }
std::string GameList::GetNetPlayName(const UICommon::GameFile& game) const std::string GameList::GetNetPlayName(const UICommon::GameFile& game) const
{ {
return m_model->GetNetPlayName(game); return m_model.GetNetPlayName(game);
} }
void GameList::SetViewColumn(int col, bool view) void GameList::SetViewColumn(int col, bool view)
@ -756,7 +752,7 @@ void GameList::SetPreferredView(bool list)
void GameList::ConsiderViewChange() void GameList::ConsiderViewChange()
{ {
if (m_model->rowCount(QModelIndex()) > 0) if (m_model.rowCount(QModelIndex()) > 0)
{ {
if (m_prefer_list) if (m_prefer_list)
setCurrentWidget(m_list); setCurrentWidget(m_list);
@ -905,7 +901,7 @@ void GameList::NewTag()
if (tag.isEmpty()) if (tag.isEmpty())
return; return;
Settings::Instance().GetGameListModel()->NewTag(tag); m_model.NewTag(tag);
} }
void GameList::DeleteTag() void GameList::DeleteTag()
@ -915,12 +911,12 @@ void GameList::DeleteTag()
if (tag.isEmpty()) if (tag.isEmpty())
return; return;
Settings::Instance().GetGameListModel()->DeleteTag(tag); m_model.DeleteTag(tag);
} }
void GameList::SetSearchTerm(const QString& term) void GameList::SetSearchTerm(const QString& term)
{ {
m_model->SetSearchTerm(term); m_model.SetSearchTerm(term);
m_list_proxy->invalidate(); m_list_proxy->invalidate();
m_grid_proxy->invalidate(); m_grid_proxy->invalidate();
@ -930,7 +926,7 @@ void GameList::SetSearchTerm(const QString& term)
void GameList::ZoomIn() void GameList::ZoomIn()
{ {
m_model->SetScale(m_model->GetScale() + 0.1); m_model.SetScale(m_model.GetScale() + 0.1);
m_list_proxy->invalidate(); m_list_proxy->invalidate();
m_grid_proxy->invalidate(); m_grid_proxy->invalidate();
@ -940,10 +936,10 @@ void GameList::ZoomIn()
void GameList::ZoomOut() void GameList::ZoomOut()
{ {
if (m_model->GetScale() <= 0.1) if (m_model.GetScale() <= 0.1)
return; return;
m_model->SetScale(m_model->GetScale() - 0.1); m_model.SetScale(m_model.GetScale() - 0.1);
m_list_proxy->invalidate(); m_list_proxy->invalidate();
m_grid_proxy->invalidate(); m_grid_proxy->invalidate();
@ -955,7 +951,7 @@ void GameList::UpdateFont()
{ {
QFont f; QFont f;
f.setPointSizeF(m_model->GetScale() * f.pointSize()); f.setPointSizeF(m_model.GetScale() * f.pointSize());
m_grid->setFont(f); m_grid->setFont(f);
} }

View File

@ -8,7 +8,8 @@
#include <QStackedWidget> #include <QStackedWidget>
class GameListModel; #include "DolphinQt/GameList/GameListModel.h"
class QLabel; class QLabel;
class QListView; class QListView;
class QSortFilterProxyModel; class QSortFilterProxyModel;
@ -46,6 +47,8 @@ public:
void PurgeCache(); void PurgeCache();
const GameListModel& GetGameListModel() const { return m_model; }
signals: signals:
void GameSelected(); void GameSelected();
void NetPlayHost(const UICommon::GameFile& game); void NetPlayHost(const UICommon::GameFile& game);
@ -85,7 +88,7 @@ private:
void ConsiderViewChange(); void ConsiderViewChange();
void UpdateFont(); void UpdateFont();
GameListModel* m_model; GameListModel m_model;
QSortFilterProxyModel* m_list_proxy; QSortFilterProxyModel* m_list_proxy;
QSortFilterProxyModel* m_grid_proxy; QSortFilterProxyModel* m_grid_proxy;

View File

@ -399,7 +399,7 @@ void MainWindow::CreateComponents()
m_watch_widget = new WatchWidget(this); m_watch_widget = new WatchWidget(this);
m_breakpoint_widget = new BreakpointWidget(this); m_breakpoint_widget = new BreakpointWidget(this);
m_code_widget = new CodeWidget(this); m_code_widget = new CodeWidget(this);
m_cheats_manager = new CheatsManager(this); m_cheats_manager = new CheatsManager(m_game_list->GetGameListModel(), this);
const auto request_watch = [this](QString name, u32 addr) { const auto request_watch = [this](QString name, u32 addr) {
m_watch_widget->AddWatch(name, addr); m_watch_widget->AddWatch(name, addr);
@ -1286,8 +1286,9 @@ void MainWindow::BootWiiSystemMenu()
void MainWindow::NetPlayInit() void MainWindow::NetPlayInit()
{ {
m_netplay_setup_dialog = new NetPlaySetupDialog(this); const auto& game_list_model = m_game_list->GetGameListModel();
m_netplay_dialog = new NetPlayDialog; m_netplay_setup_dialog = new NetPlaySetupDialog(game_list_model, this);
m_netplay_dialog = new NetPlayDialog(game_list_model);
#ifdef USE_DISCORD_PRESENCE #ifdef USE_DISCORD_PRESENCE
m_netplay_discord = new DiscordHandler(this); m_netplay_discord = new DiscordHandler(this);
#endif #endif

View File

@ -10,11 +10,10 @@
#include <QListWidget> #include <QListWidget>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "DolphinQt/GameList/GameListModel.h"
#include "DolphinQt/Settings.h"
#include "UICommon/GameFile.h" #include "UICommon/GameFile.h"
GameListDialog::GameListDialog(QWidget* parent) : QDialog(parent) GameListDialog::GameListDialog(const GameListModel& game_list_model, QWidget* parent)
: QDialog(parent), m_game_list_model(game_list_model)
{ {
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Select a game")); setWindowTitle(tr("Select a game"));
@ -47,16 +46,14 @@ void GameListDialog::ConnectWidgets()
void GameListDialog::PopulateGameList() void GameListDialog::PopulateGameList()
{ {
auto* game_list_model = Settings::Instance().GetGameListModel();
m_game_list->clear(); m_game_list->clear();
for (int i = 0; i < 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 = game_list_model->GetGameFile(i); std::shared_ptr<const UICommon::GameFile> game = m_game_list_model.GetGameFile(i);
auto* item = auto* item =
new QListWidgetItem(QString::fromStdString(game_list_model->GetNetPlayName(*game))); new QListWidgetItem(QString::fromStdString(m_game_list_model.GetNetPlayName(*game)));
item->setData(Qt::UserRole, QVariant::fromValue(std::move(game))); item->setData(Qt::UserRole, QVariant::fromValue(std::move(game)));
m_game_list->addItem(item); m_game_list->addItem(item);
} }

View File

@ -6,7 +6,8 @@
#include <QDialog> #include <QDialog>
class GameListModel; #include "DolphinQt/GameList/GameListModel.h"
class QVBoxLayout; class QVBoxLayout;
class QListWidget; class QListWidget;
class QDialogButtonBox; class QDialogButtonBox;
@ -20,7 +21,7 @@ class GameListDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit GameListDialog(QWidget* parent); explicit GameListDialog(const GameListModel& game_list_model, QWidget* parent);
int exec() override; int exec() override;
const UICommon::GameFile& GetSelectedGame() const; const UICommon::GameFile& GetSelectedGame() const;
@ -30,6 +31,7 @@ private:
void ConnectWidgets(); void ConnectWidgets();
void PopulateGameList(); void PopulateGameList();
const GameListModel& m_game_list_model;
QVBoxLayout* m_main_layout; QVBoxLayout* m_main_layout;
QListWidget* m_game_list; QListWidget* m_game_list;
QDialogButtonBox* m_button_box; QDialogButtonBox* m_button_box;

View File

@ -40,7 +40,6 @@
#include "Core/NetPlayServer.h" #include "Core/NetPlayServer.h"
#include "Core/SyncIdentifier.h" #include "Core/SyncIdentifier.h"
#include "DolphinQt/GameList/GameListModel.h"
#include "DolphinQt/NetPlay/ChunkedProgressDialog.h" #include "DolphinQt/NetPlay/ChunkedProgressDialog.h"
#include "DolphinQt/NetPlay/GameListDialog.h" #include "DolphinQt/NetPlay/GameListDialog.h"
#include "DolphinQt/NetPlay/MD5Dialog.h" #include "DolphinQt/NetPlay/MD5Dialog.h"
@ -60,8 +59,8 @@
#include "VideoCommon/RenderBase.h" #include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
NetPlayDialog::NetPlayDialog(QWidget* parent) NetPlayDialog::NetPlayDialog(const GameListModel& game_list_model, QWidget* parent)
: QDialog(parent), m_game_list_model(Settings::Instance().GetGameListModel()) : QDialog(parent), m_game_list_model(game_list_model)
{ {
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
@ -158,7 +157,7 @@ void NetPlayDialog::CreateMainLayout()
Settings::Instance().GetNetPlayServer()->ComputeMD5(m_current_game_identifier); Settings::Instance().GetNetPlayServer()->ComputeMD5(m_current_game_identifier);
}); });
m_md5_menu->addAction(tr("Other game..."), this, [this] { m_md5_menu->addAction(tr("Other game..."), this, [this] {
GameListDialog gld(this); GameListDialog gld(m_game_list_model, this);
if (gld.exec() != QDialog::Accepted) if (gld.exec() != QDialog::Accepted)
return; return;
@ -322,13 +321,13 @@ void NetPlayDialog::ConnectWidgets()
connect(m_quit_button, &QPushButton::clicked, this, &NetPlayDialog::reject); connect(m_quit_button, &QPushButton::clicked, this, &NetPlayDialog::reject);
connect(m_game_button, &QPushButton::clicked, [this] { connect(m_game_button, &QPushButton::clicked, [this] {
GameListDialog gld(this); GameListDialog gld(m_game_list_model, this);
if (gld.exec() == QDialog::Accepted) if (gld.exec() == QDialog::Accepted)
{ {
Settings& settings = Settings::Instance(); Settings& settings = Settings::Instance();
const UICommon::GameFile& game = gld.GetSelectedGame(); const UICommon::GameFile& game = gld.GetSelectedGame();
const std::string netplay_name = settings.GetGameListModel()->GetNetPlayName(game); const std::string netplay_name = m_game_list_model.GetNetPlayName(game);
settings.GetNetPlayServer()->ChangeGame(game.GetSyncIdentifier(), netplay_name); settings.GetNetPlayServer()->ChangeGame(game.GetSyncIdentifier(), netplay_name);
Settings::GetQSettings().setValue(QStringLiteral("netplay/hostgame"), Settings::GetQSettings().setValue(QStringLiteral("netplay/hostgame"),
@ -1048,9 +1047,9 @@ NetPlayDialog::FindGameFile(const NetPlay::SyncIdentifier& sync_identifier,
std::optional<std::shared_ptr<const UICommon::GameFile>> game_file = std::optional<std::shared_ptr<const UICommon::GameFile>> game_file =
RunOnObject(this, [this, &sync_identifier, found] { RunOnObject(this, [this, &sync_identifier, found] {
for (int i = 0; i < m_game_list_model->rowCount(QModelIndex()); i++) for (int i = 0; i < m_game_list_model.rowCount(QModelIndex()); i++)
{ {
auto game_file = m_game_list_model->GetGameFile(i); auto game_file = m_game_list_model.GetGameFile(i);
*found = std::min(*found, game_file->CompareSyncIdentifier(sync_identifier)); *found = std::min(*found, game_file->CompareSyncIdentifier(sync_identifier));
if (*found == NetPlay::SyncIdentifierComparison::SameGame) if (*found == NetPlay::SyncIdentifierComparison::SameGame)
return game_file; return game_file;

View File

@ -9,11 +9,11 @@
#include "Common/Lazy.h" #include "Common/Lazy.h"
#include "Core/NetPlayClient.h" #include "Core/NetPlayClient.h"
#include "DolphinQt/GameList/GameListModel.h"
#include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/OnScreenDisplay.h"
class ChunkedProgressDialog; class ChunkedProgressDialog;
class MD5Dialog; class MD5Dialog;
class GameListModel;
class PadMappingDialog; class PadMappingDialog;
class QCheckBox; class QCheckBox;
class QComboBox; class QComboBox;
@ -31,7 +31,7 @@ class NetPlayDialog : public QDialog, public NetPlay::NetPlayUI
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit NetPlayDialog(QWidget* parent = nullptr); explicit NetPlayDialog(const GameListModel& game_list_model, QWidget* parent = nullptr);
~NetPlayDialog(); ~NetPlayDialog();
void show(std::string nickname, bool use_traversal); void show(std::string nickname, bool use_traversal);
@ -151,7 +151,7 @@ private:
std::string m_current_game_name; std::string m_current_game_name;
Common::Lazy<std::string> m_external_ip_address; Common::Lazy<std::string> m_external_ip_address;
std::string m_nickname; std::string m_nickname;
GameListModel* m_game_list_model = nullptr; const GameListModel& m_game_list_model;
bool m_use_traversal = false; bool m_use_traversal = false;
bool m_is_copy_button_retry = false; bool m_is_copy_button_retry = false;
bool m_got_stop_request = true; bool m_got_stop_request = true;

View File

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

View File

@ -6,7 +6,8 @@
#include <QDialog> #include <QDialog>
class GameListModel; #include "DolphinQt/GameList/GameListModel.h"
class QCheckBox; class QCheckBox;
class QComboBox; class QComboBox;
class QDialogButtonBox; class QDialogButtonBox;
@ -27,7 +28,7 @@ class NetPlaySetupDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit NetPlaySetupDialog(QWidget* parent); explicit NetPlaySetupDialog(const GameListModel& game_list_model, QWidget* parent);
void accept() override; void accept() override;
void show(); void show();
@ -79,5 +80,5 @@ private:
QCheckBox* m_host_upnp; QCheckBox* m_host_upnp;
#endif #endif
GameListModel* m_game_list_model; const GameListModel& m_game_list_model;
}; };