Skip to content

Commit

Permalink
Merge pull request #5949 from ligfx/gamelistmodelupdategame
Browse files Browse the repository at this point in the history
GameListModel: make UpdateGame update existing files as well
  • Loading branch information
leoetlino committed Aug 22, 2017
2 parents 9d93a16 + 6bfb280 commit 788af71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions Source/Core/DolphinQt2/GameList/GameListModel.cpp
Expand Up @@ -208,19 +208,22 @@ QSharedPointer<GameFile> GameListModel::GetGameFile(int index) const
return m_games[index];
}

void GameListModel::UpdateGame(QSharedPointer<GameFile> game)
void GameListModel::UpdateGame(const QSharedPointer<GameFile>& 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)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt2/GameList/GameListModel.h
Expand Up @@ -45,7 +45,7 @@ class GameListModel final : public QAbstractTableModel
NUM_COLS
};

void UpdateGame(QSharedPointer<GameFile> game);
void UpdateGame(const QSharedPointer<GameFile>& game);
void RemoveGame(const QString& path);

private:
Expand Down

0 comments on commit 788af71

Please sign in to comment.