Wireshark 4.7.2
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
FilterCompleter Class Reference

QCompleter base for filter expressions, attachable to any QLineEdit. More...

#include <filter_completer.h>

Inheritance diagram for FilterCompleter:
CaptureFilterCompleter DisplayFilterCompleter

Public Member Functions

 FilterCompleter (QObject *parent=nullptr)
void setTokenChars (const QString &token_chars)
 Sets the characters considered part of a single completion token.
const QString & tokenChars () const
 Returns the configured token characters.
QStringList splitPath (const QString &path) const override
 Splits path into the prefix QCompleter should match against.
QString pathFromIndex (const QModelIndex &index) const override
 Maps a chosen completion row back to the text to insert.

Protected Member Functions

bool eventFilter (QObject *watched, QEvent *event) override
 Constrains the popup to its content width on show/resize.

Protected Attributes

QString token_chars_

Detailed Description

QCompleter base for filter expressions, attachable to any QLineEdit.

Token semantics live here rather than in the line edit. By overriding QCompleter::splitPath() and QCompleter::pathFromIndex(), the standard QCompleter machinery performs the "replace the token under the cursor with the chosen completion" step natively; the host widget does not hand-roll insertion.

The base provides a whitespace-token default: splitPath() returns the final whitespace-delimited word as the completion prefix, and pathFromIndex() returns the selected row's text. Subclasses (DisplayFilterCompleter, CaptureFilterCompleter) refine the token character set and the "too complex to complete" guard.

Member Function Documentation

◆ eventFilter()

bool FilterCompleter::eventFilter ( QObject * watched,
QEvent * event )
overrideprotected

Constrains the popup to its content width on show/resize.

QCompleter sizes the popup to the host widget's width (the filter field spans the whole toolbar), so the list would otherwise be far wider than the entries. Forcing a fixed width equal to the content makes QCompleter's own geometry call land at the needed width.

◆ setTokenChars()

void FilterCompleter::setTokenChars ( const QString & token_chars)
inline

Sets the characters considered part of a single completion token.

Parameters
token_charsCharacters valid within a token (e.g. letters, digits, underscore, dot). Empty means "split on whitespace".

◆ splitPath()

QStringList FilterCompleter::splitPath ( const QString & path) const
override

Splits path into the prefix QCompleter should match against.

Returns
A single-element list holding the token under/before the cursor.

Member Data Documentation

◆ token_chars_

QString FilterCompleter::token_chars_
protected

Characters valid within a completion token.


The documentation for this class was generated from the following files: