aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/display_filter_edit.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-05-12 12:35:54 -0700
committerGerald Combs <gerald@wireshark.org>2015-05-12 22:05:57 +0000
commit99ca42153b9ab122c93a5ffae4ed9ffc40665d12 (patch)
tree3430fb1fdb3e350fdf5d244da441f0d0cd3d8e23 /ui/qt/display_filter_edit.cpp
parent79ba6e6d53313f57af78bff7a771ac9c79f6c454 (diff)
Qt: Display filter completion fixes.
Fixup the logic for adding field names to the list. Connect our completer activation signal to its slot once, not twice. Bug: 11187 Change-Id: Ife1879fe05c870094ee31e59dd62e3004f588bfc Reviewed-on: https://code.wireshark.org/review/8440 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/display_filter_edit.cpp')
-rw-r--r--ui/qt/display_filter_edit.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/ui/qt/display_filter_edit.cpp b/ui/qt/display_filter_edit.cpp
index ebc7134fd7..f4b77380d3 100644
--- a/ui/qt/display_filter_edit.cpp
+++ b/ui/qt/display_filter_edit.cpp
@@ -105,7 +105,6 @@ DisplayFilterEdit::DisplayFilterEdit(QWidget *parent, bool plain) :
completion_model_ = new QStringListModel(this);
QCompleter *completer_ = new QCompleter(completion_model_, this);
setCompleter(completer_);
- connect(completer_, SIGNAL(activated(QString)), this, SLOT(insertFieldCompletion(QString)));
if (plain_) {
placeholder_text_ = QString(tr("Enter a display filter %1")).arg(UTF8_HORIZONTAL_ELLIPSIS);
@@ -427,7 +426,7 @@ void DisplayFilterEdit::buildCompletionList(const QString &field_word)
QString df_text = df_combo->itemText(i);
// Don't complete the current filter.
if (df_text.startsWith(text()) && df_text.compare(text())) {
- recent_list <<df_text;
+ recent_list << df_text;
}
}
}
@@ -441,16 +440,18 @@ void DisplayFilterEdit::buildCompletionList(const QString &field_word)
void *proto_cookie;
QStringList field_list;
- bool show_fields = field_word.contains('.');
+ int field_dots = field_word.count('.'); // Some protocol names (_ws.expert) contain periods.
for (int proto_id = proto_get_first_protocol(&proto_cookie); proto_id != -1; proto_id = proto_get_next_protocol(&proto_cookie)) {
protocol_t *protocol = find_protocol_by_id(proto_id);
if (!proto_is_protocol_enabled(protocol)) continue;
// Don't complete the current word.
const QString pfname = proto_get_protocol_filter_name(proto_id);
- if (!field_word.startsWith(pfname)) continue;
- field_list << pfname;
- if (show_fields) {
+ if (field_word.compare(pfname)) field_list << pfname;
+
+ // Add fields only if we're past the protocol name and only for the
+ // current protocol.
+ if (field_dots > pfname.count('.') && field_word.startsWith(pfname)) {
void *field_cookie;
for (header_field_info *hfinfo = proto_get_first_protocol_field(proto_id, &field_cookie); hfinfo; hfinfo = proto_get_next_protocol_field(proto_id, &field_cookie)) {
if (hfinfo->same_name_prev_id != -1) continue; // ignore duplicate names