Commit a4cbe2ac authored by Eike Ziller's avatar Eike Ziller

CommandMappings: Do special filtering only for keyboard shortcuts

The view is also used for the regular expressions for FakeVim's
ex command mapping, so we should not do special filtering for
keyboard shortcuts on OS X

Change-Id: I437b45a53beb93caeaec43af2f898c55b2a1601f
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent 2de9de7e
......@@ -33,7 +33,6 @@
#include <coreplugin/dialogs/shortcutsettings.h>
#include <utils/hostosinfo.h>
#include <utils/headerviewstretcher.h>
#include <utils/fancylineedit.h>
#include <utils/qtcassert.h>
......@@ -242,22 +241,8 @@ bool CommandMappings::filter(const QString &filterString, QTreeWidgetItem *item)
{
bool visible = filterString.isEmpty();
int columnCount = item->columnCount();
for (int i = 0; !visible && i < columnCount; ++i) {
QString text = item->text(i);
if (HostOsInfo::isMacHost()) {
// 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"));
}
}
}
visible |= (bool)text.contains(filterString, Qt::CaseInsensitive);
}
for (int i = 0; !visible && i < columnCount; ++i)
visible |= !filterColumn(filterString, item, i);
int childCount = item->childCount();
if (childCount > 0) {
......@@ -272,6 +257,12 @@ bool CommandMappings::filter(const QString &filterString, QTreeWidgetItem *item)
return !visible;
}
bool CommandMappings::filterColumn(const QString &filterString, QTreeWidgetItem *item,
int column) const
{
return !item->text(column).contains(filterString, Qt::CaseInsensitive);
}
void CommandMappings::setModified(QTreeWidgetItem *item , bool modified)
{
QFont f = item->font(0);
......
......@@ -68,8 +68,9 @@ protected:
virtual void exportAction() {}
virtual void importAction() {}
virtual bool filterColumn(const QString &filterString, QTreeWidgetItem *item, int column) const;
void filterChanged(const QString &f);
bool filter(const QString &filterString, QTreeWidgetItem *item);
virtual void commandChanged(QTreeWidgetItem *current);
......@@ -85,6 +86,8 @@ protected:
void setModified(QTreeWidgetItem *item, bool modified);
private:
bool filter(const QString &filterString, QTreeWidgetItem *item);
friend class Internal::CommandMappingsPrivate;
Internal::CommandMappingsPrivate *d;
};
......
......@@ -39,6 +39,7 @@
#include <coreplugin/actionmanager/commandsfile.h>
#include <utils/fancylineedit.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QKeyEvent>
......@@ -215,6 +216,25 @@ bool ShortcutSettingsWidget::hasConflicts() const
return false;
}
bool ShortcutSettingsWidget::filterColumn(const QString &filterString, QTreeWidgetItem *item,
int column) const
{
QString text = item->text(column);
if (Utils::HostOsInfo::isMacHost()) {
// accept e.g. Cmd+E in the filter. the text shows special fancy characters for Cmd
if (column == item->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"));
}
}
}
return !text.contains(filterString, Qt::CaseInsensitive);
}
void ShortcutSettingsWidget::setKeySequence(const QKeySequence &key)
{
m_key[0] = m_key[1] = m_key[2] = m_key[3] = 0;
......
......@@ -79,6 +79,8 @@ protected:
void defaultAction() override;
bool hasConflicts() const override;
bool filterColumn(const QString &filterString, QTreeWidgetItem *item, int column) const override;
private:
void initialize();
void handleKeyEvent(QKeyEvent *e);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment