mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
patch_manager: expand first search results
This commit is contained in:
parent
2afc7cbaaa
commit
935e398930
@ -919,7 +919,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
|
||||
QAction* pad_configure = menu.addAction(gameinfo->hasCustomPadConfig
|
||||
? tr("&Change Custom Gamepad Configuration")
|
||||
: tr("&Create Custom Gamepad Configuration"));
|
||||
QAction* configure_patches = menu.addAction(tr("&Configure Game Patches"));
|
||||
QAction* configure_patches = menu.addAction(tr("&Manage Game Patches"));
|
||||
QAction* create_ppu_cache = menu.addAction(tr("&Create PPU Cache"));
|
||||
menu.addSeparator();
|
||||
QAction* rename_title = menu.addAction(tr("&Rename In Game List"));
|
||||
@ -1099,7 +1099,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(configure_patches, &QAction::triggered, [this, current_game, gameinfo]()
|
||||
connect(configure_patches, &QAction::triggered, [this, gameinfo]()
|
||||
{
|
||||
std::unordered_map<std::string, std::set<std::string>> games;
|
||||
for (const auto& game : m_game_data)
|
||||
@ -1109,7 +1109,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
|
||||
games[game->info.serial].insert(game_list_frame::GetGameVersion(game));
|
||||
}
|
||||
}
|
||||
patch_manager_dialog patch_manager(m_gui_settings, games, current_game.serial, this);
|
||||
patch_manager_dialog patch_manager(m_gui_settings, games, gameinfo->info.serial, GetGameVersion(gameinfo), this);
|
||||
patch_manager.exec();
|
||||
});
|
||||
connect(open_game_folder, &QAction::triggered, [current_game]()
|
||||
|
@ -1880,7 +1880,7 @@ void main_window::CreateConnects()
|
||||
}
|
||||
}
|
||||
}
|
||||
patch_manager_dialog patch_manager(m_gui_settings, games, "", this);
|
||||
patch_manager_dialog patch_manager(m_gui_settings, games, "", "", this);
|
||||
patch_manager.exec();
|
||||
});
|
||||
|
||||
|
@ -52,9 +52,11 @@ enum node_level : int
|
||||
patch_level
|
||||
};
|
||||
|
||||
patch_manager_dialog::patch_manager_dialog(std::shared_ptr<gui_settings> gui_settings, std::unordered_map<std::string, std::set<std::string>> games, const std::string& search_term, QWidget* parent)
|
||||
patch_manager_dialog::patch_manager_dialog(std::shared_ptr<gui_settings> gui_settings, std::unordered_map<std::string, std::set<std::string>> games, const std::string& title_id, const std::string& version, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_gui_settings(gui_settings)
|
||||
, m_expand_current_match(!title_id.empty() && !version.empty()) // Expand first search results
|
||||
, m_search_version(QString::fromStdString(version))
|
||||
, m_owned_games(std::move(games))
|
||||
, ui(new Ui::patch_manager_dialog)
|
||||
{
|
||||
@ -68,7 +70,7 @@ patch_manager_dialog::patch_manager_dialog(std::shared_ptr<gui_settings> gui_set
|
||||
m_show_owned_games_only = m_gui_settings->GetValue(gui::pm_show_owned).toBool();
|
||||
|
||||
// Initialize gui controls
|
||||
ui->patch_filter->setText(QString::fromStdString(search_term));
|
||||
ui->patch_filter->setText(QString::fromStdString(title_id));
|
||||
ui->cb_owned_games_only->setChecked(m_show_owned_games_only);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Download latest patches"));
|
||||
@ -416,11 +418,61 @@ void patch_manager_dialog::filter_patches(const QString& term)
|
||||
return visible_items;
|
||||
};
|
||||
|
||||
bool found_version = false;
|
||||
|
||||
// Go through each top level item and try to find matches
|
||||
for (auto top_level_item : ui->patch_tree->findItems(".*", Qt::MatchRegularExpression))
|
||||
{
|
||||
show_matches(top_level_item, false);
|
||||
if (!top_level_item)
|
||||
continue;
|
||||
|
||||
const int matches = show_matches(top_level_item, false);
|
||||
|
||||
if (matches <= 0 || !m_expand_current_match)
|
||||
continue;
|
||||
|
||||
// Expand only items that match the serial and version
|
||||
for (int i = 0; i < top_level_item->childCount(); i++)
|
||||
{
|
||||
if (const auto item = top_level_item->child(i);
|
||||
item && !item->isHidden() && item->data(0, app_version_role).toString() == m_search_version)
|
||||
{
|
||||
// This should always be a serial level item
|
||||
ensure(item->data(0, node_level_role) == node_level::serial_level);
|
||||
top_level_item->setExpanded(true);
|
||||
item->setExpanded(true);
|
||||
found_version = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_expand_current_match && !found_version)
|
||||
{
|
||||
// Expand all matching top_level items if the correct version wasn't found
|
||||
for (auto top_level_item : ui->patch_tree->findItems(".*", Qt::MatchRegularExpression))
|
||||
{
|
||||
if (!top_level_item || top_level_item->isHidden())
|
||||
continue;
|
||||
|
||||
top_level_item->setExpanded(true);
|
||||
|
||||
// Expand the "All Versions" item
|
||||
for (int i = 0; i < top_level_item->childCount(); i++)
|
||||
{
|
||||
if (const auto item = top_level_item->child(i);
|
||||
item && !item->isHidden() && item->data(0, app_version_role).toString().toStdString() == patch_key::all)
|
||||
{
|
||||
// This should always be a serial level item
|
||||
ensure(item->data(0, node_level_role) == node_level::serial_level);
|
||||
item->setExpanded(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_expand_current_match = false;
|
||||
}
|
||||
|
||||
void patch_manager_dialog::update_patch_info(const patch_manager_dialog::gui_patch_info& info)
|
||||
|
@ -37,7 +37,7 @@ class patch_manager_dialog : public QDialog
|
||||
const QString tr_all_versions = tr("All versions");
|
||||
|
||||
public:
|
||||
explicit patch_manager_dialog(std::shared_ptr<gui_settings> gui_settings, std::unordered_map<std::string, std::set<std::string>> games, const std::string& search_term, QWidget* parent = nullptr);
|
||||
explicit patch_manager_dialog(std::shared_ptr<gui_settings> gui_settings, std::unordered_map<std::string, std::set<std::string>> games, const std::string& title_id, const std::string& version, QWidget* parent = nullptr);
|
||||
~patch_manager_dialog();
|
||||
|
||||
int exec() override;
|
||||
@ -61,6 +61,9 @@ private:
|
||||
|
||||
std::shared_ptr<gui_settings> m_gui_settings;
|
||||
|
||||
bool m_expand_current_match = false;
|
||||
QString m_search_version;
|
||||
|
||||
std::unordered_map<std::string, std::set<std::string>> m_owned_games;
|
||||
bool m_show_owned_games_only = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user