Commit 75dc8e5b authored by Gus Grubba's avatar Gus Grubba

Update Airmap controls to QtQuick 2.4 and bring it in sync with the new QGC UI core.

Better handle the dirty state of Airmap's flightplan
parent 5c400033
...@@ -139,9 +139,11 @@ AirMapFlightPlanManager::setFlightStartTime(QDateTime start) ...@@ -139,9 +139,11 @@ AirMapFlightPlanManager::setFlightStartTime(QDateTime start)
{ {
if(start < QDateTime::currentDateTime()) { if(start < QDateTime::currentDateTime()) {
start = QDateTime::currentDateTime().addSecs(1); start = QDateTime::currentDateTime().addSecs(1);
setDirty(true);
} }
if(_flightStartTime != start) { if(_flightStartTime != start) {
_flightStartTime = start; _flightStartTime = start;
setDirty(true);
emit flightStartTimeChanged(); emit flightStartTimeChanged();
} }
qCDebug(AirMapManagerLog) << "Set time start time" << _flightStartTime; qCDebug(AirMapManagerLog) << "Set time start time" << _flightStartTime;
...@@ -152,6 +154,7 @@ void ...@@ -152,6 +154,7 @@ void
AirMapFlightPlanManager::setFlightStartsNow(bool now) AirMapFlightPlanManager::setFlightStartsNow(bool now)
{ {
_flightStartsNow = now; _flightStartsNow = now;
setDirty(true);
emit flightStartsNowChanged(); emit flightStartsNowChanged();
} }
...@@ -159,12 +162,15 @@ AirMapFlightPlanManager::setFlightStartsNow(bool now) ...@@ -159,12 +162,15 @@ AirMapFlightPlanManager::setFlightStartsNow(bool now)
void void
AirMapFlightPlanManager::setFlightDuration(int seconds) AirMapFlightPlanManager::setFlightDuration(int seconds)
{ {
if(_flightDuration != seconds || _flightDuration < 30) {
_flightDuration = seconds; _flightDuration = seconds;
if(_flightDuration < 30) { if(_flightDuration < 30) {
_flightDuration = 30; _flightDuration = 30;
} }
setDirty(true);
emit flightDurationChanged(); emit flightDurationChanged();
qCDebug(AirMapManagerLog) << "Set time duration" << _flightDuration; qCDebug(AirMapManagerLog) << "Set time duration" << _flightDuration;
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -261,6 +267,7 @@ AirMapFlightPlanManager::updateFlightPlan() ...@@ -261,6 +267,7 @@ AirMapFlightPlanManager::updateFlightPlan()
} }
_flightPermitStatus = AirspaceFlightPlanProvider::PermitPending; _flightPermitStatus = AirspaceFlightPlanProvider::PermitPending;
emit flightPermitStatusChanged(); emit flightPermitStatusChanged();
setDirty(false);
_updateFlightPlan(true); _updateFlightPlan(true);
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* *
****************************************************************************/ ****************************************************************************/
#include "AirspaceFlightPlanProvider.h"
#include "AirMapRulesetsManager.h" #include "AirMapRulesetsManager.h"
#include "AirMapManager.h" #include "AirMapManager.h"
#include "QGCApplication.h" #include "QGCApplication.h"
...@@ -136,6 +137,7 @@ AirMapRuleFeature::setValue(const QVariant val) ...@@ -136,6 +137,7 @@ AirMapRuleFeature::setValue(const QVariant val)
settings.setValue(name(), _value); settings.setValue(name(), _value);
settings.endGroup(); settings.endGroup();
emit valueChanged(); emit valueChanged();
qgcApp()->toolbox()->airspaceManager()->flightPlan()->setDirty(true);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
This diff is collapsed.
...@@ -18,6 +18,7 @@ Item { ...@@ -18,6 +18,7 @@ Item {
implicitWidth: briefRootCol.width implicitWidth: briefRootCol.width
property real baseHeight: ScreenTools.defaultFontPixelHeight * 22 property real baseHeight: ScreenTools.defaultFontPixelHeight * 22
property real baseWidth: ScreenTools.defaultFontPixelWidth * 40 property real baseWidth: ScreenTools.defaultFontPixelWidth * 40
signal closed()
Column { Column {
id: briefRootCol id: briefRootCol
spacing: ScreenTools.defaultFontPixelHeight * 0.25 spacing: ScreenTools.defaultFontPixelHeight * 0.25
...@@ -198,11 +199,10 @@ Item { ...@@ -198,11 +199,10 @@ Item {
backRadius: 4 backRadius: 4
heightFactor: 0.3333 heightFactor: 0.3333
showBorder: true showBorder: true
enabled: _flightPermit !== AirspaceFlightPlanProvider.PermitNone && _dirty enabled: _flightPermit !== AirspaceFlightPlanProvider.PermitNone && QGroundControl.airspaceManager.flightPlan.dirty
visible: planView visible: planView
width: ScreenTools.defaultFontPixelWidth * 12 width: ScreenTools.defaultFontPixelWidth * 12
onClicked: { onClicked: {
_dirty = false
QGroundControl.airspaceManager.flightPlan.updateFlightPlan() QGroundControl.airspaceManager.flightPlan.updateFlightPlan()
} }
} }
...@@ -216,8 +216,7 @@ Item { ...@@ -216,8 +216,7 @@ Item {
visible: planView visible: planView
onClicked: { onClicked: {
QGroundControl.airspaceManager.flightPlan.submitFlightPlan() QGroundControl.airspaceManager.flightPlan.submitFlightPlan()
mainWindow.enableToolbar() _root.closed()
rootLoader.sourceComponent = null
} }
} }
QGCButton { QGCButton {
...@@ -227,8 +226,7 @@ Item { ...@@ -227,8 +226,7 @@ Item {
showBorder: true showBorder: true
width: ScreenTools.defaultFontPixelWidth * 12 width: ScreenTools.defaultFontPixelWidth * 12
onClicked: { onClicked: {
mainWindow.enableToolbar() _root.closed()
rootLoader.sourceComponent = null
} }
} }
} }
......
...@@ -71,7 +71,6 @@ Item { ...@@ -71,7 +71,6 @@ Item {
text: qsTr("Now") text: qsTr("Now")
checked: QGroundControl.airspaceManager.flightPlan.flightStartsNow checked: QGroundControl.airspaceManager.flightPlan.flightStartsNow
onClicked: { onClicked: {
_dirty = true
QGroundControl.airspaceManager.flightPlan.flightStartsNow = !QGroundControl.airspaceManager.flightPlan.flightStartsNow QGroundControl.airspaceManager.flightPlan.flightStartsNow = !QGroundControl.airspaceManager.flightPlan.flightStartsNow
} }
} }
...@@ -89,7 +88,6 @@ Item { ...@@ -89,7 +88,6 @@ Item {
enabled: !QGroundControl.airspaceManager.flightPlan.flightStartsNow enabled: !QGroundControl.airspaceManager.flightPlan.flightStartsNow
iconSource: "qrc:/airmap/expand.svg" iconSource: "qrc:/airmap/expand.svg"
onClicked: { onClicked: {
_dirty = true
datePicker.visible = true datePicker.visible = true
} }
} }
...@@ -112,7 +110,6 @@ Item { ...@@ -112,7 +110,6 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
onValueChanged: { onValueChanged: {
_dirty = true
var today = QGroundControl.airspaceManager.flightPlan.flightStartTime var today = QGroundControl.airspaceManager.flightPlan.flightStartTime
today.setHours(Math.floor(timeSlider.value * 0.25)) today.setHours(Math.floor(timeSlider.value * 0.25))
today.setMinutes((timeSlider.value * 15) % 60) today.setMinutes((timeSlider.value * 15) % 60)
......
...@@ -29,32 +29,36 @@ Rectangle { ...@@ -29,32 +29,36 @@ Rectangle {
anchors.left: parent.left anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
QGCLabel { QGCLabel {
text: feature.description text: feature ? feature.description : ""
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
visible: feature.type !== AirspaceRuleFeature.Boolean visible: feature ? (feature.type !== AirspaceRuleFeature.Boolean) : false
} }
QGCTextField { QGCTextField {
text: feature.value ? feature.value : "" text: feature ? (feature.value ? feature.value : "") : ""
visible: feature.type !== AirspaceRuleFeature.Boolean visible: feature ? (feature.type !== AirspaceRuleFeature.Boolean) : false
showUnits: true showUnits: true
unitsLabel: { unitsLabel: {
if(feature) {
if(feature.unit == AirspaceRuleFeature.Kilogram) if(feature.unit == AirspaceRuleFeature.Kilogram)
return "kg"; return "kg";
if(feature.unit == AirspaceRuleFeature.Meters) if(feature.unit == AirspaceRuleFeature.Meters)
return "m"; return "m";
if(feature.unit == AirspaceRuleFeature.MetersPerSecond) if(feature.unit == AirspaceRuleFeature.MetersPerSecond)
return "m/s"; return "m/s";
}
return "" return ""
} }
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
inputMethodHints: feature.type === AirspaceRuleFeature.Float ? Qt.ImhFormattedNumbersOnly :Qt.ImhNone inputMethodHints: feature ? (feature.type === AirspaceRuleFeature.Float ? Qt.ImhFormattedNumbersOnly : Qt.ImhNone) : Qt.ImhNone
onAccepted: { onAccepted: {
if(feature)
feature.value = parseFloat(text) feature.value = parseFloat(text)
} }
onEditingFinished: { onEditingFinished: {
if(feature)
feature.value = parseFloat(text) feature.value = parseFloat(text)
} }
} }
...@@ -62,20 +66,20 @@ Rectangle { ...@@ -62,20 +66,20 @@ Rectangle {
height: Math.max(checkBox.height, label.height) height: Math.max(checkBox.height, label.height)
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
visible: feature.type === AirspaceRuleFeature.Boolean visible: feature ? (feature.type === AirspaceRuleFeature.Boolean) : false
QGCCheckBox { QGCCheckBox {
id: checkBox id: checkBox
text: "" text: ""
onClicked: feature.value = checked onClicked: { if(feature) {feature.value = checked} }
anchors.left: parent.left anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Component.onCompleted: { Component.onCompleted: {
checked = feature.value === 2 ? false : feature.value checked = feature ? (feature.value === 2 ? false : feature.value) : false
} }
} }
QGCLabel { QGCLabel {
id: label id: label
text: feature.description text: feature ? feature.description : ""
anchors.right: parent.right anchors.right: parent.right
anchors.left: checkBox.right anchors.left: checkBox.right
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 0.5 anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 0.5
......
import QtQuick 2.3 import QtQuick 2.11
import QtQuick.Controls 1.2 import QtQuick.Controls 2.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QtQml 2.2
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
...@@ -11,35 +8,26 @@ import QGroundControl.Palette 1.0 ...@@ -11,35 +8,26 @@ import QGroundControl.Palette 1.0
import QGroundControl.Airmap 1.0 import QGroundControl.Airmap 1.0
import QGroundControl.SettingsManager 1.0 import QGroundControl.SettingsManager 1.0
Rectangle { Button {
id: _root id: _root
autoExclusive: false
height: ScreenTools.defaultFontPixelHeight height: ScreenTools.defaultFontPixelHeight
background: Rectangle {
anchors.fill: parent
color: _selected ? qgcPal.windowShade : qgcPal.window color: _selected ? qgcPal.windowShade : qgcPal.window
}
property var rule: null property var rule: null
property bool checked: false
property bool required: false
property bool _selected: { property bool _selected: {
if (exclusiveGroup) { if (autoExclusive) {
return checked return checked
} else { } else {
return rule ? rule.selected : false return rule ? rule.selected : false
} }
} }
property ExclusiveGroup exclusiveGroup: null
onExclusiveGroupChanged: {
if (exclusiveGroup) {
checked = rule.selected
exclusiveGroup.bindCheckable(_root)
}
}
onCheckedChanged: { onCheckedChanged: {
rule.selected = checked rule.selected = checked
} }
QGCPalette { contentItem: Row {
id: qgcPal
colorGroupEnabled: enabled
}
Row {
id: ruleRow id: ruleRow
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right anchors.right: parent.right
...@@ -52,20 +40,16 @@ Rectangle { ...@@ -52,20 +40,16 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
QGCLabel { QGCLabel {
text: rule.name === "" ? rule.shortName : rule.name text: rule ? (rule.name === "" ? rule.shortName : rule.name) : ""
font.pointSize: ScreenTools.smallFontPointSize font.pointSize: ScreenTools.smallFontPointSize
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
} }
MouseArea {
anchors.fill: parent
enabled: !required
onClicked: { onClicked: {
if (exclusiveGroup) { if (autoExclusive) {
checked = true checked = true
} else { } else {
rule.selected = !rule.selected rule.selected = !rule.selected
} }
} }
}
} }
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <QObject> #include <QObject>
#include <QDateTime> #include <QDateTime>
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QDebug>
class PlanMasterController; class PlanMasterController;
class AirspaceFlightInfo; class AirspaceFlightInfo;
...@@ -164,6 +165,7 @@ public: ...@@ -164,6 +165,7 @@ public:
///< Flight Management ///< Flight Management
Q_PROPERTY(AirspaceFlightModel* flightList READ flightList NOTIFY flightListChanged) Q_PROPERTY(AirspaceFlightModel* flightList READ flightList NOTIFY flightListChanged)
Q_PROPERTY(bool loadingFlightList READ loadingFlightList NOTIFY loadingFlightListChanged) Q_PROPERTY(bool loadingFlightList READ loadingFlightList NOTIFY loadingFlightListChanged)
Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged)
//-- TODO: This will submit the current flight plan in memory. //-- TODO: This will submit the current flight plan in memory.
Q_INVOKABLE virtual void submitFlightPlan () = 0; Q_INVOKABLE virtual void submitFlightPlan () = 0;
...@@ -189,11 +191,13 @@ public: ...@@ -189,11 +191,13 @@ public:
virtual QmlObjectListModel* authorizations () = 0; ///< List of AirspaceFlightAuthorization virtual QmlObjectListModel* authorizations () = 0; ///< List of AirspaceFlightAuthorization
virtual AirspaceFlightModel*flightList () = 0; ///< List of AirspaceFlightInfo virtual AirspaceFlightModel*flightList () = 0; ///< List of AirspaceFlightInfo
virtual bool loadingFlightList () = 0; virtual bool loadingFlightList () = 0;
virtual bool dirty () { return _dirty; }
virtual void setFlightStartTime (QDateTime start) = 0; virtual void setFlightStartTime (QDateTime start) = 0;
virtual void setFlightDuration (int seconds) = 0; virtual void setFlightDuration (int seconds) = 0;
virtual void setFlightStartsNow (bool now) = 0; virtual void setFlightStartsNow (bool now) = 0;
virtual void startFlightPlanning (PlanMasterController* planController) = 0; virtual void startFlightPlanning (PlanMasterController* planController) = 0;
virtual void setDirty (bool dirt) { if(_dirty != dirt) { _dirty = dirt; emit dirtyChanged(); qDebug() << "Dirty" << _dirty; }}
signals: signals:
void flightPermitStatusChanged (); void flightPermitStatusChanged ();
...@@ -205,4 +209,8 @@ signals: ...@@ -205,4 +209,8 @@ signals:
void rulesChanged (); void rulesChanged ();
void flightListChanged (); void flightListChanged ();
void loadingFlightListChanged (); void loadingFlightListChanged ();
void dirtyChanged ();
protected:
bool _dirty = false;
}; };
...@@ -735,7 +735,7 @@ Item { ...@@ -735,7 +735,7 @@ Item {
width: airspaceRow.width + (ScreenTools.defaultFontPixelWidth * 3) width: airspaceRow.width + (ScreenTools.defaultFontPixelWidth * 3)
height: airspaceRow.height * 1.25 height: airspaceRow.height * 1.25
color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75) color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.95) : Qt.rgba(0,0,0,0.75)
visible: QGroundControl.airmapSupported && _mainIsMap && flightPermit && flightPermit !== AirspaceFlightPlanProvider.PermitNone && !messageArea.visible && !criticalMmessageArea.visible visible: QGroundControl.airmapSupported && _mainIsMap && flightPermit && flightPermit !== AirspaceFlightPlanProvider.PermitNone
radius: 3 radius: 3
border.width: 1 border.width: 1
border.color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.35) : Qt.rgba(1,1,1,0.35) border.color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.35) : Qt.rgba(1,1,1,0.35)
......
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