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

QLineEdit with validation-state tinting plus an injected filter validator and completer. More...

#include <filter_edit.h>

Inheritance diagram for FilterEdit:
FilterExpressionEdit CaptureFilterEntry DisplayFilterEntry

Public Types

enum class  SyntaxState {
  Empty , Busy , Intermediate , Invalid ,
  Deprecated , Valid
}
 Visual/semantic state of the current text, mapped from the validator. More...

Public Slots

void insertFilter (const QString &filter)
 Inserts filter at the cursor, padding with spaces as needed to keep the expression well-formed. Replaces a current selection.

Signals

void syntaxStateChanged (FilterEdit::SyntaxState state)
 Emitted whenever the syntax state changes.

Public Member Functions

 FilterEdit (QWidget *parent=nullptr)
SyntaxState state () const
 Current syntax state.
QString syntaxStateName () const
 Lowercase state name used for QSS property matching.
void setValidator (FilterValidator *validator)
 Installs the filter validator. Widget-owned (deleted with the widget, and replaces any previous validator).
FilterValidatorvalidator () const
 The installed filter validator, or nullptr.
void setCompleter (FilterCompleter *completer)
 Installs the filter completer. Widget-owned, and also set as the QLineEdit completer so the native typeahead popup works.
FilterCompletercompleter () const
 The installed filter completer, or nullptr.
QString lastError () const
 Short error message from the last validation, or empty.
QString lastErrorFull () const
 Full, location-annotated error message, or empty.
QString deprecatedToken () const
 Deprecated token from the last validation, or empty.

Protected Member Functions

void setState (SyntaxState state)
 Sets the state, re-polishes the style for the new QSS property, and emits syntaxStateChanged() if it changed.
void validateNow ()
 Runs the validator against the current text and updates the state.

Properties

QString syntaxState

Detailed Description

QLineEdit with validation-state tinting plus an injected filter validator and completer.

FilterEdit has exactly two responsibilities: drive the syntaxState QSS property from a FilterValidator, and hold the FilterValidator / FilterCompleter so any QLineEdit-shaped site gets filter validation and completion without the toolbar affordances. It is light enough to serve as an item-view delegate editor.

It deliberately does not install the validator on QLineEdit: a QLineEdit rejects keystrokes while its validator returns Invalid, but a filter is routinely invalid mid-typing. Instead the validator runs on a debounce purely to colour the field. The completer is installed on QLineEdit so the native typeahead popup works.

Buttons, menus, history, bookmarks, drag-drop and statusbar coupling live in the FilterExpressionEdit subclass and below, never here.

Member Enumeration Documentation

◆ SyntaxState

enum class FilterEdit::SyntaxState
strong

Visual/semantic state of the current text, mapped from the validator.

Enumerator
Empty 

Field empty; no validation performed. Base palette.

Busy 

Asynchronous validation in progress (reserved; see note).

Intermediate 

Still typing, not wrong yet. Neutral, never red.

Invalid 

Fails validation. Red tint.

Deprecated 

Valid but uses a deprecated construct. Amber tint.

Valid 

Passes validation. Green tint.

Member Function Documentation

◆ setValidator()

void FilterEdit::setValidator ( FilterValidator * validator)

Installs the filter validator. Widget-owned (deleted with the widget, and replaces any previous validator).

The validator is not handed to QLineEdit::setValidator(); it is run on the debounce only, to drive syntaxState. With no validator set the state stays Empty and the field is never tinted.

◆ validateNow()

void FilterEdit::validateNow ( )
protected

Runs the validator against the current text and updates the state.

Synchronous: validate() returns immediately and lastDetail() is read right after. Used both by the debounce and by subclasses that must validate before committing.

Property Documentation

◆ syntaxState

QString FilterEdit::syntaxState
read

String-valued for QSS selectors, e.g. FilterEdit[syntaxState="invalid"].


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