From 7e543bb02cd87df43af74b7bc451a92308962ea8 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Mon, 23 Jul 2018 17:45:21 -0400 Subject: [PATCH] Add a button to clear feature responses More clang warnings cleanup --- src/Airmap/AirMapFlightPlanManager.cc | 18 ++++----- src/Airmap/AirMapManager.cc | 6 +-- src/Airmap/AirmapSettings.qml | 54 +++++++++++++++++++-------- src/Airmap/FlightFeature.qml | 2 +- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/Airmap/AirMapFlightPlanManager.cc b/src/Airmap/AirMapFlightPlanManager.cc index b5d107f1c..1dd088deb 100644 --- a/src/Airmap/AirMapFlightPlanManager.cc +++ b/src/Airmap/AirMapFlightPlanManager.cc @@ -597,7 +597,7 @@ adv_sort(QObject* a, QObject* b) AirMapAdvisory* aa = qobject_cast(a); AirMapAdvisory* bb = qobject_cast(b); if(!aa || !bb) return false; - return (int)aa->color() > (int)bb->color(); + return static_cast(aa->color()) > static_cast(bb->color()); } //----------------------------------------------------------------------------- @@ -607,7 +607,7 @@ rules_sort(QObject* a, QObject* b) AirMapRule* aa = qobject_cast(a); AirMapRule* bb = qobject_cast(b); if(!aa || !bb) return false; - return (int)aa->status() > (int)bb->status(); + return static_cast(aa->status()) > static_cast(bb->status()); } //----------------------------------------------------------------------------- @@ -627,7 +627,7 @@ AirMapFlightPlanManager::_findBriefFeature(const QString& name) void AirMapFlightPlanManager::_pollBriefing() { - qCDebug(AirMapManagerLog) << "Poll Briefing. State:" << (int)_state; + qCDebug(AirMapManagerLog) << "Poll Briefing. State:" << static_cast(_state); if(_state != State::Idle) { QTimer::singleShot(100, this, &AirMapFlightPlanManager::_pollBriefing); return; @@ -721,7 +721,7 @@ AirMapFlightPlanManager::_pollBriefing() for (const auto& authorization : briefing.evaluation.authorizations) { AirMapFlightAuthorization* pAuth = new AirMapFlightAuthorization(authorization, this); _authorizations.append(pAuth); - qCDebug(AirMapManagerLog) << "Autorization:" << pAuth->name() << " (" << pAuth->message() << ")" << (int)pAuth->status(); + qCDebug(AirMapManagerLog) << "Autorization:" << pAuth->name() << " (" << pAuth->message() << ")" << static_cast(pAuth->status()); switch (authorization.status) { case Evaluation::Authorization::Status::accepted: case Evaluation::Authorization::Status::accepted_upon_submission: @@ -840,7 +840,7 @@ AirMapFlightPlanManager::loadFlightList(QDateTime startTime, QDateTime endTime) void AirMapFlightPlanManager::_loadFlightList() { - qCDebug(AirMapManagerLog) << "Load flight list. State:" << (int)_state; + qCDebug(AirMapManagerLog) << "Load flight list. State:" << static_cast(_state); if(_state != State::Idle) { QTimer::singleShot(100, this, &AirMapFlightPlanManager::_loadFlightList); return; @@ -854,10 +854,10 @@ AirMapFlightPlanManager::_loadFlightList() if (_state != State::LoadFlightList) return; Flights::Search::Parameters params; params.authorization = login_token.toStdString(); - quint64 start = _rangeStart.toUTC().toMSecsSinceEpoch(); - quint64 end = _rangeEnd.toUTC().toMSecsSinceEpoch(); - params.start_after = airmap::from_milliseconds_since_epoch(airmap::milliseconds((long long)start)); - params.start_before = airmap::from_milliseconds_since_epoch(airmap::milliseconds((long long)end)); + quint64 start = static_cast(_rangeStart.toUTC().toMSecsSinceEpoch()); + quint64 end = static_cast(_rangeEnd.toUTC().toMSecsSinceEpoch()); + params.start_after = airmap::from_milliseconds_since_epoch(airmap::milliseconds(static_cast(start))); + params.start_before = airmap::from_milliseconds_since_epoch(airmap::milliseconds(static_cast(end))); params.limit = 250; params.pilot_id = _pilotID.toStdString(); _shared.client()->flights().search(params, [this, isAlive](const Flights::Search::Result& result) { diff --git a/src/Airmap/AirMapManager.cc b/src/Airmap/AirMapManager.cc index fab5f2363..5263f3959 100644 --- a/src/Airmap/AirMapManager.cc +++ b/src/Airmap/AirMapManager.cc @@ -42,9 +42,9 @@ AirMapManager::AirMapManager(QGCApplication* app, QGCToolbox* toolbox) { _logger = std::make_shared(); qt::register_types(); // TODO: still needed? - _logger->logging_category().setEnabled(QtDebugMsg, false); - _logger->logging_category().setEnabled(QtInfoMsg, false); - _logger->logging_category().setEnabled(QtWarningMsg, false); + _logger->logging_category().setEnabled(QtDebugMsg, true); + _logger->logging_category().setEnabled(QtInfoMsg, true); + _logger->logging_category().setEnabled(QtWarningMsg, true); _dispatchingLogger = std::make_shared(_logger); connect(&_shared, &AirMapSharedState::error, this, &AirMapManager::_error); } diff --git a/src/Airmap/AirmapSettings.qml b/src/Airmap/AirmapSettings.qml index a7a901c4b..3c27090ce 100644 --- a/src/Airmap/AirmapSettings.qml +++ b/src/Airmap/AirmapSettings.qml @@ -75,26 +75,50 @@ QGCView { } } Rectangle { - height: generalCol.height + (ScreenTools.defaultFontPixelHeight * 2) + height: generalRow.height + (ScreenTools.defaultFontPixelHeight * 2) width: _panelWidth color: qgcPal.windowShade anchors.margins: ScreenTools.defaultFontPixelWidth anchors.horizontalCenter: parent.horizontalCenter - Column { - id: generalCol - spacing: ScreenTools.defaultFontPixelWidth - anchors.centerIn: parent - FactCheckBox { - text: qsTr("Enable AirMap Services") - fact: _enableAirMapFact - visible: _enableAirMapFact.visible + Row { + id: generalRow + spacing: ScreenTools.defaultFontPixelWidth * 4 + anchors.centerIn: parent + Column { + spacing: ScreenTools.defaultFontPixelWidth + FactCheckBox { + text: qsTr("Enable AirMap Services") + fact: _enableAirMapFact + visible: _enableAirMapFact.visible + } + FactCheckBox { + text: qsTr("Enable Telemetry") + fact: _enableTelemetryFact + visible: _enableTelemetryFact.visible + enabled: _airMapEnabled + property Fact _enableTelemetryFact: QGroundControl.settingsManager.airMapSettings.enableTelemetry + } } - FactCheckBox { - text: qsTr("Enable Telemetry") - fact: _enableTelemetryFact - visible: _enableTelemetryFact.visible - enabled: _airMapEnabled - property Fact _enableTelemetryFact: QGroundControl.settingsManager.airMapSettings.enableTelemetry + QGCButton { + text: qsTr("Reset AirMap Data") + enabled: _enableAirMapFact.rawValue + onClicked: clearDialog.open() + anchors.verticalCenter: parent.verticalCenter + MessageDialog { + id: clearDialog + visible: false + icon: StandardIcon.Warning + standardButtons: StandardButton.Yes | StandardButton.No + title: qsTr("Reset AirMap Data") + text: qsTr("All saved ruleset answers will be cleared. Is this really what you want?") + onYes: { + QGroundControl.airspaceManager.ruleSets.clearAllFeatures() + clearDialog.close() + } + onNo: { + clearDialog.close() + } + } } } } diff --git a/src/Airmap/FlightFeature.qml b/src/Airmap/FlightFeature.qml index 59efe9152..31f555759 100644 --- a/src/Airmap/FlightFeature.qml +++ b/src/Airmap/FlightFeature.qml @@ -60,7 +60,7 @@ Rectangle { anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter Component.onCompleted: { - checked = feature.value && feature.value < 2 ? feature.value : false + checked = feature.value === 2 ? false : feature.value } } QGCLabel { -- 2.22.0