From bdb044dfb3a20c8459416ebd68ebe4aad3de7c93 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Sat, 3 Mar 2018 12:37:43 -0500 Subject: [PATCH] Show flight area on map when listing flights Add message asking user confirmation to end a flight --- src/Airmap/AirMapAdvisoryManager.cc | 2 +- src/Airmap/AirMapManager.cc | 6 +-- src/Airmap/AirMapRestrictionManager.cc | 2 +- src/Airmap/AirMapRulesetsManager.cc | 2 +- src/Airmap/AirMapWeatherInfoManager.cc | 2 +- src/Airmap/AirmapSettings.qml | 46 +++++++++++----------- .../AirspaceFlightPlanProvider.cc | 4 +- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/Airmap/AirMapAdvisoryManager.cc b/src/Airmap/AirMapAdvisoryManager.cc index 090b6af..57a5d52 100644 --- a/src/Airmap/AirMapAdvisoryManager.cc +++ b/src/Airmap/AirMapAdvisoryManager.cc @@ -58,7 +58,7 @@ adv_sort(QObject* a, QObject* b) void AirMapAdvisoryManager::_requestAdvisories() { - qCDebug(AirMapManagerLog) << "Advisories Request"; + qCDebug(AirMapManagerLog) << "Advisories Request (ROI Changed)"; if (!_shared.client()) { qCDebug(AirMapManagerLog) << "No AirMap client instance. Not updating Advisories"; _valid = false; diff --git a/src/Airmap/AirMapManager.cc b/src/Airmap/AirMapManager.cc index 9020d99..2896992 100644 --- a/src/Airmap/AirMapManager.cc +++ b/src/Airmap/AirMapManager.cc @@ -37,9 +37,9 @@ AirMapManager::AirMapManager(QGCApplication* app, QGCToolbox* toolbox) { _logger = std::make_shared(); qt::register_types(); // TODO: still needed? - _logger->logging_category().setEnabled(QtDebugMsg, true); - _logger->logging_category().setEnabled(QtInfoMsg, true); - _logger->logging_category().setEnabled(QtWarningMsg, true); + _logger->logging_category().setEnabled(QtDebugMsg, false); + _logger->logging_category().setEnabled(QtInfoMsg, false); + _logger->logging_category().setEnabled(QtWarningMsg, false); _dispatchingLogger = std::make_shared(_logger); connect(&_shared, &AirMapSharedState::error, this, &AirMapManager::_error); } diff --git a/src/Airmap/AirMapRestrictionManager.cc b/src/Airmap/AirMapRestrictionManager.cc index 2bf78c5..f22f3d2 100644 --- a/src/Airmap/AirMapRestrictionManager.cc +++ b/src/Airmap/AirMapRestrictionManager.cc @@ -49,7 +49,7 @@ AirMapRestrictionManager::_requestRestrictions(const QGCGeoBoundingCube& roi) qCWarning(AirMapManagerLog) << "AirMapRestrictionManager::updateROI: state not idle"; return; } - qCDebug(AirMapManagerLog) << "Setting Restriction Manager ROI"; + qCDebug(AirMapManagerLog) << "Restrictions Request (ROI Changed)"; _polygons.clear(); _circles.clear(); _state = State::RetrieveItems; diff --git a/src/Airmap/AirMapRulesetsManager.cc b/src/Airmap/AirMapRulesetsManager.cc index 4d0cfe8..8e93d46 100644 --- a/src/Airmap/AirMapRulesetsManager.cc +++ b/src/Airmap/AirMapRulesetsManager.cc @@ -199,7 +199,7 @@ void AirMapRulesetsManager::setROI(const QGCGeoBoundingCube& roi) qCWarning(AirMapManagerLog) << "AirMapRulesetsManager::updateROI: state not idle"; return; } - qCDebug(AirMapManagerLog) << "Setting ROI for Rulesets"; + qCDebug(AirMapManagerLog) << "Rulesets Request (ROI Changed)"; _valid = false; _ruleSets.clearAndDeleteContents(); _state = State::RetrieveItems; diff --git a/src/Airmap/AirMapWeatherInfoManager.cc b/src/Airmap/AirMapWeatherInfoManager.cc index 766f4f1..62dbd9b 100644 --- a/src/Airmap/AirMapWeatherInfoManager.cc +++ b/src/Airmap/AirMapWeatherInfoManager.cc @@ -42,7 +42,7 @@ AirMapWeatherInfoManager::setROI(const QGCGeoBoundingCube& roi) void AirMapWeatherInfoManager::_requestWeatherUpdate(const QGeoCoordinate& coordinate) { - qCDebug(AirMapManagerLog) << "Request Weather"; + qCDebug(AirMapManagerLog) << "Weather Request (ROI Changed)"; if (!_shared.client()) { qCDebug(AirMapManagerLog) << "No AirMap client instance. Not updating Weather information"; _valid = false; diff --git a/src/Airmap/AirmapSettings.qml b/src/Airmap/AirmapSettings.qml index 7f99b3e..5d6fd0c 100644 --- a/src/Airmap/AirmapSettings.qml +++ b/src/Airmap/AirmapSettings.qml @@ -306,14 +306,10 @@ QGCView { selectionMode: SelectionMode.SingleSelection Layout.fillWidth: true onCurrentRowChanged: { - map.fitViewportToMapItems() var o = _flightList.get(tableView.currentRow) if(o) { - console.log(o.boundingBox.count) - console.log(o.boundingBox) - console.log(o.flightID) - } else { - console.log('No bounding box') + flightArea.path = o.boundingBox + map.fitViewportToMapItems() } } TableViewColumn { @@ -516,9 +512,24 @@ QGCView { } anchors.horizontalCenter: parent.horizontalCenter onClicked: { - var o = _flightList.get(tableView.currentRow) - if(o) { - QGroundControl.airspaceManager.flightPlan.endFlight(o.flightID) + endFlightDialog.visible = true + } + MessageDialog { + id: endFlightDialog + visible: false + icon: StandardIcon.Warning + standardButtons: StandardButton.Yes | StandardButton.No + title: qsTr("End Flight") + text: qsTr("Confirm ending active flight?") + onYes: { + var o = _flightList.get(tableView.currentRow) + if(o) { + QGroundControl.airspaceManager.flightPlan.endFlight(o.flightID) + } + endFlightDialog.visible = false + } + onNo: { + endFlightDialog.visible = false } } } @@ -573,19 +584,10 @@ QGCView { } } } - MapItemView { - model: { - var o = _flightList.get(tableView.currentRow) - if(o) { - return o.boundingBox - } - return [] - } - delegate: MapPolygon { - path: object - color: Qt.rgba(1,0,0,0.2) - border.color: Qt.rgba(1,1,1,0.65) - } + MapPolygon { + id: flightArea + color: Qt.rgba(1,0,0,0.2) + border.color: Qt.rgba(1,1,1,0.65) } Component.onCompleted: { updateActiveMapType() diff --git a/src/AirspaceManagement/AirspaceFlightPlanProvider.cc b/src/AirspaceManagement/AirspaceFlightPlanProvider.cc index 574523e..434c5b8 100644 --- a/src/AirspaceManagement/AirspaceFlightPlanProvider.cc +++ b/src/AirspaceManagement/AirspaceFlightPlanProvider.cc @@ -105,13 +105,13 @@ void AirspaceFlightModel::clear(void) { if(!_flightEntries.isEmpty()) { - beginRemoveRows(QModelIndex(), 0, _flightEntries.count()); + beginResetModel(); while (_flightEntries.count()) { AirspaceFlightInfo* entry = _flightEntries.last(); if(entry) entry->deleteLater(); _flightEntries.removeLast(); } - endRemoveRows(); + endResetModel(); emit countChanged(); } }