mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-29 06:46:22 -05:00
Merge pull request #681 from lioncash/const
game_list: Make containsAllWords a const member function
This commit is contained in:
commit
3d1e8f750c
2 changed files with 7 additions and 5 deletions
|
@ -138,10 +138,12 @@ GameList::SearchField::SearchField(GameList* parent) : QWidget{parent} {
|
||||||
* @param userinput String containing all words getting checked
|
* @param userinput 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) {
|
bool GameList::ContainsAllWords(const QString& haystack, const QString& userinput) const {
|
||||||
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); });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event in order to filter the gamelist after editing the searchfield
|
// Event in order to filter the gamelist after editing the searchfield
|
||||||
|
@ -175,7 +177,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(i, root_index, false);
|
tree_view->setRowHidden(i, root_index, false);
|
||||||
++result_count;
|
++result_count;
|
||||||
|
|
|
@ -89,7 +89,7 @@ private:
|
||||||
|
|
||||||
void PopupContextMenu(const QPoint& menu_location);
|
void PopupContextMenu(const QPoint& menu_location);
|
||||||
void RefreshGameDirectory();
|
void RefreshGameDirectory();
|
||||||
bool containsAllWords(QString haystack, QString userinput);
|
bool ContainsAllWords(const QString& haystack, const QString& userinput) const;
|
||||||
|
|
||||||
SearchField* search_field;
|
SearchField* search_field;
|
||||||
GMainWindow* main_window = nullptr;
|
GMainWindow* main_window = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue