From f724a061084e85081363d76f88847ff393e32ced Mon Sep 17 00:00:00 2001 From: Michael M Date: Sun, 20 Aug 2017 13:30:55 -0700 Subject: [PATCH 1/2] GameListModel: make UpdateGame update existing files as well --- .../DolphinQt2/GameList/GameListModel.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Source/Core/DolphinQt2/GameList/GameListModel.cpp b/Source/Core/DolphinQt2/GameList/GameListModel.cpp index 860fbbe9d0..f62d515849 100644 --- a/Source/Core/DolphinQt2/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt2/GameList/GameListModel.cpp @@ -204,15 +204,18 @@ void GameListModel::UpdateGame(QSharedPointer game) { QString path = game->GetFilePath(); - int entry = FindGame(path); - if (entry < 0) - entry = m_games.size(); + int index = FindGame(path); + if (index < 0) + { + beginInsertRows(QModelIndex(), m_games.size(), m_games.size()); + m_games.push_back(game); + endInsertRows(); + } else - return; - - beginInsertRows(QModelIndex(), entry, entry); - m_games.insert(entry, game); - endInsertRows(); + { + m_games[index] = game; + emit dataChanged(createIndex(index, 0), createIndex(index + 1, columnCount(QModelIndex()))); + } } void GameListModel::RemoveGame(const QString& path) From 6bfb280cec68c4987bd8b4f6744bf51aea873b9c Mon Sep 17 00:00:00 2001 From: Michael M Date: Sun, 20 Aug 2017 13:32:24 -0700 Subject: [PATCH 2/2] GameListModel: make UpdateGame take a const ref --- Source/Core/DolphinQt2/GameList/GameListModel.cpp | 2 +- Source/Core/DolphinQt2/GameList/GameListModel.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinQt2/GameList/GameListModel.cpp b/Source/Core/DolphinQt2/GameList/GameListModel.cpp index f62d515849..aca35b6e5f 100644 --- a/Source/Core/DolphinQt2/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt2/GameList/GameListModel.cpp @@ -200,7 +200,7 @@ QSharedPointer GameListModel::GetGameFile(int index) const return m_games[index]; } -void GameListModel::UpdateGame(QSharedPointer game) +void GameListModel::UpdateGame(const QSharedPointer& game) { QString path = game->GetFilePath(); diff --git a/Source/Core/DolphinQt2/GameList/GameListModel.h b/Source/Core/DolphinQt2/GameList/GameListModel.h index 1230573d98..4e2a8d27c9 100644 --- a/Source/Core/DolphinQt2/GameList/GameListModel.h +++ b/Source/Core/DolphinQt2/GameList/GameListModel.h @@ -45,7 +45,7 @@ public: NUM_COLS }; - void UpdateGame(QSharedPointer game); + void UpdateGame(const QSharedPointer& game); void RemoveGame(const QString& path); signals: