mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-09 05:32:36 +00:00
+15
-11
@@ -12,25 +12,29 @@ namespace Yuzu {
|
|||||||
|
|
||||||
inline bool ContainsAllWords(const QString& haystack, const QString& userinput) {
|
inline bool ContainsAllWords(const QString& haystack, const QString& userinput) {
|
||||||
const QStringList userinput_split = userinput.split(QLatin1Char{' '}, Qt::SkipEmptyParts);
|
const QStringList userinput_split = userinput.split(QLatin1Char{' '}, Qt::SkipEmptyParts);
|
||||||
return std::all_of(userinput_split.begin(), userinput_split.end(),
|
return std::all_of(userinput_split.begin(), userinput_split.end(), [&haystack](const QString& s) {
|
||||||
[&haystack](const QString& s) { return haystack.contains(s); });
|
return haystack.contains(s);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool FilterMatches(const QString& filter, const QStandardItem* item) {
|
inline bool FilterMatches(const QString& filter, const QStandardItem* item) {
|
||||||
if (filter.isEmpty())
|
if (filter.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
auto const sluggify = [](const QString& s) {
|
||||||
|
QString o(s.normalized(QString::NormalizationForm_D).toLower());
|
||||||
|
return o.replace(QRegularExpression(QStringLiteral("[^a-z\\s]")), QStringLiteral(""));
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto norm_filter = sluggify(filter);
|
||||||
const auto program_id = item->data(GameListItemPath::ProgramIdRole).toULongLong();
|
const auto program_id = item->data(GameListItemPath::ProgramIdRole).toULongLong();
|
||||||
|
const QString file_path = sluggify(item->data(GameListItemPath::FullPathRole).toString());
|
||||||
const QString file_path = item->data(GameListItemPath::FullPathRole).toString().toLower();
|
const QString file_title = sluggify(item->data(GameListItemPath::TitleRole).toString());
|
||||||
const QString file_title = item->data(GameListItemPath::TitleRole).toString().toLower();
|
|
||||||
const QString file_program_id = QStringLiteral("%1").arg(program_id, 16, 16, QLatin1Char{'0'});
|
const QString file_program_id = QStringLiteral("%1").arg(program_id, 16, 16, QLatin1Char{'0'});
|
||||||
|
const QString file_name = sluggify(file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + file_title);
|
||||||
const QString file_name =
|
return (ContainsAllWords(file_name, norm_filter)
|
||||||
file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + file_title;
|
|| ContainsAllWords(file_title, norm_filter))
|
||||||
|
|| (file_program_id.size() == 16 && file_program_id.contains(norm_filter));
|
||||||
return Yuzu::ContainsAllWords(file_name, filter) ||
|
|
||||||
(file_program_id.size() == 16 && file_program_id.contains(filter));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Yuzu
|
} // namespace Yuzu
|
||||||
|
|||||||
Reference in New Issue
Block a user