Skip to content

SentencesPage

class nmeasim::app::SentencesPage · Applications

Settings tab that lists every sentence in the registry with its enabled flag, talker and period, plus the position precision.

Inherits QWidget

Declared in src/app/dialogs/sentences_page.hpp (line 41)

Below the registry table, a second table holds the custom sentences. SettingsDialog calls load once with its copy of the profile, validate when the operator presses OK, and store into the same copy when every page is valid. The widgets are the only state of the page.

The registry table has one row per descriptor of core::nmea0183::SentenceRegistry::standard, in catalogue order, created once by the constructor; its rows are never added or removed. The Talker and Period cells hold a QLineEdit and a QSpinBox as cell widgets, and the Id, Description and Group cells are read-only. The custom table has one row per custom sentence, with a QLineEdit in the Id and Sentence cells and a QSpinBox in the Period cell.

Every widget, cell widget and table item is owned through Qt parents by the page, and the public widget pointers are never null and stay valid for the lifetime of the page. The class declares no signals or slots of its own.

See also

Summary

Public types

Name Description
Column Columns of table, the registry sentences.
CustomColumn Columns of custom_table, the custom sentences.

Public member functions

Name Description
SentencesPage() Creates the page with one row per registry sentence, every row unticked, and an empty custom table.
load() Shows the sentence settings of a profile in the widgets.
store() Writes the widget values into the sentence fields of a profile.
validate() Checks the talkers of the registry rows and the custom sentences, row by row.
row_of() Returns the row of a registry id in the table.
set_enabled() Ticks or unticks the enabled flag of a registry row.
is_enabled() Returns whether the enabled flag of a registry row is ticked.
add_custom() Appends a custom sentence row and selects it.
remove_current_custom() Removes the current row of the custom table; does nothing when there is none.
custom_count() Returns the number of rows in the custom table.
custom_at() Returns the custom sentence of a row as store writes it.

Public data members

Name Description
position_decimals_spin Number of decimals of the minutes in latitudes and longitudes, core::nmea0183::EncoderOptions::position_decimals; [2, 8], the range the profile accepts.
table The registry sentences, one row per descriptor in catalogue order, with the columns of Column.
custom_table The custom sentences in emission order, with the columns of CustomColumn; rows are added by add_custom and removed by remove_current_custom.
add_custom_button The Add custom sentence button, which calls add_custom with an empty body.
remove_custom_button The Remove button, which calls remove_current_custom.

Private member functions

Name Description
set_all() Ticks or unticks the enabled flag of every registry row.
reset_defaults() Returns every registry row to its defaults.
number_custom_placeholders() Sets the placeholder of every custom id field to the id an empty field is sent as.

Private static member functions

Name Description
default_custom_id() Returns the id the scheduler gives a custom sentence without one.

Public types

Column

enum Column

Columns of table, the registry sentences.

Enumerator Value Description
Enabled 0 Checkable item: whether the sentence is sent.
Id Read-only registry id, such as RMC or MWV-T.
Description Read-only one-line summary of the sentence.
Group Read-only name of the sentence group, such as GNSS.
Talker QLineEdit cell widget with the talker; empty uses the default.
Period QSpinBox cell widget with the period in milliseconds.
ColumnCount Number of columns, not a column.

Declared in src/app/dialogs/sentences_page.hpp:46

CustomColumn

enum CustomColumn

Columns of custom_table, the custom sentences.

Enumerator Value Description
CustomEnabled 0 Checkable item: whether the sentence is sent.
CustomId QLineEdit cell widget with the id; empty gives CUSTOM-<row>.
CustomBody QLineEdit cell widget with the sentence without checksum.
CustomPeriod QSpinBox cell widget with the period in milliseconds.
CustomColumnCount Number of columns, not a column.

Declared in src/app/dialogs/sentences_page.hpp:56

Public member functions

SentencesPage()

explicit SentencesPage(QWidget* parent = nullptr)

Creates the page with one row per registry sentence, every row unticked, and an empty custom table.

The rows show no profile until load is called. Connects the Enable all, Disable all, Reset to defaults, Add custom sentence and Remove buttons.

Parameters

Name Type Description
parent QWidget* The owner of the page, normally the SettingsDialog; when null, the caller owns the page.

Declared in src/app/dialogs/sentences_page.hpp:72 · defined in src/app/dialogs/sentences_page.cpp:42

load()

void load(const io::Profile& profile)

Shows the sentence settings of a profile in the widgets.

The custom table is rebuilt from io::Profile::custom_sentences, in order. Each registry row shows the setting that io::Profile::make_scheduler gives the sentence: the profile's setting when it has one, the registry default otherwise. The talker is shown upper-cased, and empty, with the default talker as placeholder, when the setting has none. A period outside the range of the period spin box, which a profile file can hold, is clamped to it.

Parameters

Name Type Description
profile const io::Profile& The profile to show; only read during the call.

Declared in src/app/dialogs/sentences_page.hpp:84 · defined in src/app/dialogs/sentences_page.cpp:237

store()

void store(io::Profile& profile) const

Writes the widget values into the sentence fields of a profile.

Writes io::Profile::encoder position decimals, replaces io::Profile::custom_sentences with the rows of the custom table as custom_at returns them, and replaces io::Profile::sentences with the registry rows that differ from the registry defaults. Talkers are upper-cased, and a talker equal to the default is stored as empty, so it does not make a row differ. Writing only the differences keeps a saved profile small and lets it follow registry changes in later versions.

Parameters

Name Type Description
profile io::Profile& The profile to update, normally the dialog's copy.

Note

store does not validate the custom sentences. SettingsDialog calls it only after validate returned an empty string.

Declared in src/app/dialogs/sentences_page.hpp:97 · defined in src/app/dialogs/sentences_page.cpp:265

validate()

QString validate() const

Checks the talkers of the registry rows and the custom sentences, row by row.

A registry row is refused when its talker has one letter: a talker is two letters, or empty for the default. A custom row is refused when core::simulation::validate_custom_sentence refuses its body, when its id, as custom_at returns it, is a registry id, or when an earlier custom row has the same id; an empty id counts as the CUSTOM-n it is sent as.

Returns QString: For the first refused row, Sentence <id>: or Custom sentence n: followed by the reason, or Custom sentences m and n have the same id <id>, where m and n are 1-based row numbers; an empty string when every row is valid.

Declared in src/app/dialogs/sentences_page.hpp:109 · defined in src/app/dialogs/sentences_page.cpp:204

row_of()

int row_of(const QString& id) const

Returns the row of a registry id in the table.

Parameters

Name Type Description
id const QString& The registry id, such as RMC or MWV-T; compared case-sensitively.

Returns int: The row index, or -1 when no row has that id.

Declared in src/app/dialogs/sentences_page.hpp:115 · defined in src/app/dialogs/sentences_page.cpp:295

set_enabled()

void set_enabled(int row, bool enabled)

Ticks or unticks the enabled flag of a registry row.

Parameters

Name Type Description
row int The row index, as row_of returns it.
enabled bool Whether the sentence is sent.

Preconditions

  • row is in [0, table->rowCount()).

Declared in src/app/dialogs/sentences_page.hpp:121 · defined in src/app/dialogs/sentences_page.cpp:304

is_enabled()

bool is_enabled(int row) const

Returns whether the enabled flag of a registry row is ticked.

Parameters

Name Type Description
row int The row index, as row_of returns it.

Returns bool: True when the sentence is enabled.

Preconditions

  • row is in [0, table->rowCount()).

Declared in src/app/dialogs/sentences_page.hpp:127 · defined in src/app/dialogs/sentences_page.cpp:308

add_custom()

void add_custom(const QString& body = {})

Appends a custom sentence row and selects it.

The new row is enabled, has an empty id with CUSTOM-n as placeholder, where n is the new row count, and a period of 1000 ms. The placeholders of the custom rows always show the id an empty field is sent as, also after a row is removed. The id field accepts at most 12 letters, digits and hyphens; the sentence field accepts at most 80 characters, and validate applies the exact length limit to the framed sentence. The period spin box accepts [50, 3600000] ms, the range the profile accepts for custom sentences. The Add custom sentence button calls it with an empty body.

Parameters

Name Type Description
body const QString& The sentence text to start with, unchecked; empty for none.

Declared in src/app/dialogs/sentences_page.hpp:140 · defined in src/app/dialogs/sentences_page.cpp:140

remove_current_custom()

void remove_current_custom()

Removes the current row of the custom table; does nothing when there is none.

The CUSTOM-n placeholders of the rows below it are renumbered.

Connected to the Remove button.

Declared in src/app/dialogs/sentences_page.hpp:146 · defined in src/app/dialogs/sentences_page.cpp:166

custom_count()

int custom_count() const

Returns the number of rows in the custom table.

Returns int: The number of custom sentences, enabled or not.

Declared in src/app/dialogs/sentences_page.hpp:150 · defined in src/app/dialogs/sentences_page.cpp:185

custom_at()

core::simulation::CustomSentence custom_at(int row) const

Returns the custom sentence of a row as store writes it.

The id is trimmed and upper-cased. The body is taken as typed, surrounding white space included; core::simulation::validate_custom_sentence and the scheduler ignore it.

Parameters

Name Type Description
row int The row index in the custom table.

Returns core::simulation::CustomSentence: The sentence with its enabled flag, id, body and period.

Preconditions

Declared in src/app/dialogs/sentences_page.hpp:160 · defined in src/app/dialogs/sentences_page.cpp:189

Public data members

position_decimals_spin

QSpinBox* position_decimals_spin

Number of decimals of the minutes in latitudes and longitudes, core::nmea0183::EncoderOptions::position_decimals; [2, 8], the range the profile accepts.

The encoders lower it when a sentence would exceed 82 characters, as its tooltip says.

Declared in src/app/dialogs/sentences_page.hpp:167

table

QTableWidget* table

The registry sentences, one row per descriptor in catalogue order, with the columns of Column.

The talker cell accepts two letters or none; a single letter can be typed on the way to two, and validate refuses it. The period cell accepts [50, 3600000] ms, the range the profile accepts for custom sentences, in steps of 100 ms.

Declared in src/app/dialogs/sentences_page.hpp:174

custom_table

QTableWidget* custom_table

The custom sentences in emission order, with the columns of CustomColumn; rows are added by add_custom and removed by remove_current_custom.

Declared in src/app/dialogs/sentences_page.hpp:177

add_custom_button

QPushButton* add_custom_button

The Add custom sentence button, which calls add_custom with an empty body.

Declared in src/app/dialogs/sentences_page.hpp:179

remove_custom_button

QPushButton* remove_custom_button

The Remove button, which calls remove_current_custom.

Declared in src/app/dialogs/sentences_page.hpp:181

Private member functions

set_all()

void set_all(bool enabled)

Ticks or unticks the enabled flag of every registry row.

Connected to the Enable all button with true and the Disable all button with false.

Parameters

Name Type Description
enabled bool Whether every registry sentence is sent.

Declared in src/app/dialogs/sentences_page.hpp:190 · defined in src/app/dialogs/sentences_page.cpp:312

reset_defaults()

void reset_defaults()

Returns every registry row to its defaults.

Loads a default-constructed io::Profile, which has no sentence settings, with the current custom sentences and position decimals copied into it, so the custom table keeps its rows and the decimals stay; the custom ids come back trimmed and upper-cased. Connected to the Reset to defaults button.

Declared in src/app/dialogs/sentences_page.hpp:197 · defined in src/app/dialogs/sentences_page.cpp:318

number_custom_placeholders()

void number_custom_placeholders()

Sets the placeholder of every custom id field to the id an empty field is sent as.

Declared in src/app/dialogs/sentences_page.hpp:199 · defined in src/app/dialogs/sentences_page.cpp:174

Private static member functions

default_custom_id()

static QString default_custom_id(int row)

Returns the id the scheduler gives a custom sentence without one.

Parameters

Name Type Description
row int The row index in the custom table, from 0.

Returns QString: CUSTOM-n, where n is row + 1.

See also

Declared in src/app/dialogs/sentences_page.hpp:205 · defined in src/app/dialogs/sentences_page.cpp:181