summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2020-09-23 11:28:08 -0400
committerGravatar Lioncash2020-09-23 11:28:11 -0400
commitf43a1da808a26d5521cb0260998fe2403a3efc07 (patch)
treef8056a334d18c94201fedcad4e469a4adea20877 /src
parentgame_list: Eliminate redundant argument copies (diff)
downloadyuzu-f43a1da808a26d5521cb0260998fe2403a3efc07.tar.gz
yuzu-f43a1da808a26d5521cb0260998fe2403a3efc07.tar.xz
yuzu-f43a1da808a26d5521cb0260998fe2403a3efc07.zip
game_list: Make game list function naming consistent
Makes the naming consistent with the rest of the functions that are present.
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/game_list.cpp48
-rw-r--r--src/yuzu/game_list.h18
-rw-r--r--src/yuzu/main.cpp15
3 files changed, 45 insertions, 36 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 12d0321db..a9738e298 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -56,7 +56,7 @@ bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* eve
56 case Qt::Key_Return: 56 case Qt::Key_Return:
57 case Qt::Key_Enter: { 57 case Qt::Key_Enter: {
58 if (gamelist->search_field->visible == 1) { 58 if (gamelist->search_field->visible == 1) {
59 QString file_path = gamelist->getLastFilterResultItem(); 59 const QString file_path = gamelist->GetLastFilterResultItem();
60 60
61 // To avoid loading error dialog loops while confirming them using enter 61 // To avoid loading error dialog loops while confirming them using enter
62 // Also users usually want to run a different game after closing one 62 // Also users usually want to run a different game after closing one
@@ -83,7 +83,7 @@ void GameListSearchField::setFilterResult(int visible, int total) {
83 label_filter_result->setText(tr("%1 of %n result(s)", "", total).arg(visible)); 83 label_filter_result->setText(tr("%1 of %n result(s)", "", total).arg(visible));
84} 84}
85 85
86QString GameList::getLastFilterResultItem() const { 86QString GameList::GetLastFilterResultItem() const {
87 QString file_path; 87 QString file_path;
88 const int folder_count = item_model->rowCount(); 88 const int folder_count = item_model->rowCount();
89 89
@@ -126,7 +126,7 @@ GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} {
126 edit_filter->setPlaceholderText(tr("Enter pattern to filter")); 126 edit_filter->setPlaceholderText(tr("Enter pattern to filter"));
127 edit_filter->installEventFilter(key_release_eater); 127 edit_filter->installEventFilter(key_release_eater);
128 edit_filter->setClearButtonEnabled(true); 128 edit_filter->setClearButtonEnabled(true);
129 connect(edit_filter, &QLineEdit::textChanged, parent, &GameList::onTextChanged); 129 connect(edit_filter, &QLineEdit::textChanged, parent, &GameList::OnTextChanged);
130 label_filter_result = new QLabel; 130 label_filter_result = new QLabel;
131 button_filter_close = new QToolButton(this); 131 button_filter_close = new QToolButton(this);
132 button_filter_close->setText(QStringLiteral("X")); 132 button_filter_close->setText(QStringLiteral("X"));
@@ -136,7 +136,7 @@ GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} {
136 "#000000; font-weight: bold; background: #F0F0F0; }" 136 "#000000; font-weight: bold; background: #F0F0F0; }"
137 "QToolButton:hover{ border: none; padding: 0px; color: " 137 "QToolButton:hover{ border: none; padding: 0px; color: "
138 "#EEEEEE; font-weight: bold; background: #E81123}")); 138 "#EEEEEE; font-weight: bold; background: #E81123}"));
139 connect(button_filter_close, &QToolButton::clicked, parent, &GameList::onFilterCloseClicked); 139 connect(button_filter_close, &QToolButton::clicked, parent, &GameList::OnFilterCloseClicked);
140 layout_filter->setSpacing(10); 140 layout_filter->setSpacing(10);
141 layout_filter->addWidget(label_filter); 141 layout_filter->addWidget(label_filter);
142 layout_filter->addWidget(edit_filter); 142 layout_filter->addWidget(edit_filter);
@@ -162,16 +162,22 @@ static bool ContainsAllWords(const QString& haystack, const QString& userinput)
162} 162}
163 163
164// Syncs the expanded state of Game Directories with settings to persist across sessions 164// Syncs the expanded state of Game Directories with settings to persist across sessions
165void GameList::onItemExpanded(const QModelIndex& item) { 165void GameList::OnItemExpanded(const QModelIndex& item) {
166 const auto type = item.data(GameListItem::TypeRole).value<GameListItemType>(); 166 const auto type = item.data(GameListItem::TypeRole).value<GameListItemType>();
167 if (type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir || 167 const bool is_dir = type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir ||
168 type == GameListItemType::UserNandDir || type == GameListItemType::SysNandDir) 168 type == GameListItemType::UserNandDir ||
169 item.data(GameListDir::GameDirRole).value<UISettings::GameDir*>()->expanded = 169 type == GameListItemType::SysNandDir;
170 tree_view->isExpanded(item); 170
171 if (!is_dir) {
172 return;
173 }
174
175 auto* game_dir = item.data(GameListDir::GameDirRole).value<UISettings::GameDir*>();
176 game_dir->expanded = tree_view->isExpanded(item);
171} 177}
172 178
173// Event in order to filter the gamelist after editing the searchfield 179// Event in order to filter the gamelist after editing the searchfield
174void GameList::onTextChanged(const QString& new_text) { 180void GameList::OnTextChanged(const QString& new_text) {
175 const int folder_count = tree_view->model()->rowCount(); 181 const int folder_count = tree_view->model()->rowCount();
176 QString edit_filter_text = new_text.toLower(); 182 QString edit_filter_text = new_text.toLower();
177 QStandardItem* folder; 183 QStandardItem* folder;
@@ -227,7 +233,7 @@ void GameList::onTextChanged(const QString& new_text) {
227 } 233 }
228} 234}
229 235
230void GameList::onUpdateThemedIcons() { 236void GameList::OnUpdateThemedIcons() {
231 for (int i = 0; i < item_model->invisibleRootItem()->rowCount(); i++) { 237 for (int i = 0; i < item_model->invisibleRootItem()->rowCount(); i++) {
232 QStandardItem* child = item_model->invisibleRootItem()->child(i); 238 QStandardItem* child = item_model->invisibleRootItem()->child(i);
233 239
@@ -279,7 +285,7 @@ void GameList::onUpdateThemedIcons() {
279 } 285 }
280} 286}
281 287
282void GameList::onFilterCloseClicked() { 288void GameList::OnFilterCloseClicked() {
283 main_window->filterBarSetChecked(false); 289 main_window->filterBarSetChecked(false);
284} 290}
285 291
@@ -320,11 +326,11 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvide
320 } 326 }
321 item_model->setSortRole(GameListItemPath::SortRole); 327 item_model->setSortRole(GameListItemPath::SortRole);
322 328
323 connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::onUpdateThemedIcons); 329 connect(main_window, &GMainWindow::UpdateThemedIcons, this, &GameList::OnUpdateThemedIcons);
324 connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry); 330 connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry);
325 connect(tree_view, &QTreeView::customContextMenuRequested, this, &GameList::PopupContextMenu); 331 connect(tree_view, &QTreeView::customContextMenuRequested, this, &GameList::PopupContextMenu);
326 connect(tree_view, &QTreeView::expanded, this, &GameList::onItemExpanded); 332 connect(tree_view, &QTreeView::expanded, this, &GameList::OnItemExpanded);
327 connect(tree_view, &QTreeView::collapsed, this, &GameList::onItemExpanded); 333 connect(tree_view, &QTreeView::collapsed, this, &GameList::OnItemExpanded);
328 334
329 // We must register all custom types with the Qt Automoc system so that we are able to use 335 // We must register all custom types with the Qt Automoc system so that we are able to use
330 // it with signals/slots. In this case, QList falls under the umbrells of custom types. 336 // it with signals/slots. In this case, QList falls under the umbrells of custom types.
@@ -341,17 +347,17 @@ GameList::~GameList() {
341 emit ShouldCancelWorker(); 347 emit ShouldCancelWorker();
342} 348}
343 349
344void GameList::setFilterFocus() { 350void GameList::SetFilterFocus() {
345 if (tree_view->model()->rowCount() > 0) { 351 if (tree_view->model()->rowCount() > 0) {
346 search_field->setFocus(); 352 search_field->setFocus();
347 } 353 }
348} 354}
349 355
350void GameList::setFilterVisible(bool visibility) { 356void GameList::SetFilterVisible(bool visibility) {
351 search_field->setVisible(visibility); 357 search_field->setVisible(visibility);
352} 358}
353 359
354void GameList::clearFilter() { 360void GameList::ClearFilter() {
355 search_field->clear(); 361 search_field->clear();
356} 362}
357 363
@@ -400,10 +406,11 @@ void GameList::ValidateEntry(const QModelIndex& item) {
400 } 406 }
401} 407}
402 408
403bool GameList::isEmpty() const { 409bool GameList::IsEmpty() const {
404 for (int i = 0; i < item_model->rowCount(); i++) { 410 for (int i = 0; i < item_model->rowCount(); i++) {
405 const QStandardItem* child = item_model->invisibleRootItem()->child(i); 411 const QStandardItem* child = item_model->invisibleRootItem()->child(i);
406 const auto type = static_cast<GameListItemType>(child->type()); 412 const auto type = static_cast<GameListItemType>(child->type());
413
407 if (!child->hasChildren() && 414 if (!child->hasChildren() &&
408 (type == GameListItemType::SdmcDir || type == GameListItemType::UserNandDir || 415 (type == GameListItemType::SdmcDir || type == GameListItemType::UserNandDir ||
409 type == GameListItemType::SysNandDir)) { 416 type == GameListItemType::SysNandDir)) {
@@ -411,11 +418,12 @@ bool GameList::isEmpty() const {
411 i--; 418 i--;
412 } 419 }
413 } 420 }
421
414 return !item_model->invisibleRootItem()->hasChildren(); 422 return !item_model->invisibleRootItem()->hasChildren();
415} 423}
416 424
417void GameList::DonePopulating(const QStringList& watch_list) { 425void GameList::DonePopulating(const QStringList& watch_list) {
418 emit ShowList(!isEmpty()); 426 emit ShowList(!IsEmpty());
419 427
420 item_model->invisibleRootItem()->appendRow(new GameListAddDir()); 428 item_model->invisibleRootItem()->appendRow(new GameListAddDir());
421 429
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h
index 63aae2111..58059a3c4 100644
--- a/src/yuzu/game_list.h
+++ b/src/yuzu/game_list.h
@@ -67,11 +67,11 @@ public:
67 FileSys::ManualContentProvider* provider, GMainWindow* parent = nullptr); 67 FileSys::ManualContentProvider* provider, GMainWindow* parent = nullptr);
68 ~GameList() override; 68 ~GameList() override;
69 69
70 QString getLastFilterResultItem() const; 70 QString GetLastFilterResultItem() const;
71 void clearFilter(); 71 void ClearFilter();
72 void setFilterFocus(); 72 void SetFilterFocus();
73 void setFilterVisible(bool visibility); 73 void SetFilterVisible(bool visibility);
74 bool isEmpty() const; 74 bool IsEmpty() const;
75 75
76 void LoadCompatibilityList(); 76 void LoadCompatibilityList();
77 void PopulateAsync(QVector<UISettings::GameDir>& game_dirs); 77 void PopulateAsync(QVector<UISettings::GameDir>& game_dirs);
@@ -99,10 +99,10 @@ signals:
99 void ShowList(bool show); 99 void ShowList(bool show);
100 100
101private slots: 101private slots:
102 void onItemExpanded(const QModelIndex& item); 102 void OnItemExpanded(const QModelIndex& item);
103 void onTextChanged(const QString& new_text); 103 void OnTextChanged(const QString& new_text);
104 void onFilterCloseClicked(); 104 void OnFilterCloseClicked();
105 void onUpdateThemedIcons(); 105 void OnUpdateThemedIcons();
106 106
107private: 107private:
108 void AddDirEntry(GameListDir* entry_items); 108 void AddDirEntry(GameListDir* entry_items);
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index bb3a08ac7..6a2a88dd8 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -838,7 +838,7 @@ void GMainWindow::RestoreUIState() {
838 OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); 838 OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked());
839 839
840 ui.action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar); 840 ui.action_Show_Filter_Bar->setChecked(UISettings::values.show_filter_bar);
841 game_list->setFilterVisible(ui.action_Show_Filter_Bar->isChecked()); 841 game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked());
842 842
843 ui.action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar); 843 ui.action_Show_Status_Bar->setChecked(UISettings::values.show_status_bar);
844 statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked()); 844 statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked());
@@ -1199,11 +1199,12 @@ void GMainWindow::ShutdownGame() {
1199 render_window->hide(); 1199 render_window->hide();
1200 loading_screen->hide(); 1200 loading_screen->hide();
1201 loading_screen->Clear(); 1201 loading_screen->Clear();
1202 if (game_list->isEmpty()) 1202 if (game_list->IsEmpty()) {
1203 game_list_placeholder->show(); 1203 game_list_placeholder->show();
1204 else 1204 } else {
1205 game_list->show(); 1205 game_list->show();
1206 game_list->setFilterFocus(); 1206 }
1207 game_list->SetFilterFocus();
1207 1208
1208 setMouseTracking(false); 1209 setMouseTracking(false);
1209 ui.centralwidget->setMouseTracking(false); 1210 ui.centralwidget->setMouseTracking(false);
@@ -2361,11 +2362,11 @@ void GMainWindow::OnAbout() {
2361} 2362}
2362 2363
2363void GMainWindow::OnToggleFilterBar() { 2364void GMainWindow::OnToggleFilterBar() {
2364 game_list->setFilterVisible(ui.action_Show_Filter_Bar->isChecked()); 2365 game_list->SetFilterVisible(ui.action_Show_Filter_Bar->isChecked());
2365 if (ui.action_Show_Filter_Bar->isChecked()) { 2366 if (ui.action_Show_Filter_Bar->isChecked()) {
2366 game_list->setFilterFocus(); 2367 game_list->SetFilterFocus();
2367 } else { 2368 } else {
2368 game_list->clearFilter(); 2369 game_list->ClearFilter();
2369 } 2370 }
2370} 2371}
2371 2372