summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2018-10-28 17:00:04 +0100
committerGitHub <noreply@github.com>2018-10-28 17:00:04 +0100
commit98b0efb6ded174fdf85fa8a392e59f11b8c5520f (patch)
tree00ee2e4c52d6b8a7fd873cf64154c4dff39ddbc0 /Source
parent48862850ca1deb5a5053b0931f7eeaf14b46e2bc (diff)
parent8bbec312953277fa7970fd3adf88976eb6515dd7 (diff)
Merge pull request #7499 from JosJuice/purge-game-list-cache
DolphinQt: Implement "Purge Game List Cache"
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinQt/GameList/GameList.cpp5
-rw-r--r--Source/Core/DolphinQt/GameList/GameList.h2
-rw-r--r--Source/Core/DolphinQt/GameList/GameListModel.cpp5
-rw-r--r--Source/Core/DolphinQt/GameList/GameListModel.h2
-rw-r--r--Source/Core/DolphinQt/GameList/GameTracker.cpp9
-rw-r--r--Source/Core/DolphinQt/GameList/GameTracker.h4
-rw-r--r--Source/Core/DolphinQt/MainWindow.cpp1
-rw-r--r--Source/Core/DolphinQt/MenuBar.cpp2
-rw-r--r--Source/Core/DolphinQt/MenuBar.h1
-rw-r--r--Source/Core/UICommon/GameFileCache.cpp5
-rw-r--r--Source/Core/UICommon/GameFileCache.h8
11 files changed, 41 insertions, 3 deletions
diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp
index 2bec941b97..c2a098281f 100644
--- a/Source/Core/DolphinQt/GameList/GameList.cpp
+++ b/Source/Core/DolphinQt/GameList/GameList.cpp
@@ -89,6 +89,11 @@ GameList::GameList(QWidget* parent) : QStackedWidget(parent)
[this] { m_grid_proxy->invalidate(); });
}
+void GameList::PurgeCache()
+{
+ m_model->PurgeCache();
+}
+
void GameList::MakeListView()
{
m_list = new QTableView(this);
diff --git a/Source/Core/DolphinQt/GameList/GameList.h b/Source/Core/DolphinQt/GameList/GameList.h
index dd2635ea4b..fac9932c3c 100644
--- a/Source/Core/DolphinQt/GameList/GameList.h
+++ b/Source/Core/DolphinQt/GameList/GameList.h
@@ -41,6 +41,8 @@ public:
void resizeEvent(QResizeEvent* event) override;
+ void PurgeCache();
+
signals:
void GameSelected();
void NetPlayHost(const QString& game_id);
diff --git a/Source/Core/DolphinQt/GameList/GameListModel.cpp b/Source/Core/DolphinQt/GameList/GameListModel.cpp
index 17cd5a6334..4644a08ae3 100644
--- a/Source/Core/DolphinQt/GameList/GameListModel.cpp
+++ b/Source/Core/DolphinQt/GameList/GameListModel.cpp
@@ -362,3 +362,8 @@ void GameListModel::DeleteTag(const QString& name)
Settings::GetQSettings().setValue(QStringLiteral("gamelist/tags"), m_tag_list);
}
+
+void GameListModel::PurgeCache()
+{
+ m_tracker.PurgeCache();
+}
diff --git a/Source/Core/DolphinQt/GameList/GameListModel.h b/Source/Core/DolphinQt/GameList/GameListModel.h
index 9b7d06a421..7defb3f9cb 100644
--- a/Source/Core/DolphinQt/GameList/GameListModel.h
+++ b/Source/Core/DolphinQt/GameList/GameListModel.h
@@ -75,6 +75,8 @@ public:
void NewTag(const QString& name);
void DeleteTag(const QString& name);
+ void PurgeCache();
+
private:
// Index in m_games, or -1 if it isn't found
int FindGame(const std::string& path) const;
diff --git a/Source/Core/DolphinQt/GameList/GameTracker.cpp b/Source/Core/DolphinQt/GameList/GameTracker.cpp
index 056bcf0e66..ea1b87e1fd 100644
--- a/Source/Core/DolphinQt/GameList/GameTracker.cpp
+++ b/Source/Core/DolphinQt/GameList/GameTracker.cpp
@@ -75,6 +75,9 @@ GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent)
});
QueueOnObject(this, [this] { Settings::Instance().NotifyMetadataRefreshComplete(); });
break;
+ case CommandType::PurgeCache:
+ m_cache.Clear(UICommon::GameFileCache::DeleteOnDisk::Yes);
+ break;
}
});
@@ -322,3 +325,9 @@ void GameTracker::LoadGame(const QString& path)
m_cache.Save();
}
}
+
+void GameTracker::PurgeCache()
+{
+ m_load_thread.EmplaceItem(Command{CommandType::PurgeCache, {}});
+ RefreshAll();
+}
diff --git a/Source/Core/DolphinQt/GameList/GameTracker.h b/Source/Core/DolphinQt/GameList/GameTracker.h
index d212d983a2..79a2678d33 100644
--- a/Source/Core/DolphinQt/GameList/GameTracker.h
+++ b/Source/Core/DolphinQt/GameList/GameTracker.h
@@ -41,6 +41,7 @@ public:
void AddDirectory(const QString& dir);
void RemoveDirectory(const QString& dir);
void RefreshAll();
+ void PurgeCache();
signals:
void GameLoaded(const std::shared_ptr<const UICommon::GameFile>& game);
@@ -70,7 +71,8 @@ private:
RemoveDirectory,
UpdateDirectory,
UpdateFile,
- UpdateMetadata
+ UpdateMetadata,
+ PurgeCache
};
struct Command
diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp
index b80a0bd2ab..79dd010cbb 100644
--- a/Source/Core/DolphinQt/MainWindow.cpp
+++ b/Source/Core/DolphinQt/MainWindow.cpp
@@ -429,6 +429,7 @@ void MainWindow::ConnectMenuBar()
// View
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
connect(m_menu_bar, &MenuBar::ShowGrid, m_game_list, &GameList::SetGridView);
+ connect(m_menu_bar, &MenuBar::PurgeGameListCache, m_game_list, &GameList::PurgeCache);
connect(m_menu_bar, &MenuBar::ToggleSearch, m_search_bar, &SearchBar::Toggle);
connect(m_menu_bar, &MenuBar::ColumnVisibilityToggled, m_game_list,
diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp
index 499a7fac6d..6b3e88e930 100644
--- a/Source/Core/DolphinQt/MenuBar.cpp
+++ b/Source/Core/DolphinQt/MenuBar.cpp
@@ -458,6 +458,8 @@ void MenuBar::AddViewMenu()
AddShowRegionsMenu(view_menu);
view_menu->addSeparator();
+ view_menu->addAction(tr("Purge Game List Cache"), this, &MenuBar::PurgeGameListCache);
+ view_menu->addSeparator();
view_menu->addAction(tr("Search"), this, &MenuBar::ToggleSearch,
QKeySequence(QStringLiteral("Ctrl+F")));
}
diff --git a/Source/Core/DolphinQt/MenuBar.h b/Source/Core/DolphinQt/MenuBar.h
index 858b5c0fde..eedee4b6d5 100644
--- a/Source/Core/DolphinQt/MenuBar.h
+++ b/Source/Core/DolphinQt/MenuBar.h
@@ -90,6 +90,7 @@ signals:
// View
void ShowList();
void ShowGrid();
+ void PurgeGameListCache();
void ToggleSearch();
void ColumnVisibilityToggled(const QString& row, bool visible);
void GameListPlatformVisibilityToggled(const QString& row, bool visible);
diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp
index 282dcd0ee8..7fa558d889 100644
--- a/Source/Core/UICommon/GameFileCache.cpp
+++ b/Source/Core/UICommon/GameFileCache.cpp
@@ -58,8 +58,11 @@ size_t GameFileCache::GetSize() const
return m_cached_files.size();
}
-void GameFileCache::Clear()
+void GameFileCache::Clear(DeleteOnDisk delete_on_disk)
{
+ if (delete_on_disk != DeleteOnDisk::No)
+ File::Delete(m_path);
+
m_cached_files.clear();
}
diff --git a/Source/Core/UICommon/GameFileCache.h b/Source/Core/UICommon/GameFileCache.h
index 197cceb547..2e09c6da16 100644
--- a/Source/Core/UICommon/GameFileCache.h
+++ b/Source/Core/UICommon/GameFileCache.h
@@ -24,13 +24,19 @@ std::vector<std::string> FindAllGamePaths(const std::vector<std::string>& direct
class GameFileCache
{
public:
+ enum class DeleteOnDisk
+ {
+ No = 0,
+ Yes = 1,
+ };
+
GameFileCache(); // Uses the default path
explicit GameFileCache(std::string path);
void ForEach(std::function<void(const std::shared_ptr<const GameFile>&)> f) const;
size_t GetSize() const;
- void Clear();
+ void Clear(DeleteOnDisk delete_on_disk);
// Returns nullptr if the file is invalid.
std::shared_ptr<const GameFile> AddOrGet(const std::string& path, bool* cache_changed);