Merge pull request #5949 from ligfx/gamelistmodelupdategame
GameListModel: make UpdateGame update existing files as well
This commit is contained in:
commit
788af71f30
|
@ -208,19 +208,22 @@ QSharedPointer<GameFile> GameListModel::GetGameFile(int index) const
|
||||||
return m_games[index];
|
return m_games[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameListModel::UpdateGame(QSharedPointer<GameFile> game)
|
void GameListModel::UpdateGame(const QSharedPointer<GameFile>& game)
|
||||||
{
|
{
|
||||||
QString path = game->GetFilePath();
|
QString path = game->GetFilePath();
|
||||||
|
|
||||||
int entry = FindGame(path);
|
int index = FindGame(path);
|
||||||
if (entry < 0)
|
if (index < 0)
|
||||||
entry = m_games.size();
|
{
|
||||||
|
beginInsertRows(QModelIndex(), m_games.size(), m_games.size());
|
||||||
|
m_games.push_back(game);
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return;
|
{
|
||||||
|
m_games[index] = game;
|
||||||
beginInsertRows(QModelIndex(), entry, entry);
|
emit dataChanged(createIndex(index, 0), createIndex(index + 1, columnCount(QModelIndex())));
|
||||||
m_games.insert(entry, game);
|
}
|
||||||
endInsertRows();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameListModel::RemoveGame(const QString& path)
|
void GameListModel::RemoveGame(const QString& path)
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
NUM_COLS
|
NUM_COLS
|
||||||
};
|
};
|
||||||
|
|
||||||
void UpdateGame(QSharedPointer<GameFile> game);
|
void UpdateGame(const QSharedPointer<GameFile>& game);
|
||||||
void RemoveGame(const QString& path);
|
void RemoveGame(const QString& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue