Unverified Commit ef13fe17 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7787 from DonLakeFlyer/CommandChange

Correctly handle command changes from no-coordinate item to coordinate
parents fdcd39ae ef046629
...@@ -743,6 +743,10 @@ void SimpleMissionItem::_setDefaultsForCommand(void) ...@@ -743,6 +743,10 @@ void SimpleMissionItem::_setDefaultsForCommand(void)
// No need to carry across previous lat/lon // No need to carry across previous lat/lon
_missionItem._param5Fact.setRawValue(0); _missionItem._param5Fact.setRawValue(0);
_missionItem._param6Fact.setRawValue(0); _missionItem._param6Fact.setRawValue(0);
} else if ((specifiesCoordinate() || isStandaloneCoordinate()) && _missionItem._param5Fact.rawValue().toDouble() == 0 && _missionItem._param6Fact.rawValue().toDouble() == 0) {
// We switched from a command without a coordinate to a command with a coordinate. Use the hint.
_missionItem._param5Fact.setRawValue(_mapCenterHint.latitude());
_missionItem._param6Fact.setRawValue(_mapCenterHint.longitude());
} }
// Set global defaults first, then if there are param defaults they will get reset // Set global defaults first, then if there are param defaults they will get reset
......
...@@ -49,6 +49,11 @@ public: ...@@ -49,6 +49,11 @@ public:
Q_PROPERTY(QmlObjectListModel* textFieldFacts READ textFieldFacts CONSTANT) Q_PROPERTY(QmlObjectListModel* textFieldFacts READ textFieldFacts CONSTANT)
Q_PROPERTY(QmlObjectListModel* nanFacts READ nanFacts CONSTANT) Q_PROPERTY(QmlObjectListModel* nanFacts READ nanFacts CONSTANT)
/// This should be called before changing the command. It is needed if the command changes
/// from an item which does not include a coordinate to an item which requires a coordinate.
/// It uses this value to set that new coordinate.
Q_INVOKABLE void setMapCenterHintForCommandChange(QGeoCoordinate mapCenter) { _mapCenterHint = mapCenter; };
/// Scans the loaded items for additional section settings /// Scans the loaded items for additional section settings
/// @param visualItems List of all visual items /// @param visualItems List of all visual items
/// @param scanIndex Index to start scanning from /// @param scanIndex Index to start scanning from
...@@ -162,6 +167,7 @@ private: ...@@ -162,6 +167,7 @@ private:
bool _rawEdit; bool _rawEdit;
bool _dirty; bool _dirty;
bool _ignoreDirtyChangeSignals; bool _ignoreDirtyChangeSignals;
QGeoCoordinate _mapCenterHint;
SpeedSection* _speedSection; SpeedSection* _speedSection;
CameraSection* _cameraSection; CameraSection* _cameraSection;
......
...@@ -204,7 +204,8 @@ Rectangle { ...@@ -204,7 +204,8 @@ Rectangle {
id: commandDialog id: commandDialog
MissionCommandDialog { MissionCommandDialog {
missionItem: _root.missionItem missionItem: _root.missionItem
map: _root.map
} }
} }
......
...@@ -20,6 +20,7 @@ QGCViewDialog { ...@@ -20,6 +20,7 @@ QGCViewDialog {
id: root id: root
property var missionItem property var missionItem
property var map
property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle
...@@ -96,6 +97,7 @@ QGCViewDialog { ...@@ -96,6 +97,7 @@ QGCViewDialog {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
missionItem.setMapCenterHintForCommandChange(map.center)
missionItem.command = mavCmdInfo.command missionItem.command = mavCmdInfo.command
root.reject() root.reject()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment