ConsoleWidget¶
class nmeasim::app::ConsoleWidget · Applications
Scrolling view of the sentences being sent, coloured like a protocol analyser.
Inherits QWidget
Declared in src/app/widgets/console_widget.hpp (line 29)
Lines are buffered and flushed a few times per second so that high output rates never stall the interface.
Above the read-only view sit a Pause check box, a filter field and a Clear button. The view keeps the most recent 2000 lines, drops older ones, does not wrap lines and uses theme::Theme::mono_font; a SentenceHighlighter colours it. New lines are added every 150 ms while sentences arrive. The view follows new lines only while it is scrolled to the bottom, so the operator can scroll back and read without being pulled down.
Summary¶
Public member functions
| Name | Description |
|---|---|
ConsoleWidget() |
Creates an empty, unpaused console with an empty filter. |
append_sentence() |
Queues one sentence or message for display, unless it is paused or filtered out. |
clear() |
Removes every line shown and every line still waiting to be shown. |
line_count() |
Returns the number of lines shown in the view. |
paused() |
Returns whether the operator ticked Pause. |
Private member functions
| Name | Description |
|---|---|
flush() |
Appends the waiting lines to the view in one edit, then empties the buffer. |
Private data members
| Name | Description |
|---|---|
view_ |
The read-only text view; owned by this widget through the Qt parent. |
highlighter_ |
Highlighter of the document of view_, which owns it. |
pause_check_ |
The Pause check box; owned by this widget. |
filter_edit_ |
The filter field; owned by this widget. |
flush_timer_ |
Fires every 150 ms while lines are waiting; stopped when the console is idle. |
pending_ |
Lines waiting for the next flush, oldest first; at most 2000. |
Public member functions¶
ConsoleWidget()¶
explicit ConsoleWidget(QWidget* parent = nullptr)
Creates an empty, unpaused console with an empty filter.
Parameters
| Name | Type | Description |
|---|---|---|
parent |
QWidget* |
Qt parent that owns the widget; null leaves ownership to the caller. |
Declared in src/app/widgets/console_widget.hpp:36 · defined in src/app/widgets/console_widget.cpp:28
append_sentence()¶
void append_sentence(const QString& id, const QString& text)
Queues one sentence or message for display, unless it is paused or filtered out.
Does nothing while Pause is ticked: those sentences are dropped, not kept for later. When the filter field (trimmed) is not empty, the line is kept only if id or text contains it, ignoring case; changing the filter affects new lines only. A kept line waits in a buffer that holds at most 2000 lines, dropping the oldest, and appears at the next flush, within 150 ms. Connected to io::SimulationRunner::sentence_emitted.
Parameters
| Name | Type | Description |
|---|---|---|
id |
const QString& |
Registry or custom sentence id such as RMC, or SIGNALK or VIEWSYNC for a state message; used only by the filter. |
text |
const QString& |
The line to show, without line terminator. |
Declared in src/app/widgets/console_widget.hpp:49 · defined in src/app/widgets/console_widget.cpp:59
clear()¶
void clear()
Removes every line shown and every line still waiting to be shown.
Leaves Pause and the filter as they are. Connected to the Clear button.
Declared in src/app/widgets/console_widget.hpp:53 · defined in src/app/widgets/console_widget.cpp:93
line_count()¶
int line_count() const
Returns the number of lines shown in the view.
Returns int: From 0 to 2000; lines still waiting for the next flush are not counted.
Declared in src/app/widgets/console_widget.hpp:57 · defined in src/app/widgets/console_widget.cpp:98
paused()¶
bool paused() const
Returns whether the operator ticked Pause.
Returns bool: True while new sentences are dropped instead of shown.
Declared in src/app/widgets/console_widget.hpp:61 · defined in src/app/widgets/console_widget.cpp:102
Private member functions¶
flush()¶
void flush()
Appends the waiting lines to the view in one edit, then empties the buffer.
Scrolls to the new bottom only when the view was at the bottom before. Stops the timer when nothing was waiting, so an idle console costs nothing. Called by flush_timer_.
Declared in src/app/widgets/console_widget.hpp:69 · defined in src/app/widgets/console_widget.cpp:77
Private data members¶
view_¶
QPlainTextEdit* view_
The read-only text view; owned by this widget through the Qt parent.
Declared in src/app/widgets/console_widget.hpp:72
highlighter_¶
SentenceHighlighter* highlighter_{nullptr}
Highlighter of the document of view_, which owns it.
Declared in src/app/widgets/console_widget.hpp:74
pause_check_¶
QCheckBox* pause_check_
The Pause check box; owned by this widget.
Declared in src/app/widgets/console_widget.hpp:76
filter_edit_¶
QLineEdit* filter_edit_
The filter field; owned by this widget.
Declared in src/app/widgets/console_widget.hpp:78
flush_timer_¶
QTimer flush_timer_
Fires every 150 ms while lines are waiting; stopped when the console is idle.
Declared in src/app/widgets/console_widget.hpp:80
pending_¶
QStringList pending_
Lines waiting for the next flush, oldest first; at most 2000.
Declared in src/app/widgets/console_widget.hpp:82