citra-emu
/
citra-canary
Archived
1
0
Fork 0

Merge pull request #3958 from lioncash/func

game_list: Make containsAllWords() a non-member function
This commit is contained in:
Weiyi Wang 2018-07-19 10:14:18 +03:00 committed by GitHub
commit f40ce71f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -166,10 +166,12 @@ GameList::SearchField::SearchField(GameList* parent) : QWidget{parent} {
* @param String containing all words getting checked * @param String containing all words getting checked
* @return true if the haystack contains all words of userinput * @return true if the haystack contains all words of userinput
*/ */
bool GameList::containsAllWords(QString haystack, QString userinput) { static bool ContainsAllWords(const QString& haystack, const QString& userinput) {
QStringList userinput_split = userinput.split(" ", QString::SplitBehavior::SkipEmptyParts); const QStringList userinput_split =
userinput.split(' ', QString::SplitBehavior::SkipEmptyParts);
return std::all_of(userinput_split.begin(), userinput_split.end(), return std::all_of(userinput_split.begin(), userinput_split.end(),
[haystack](QString s) { return haystack.contains(s); }); [&haystack](const QString& s) { return haystack.contains(s); });
} }
// Syncs the expanded state of Game Directories with settings to persist across sessions // Syncs the expanded state of Game Directories with settings to persist across sessions
@ -223,7 +225,7 @@ void GameList::onTextChanged(const QString& newText) {
// The search is case insensitive because of toLower() // The search is case insensitive because of toLower()
// I decided not to use Qt::CaseInsensitive in containsAllWords to prevent // I decided not to use Qt::CaseInsensitive in containsAllWords to prevent
// multiple conversions of edit_filter_text for each game in the gamelist // multiple conversions of edit_filter_text for each game in the gamelist
if (containsAllWords(file_name.append(" ").append(file_title), edit_filter_text) || if (ContainsAllWords(file_name.append(' ').append(file_title), edit_filter_text) ||
(file_programmid.count() == 16 && edit_filter_text.contains(file_programmid))) { (file_programmid.count() == 16 && edit_filter_text.contains(file_programmid))) {
tree_view->setRowHidden(j, folder_index, false); tree_view->setRowHidden(j, folder_index, false);
++result_count; ++result_count;

View File

@ -115,7 +115,6 @@ private:
void DonePopulating(QStringList watch_list); void DonePopulating(QStringList watch_list);
void RefreshGameDirectory(); void RefreshGameDirectory();
bool containsAllWords(QString haystack, QString userinput);
void PopupContextMenu(const QPoint& menu_location); void PopupContextMenu(const QPoint& menu_location);
void AddGamePopup(QMenu& context_menu, u64 program_id); void AddGamePopup(QMenu& context_menu, u64 program_id);