Unverified Commit 26cc44d2 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7918 from DonLakeFlyer/PlanOverlay

Plan: Create Plan overlay and friends
parents 7dd98eac 636175dc
......@@ -35,16 +35,18 @@ SettingsFact::SettingsFact(QString settingsGroup, FactMetaData* metaData, QObjec
_visible = qgcApp()->toolbox()->corePlugin()->adjustSettingMetaData(settingsGroup, *metaData);
setMetaData(metaData);
QVariant rawDefaultValue = metaData->rawDefaultValue();
if (_visible) {
QVariant typedValue;
QString errorString;
metaData->convertAndValidateRaw(settings.value(_name, rawDefaultValue), true /* conertOnly */, typedValue, errorString);
_rawValue = typedValue;
} else {
// Setting is not visible, force to default value always
settings.setValue(_name, rawDefaultValue);
_rawValue = rawDefaultValue;
if (metaData->defaultValueAvailable()) {
QVariant rawDefaultValue = metaData->rawDefaultValue();
if (_visible) {
QVariant typedValue;
QString errorString;
metaData->convertAndValidateRaw(settings.value(_name, rawDefaultValue), true /* conertOnly */, typedValue, errorString);
_rawValue = typedValue;
} else {
// Setting is not visible, force to default value always
settings.setValue(_name, rawDefaultValue);
_rawValue = rawDefaultValue;
}
}
connect(this, &Fact::rawValueChanged, this, &SettingsFact::_rawValueChanged);
......
......@@ -1004,16 +1004,16 @@ bool MissionController::loadTextFile(QFile& file, QString& errorString)
return true;
}
bool MissionController::readyForSaveSend(void) const
int MissionController::readyForSaveState(void) const
{
for (int i=0; i<_visualItems->count(); i++) {
VisualMissionItem* visualItem = qobject_cast<VisualMissionItem*>(_visualItems->get(i));
if (visualItem->readyForSaveState() != VisualMissionItem::ReadyForSave) {
return false;
return visualItem->readyForSaveState();
}
}
return true;
return VisualMissionItem::ReadyForSave;
}
void MissionController::save(QJsonObject& json)
......
......@@ -145,9 +145,10 @@ public:
/// Returns the index of this item in the visual item list
Q_INVOKABLE int visualItemIndexFromSequenceNumber(int sequenceNumber) const;
/// Determines if the mission has all data needed to be saved or sent to the vehicle. Currently the only case where this
/// would return false is when it is still waiting on terrain data to determine correct altitudes.
bool readyForSaveSend(void) const;
/// Determines if the mission has all data needed to be saved or sent to the vehicle.
/// IMPORTANT NOTE: The return value is a VisualMissionItem::ReadForSaveState value. It is an int here to work around
/// a nightmare of circular header dependency problems.
int readyForSaveState(void) const;
/// Sends the mission items to the specified vehicle
static void sendItemsToVehicle(Vehicle* vehicle, QmlObjectListModel* visualMissionItems);
......
......@@ -29,7 +29,7 @@ class PlanMasterController : public QObject
public:
PlanMasterController(QObject* parent = nullptr);
~PlanMasterController();
Q_PROPERTY(MissionController* missionController READ missionController CONSTANT)
Q_PROPERTY(GeoFenceController* geoFenceController READ geoFenceController CONSTANT)
Q_PROPERTY(RallyPointController* rallyPointController READ rallyPointController CONSTANT)
......@@ -52,9 +52,10 @@ public:
/// @param deleteWhenSendCmplete The PlanMasterController object should be deleted after the first send is completed.
Q_INVOKABLE void startStaticActiveVehicle(Vehicle* vehicle, bool deleteWhenSendCompleted = false);
/// Determines if the plan has all data needed to be saved or sent to the vehicle. Currently the only case where this
/// would return false is when it is still waiting on terrain data to determine correct altitudes.
Q_INVOKABLE bool readyForSaveSend(void) const { return _missionController.readyForSaveSend(); }
/// Determines if the plan has all information needed to be saved or sent to the vehicle.
/// IMPORTANT NOTE: The return value is a VisualMissionItem::ReadForSaveState value. It is an int here to work around
/// a nightmare of circular header dependency problems.
Q_INVOKABLE int readyForSaveState(void) const { return _missionController.readyForSaveState(); }
/// Sends a plan to the specified file
/// @param[in] vehicle Vehicle we are sending a plan to
......
......@@ -181,13 +181,29 @@ Item {
mainWindow.planMasterControllerPlan = _planMasterController
}
function waitingOnDataMessage() {
mainWindow.showMessageDialog(qsTr("Unable to Save/Upload"), qsTr("Plan is waiting on terrain data from server for correct altitude values."))
function waitingOnIncompleteDataMessage(save) {
var saveOrUpload = save ? qsTr("Save") : qsTr("Upload")
mainWindow.showMessageDialog(qsTr("Unable to %1").arg(saveOrUpload), qsTr("Plan has incomplete items. Complete all items and %1 again.").arg(saveOrUpload))
}
function waitingOnTerrainDataMessage(save) {
var saveOrUpload = save ? qsTr("Save") : qsTr("Upload")
mainWindow.showMessageDialog(qsTr("Unable to %1").arg(saveOrUpload), qsTr("Plan is waiting on terrain data from server for correct altitude values."))
}
function checkReadyForSaveUpload(save) {
if (readyForSaveState() == VisualMissionItem.NotReadyForSaveData) {
waitingOnIncompleteDataMessage(save)
return false
} else if (readyForSaveState() == VisualMissionItem.NotReadyForSaveTerrain) {
waitingOnTerrainDataMessage(save)
return false
}
return true
}
function upload() {
if (!readyForSaveSend()) {
waitingOnDataMessage()
if (!checkReadyForSaveUpload(false /* save */)) {
return
}
if (activeVehicle && activeVehicle.armed && activeVehicle.flightMode === activeVehicle.missionFlightMode) {
......@@ -208,8 +224,7 @@ Item {
}
function saveToSelectedFile() {
if (!readyForSaveSend()) {
waitingOnDataMessage()
if (!checkReadyForSaveUpload(true /* save */)) {
return
}
fileDialog.title = qsTr("Save Plan")
......@@ -236,8 +251,7 @@ Item {
}
function saveKmlToSelectedFile() {
if (!readyForSaveSend()) {
waitingOnDataMessage()
if (!checkReadyForSaveUpload(true /* save */)) {
return
}
fileDialog.title = qsTr("Save KML")
......@@ -1040,10 +1054,13 @@ Item {
QGCButton {
text: qsTr("New...")
Layout.fillWidth: true
enabled: _planMasterController.containsItems
onClicked: {
dropPanel.hide()
mainWindow.showComponentDialog(removeAllPromptDialog, qsTr("New Plan"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
if (_planMasterController.containsItems) {
mainWindow.showComponentDialog(removeAllPromptDialog, qsTr("New Plan"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
} else {
startOverlay.visible = true
}
}
}
......
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