Don't store custom names from TitleDatabase in GameFileCache

This saves us from having to update the GameFileCache when the
TitleDatabase changes (for instance when the user changes language).
This commit is contained in:
JosJuice
2018-06-03 12:07:53 +02:00
parent 0f7370a22c
commit 85e94cc510
12 changed files with 75 additions and 94 deletions

View File

@ -80,7 +80,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
case COL_TITLE:
if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
{
QString name = QString::fromStdString(game.GetName());
QString name = QString::fromStdString(game.GetName(m_title_database));
const int disc_nr = game.GetDiscNumber() + 1;
if (disc_nr > 1)
{
@ -161,8 +161,10 @@ bool GameListModel::ShouldDisplayGameListItem(int index) const
const UICommon::GameFile& game = *m_games[index];
if (!m_term.isEmpty() &&
!QString::fromStdString(game.GetName()).contains(m_term, Qt::CaseInsensitive))
!QString::fromStdString(game.GetName(m_title_database)).contains(m_term, Qt::CaseInsensitive))
{
return false;
}
const bool show_platform = [&game] {
switch (game.GetPlatform())

View File

@ -10,6 +10,8 @@
#include <QAbstractTableModel>
#include <QString>
#include "Core/TitleDatabase.h"
#include "DolphinQt2/GameList/GameTracker.h"
#include "UICommon/GameFile.h"
@ -63,5 +65,6 @@ private:
GameTracker m_tracker;
QList<std::shared_ptr<const UICommon::GameFile>> m_games;
Core::TitleDatabase m_title_database;
QString m_term;
};

View File

@ -105,7 +105,7 @@ void GameTracker::StartInternal()
m_initial_games_emitted_event.Wait();
bool cache_updated = m_cache.Update(paths, emit_game_loaded, emit_game_removed);
cache_updated |= m_cache.UpdateAdditionalMetadata(m_title_database, emit_game_updated);
cache_updated |= m_cache.UpdateAdditionalMetadata(emit_game_updated);
if (cache_updated)
m_cache.Save();
}
@ -256,7 +256,7 @@ void GameTracker::LoadGame(const QString& path)
if (!DiscIO::ShouldHideFromGameList(converted_path))
{
bool cache_changed = false;
auto game = m_cache.AddOrGet(converted_path, &cache_changed, m_title_database);
auto game = m_cache.AddOrGet(converted_path, &cache_changed);
if (game)
emit GameLoaded(std::move(game));
if (cache_changed)

View File

@ -14,7 +14,6 @@
#include "Common/Event.h"
#include "Common/WorkQueueThread.h"
#include "Core/TitleDatabase.h"
#include "UICommon/GameFile.h"
#include "UICommon/GameFileCache.h"
@ -75,7 +74,6 @@ private:
QMap<QString, QSet<QString>> m_tracked_files;
Common::WorkQueueThread<Command> m_load_thread;
UICommon::GameFileCache m_cache;
Core::TitleDatabase m_title_database;
Common::Event m_cache_loaded_event;
Common::Event m_initial_games_emitted_event;
bool m_initial_games_emitted = false;