Skip to content

Commit 12f1adf

Browse files
authored
pass and update current index [CPP-852] (#888)
* pass format index as field * handle only init * only init once for interactive components * pylint * should only reflect counters when sbp is logging
1 parent b9b8d3e commit 12f1adf

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

resources/LoggingBar.qml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ Rectangle {
163163
SwiftComboBox {
164164
id: sbpLoggingFormat
165165

166-
currentIndex: 0
167166
Layout.preferredWidth: Constants.loggingBar.sbpLoggingButtonWidth
168167
Layout.preferredHeight: loggingBarRowLayout.preferredButtonHeight
169168
enabled: !sbpLoggingButton.checked
@@ -287,11 +286,14 @@ Rectangle {
287286
repeat: true
288287
onTriggered: {
289288
logging_bar_model.fill_data(loggingBarData);
290-
sbpLoggingButton.checked = loggingBarData.sbp_logging;
291-
csvLoggingButton.checked = loggingBarData.csv_logging;
289+
if (sbpLoggingFormat.currentIndex == -1) {
290+
sbpLoggingFormat.currentIndex = loggingBarData.sbp_logging_format_index;
291+
sbpLoggingButton.checked = loggingBarData.sbp_logging;
292+
csvLoggingButton.checked = loggingBarData.csv_logging;
293+
}
292294
if (loggingBarData.recording_filename)
293295
recordingFilenameText.editText = loggingBarData.recording_filename;
294-
let recording = sbpLoggingButton.checked || csvLoggingButton.checked;
296+
let recording = loggingBarData.sbp_logging;
295297
if (mockTime) {
296298
mockRecordingTime += interval;
297299
recordingTime.text = loggingDurationFormat(mockRecordingTime / 1000);

swiftnav_console/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class Keys(str, Enum):
102102
PREVIOUS_FOLDERS = "PREVIOUS_FOLDERS"
103103
SBP_LOGGING = "SBP_LOGGING"
104104
SBP_LOGGING_FORMAT = "SBP_LOGGING_FORMAT"
105+
SBP_LOGGING_FORMAT_INDEX = "SBP_LOGGING_FORMAT_INDEX"
105106
CSV_LOGGING = "CSV_LOGGING"
106107
SBP_LOGGING_LABELS = "SBP_LOGGING_LABELS"
107108
LOG_LEVEL_LABELS = "LOG_LEVEL_LABELS"

swiftnav_console/logging_bar.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def logging_bar_update() -> Dict[str, Any]:
4141
Keys.CSV_LOGGING: False,
4242
Keys.SBP_LOGGING: False,
4343
Keys.SBP_LOGGING_FORMAT: SbpLogging.SBP_JSON,
44+
Keys.SBP_LOGGING_FORMAT_INDEX: 0,
4445
Keys.SBP_LOGGING_LABELS: [SbpLogging.SBP_JSON, SbpLogging.SBP],
4546
}
4647

@@ -70,11 +71,12 @@ def __len__(self) -> int:
7071

7172

7273
@QmlElement
73-
class LoggingBarData(QObject): # pylint: disable=too-many-instance-attributes
74+
class LoggingBarData(QObject): # pylint: disable=too-many-instance-attributes, too-many-public-methods
7475
_instance: "LoggingBarData"
7576
_csv_logging: bool = False
7677
_sbp_logging: bool = False
7778
_sbp_logging_format: str = SbpLogging.SBP_JSON
79+
_sbp_logging_format_index: int = 0
7880
_sbp_logging_labels: QStringListModel = SwiftStringListModel()
7981
_previous_folders: QStringListModel = SwiftStringListModel()
8082
_recording_duration_sec: int = 0
@@ -97,6 +99,7 @@ def __init__(self):
9799

98100
@classmethod
99101
def post_data_update(cls, update_data: Dict[str, Any]) -> None:
102+
update_data[Keys.SBP_LOGGING_FORMAT_INDEX] = update_data[Keys.SBP_LOGGING_LABELS].index(update_data[Keys.SBP_LOGGING_FORMAT])
100103
LOGGING_BAR[0] = update_data
101104
cls._instance._data_updated.emit() # pylint: disable=protected-access
102105

@@ -148,6 +151,14 @@ def set_sbp_logging_format(self, sbp_logging_format: str) -> None:
148151

149152
sbp_logging_format = Property(str, get_sbp_logging_format, set_sbp_logging_format)
150153

154+
def get_sbp_logging_format_index(self) -> int:
155+
return self._sbp_logging_format_index
156+
157+
def set_sbp_logging_format_index(self, sbp_logging_format_index: int) -> None:
158+
self._sbp_logging_format_index = sbp_logging_format_index
159+
160+
sbp_logging_format_index = Property(int, get_sbp_logging_format_index, set_sbp_logging_format_index)
161+
151162
# sbp_logging_labels property
152163
def get_sbp_logging_labels(self) -> QObject:
153164
return self._sbp_logging_labels
@@ -203,6 +214,7 @@ def fill_data(self, cp: LoggingBarData) -> LoggingBarData: # pylint:disable=no-
203214
cp.set_csv_logging(cp.logging_bar[Keys.CSV_LOGGING])
204215
cp.set_sbp_logging(cp.logging_bar[Keys.SBP_LOGGING])
205216
cp.set_sbp_logging_format(cp.logging_bar[Keys.SBP_LOGGING_FORMAT])
217+
cp.set_sbp_logging_format_index(cp.logging_bar[Keys.SBP_LOGGING_FORMAT_INDEX])
206218
cp.set_sbp_logging_labels(cp.logging_bar[Keys.SBP_LOGGING_LABELS])
207219
cp.set_previous_folders(cp.logging_bar[Keys.PREVIOUS_FOLDERS])
208220
cp.set_recording_size(cp.logging_bar_recording[Keys.RECORDING_SIZE])

0 commit comments

Comments
 (0)