From f6eefeb1d88618333a38b6d248851f1027b8d3f7 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 22 May 2012 15:14:22 +0200 Subject: [PATCH] Mac: Allow searching for e.g. Cmd+E in shortcut settings. The tree view shows the fancy special characters for the modifier keys, so it's not possible to filter for them. Change-Id: I3f0cab24afe8ccb9a95300e91eb1bc45a0e4313a Reviewed-by: Bradley T. Hughes Reviewed-by: Eike Ziller --- .../actionmanager/commandmappings.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/actionmanager/commandmappings.cpp b/src/plugins/coreplugin/actionmanager/commandmappings.cpp index 30f8950ad7a..20068c31aec 100644 --- a/src/plugins/coreplugin/actionmanager/commandmappings.cpp +++ b/src/plugins/coreplugin/actionmanager/commandmappings.cpp @@ -169,8 +169,22 @@ bool CommandMappings::filter(const QString &filterString, QTreeWidgetItem *item) { bool visible = filterString.isEmpty(); int columnCount = item->columnCount(); - for (int i = 0; !visible && i < columnCount; ++i) - visible |= (bool)item->text(i).contains(filterString, Qt::CaseInsensitive); + for (int i = 0; !visible && i < columnCount; ++i) { + QString text = item->text(i); +#ifdef Q_OS_MAC + // accept e.g. Cmd+E in the filter. the text shows special fancy characters for Cmd + if (i == columnCount - 1) { + QKeySequence key = QKeySequence::fromString(text, QKeySequence::NativeText); + if (!key.isEmpty()) { + text = key.toString(QKeySequence::PortableText); + text.replace(QLatin1String("Ctrl"), QLatin1String("Cmd")); + text.replace(QLatin1String("Meta"), QLatin1String("Ctrl")); + text.replace(QLatin1String("Alt"), QLatin1String("Opt")); + } + } +#endif + visible |= (bool)text.contains(filterString, Qt::CaseInsensitive); + } int childCount = item->childCount(); if (childCount > 0) {