|
Wireshark 4.7.2
The Wireshark network protocol analyzer
|
QLineEdit with validation-state tinting plus an injected filter validator and completer. More...
#include <filter_edit.h>
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). | |
| FilterValidator * | validator () 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. | |
| FilterCompleter * | completer () 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 |
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.
|
strong |
Visual/semantic state of the current text, mapped from the validator.
| 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.
|
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.
|
read |
String-valued for QSS selectors, e.g. FilterEdit[syntaxState="invalid"].