aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorMartin Mathieson <martin.mathieson@keysight.com>2020-07-03 12:15:29 +0100
committerAnders Broman <a.broman58@gmail.com>2020-07-05 07:46:41 +0000
commit0162ba730a8c43744b2cfff44c484dc80989c966 (patch)
tree138ac37f5ad1e1f77d167a46473919b15f385576 /ui
parent18421cc7332c6ce7bd44879f02fc266807271769 (diff)
Enable display filter autocomplete on find packet search.
Bug: 16638 Change-Id: Ifd9c9e4392fdc3d32b2aa4466d5a7f2835893338 Reviewed-on: https://code.wireshark.org/review/37682 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/search_frame.cpp3
-rw-r--r--ui/qt/search_frame.ui6
-rw-r--r--ui/qt/widgets/syntax_line_edit.cpp17
-rw-r--r--ui/qt/widgets/syntax_line_edit.h2
4 files changed, 23 insertions, 5 deletions
diff --git a/ui/qt/search_frame.cpp b/ui/qt/search_frame.cpp
index 8ef0e3c5f6..51c3ea145e 100644
--- a/ui/qt/search_frame.cpp
+++ b/ui/qt/search_frame.cpp
@@ -274,6 +274,9 @@ void SearchFrame::updateWidgets()
return;
}
+ // Enable completion only for display filter search.
+ sf_ui_->searchLineEdit->allowCompletion(search_type == df_search_);
+
if (sf_ui_->searchLineEdit->text().isEmpty() || sf_ui_->searchLineEdit->syntaxState() == SyntaxLineEdit::Invalid) {
sf_ui_->findButton->setEnabled(false);
} else {
diff --git a/ui/qt/search_frame.ui b/ui/qt/search_frame.ui
index 8d709d0f3d..c3bb99087c 100644
--- a/ui/qt/search_frame.ui
+++ b/ui/qt/search_frame.ui
@@ -147,7 +147,7 @@
</widget>
</item>
<item>
- <widget class="SyntaxLineEdit" name="searchLineEdit">
+ <widget class="DisplayFilterEdit" name="searchLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
@@ -195,9 +195,9 @@
<container>1</container>
</customwidget>
<customwidget>
- <class>SyntaxLineEdit</class>
+ <class>DisplayFilterEdit</class>
<extends>QLineEdit</extends>
- <header>widgets/syntax_line_edit.h</header>
+ <header>widgets/display_filter_edit.h</header>
</customwidget>
</customwidgets>
<resources/>
diff --git a/ui/qt/widgets/syntax_line_edit.cpp b/ui/qt/widgets/syntax_line_edit.cpp
index 71128d0ee1..187f432ee8 100644
--- a/ui/qt/widgets/syntax_line_edit.cpp
+++ b/ui/qt/widgets/syntax_line_edit.cpp
@@ -38,7 +38,8 @@ const int max_completion_items_ = 20;
SyntaxLineEdit::SyntaxLineEdit(QWidget *parent) :
QLineEdit(parent),
completer_(NULL),
- completion_model_(NULL)
+ completion_model_(NULL),
+ completion_enabled_(false)
{
// Try to matche QLineEdit's placeholder text color (which sets the
// alpha channel to 50%, which doesn't work in style sheets).
@@ -70,6 +71,14 @@ void SyntaxLineEdit::setCompleter(QCompleter *c)
completer_->setMaxVisibleItems(max_completion_items_);
QObject::connect(completer_, static_cast<void (QCompleter::*)(const QString &)>(&QCompleter::activated),
this, &SyntaxLineEdit::insertFieldCompletion);
+
+ // Auto-completion is turned on.
+ completion_enabled_ = true;
+}
+
+void SyntaxLineEdit::allowCompletion(bool enabled)
+{
+ completion_enabled_ = enabled;
}
void SyntaxLineEdit::setSyntaxState(SyntaxState state) {
@@ -148,6 +157,10 @@ void SyntaxLineEdit::insertFilter(const QString &filter)
void SyntaxLineEdit::checkDisplayFilter(QString filter)
{
+ if (!completion_enabled_) {
+ return;
+ }
+
if (filter.isEmpty()) {
setSyntaxState(SyntaxLineEdit::Empty);
return;
@@ -317,7 +330,7 @@ void SyntaxLineEdit::completionKeyPressEvent(QKeyEvent *event)
// ...otherwise process the key ourselves.
SyntaxLineEdit::keyPressEvent(event);
- if (!completer_ || !completion_model_ || !prefs.gui_autocomplete_filter) return;
+ if (!completion_enabled_ || !completer_ || !completion_model_ || !prefs.gui_autocomplete_filter) return;
// Do nothing on bare shift.
if ((event->modifiers() & Qt::ShiftModifier) && event->text().isEmpty()) return;
diff --git a/ui/qt/widgets/syntax_line_edit.h b/ui/qt/widgets/syntax_line_edit.h
index 820795fd96..cc1b8461e3 100644
--- a/ui/qt/widgets/syntax_line_edit.h
+++ b/ui/qt/widgets/syntax_line_edit.h
@@ -36,6 +36,7 @@ public:
void setCompleter(QCompleter *c);
QCompleter *completer() const { return completer_; }
+ void allowCompletion(bool enabled);
public slots:
void setStyleSheet(const QString &style_sheet);
@@ -70,6 +71,7 @@ private:
QString syntax_error_message_;
QString token_chars_;
QColor busy_fg_;
+ bool completion_enabled_;
private slots:
void insertFieldCompletion(const QString &completion_text);