QLineEdit subclass that adds syntax-state colouring, error messaging, and partial token-based autocompletion for display filters, field names, custom columns, and integer inputs.
More...
#include <syntax_line_edit.h>
|
| void | setStyleSheet (const QString &style_sheet) |
| | Sets the base style sheet; the state-driven style is composited on top.
|
| |
| void | insertFilter (const QString &filter) |
| | Inserts filter text at the cursor position, adding surrounding spaces where necessary to keep the expression well-formed.
|
| |
| bool | checkDisplayFilter (QString filter) |
| | Validates filter as a Wireshark display filter and updates the syntax state and error message accordingly.
|
| |
| void | checkFieldName (QString field) |
| | Validates field as a protocol field name and updates the syntax state.
|
| |
| void | checkCustomColumn (QString fields) |
| | Validates fields as a custom-column field expression and updates the syntax state.
|
| |
| void | checkInteger (QString number) |
| | Validates number as a well-formed integer and updates the syntax state.
|
| |
|
| | SyntaxLineEdit (QWidget *parent=0) |
| | Constructs the SyntaxLineEdit in the Empty state with no completer.
|
| |
| SyntaxState | syntaxState () const |
| | Returns the current syntax validation state.
|
| |
| void | setSyntaxState (SyntaxState state=Empty) |
| | Sets the syntax state and updates the widget's style sheet to reflect it.
|
| |
| QString | syntaxErrorMessage () |
| | Returns a short, human-readable description of the current syntax error.
|
| |
| QString | syntaxErrorMessageFull () |
| | Returns a full error message that includes the filter expression and the location of the error within it.
|
| |
| QString | styleSheet () const |
| | Returns the base style sheet, excluding any state-driven overrides.
|
| |
| QString | deprecatedToken () |
| | Returns the deprecated token string when the state is Deprecated.
|
| |
| void | setCompleter (QCompleter *c) |
| | Installs a QCompleter for token-based autocompletion.
|
| |
| QCompleter * | completer () const |
| | Returns the currently installed completer.
|
| |
| void | allowCompletion (bool enabled) |
| | Enables or disables autocompletion without removing the completer.
|
| |
|
| static QString | createSyntaxErrorMessageFull (const QString &filter, const QString &err_msg, qsizetype loc_start, size_t loc_length) |
| | Builds a full syntax error message string combining the filter expression with a location-annotated error description.
|
| |
|
| void | setCompletionTokenChars (const QString &token_chars) |
| | Sets the characters that may appear in a completion token (e.g. letters, digits, underscores, dots). Must be called by subclasses before completion is used.
|
| |
| bool | isComplexFilter (const QString &filter) |
| | Returns true if filter contains operators or structure that make it too complex for token-level autocompletion.
|
| |
| virtual void | buildCompletionList (const QString &field_word, const QString &preamble) |
| | Builds the list of completion candidates based on the current token and filter context. Subclasses must override this to provide context-appropriate completions.
|
| |
| QPoint | getTokenUnderCursor () |
| | Returns the start position and length of the token under the cursor.
|
| |
| QStringList | splitLineUnderCursor () |
| | Splits the line at the cursor into the preamble and the current token.
|
| |
| virtual bool | event (QEvent *event) |
| | Intercepts Tab and other keys to trigger or dismiss the completer.
|
| |
| void | completionKeyPressEvent (QKeyEvent *event) |
| | Handles key press events while the completer popup is visible, forwarding navigation keys to the popup and committing on Enter/Tab.
|
| |
| void | completionFocusInEvent (QFocusEvent *event) |
| | Triggers a completion refresh when the widget gains focus.
|
| |
| virtual void | focusOutEvent (QFocusEvent *event) |
| | Hides the completer popup when the widget loses focus.
|
| |
| virtual void | paintEvent (QPaintEvent *event) |
| | Paints the widget, overlaying a state-appropriate background colour.
|
| |
QLineEdit subclass that adds syntax-state colouring, error messaging, and partial token-based autocompletion for display filters, field names, custom columns, and integer inputs.
Autocompletion is partially implemented. Subclasses must:
◆ SyntaxState
Visual and semantic state of the text currently in the editor.
| Enumerator |
|---|
| Empty | The field is empty; no validation has been performed.
|
| Busy | Validation is in progress (e.g. asynchronous lookup).
|
| Invalid | The current text fails validation.
|
| Deprecated | The current text is valid but uses a deprecated construct.
|
| Valid | The current text passes validation.
|
◆ SyntaxLineEdit()
| SyntaxLineEdit::SyntaxLineEdit |
( |
QWidget * |
parent = 0 | ) |
|
|
explicit |
Constructs the SyntaxLineEdit in the Empty state with no completer.
- Parameters
-
| parent | Optional parent widget. |
◆ allowCompletion()
| void SyntaxLineEdit::allowCompletion |
( |
bool |
enabled | ) |
|
Enables or disables autocompletion without removing the completer.
- Parameters
-
| enabled | true to allow completion popups; false to suppress them. |
◆ buildCompletionList()
| virtual void SyntaxLineEdit::buildCompletionList |
( |
const QString & |
field_word, |
|
|
const QString & |
preamble |
|
) |
| |
|
inlineprotectedvirtual |
Builds the list of completion candidates based on the current token and filter context. Subclasses must override this to provide context-appropriate completions.
- Parameters
-
| field_word | The current token under the cursor that is being completed. |
| preamble | The portion of the filter before the current token, which may provide context for filtering the completion list. |
◆ checkCustomColumn
| void SyntaxLineEdit::checkCustomColumn |
( |
QString |
fields | ) |
|
|
slot |
Validates fields as a custom-column field expression and updates the syntax state.
- Parameters
-
| fields | Custom column field expression to check. |
◆ checkDisplayFilter
| bool SyntaxLineEdit::checkDisplayFilter |
( |
QString |
filter | ) |
|
|
slot |
Validates filter as a Wireshark display filter and updates the syntax state and error message accordingly.
- Parameters
-
| filter | Display filter expression to check. |
- Returns
true if the filter is valid or empty; false if invalid.
◆ checkFieldName
| void SyntaxLineEdit::checkFieldName |
( |
QString |
field | ) |
|
|
slot |
Validates field as a protocol field name and updates the syntax state.
- Parameters
-
| field | Field name string to check (e.g. "tcp.port"). |
◆ checkInteger
| void SyntaxLineEdit::checkInteger |
( |
QString |
number | ) |
|
|
slot |
Validates number as a well-formed integer and updates the syntax state.
- Parameters
-
| number | String to validate as an integer. |
◆ completer()
| QCompleter * SyntaxLineEdit::completer |
( |
| ) |
const |
|
inline |
Returns the currently installed completer.
- Returns
- Pointer to the QCompleter, or
nullptr if none is installed.
◆ completionFocusInEvent()
| void SyntaxLineEdit::completionFocusInEvent |
( |
QFocusEvent * |
event | ) |
|
|
protected |
Triggers a completion refresh when the widget gains focus.
- Parameters
-
◆ completionKeyPressEvent()
| void SyntaxLineEdit::completionKeyPressEvent |
( |
QKeyEvent * |
event | ) |
|
|
protected |
Handles key press events while the completer popup is visible, forwarding navigation keys to the popup and committing on Enter/Tab.
- Parameters
-
| event | The key press event. |
◆ createSyntaxErrorMessageFull()
| QString SyntaxLineEdit::createSyntaxErrorMessageFull |
( |
const QString & |
filter, |
|
|
const QString & |
err_msg, |
|
|
qsizetype |
loc_start, |
|
|
size_t |
loc_length |
|
) |
| |
|
static |
Builds a full syntax error message string combining the filter expression with a location-annotated error description.
- Parameters
-
| filter | The filter expression that failed validation. |
| err_msg | Short error message returned by the validator. |
| loc_start | Zero-based character offset where the error begins. |
| loc_length | Number of characters the error spans. |
- Returns
- Formatted full error message string.
◆ deprecatedToken()
| QString SyntaxLineEdit::deprecatedToken |
( |
| ) |
|
Returns the deprecated token string when the state is Deprecated.
- Returns
- The deprecated token, or an empty string if the state is not Deprecated.
◆ event()
| bool SyntaxLineEdit::event |
( |
QEvent * |
event | ) |
|
|
protectedvirtual |
Intercepts Tab and other keys to trigger or dismiss the completer.
- Parameters
-
| event | The event to inspect. |
- Returns
true if the event was consumed; false to pass it on.
◆ focusOutEvent()
| void SyntaxLineEdit::focusOutEvent |
( |
QFocusEvent * |
event | ) |
|
|
protectedvirtual |
◆ getTokenUnderCursor()
| QPoint SyntaxLineEdit::getTokenUnderCursor |
( |
| ) |
|
|
protected |
Returns the start position and length of the token under the cursor.
- Returns
- QPoint where x is the start character offset and y is the token length.
◆ insertFilter
| void SyntaxLineEdit::insertFilter |
( |
const QString & |
filter | ) |
|
|
slot |
Inserts filter text at the cursor position, adding surrounding spaces where necessary to keep the expression well-formed.
- Parameters
-
| filter | Filter text to insert. |
◆ isComplexFilter()
| bool SyntaxLineEdit::isComplexFilter |
( |
const QString & |
filter | ) |
|
|
protected |
Returns true if filter contains operators or structure that make it too complex for token-level autocompletion.
- Parameters
-
| filter | Filter expression to inspect. |
- Returns
true if the filter is considered complex.
◆ paintEvent()
| void SyntaxLineEdit::paintEvent |
( |
QPaintEvent * |
event | ) |
|
|
protectedvirtual |
◆ setCompleter()
| void SyntaxLineEdit::setCompleter |
( |
QCompleter * |
c | ) |
|
Installs a QCompleter for token-based autocompletion.
- Parameters
-
| c | Completer to install; pass nullptr to remove the current completer. |
◆ setCompletionTokenChars()
| void SyntaxLineEdit::setCompletionTokenChars |
( |
const QString & |
token_chars | ) |
|
|
inlineprotected |
Sets the characters that may appear in a completion token (e.g. letters, digits, underscores, dots). Must be called by subclasses before completion is used.
- Parameters
-
| token_chars | String of characters valid within a single completion token. |
◆ setStyleSheet
| void SyntaxLineEdit::setStyleSheet |
( |
const QString & |
style_sheet | ) |
|
|
slot |
Sets the base style sheet; the state-driven style is composited on top.
- Parameters
-
| style_sheet | New base style sheet string. |
◆ setSyntaxState()
Sets the syntax state and updates the widget's style sheet to reflect it.
- Parameters
-
| state | New syntax state; defaults to Empty. |
◆ splitLineUnderCursor()
| QStringList SyntaxLineEdit::splitLineUnderCursor |
( |
| ) |
|
|
protected |
Splits the line at the cursor into the preamble and the current token.
- Returns
- QStringList of exactly two elements: { preamble, token }.
◆ styleSheet()
| QString SyntaxLineEdit::styleSheet |
( |
| ) |
const |
Returns the base style sheet, excluding any state-driven overrides.
- Returns
- Base style sheet string.
◆ syntaxErrorMessage()
| QString SyntaxLineEdit::syntaxErrorMessage |
( |
| ) |
|
Returns a short, human-readable description of the current syntax error.
- Returns
- Error message string, or an empty string if the state is not Invalid.
◆ syntaxErrorMessageFull()
| QString SyntaxLineEdit::syntaxErrorMessageFull |
( |
| ) |
|
Returns a full error message that includes the filter expression and the location of the error within it.
- Returns
- Full error message string, or an empty string if there is no error.
◆ syntaxState()
Returns the current syntax validation state.
- Returns
- Current SyntaxState value.
◆ completer_
| QCompleter* SyntaxLineEdit::completer_ |
|
protected |
Installed autocompletion provider; may be nullptr.
◆ completion_model_
| QStringListModel* SyntaxLineEdit::completion_model_ |
|
protected |
String list model backing the completer.
The documentation for this class was generated from the following files:
- /builds/wireshark/wireshark/ui/qt/widgets/syntax_line_edit.h
- /builds/wireshark/wireshark/ui/qt/widgets/syntax_line_edit.cpp