Skip to content

Commit

Permalink
Merge pull request #567 from opengisch/tracking_session_ui
Browse files Browse the repository at this point in the history
Tracking session UI
  • Loading branch information
suricactus authored Mar 14, 2024
2 parents 89d3a91 + 8d1bc09 commit 1050a59
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 85 deletions.
130 changes: 99 additions & 31 deletions qfieldsync/gui/map_layer_config_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ def __init__(self, layer, canvas, parent):
self.layer_source.action,
)

self.attachmentNamingTable = AttachmentNamingTableWidget()
self.attachmentNamingTable.addLayerFields(self.layer_source)
self.attachmentNamingTable.setLayerColumnHidden(True)

self.relationshipConfigurationTable = RelationshipConfigurationTableWidget()
self.relationshipConfigurationTable.addLayerFields(self.layer_source)
self.relationshipConfigurationTable.setLayerColumnHidden(True)

self.measurementTypeComboBox.addItem(
"Elapsed time (seconds since start of tracking)"
)
self.measurementTypeComboBox.addItem(
self.tr("Timestamp (milliseconds since epoch)")
)
self.measurementTypeComboBox.addItem(self.tr("Ground speed"))
self.measurementTypeComboBox.addItem(self.tr("Bearing"))
self.measurementTypeComboBox.addItem(self.tr("Horizontal accuracy"))
self.measurementTypeComboBox.addItem(self.tr("Vertical accuracy"))
self.measurementTypeComboBox.addItem(self.tr("PDOP"))
self.measurementTypeComboBox.addItem(self.tr("HDOP"))
self.measurementTypeComboBox.addItem(self.tr("VDOP"))

if layer.type() == QgsMapLayer.VectorLayer:
prop = QgsProperty.fromExpression(
self.layer_source.geometry_locked_expression
Expand All @@ -100,17 +122,9 @@ def __init__(self, layer, canvas, parent):
self.isGeometryLockedCheckBox.setChecked(
self.layer_source.is_geometry_locked
)
else:
self.isGeometryLockedDDButton.setVisible(False)
self.isGeometryLockedCheckBox.setVisible(False)

self.attachmentNamingTable = AttachmentNamingTableWidget()
self.attachmentNamingTable.addLayerFields(self.layer_source)
self.attachmentNamingTable.setLayerColumnHidden(True)

# append the attachment naming table to the layout
if layer.type() == QgsMapLayer.VectorLayer:
self.layout().insertRow(
# append the attachment naming table to the layout
self.attachmentsRelationsLayout.insertRow(
-1, self.tr("Attachment\nnaming"), self.attachmentNamingTable
)
tip = QLabel(
Expand All @@ -119,18 +133,13 @@ def __init__(self, layer, canvas, parent):
)
)
tip.setWordWrap(True)
self.layout().insertRow(-1, "", tip)
self.attachmentsRelationsLayout.insertRow(-1, "", tip)
self.attachmentNamingTable.setEnabled(
self.attachmentNamingTable.rowCount() > 0
)

self.relationshipConfigurationTable = RelationshipConfigurationTableWidget()
self.relationshipConfigurationTable.addLayerFields(self.layer_source)
self.relationshipConfigurationTable.setLayerColumnHidden(True)

# append the relationship configuration table to the layout
if layer.type() == QgsMapLayer.VectorLayer:
self.layout().insertRow(
# append the relationship configuration table to the layout
self.attachmentsRelationsLayout.insertRow(
-1,
self.tr("Relationship\nconfiguration"),
self.relationshipConfigurationTable,
Expand All @@ -139,10 +148,47 @@ def __init__(self, layer, canvas, parent):
self.relationshipConfigurationTable.rowCount() > 0
)

self.trackingSessionGroupBox.setChecked(
self.layer_source.tracking_session_active
)
self.timeRequirementCheckBox.setChecked(
self.layer_source.tracking_time_requirement_active
)
self.timeRequirementIntervalSecondsSpinBox.setValue(
self.layer_source.tracking_time_requirement_interval_seconds
)
self.distanceRequirementCheckBox.setChecked(
self.layer_source.tracking_distance_requirement_active
)
self.distanceRequirementMinimumMetersSpinBox.setValue(
self.layer_source.tracking_distance_requirement_minimum_meters
)
self.sensorDataRequirementCheckBox.setChecked(
self.layer_source.tracking_sensor_data_requirement_active
)
self.allRequirementsCheckBox.setChecked(
self.layer_source.tracking_all_requirements_active
)
self.erroneousDistanceSafeguardCheckBox.setChecked(
self.layer_source.tracking_erroneous_distance_safeguard_active
)
self.erroneousDistanceSafeguardMaximumMetersSpinBox.setValue(
self.layer_source.tracking_erroneous_distance_safeguard_maximum_meters
)
self.measurementTypeComboBox.setCurrentIndex(
self.layer_source.tracking_measurement_type
)
else:
self.isGeometryLockedDDButton.setVisible(False)
self.isGeometryLockedCheckBox.setVisible(False)

self.attachmentsRelationsGroupBox.setVisible(False)
self.trackingSessionGroupBox.setVisible(False)

def apply(self):
old_layer_action = self.layer_source.action
old_layer_cloud_action = self.layer_source.cloud_action
old_is_geometry_locked = self.layer_source.is_geometry_locked
self.layer_source.action
self.layer_source.cloud_action
self.layer_source.is_geometry_locked

self.layer_source.cloud_action = self.cloudLayerActionComboBox.itemData(
self.cloudLayerActionComboBox.currentIndex()
Expand All @@ -157,15 +203,37 @@ def apply(self):
self.attachmentNamingTable.syncLayerSourceValues()
self.relationshipConfigurationTable.syncLayerSourceValues()

# apply always the attachment naming (to store default values on first apply as well)
if (
self.layer_source.action != old_layer_action
or self.layer_source.cloud_action != old_layer_cloud_action
or self.layer_source.is_geometry_locked != old_is_geometry_locked
or self.attachmentNamingTable.rowCount() > 0
or self.relationshipConfigurationTable.rowCount() > 0
):
self.layer_source.apply()
self.project.setDirty(True)
self.layer_source.tracking_session_active = (
self.trackingSessionGroupBox.isChecked()
)
self.layer_source.tracking_time_requirement_active = (
self.timeRequirementCheckBox.isChecked()
)
self.layer_source.tracking_time_requirement_interval_seconds = (
self.timeRequirementIntervalSecondsSpinBox.value()
)
self.layer_source.tracking_distance_requirement_active = (
self.distanceRequirementCheckBox.isChecked()
)
self.layer_source.tracking_distance_requirement_minimum_meters = (
self.distanceRequirementMinimumMetersSpinBox.value()
)
self.layer_source.tracking_sensor_data_requirement_active = (
self.sensorDataRequirementCheckBox.isChecked()
)
self.layer_source.tracking_all_requirements_active = (
self.allRequirementsCheckBox.isChecked()
)
self.layer_source.tracking_erroneous_distance_safeguard_active = (
self.erroneousDistanceSafeguardCheckBox.isChecked()
)
self.layer_source.tracking_erroneous_distance_safeguard_maximum_meters = (
self.erroneousDistanceSafeguardMaximumMetersSpinBox.value()
)
self.layer_source.tracking_measurement_type = (
self.measurementTypeComboBox.currentIndex()
)

if self.layer_source.apply():
self.project.setDirty(True)
message_bus.messaged.emit("layer_config_saved")
Loading

0 comments on commit 1050a59

Please sign in to comment.