aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-10-01 07:39:44 +0200
committercrueter <crueter@eden-emu.dev>2026-10-01 07:39:44 +0200
commitd3550c45718609dc563d8b58adfc0d846feefd03 (patch)
tree6838333f55261fd202ffdcc2e88650128ee4b637 /src/yuzu
parent963119e7cc3851007252c9981e4fae3e88b7687f (diff)
[qt] Filter collates accents (Unicode NFD) (#4380)
Now "POKEMON" and "pokemon" are the same, and search's no longer case sensitive. Maybe we could transliterate? But that would require icu which is a bit overkill. Main point is to be able to search "Pokemon" (accent on 'e') without actually typing the accent https://unicode.org/reports/tr15/ Signed-off-by: lizzie <lizzie@eden-emu.dev> - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4380 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/game/common.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/yuzu/game/common.h b/src/yuzu/game/common.h
index 03505d6313..063733e8d8 100644
--- a/src/yuzu/game/common.h
+++ b/src/yuzu/game/common.h
@@ -12,25 +12,29 @@ namespace Yuzu {
inline bool ContainsAllWords(const QString& haystack, const QString& userinput) {
const QStringList userinput_split = userinput.split(QLatin1Char{' '}, Qt::SkipEmptyParts);
- return std::all_of(userinput_split.begin(), userinput_split.end(),
- [&haystack](const QString& s) { return haystack.contains(s); });
+ return std::all_of(userinput_split.begin(), userinput_split.end(), [&haystack](const QString& s) {
+ return haystack.contains(s);
+ });
}
inline bool FilterMatches(const QString& filter, const QStandardItem* item) {
if (filter.isEmpty())
return true;
- const auto program_id = item->data(GameListItemPath::ProgramIdRole).toULongLong();
+ auto const sluggify = [](const QString& s) {
+ QString o(s.normalized(QString::NormalizationForm_D).toLower());
+ return o.replace(QRegularExpression(QStringLiteral("[^a-z\\s]")), QStringLiteral(""));
+ };
- const QString file_path = item->data(GameListItemPath::FullPathRole).toString().toLower();
- const QString file_title = item->data(GameListItemPath::TitleRole).toString().toLower();
+ const auto norm_filter = sluggify(filter);
+ const auto program_id = item->data(GameListItemPath::ProgramIdRole).toULongLong();
+ const QString file_path = sluggify(item->data(GameListItemPath::FullPathRole).toString());
+ const QString file_title = sluggify(item->data(GameListItemPath::TitleRole).toString());
const QString file_program_id = QStringLiteral("%1").arg(program_id, 16, 16, QLatin1Char{'0'});
-
- const QString file_name =
- file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + file_title;
-
- return Yuzu::ContainsAllWords(file_name, filter) ||
- (file_program_id.size() == 16 && file_program_id.contains(filter));
+ const QString file_name = sluggify(file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + file_title);
+ return (ContainsAllWords(file_name, norm_filter)
+ || ContainsAllWords(file_title, norm_filter))
+ || (file_program_id.size() == 16 && file_program_id.contains(norm_filter));
}
} // namespace Yuzu