aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/game_list.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu/game_list.cpp')
-rw-r--r--src/yuzu/game_list.cpp56
1 files changed, 17 insertions, 39 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 63cf82f7d..9308cfef8 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -91,9 +91,8 @@ QString GameListSearchField::filterText() const {
QString GameList::GetLastFilterResultItem() const {
QString file_path;
- const int folder_count = item_model->rowCount();
- for (int i = 0; i < folder_count; ++i) {
+ for (int i = 1; i < item_model->rowCount() - 1; ++i) {
const QStandardItem* folder = item_model->item(i, 0);
const QModelIndex folder_index = folder->index();
const int children_count = folder->rowCount();
@@ -184,7 +183,6 @@ void GameList::OnItemExpanded(const QModelIndex& item) {
// Event in order to filter the gamelist after editing the searchfield
void GameList::OnTextChanged(const QString& new_text) {
- const int folder_count = tree_view->model()->rowCount();
QString edit_filter_text = new_text.toLower();
QStandardItem* folder;
int children_total = 0;
@@ -194,7 +192,7 @@ void GameList::OnTextChanged(const QString& new_text) {
if (edit_filter_text.isEmpty()) {
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(),
UISettings::values.favorited_ids.size() == 0);
- for (int i = 1; i < folder_count; ++i) {
+ for (int i = 1; i < item_model->rowCount() - 1; ++i) {
folder = item_model->item(i, 0);
const QModelIndex folder_index = folder->index();
const int children_count = folder->rowCount();
@@ -207,7 +205,7 @@ void GameList::OnTextChanged(const QString& new_text) {
} else {
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true);
int result_count = 0;
- for (int i = 1; i < folder_count; ++i) {
+ for (int i = 1; i < item_model->rowCount() - 1; ++i) {
folder = item_model->item(i, 0);
const QModelIndex folder_index = folder->index();
const int children_count = folder->rowCount();
@@ -328,18 +326,14 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvide
tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
tree_view->setStyleSheet(QStringLiteral("QTreeView{ border: none; }"));
- item_model->insertColumns(0, UISettings::values.show_add_ons ? COLUMN_COUNT : COLUMN_COUNT - 1);
+ item_model->insertColumns(0, COLUMN_COUNT);
item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name"));
item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility"));
- if (UISettings::values.show_add_ons) {
- item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons"));
- item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
- item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
- } else {
- item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type"));
- item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size"));
- }
+ item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons"));
+ tree_view->setColumnHidden(COLUMN_ADD_ONS, !UISettings::values.show_add_ons);
+ item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
+ item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
item_model->setSortRole(GameListItemPath::SortRole);
connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::OnUpdateThemedIcons);
@@ -466,9 +460,8 @@ void GameList::DonePopulating(const QStringList& watch_list) {
QCoreApplication::processEvents();
}
tree_view->setEnabled(true);
- const int folder_count = tree_view->model()->rowCount();
int children_total = 0;
- for (int i = 1; i < folder_count; ++i) {
+ for (int i = 1; i < item_model->rowCount() - 1; ++i) {
children_total += item_model->item(i, 0)->rowCount();
}
search_field->setFilterResult(children_total, children_total);
@@ -561,11 +554,11 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri
connect(remove_dlc, &QAction::triggered, [this, program_id]() {
emit RemoveInstalledEntryRequested(program_id, InstalledEntryType::AddOnContent);
});
- connect(remove_shader_cache, &QAction::triggered, [this, program_id]() {
- emit RemoveFileRequested(program_id, GameListRemoveTarget::ShaderCache);
+ connect(remove_shader_cache, &QAction::triggered, [this, program_id, path]() {
+ emit RemoveFileRequested(program_id, GameListRemoveTarget::ShaderCache, path);
});
- connect(remove_custom_config, &QAction::triggered, [this, program_id]() {
- emit RemoveFileRequested(program_id, GameListRemoveTarget::CustomConfiguration);
+ connect(remove_custom_config, &QAction::triggered, [this, program_id, path]() {
+ emit RemoveFileRequested(program_id, GameListRemoveTarget::CustomConfiguration, path);
});
connect(dump_romfs, &QAction::triggered,
[this, program_id, path]() { emit DumpRomFSRequested(program_id, path); });
@@ -649,9 +642,9 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) {
}
void GameList::AddFavoritesPopup(QMenu& context_menu) {
- QAction* clear_all = context_menu.addAction(tr("Clear"));
+ QAction* clear = context_menu.addAction(tr("Clear"));
- connect(clear_all, &QAction::triggered, [this] {
+ connect(clear, &QAction::triggered, [this] {
for (const auto id : UISettings::values.favorited_ids) {
RemoveFavorite(id);
}
@@ -708,22 +701,7 @@ void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
tree_view->setEnabled(false);
// Update the columns in case UISettings has changed
- item_model->removeColumns(0, item_model->columnCount());
- item_model->insertColumns(0, UISettings::values.show_add_ons ? COLUMN_COUNT : COLUMN_COUNT - 1);
- item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name"));
- item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility"));
-
- if (UISettings::values.show_add_ons) {
- item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons"));
- item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type"));
- item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size"));
- } else {
- item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type"));
- item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size"));
- item_model->removeColumns(COLUMN_COUNT - 1, 1);
- }
-
- LoadInterfaceLayout();
+ tree_view->setColumnHidden(COLUMN_ADD_ONS, !UISettings::values.show_add_ons);
// Delete any rows that might already exist if we're repopulating
item_model->removeRows(0, item_model->rowCount());
@@ -800,7 +778,7 @@ void GameList::AddFavorite(u64 program_id) {
if (folder->child(j)->data(GameListItemPath::ProgramIdRole).toULongLong() ==
program_id) {
QList<QStandardItem*> list;
- for (int k = 0; k < item_model->columnCount(); k++) {
+ for (int k = 0; k < COLUMN_COUNT; k++) {
list.append(folder->child(j, k)->clone());
}
list[0]->setData(folder->child(j)->data(GameListItem::SortRole),