game_list: Eliminate redundant argument copies
Several functions can be taken by const reference to avoid copies
This commit is contained in:
parent
2b863c9aa3
commit
d264b7375c
|
@ -84,21 +84,24 @@ void GameListSearchField::setFilterResult(int visible, int total) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GameList::getLastFilterResultItem() const {
|
QString GameList::getLastFilterResultItem() const {
|
||||||
QStandardItem* folder;
|
|
||||||
QStandardItem* child;
|
|
||||||
QString file_path;
|
QString file_path;
|
||||||
const int folder_count = item_model->rowCount();
|
const int folder_count = item_model->rowCount();
|
||||||
|
|
||||||
for (int i = 0; i < folder_count; ++i) {
|
for (int i = 0; i < folder_count; ++i) {
|
||||||
folder = item_model->item(i, 0);
|
const QStandardItem* folder = item_model->item(i, 0);
|
||||||
const QModelIndex folder_index = folder->index();
|
const QModelIndex folder_index = folder->index();
|
||||||
const int children_count = folder->rowCount();
|
const int children_count = folder->rowCount();
|
||||||
|
|
||||||
for (int j = 0; j < children_count; ++j) {
|
for (int j = 0; j < children_count; ++j) {
|
||||||
if (!tree_view->isRowHidden(j, folder_index)) {
|
if (tree_view->isRowHidden(j, folder_index)) {
|
||||||
child = folder->child(j, 0);
|
continue;
|
||||||
file_path = child->data(GameListItemPath::FullPathRole).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QStandardItem* child = folder->child(j, 0);
|
||||||
|
file_path = child->data(GameListItemPath::FullPathRole).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return file_path;
|
return file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,7 +414,7 @@ bool GameList::isEmpty() const {
|
||||||
return !item_model->invisibleRootItem()->hasChildren();
|
return !item_model->invisibleRootItem()->hasChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::DonePopulating(QStringList watch_list) {
|
void GameList::DonePopulating(const QStringList& watch_list) {
|
||||||
emit ShowList(!isEmpty());
|
emit ShowList(!isEmpty());
|
||||||
|
|
||||||
item_model->invisibleRootItem()->appendRow(new GameListAddDir());
|
item_model->invisibleRootItem()->appendRow(new GameListAddDir());
|
||||||
|
@ -472,7 +475,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
|
||||||
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
|
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, std::string path) {
|
void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path) {
|
||||||
QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location"));
|
QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location"));
|
||||||
QAction* open_mod_location = context_menu.addAction(tr("Open Mod Data Location"));
|
QAction* open_mod_location = context_menu.addAction(tr("Open Mod Data Location"));
|
||||||
QAction* open_transferable_shader_cache =
|
QAction* open_transferable_shader_cache =
|
||||||
|
@ -690,12 +693,15 @@ void GameList::SaveInterfaceLayout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::LoadInterfaceLayout() {
|
void GameList::LoadInterfaceLayout() {
|
||||||
auto header = tree_view->header();
|
auto* header = tree_view->header();
|
||||||
if (!header->restoreState(UISettings::values.gamelist_header_state)) {
|
|
||||||
// We are using the name column to display icons and titles
|
if (header->restoreState(UISettings::values.gamelist_header_state)) {
|
||||||
// so make it as large as possible as default.
|
return;
|
||||||
header->resizeSection(COLUMN_NAME, header->width());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We are using the name column to display icons and titles
|
||||||
|
// so make it as large as possible as default.
|
||||||
|
header->resizeSection(COLUMN_NAME, header->width());
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList GameList::supported_file_extensions = {
|
const QStringList GameList::supported_file_extensions = {
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
static const QStringList supported_file_extensions;
|
static const QStringList supported_file_extensions;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void GameChosen(QString game_path);
|
void GameChosen(const QString& game_path);
|
||||||
void ShouldCancelWorker();
|
void ShouldCancelWorker();
|
||||||
void OpenFolderRequested(u64 program_id, GameListOpenTarget target,
|
void OpenFolderRequested(u64 program_id, GameListOpenTarget target,
|
||||||
const std::string& game_path);
|
const std::string& game_path);
|
||||||
|
@ -108,12 +108,12 @@ private:
|
||||||
void AddDirEntry(GameListDir* entry_items);
|
void AddDirEntry(GameListDir* entry_items);
|
||||||
void AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* parent);
|
void AddEntry(const QList<QStandardItem*>& entry_items, GameListDir* parent);
|
||||||
void ValidateEntry(const QModelIndex& item);
|
void ValidateEntry(const QModelIndex& item);
|
||||||
void DonePopulating(QStringList watch_list);
|
void DonePopulating(const QStringList& watch_list);
|
||||||
|
|
||||||
void RefreshGameDirectory();
|
void RefreshGameDirectory();
|
||||||
|
|
||||||
void PopupContextMenu(const QPoint& menu_location);
|
void PopupContextMenu(const QPoint& menu_location);
|
||||||
void AddGamePopup(QMenu& context_menu, u64 program_id, std::string path);
|
void AddGamePopup(QMenu& context_menu, u64 program_id, const std::string& path);
|
||||||
void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected);
|
void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected);
|
||||||
void AddPermDirPopup(QMenu& context_menu, QModelIndex selected);
|
void AddPermDirPopup(QMenu& context_menu, QModelIndex selected);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue