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