Emu: some cleanup

This commit is contained in:
Megamouse 2021-04-07 23:05:18 +02:00
parent a3e8a61547
commit 03b76b4606
149 changed files with 957 additions and 1139 deletions

View file

@ -54,7 +54,7 @@ enum node_level : int
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_gui_settings(std::move(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))
@ -224,7 +224,7 @@ void patch_manager_dialog::populate_tree()
QTreeWidgetItem* title_level_item = nullptr;
// Find top level item for this title
if (const auto list = ui->patch_tree->findItems(visible_title, Qt::MatchFlag::MatchExactly, 0); list.size() > 0)
if (const auto list = ui->patch_tree->findItems(visible_title, Qt::MatchFlag::MatchExactly, 0); !list.empty())
{
title_level_item = list[0];
}
@ -320,7 +320,7 @@ void patch_manager_dialog::populate_tree()
for (int i = ui->patch_tree->topLevelItemCount() - 1; i >= 0; i--)
{
if (auto title_level_item = ui->patch_tree->topLevelItem(i))
if (const auto title_level_item = ui->patch_tree->topLevelItem(i))
{
if (!title_level_item->data(0, persistance_role).toBool())
{
@ -337,7 +337,7 @@ void patch_manager_dialog::populate_tree()
// Move "All titles" to the top
// NOTE: "All serials" is only allowed as the only node in "All titles", so there is no need to move it up
// NOTE: "All versions" will be above valid numerical versions through sorting anyway
if (const auto all_title_items = ui->patch_tree->findItems(tr_all_titles, Qt::MatchExactly); all_title_items.size() > 0)
if (const auto all_title_items = ui->patch_tree->findItems(tr_all_titles, Qt::MatchExactly); !all_title_items.empty())
{
const auto item = all_title_items[0];
ensure(item && all_title_items.size() == 1);
@ -361,7 +361,7 @@ void patch_manager_dialog::populate_tree()
}
}
void patch_manager_dialog::save_config()
void patch_manager_dialog::save_config() const
{
patch_engine::save_config(m_map);
}
@ -475,7 +475,7 @@ void patch_manager_dialog::filter_patches(const QString& term)
m_expand_current_match = false;
}
void patch_manager_dialog::update_patch_info(const patch_manager_dialog::gui_patch_info& info)
void patch_manager_dialog::update_patch_info(const patch_manager_dialog::gui_patch_info& info) const
{
ui->label_hash->setText(info.hash);
ui->label_author->setText(info.author);
@ -540,10 +540,6 @@ void patch_manager_dialog::handle_item_selected(QTreeWidgetItem *current, QTreeW
const QString title = current->data(0, title_role).toString();
info.title = title.toStdString() == patch_key::all ? tr_all_titles : title;
[[fallthrough]];
}
default:
{
break;
}
}
@ -865,7 +861,7 @@ void patch_manager_dialog::dragLeaveEvent(QDragLeaveEvent* event)
event->accept();
}
void patch_manager_dialog::download_update()
void patch_manager_dialog::download_update() const
{
patch_log.notice("Patch download triggered");
@ -874,7 +870,7 @@ void patch_manager_dialog::download_update()
if (fs::is_file(path))
{
if (fs::file patch_file{path})
if (const fs::file patch_file{path})
{
const std::string hash = downloader::get_hash(patch_file.to_string().c_str(), patch_file.size(), true);
url += "&sha256=" + hash;