From 15a1a6bd9c8af1c3ca7adf23604bde00b1fd1bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Tue, 19 Dec 2017 19:56:18 +0100 Subject: [PATCH] Add Quick Filter to StringsWidget #162 --- src/widgets/FunctionsWidget.cpp | 4 ++-- src/widgets/StringsWidget.cpp | 13 +++++++++++++ src/widgets/StringsWidget.ui | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/widgets/FunctionsWidget.cpp b/src/widgets/FunctionsWidget.cpp index 325adcbc..d3398963 100644 --- a/src/widgets/FunctionsWidget.cpp +++ b/src/widgets/FunctionsWidget.cpp @@ -333,12 +333,12 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) : //ui->filterLineEdit->setVisible(false); // Ctrl-F to show/hide the filter entry - QShortcut *search_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this); + QShortcut *search_shortcut = new QShortcut(QKeySequence::Find, this); connect(search_shortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter); search_shortcut->setContext(Qt::WidgetWithChildrenShortcut); // Esc to clear the filter entry - QShortcut *clear_shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this); + QShortcut *clear_shortcut = new QShortcut(QKeySequence::Cancel, this); connect(clear_shortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::clearFilter); clear_shortcut->setContext(Qt::WidgetWithChildrenShortcut); diff --git a/src/widgets/StringsWidget.cpp b/src/widgets/StringsWidget.cpp index 6c112500..830300af 100644 --- a/src/widgets/StringsWidget.cpp +++ b/src/widgets/StringsWidget.cpp @@ -126,11 +126,24 @@ StringsWidget::StringsWidget(QWidget *parent) : qhelpers::setVerticalScrollMode(ui->stringsTreeView); + // Ctrl-F to show/hide the filter entry + QShortcut *search_shortcut = new QShortcut(QKeySequence::Find, this); + connect(search_shortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::showFilter); + search_shortcut->setContext(Qt::WidgetWithChildrenShortcut); + + // Esc to clear the filter entry + QShortcut *clear_shortcut = new QShortcut(QKeySequence::Cancel, this); + connect(clear_shortcut, &QShortcut::activated, ui->quickFilterView, &QuickFilterView::clearFilter); + clear_shortcut->setContext(Qt::WidgetWithChildrenShortcut); + model = new StringsModel(&strings, this); proxy_model = new StringsSortFilterProxyModel(model, this); ui->stringsTreeView->setModel(proxy_model); ui->stringsTreeView->sortByColumn(StringsModel::OFFSET, Qt::AscendingOrder); + connect(ui->quickFilterView, SIGNAL(filterTextChanged(const QString &)), proxy_model, SLOT(setFilterWildcard(const QString &))); + connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->stringsTreeView, SLOT(setFocus())); + connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshStrings())); } diff --git a/src/widgets/StringsWidget.ui b/src/widgets/StringsWidget.ui index bacc1817..7622b983 100644 --- a/src/widgets/StringsWidget.ui +++ b/src/widgets/StringsWidget.ui @@ -15,6 +15,9 @@ + + 0 + 0 @@ -56,9 +59,27 @@ + + + + + 0 + 0 + + + + + + + QuickFilterView + QWidget +
widgets/QuickFilterView.h
+ 1 +
+