diff options
| author | 2017-05-07 13:46:46 -0700 | |
|---|---|---|
| committer | 2017-05-07 13:46:46 -0700 | |
| commit | e33558c6ce38dac56ec66d2d65e51d4dee0b9840 (patch) | |
| tree | be068ded3b29b3e8e56e9c545fe2727554443aa6 /src | |
| parent | Merge pull request #2686 from wwylele/tex-coord-reg (diff) | |
| parent | Don’t focus the search field if the game is empty (diff) | |
| download | yuzu-e33558c6ce38dac56ec66d2d65e51d4dee0b9840.tar.gz yuzu-e33558c6ce38dac56ec66d2d65e51d4dee0b9840.tar.xz yuzu-e33558c6ce38dac56ec66d2d65e51d4dee0b9840.zip | |
Merge pull request #2682 from nicoboss/filter
citra-qt: game list search function fixed minor mistakes
Diffstat (limited to 'src')
| -rw-r--r-- | src/citra_qt/game_list.cpp | 61 | ||||
| -rw-r--r-- | src/citra_qt/game_list.h | 4 |
2 files changed, 35 insertions, 30 deletions
diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index d6e26ed47..51257520b 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp | |||
| @@ -45,7 +45,7 @@ bool GameList::SearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* e | |||
| 45 | break; | 45 | break; |
| 46 | } | 46 | } |
| 47 | // Return and Enter | 47 | // Return and Enter |
| 48 | // If the enter key gets pressed first checks how many and which entry is visable | 48 | // If the enter key gets pressed first checks how many and which entry is visible |
| 49 | // If there is only one result launch this game | 49 | // If there is only one result launch this game |
| 50 | case Qt::Key_Return: | 50 | case Qt::Key_Return: |
| 51 | case Qt::Key_Enter: { | 51 | case Qt::Key_Enter: { |
| @@ -80,7 +80,7 @@ bool GameList::SearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* e | |||
| 80 | return QObject::eventFilter(obj, event); | 80 | return QObject::eventFilter(obj, event); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | void GameList::SearchField::setFilterResult(int visable, int total) { | 83 | void GameList::SearchField::setFilterResult(int visible, int total) { |
| 84 | QString result_of_text = tr("of"); | 84 | QString result_of_text = tr("of"); |
| 85 | QString result_text; | 85 | QString result_text; |
| 86 | if (total == 1) { | 86 | if (total == 1) { |
| @@ -89,7 +89,7 @@ void GameList::SearchField::setFilterResult(int visable, int total) { | |||
| 89 | result_text = tr("results"); | 89 | result_text = tr("results"); |
| 90 | } | 90 | } |
| 91 | label_filter_result->setText( | 91 | label_filter_result->setText( |
| 92 | QString("%1 %2 %3 %4").arg(visable).arg(result_of_text).arg(total).arg(result_text)); | 92 | QString("%1 %2 %3 %4").arg(visible).arg(result_of_text).arg(total).arg(result_text)); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | void GameList::SearchField::clear() { | 95 | void GameList::SearchField::clear() { |
| @@ -133,13 +133,13 @@ GameList::SearchField::SearchField(GameList* parent) : QWidget{parent} { | |||
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /** | 135 | /** |
| 136 | * Checks if all words separated by spaces are contained in another string | 136 | * Checks if all words separated by spaces are contained in another string |
| 137 | * This offers a word order insensitive search function | 137 | * This offers a word order insensitive search function |
| 138 | * | 138 | * |
| 139 | * @param String that gets checked if it contains all words of the userinput string | 139 | * @param String that gets checked if it contains all words of the userinput string |
| 140 | * @param String containing all words getting checked | 140 | * @param String containing all words getting checked |
| 141 | * @return true if the haystack contains all words of userinput | 141 | * @return true if the haystack contains all words of userinput |
| 142 | */ | 142 | */ |
| 143 | bool GameList::containsAllWords(QString haystack, QString userinput) { | 143 | bool GameList::containsAllWords(QString haystack, QString userinput) { |
| 144 | QStringList userinput_split = userinput.split(" ", QString::SplitBehavior::SkipEmptyParts); | 144 | QStringList userinput_split = userinput.split(" ", QString::SplitBehavior::SkipEmptyParts); |
| 145 | return std::all_of(userinput_split.begin(), userinput_split.end(), | 145 | return std::all_of(userinput_split.begin(), userinput_split.end(), |
| @@ -236,11 +236,13 @@ GameList::~GameList() { | |||
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | void GameList::setFilterFocus() { | 238 | void GameList::setFilterFocus() { |
| 239 | search_field->setFocus(); | 239 | if (tree_view->model()->rowCount() > 0) { |
| 240 | search_field->setFocus(); | ||
| 241 | } | ||
| 240 | } | 242 | } |
| 241 | 243 | ||
| 242 | void GameList::setFilterVisible(bool visablility) { | 244 | void GameList::setFilterVisible(bool visibility) { |
| 243 | search_field->setVisible(visablility); | 245 | search_field->setVisible(visibility); |
| 244 | } | 246 | } |
| 245 | 247 | ||
| 246 | void GameList::clearFilter() { | 248 | void GameList::clearFilter() { |
| @@ -271,7 +273,9 @@ void GameList::DonePopulating() { | |||
| 271 | tree_view->setEnabled(true); | 273 | tree_view->setEnabled(true); |
| 272 | int rowCount = tree_view->model()->rowCount(); | 274 | int rowCount = tree_view->model()->rowCount(); |
| 273 | search_field->setFilterResult(rowCount, rowCount); | 275 | search_field->setFilterResult(rowCount, rowCount); |
| 274 | search_field->setFocus(); | 276 | if (rowCount > 0) { |
| 277 | search_field->setFocus(); | ||
| 278 | } | ||
| 275 | } | 279 | } |
| 276 | 280 | ||
| 277 | void GameList::PopupContextMenu(const QPoint& menu_location) { | 281 | void GameList::PopupContextMenu(const QPoint& menu_location) { |
| @@ -295,6 +299,7 @@ void GameList::PopulateAsync(const QString& dir_path, bool deep_scan) { | |||
| 295 | if (!FileUtil::Exists(dir_path.toStdString()) || | 299 | if (!FileUtil::Exists(dir_path.toStdString()) || |
| 296 | !FileUtil::IsDirectory(dir_path.toStdString())) { | 300 | !FileUtil::IsDirectory(dir_path.toStdString())) { |
| 297 | LOG_ERROR(Frontend, "Could not find game list folder at %s", dir_path.toLocal8Bit().data()); | 301 | LOG_ERROR(Frontend, "Could not find game list folder at %s", dir_path.toLocal8Bit().data()); |
| 302 | search_field->setFilterResult(0, 0); | ||
| 298 | return; | 303 | return; |
| 299 | } | 304 | } |
| 300 | 305 | ||
| @@ -355,20 +360,20 @@ void GameList::RefreshGameDirectory() { | |||
| 355 | } | 360 | } |
| 356 | 361 | ||
| 357 | /** | 362 | /** |
| 358 | * Adds the game list folder to the QFileSystemWatcher to check for updates. | 363 | * Adds the game list folder to the QFileSystemWatcher to check for updates. |
| 359 | * | 364 | * |
| 360 | * The file watcher will fire off an update to the game list when a change is detected in the game | 365 | * The file watcher will fire off an update to the game list when a change is detected in the game |
| 361 | * list folder. | 366 | * list folder. |
| 362 | * | 367 | * |
| 363 | * Notice: This method is run on the UI thread because QFileSystemWatcher is not thread safe and | 368 | * Notice: This method is run on the UI thread because QFileSystemWatcher is not thread safe and |
| 364 | * this function is fast enough to not stall the UI thread. If performance is an issue, it should | 369 | * this function is fast enough to not stall the UI thread. If performance is an issue, it should |
| 365 | * be moved to another thread and properly locked to prevent concurrency issues. | 370 | * be moved to another thread and properly locked to prevent concurrency issues. |
| 366 | * | 371 | * |
| 367 | * @param dir folder to check for changes in | 372 | * @param dir folder to check for changes in |
| 368 | * @param recursion 0 if recursion is disabled. Any positive number passed to this will add each | 373 | * @param recursion 0 if recursion is disabled. Any positive number passed to this will add each |
| 369 | * directory recursively to the watcher and will update the file list if any of the folders | 374 | * directory recursively to the watcher and will update the file list if any of the folders |
| 370 | * change. The number determines how deep the recursion should traverse. | 375 | * change. The number determines how deep the recursion should traverse. |
| 371 | */ | 376 | */ |
| 372 | void GameList::UpdateWatcherList(const std::string& dir, unsigned int recursion) { | 377 | void GameList::UpdateWatcherList(const std::string& dir, unsigned int recursion) { |
| 373 | const auto callback = [this, recursion](unsigned* num_entries_out, const std::string& directory, | 378 | const auto callback = [this, recursion](unsigned* num_entries_out, const std::string& directory, |
| 374 | const std::string& virtual_name) -> bool { | 379 | const std::string& virtual_name) -> bool { |
diff --git a/src/citra_qt/game_list.h b/src/citra_qt/game_list.h index 3c06cddc8..d8f8bc5b6 100644 --- a/src/citra_qt/game_list.h +++ b/src/citra_qt/game_list.h | |||
| @@ -34,7 +34,7 @@ public: | |||
| 34 | 34 | ||
| 35 | class SearchField : public QWidget { | 35 | class SearchField : public QWidget { |
| 36 | public: | 36 | public: |
| 37 | void setFilterResult(int visable, int total); | 37 | void setFilterResult(int visible, int total); |
| 38 | void clear(); | 38 | void clear(); |
| 39 | void setFocus(); | 39 | void setFocus(); |
| 40 | explicit SearchField(GameList* parent = nullptr); | 40 | explicit SearchField(GameList* parent = nullptr); |
| @@ -64,7 +64,7 @@ public: | |||
| 64 | 64 | ||
| 65 | void clearFilter(); | 65 | void clearFilter(); |
| 66 | void setFilterFocus(); | 66 | void setFilterFocus(); |
| 67 | void setFilterVisible(bool visablility); | 67 | void setFilterVisible(bool visibility); |
| 68 | 68 | ||
| 69 | void PopulateAsync(const QString& dir_path, bool deep_scan); | 69 | void PopulateAsync(const QString& dir_path, bool deep_scan); |
| 70 | 70 | ||