Handle initial null position from CCoordinateDialog

Summary:
CCoordinateDialog is setup with an initial null position. The user has to manually set one in case own aircraft position is de-selected to proceed with weather fetching. Previously the null position was accepted and passed on to the weather request with undefined results.

Reviewers: #swift_pilot_client

Maniphest Tasks: T406

Differential Revision: https://dev.swift-project.org/D81
This commit is contained in:
Roland Rossgotterer
2018-12-26 02:31:32 +01:00
committed by Mat Sutcliffe
parent 96b77c64d8
commit 3db811f11d
6 changed files with 93 additions and 26 deletions

View File

@@ -27,7 +27,7 @@ namespace BlackGui
ui->editor_Coordinate->showSetButton(false); ui->editor_Coordinate->showSetButton(false);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
this->noDefaultButtons(); this->noDefaultButtons();
connect(ui->editor_Coordinate, &CCoordinateForm::changedCoordinate, this, &CCoordinateDialog::changedCoordinate); connect(this, &QDialog::accepted, this, &CCoordinateDialog::changedCoordinate);
} }
CCoordinateDialog::~CCoordinateDialog() CCoordinateDialog::~CCoordinateDialog()

View File

@@ -6,26 +6,41 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>500</width> <width>599</width>
<height>150</height> <height>158</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>500</width>
<height>150</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Coordinates</string> <string>Coordinates</string>
</property> </property>
<layout class="QVBoxLayout" name="vl_CoordinateDialog"> <layout class="QVBoxLayout" name="vl_CoordinateDialog">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item alignment="Qt::AlignTop"> <item alignment="Qt::AlignTop">
<widget class="BlackGui::Editors::CCoordinateForm" name="editor_Coordinate"> <widget class="BlackGui::Editors::CCoordinateForm" name="editor_Coordinate">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>75</height> <height>0</height>
</size> </size>
</property> </property>
<property name="frameShape"> <property name="frameShape">

View File

@@ -46,7 +46,7 @@ namespace BlackGui
ui->setupUi(this); ui->setupUi(this);
m_coordinateDialog->showElevation(false); m_coordinateDialog->showElevation(false);
m_coordinateDialog->setReadOnly(ui->cb_UseOwnAcftPosition->isChecked()); m_coordinateDialog->setReadOnly(ui->cb_UseOwnAcftPosition->isChecked());
connect(ui->pb_Coordinate, &QPushButton::clicked, this, &CWeatherComponent::showCoordinateDialog); connect(ui->pb_SetPosition, &QPushButton::clicked, this, &CWeatherComponent::showCoordinateDialog);
m_weatherScenarios = CWeatherGrid::getAllScenarios(); m_weatherScenarios = CWeatherGrid::getAllScenarios();
for (const auto &scenario : as_const(m_weatherScenarios)) for (const auto &scenario : as_const(m_weatherScenarios))
@@ -103,10 +103,14 @@ namespace BlackGui
if (useOwnAircraftPosition) if (useOwnAircraftPosition)
{ {
m_weatherUpdateTimer.start(); m_weatherUpdateTimer.start();
ui->pb_SetPosition->setText("Show Position");
} }
else else
{ {
m_weatherUpdateTimer.stop(); m_weatherUpdateTimer.stop();
const CCoordinateGeodetic c;
m_coordinateDialog->setCoordinate(c);
ui->pb_SetPosition->setText("Select Position");
} }
updateWeatherInformation(); updateWeatherInformation();
} }
@@ -157,6 +161,7 @@ namespace BlackGui
void CWeatherComponent::updateWeatherInformation() void CWeatherComponent::updateWeatherInformation()
{ {
setWeatherGrid({}); setWeatherGrid({});
ui->lbl_Status->setText({});
const bool useOwnAcftPosition = ui->cb_UseOwnAcftPosition->isChecked(); const bool useOwnAcftPosition = ui->cb_UseOwnAcftPosition->isChecked();
BlackMisc::Geo::CCoordinateGeodetic position; BlackMisc::Geo::CCoordinateGeodetic position;
Q_ASSERT(ui->cb_weatherScenario->currentData().canConvert<CWeatherScenario>()); Q_ASSERT(ui->cb_weatherScenario->currentData().canConvert<CWeatherScenario>());
@@ -166,10 +171,16 @@ namespace BlackGui
{ {
Q_ASSERT(sGui->getIContextOwnAircraft()); Q_ASSERT(sGui->getIContextOwnAircraft());
position = sGui->getIContextOwnAircraft()->getOwnAircraft().getPosition(); position = sGui->getIContextOwnAircraft()->getOwnAircraft().getPosition();
m_coordinateDialog->setCoordinate(position);
} }
else else
{ {
position = m_coordinateDialog->getCoordinate(); position = m_coordinateDialog->getCoordinate();
if (position.isNull())
{
ui->lbl_Status->setText("No position selected.");
return;
}
} }
if (CWeatherScenario::isRealWeatherScenario(scenario)) if (CWeatherScenario::isRealWeatherScenario(scenario))
@@ -218,7 +229,7 @@ namespace BlackGui
void CWeatherComponent::requestWeatherGrid(const CCoordinateGeodetic &position) void CWeatherComponent::requestWeatherGrid(const CCoordinateGeodetic &position)
{ {
ui->lbl_Status->setText("Loading..."); ui->lbl_Status->setText(QStringLiteral("Loading around %1 %2").arg(position.latitude().toWgs84(), position.longitude().toWgs84()));
CWeatherGrid weatherGrid { { {}, position } }; CWeatherGrid weatherGrid { { {}, position } };
auto ident = identifier(); auto ident = identifier();
sGui->getIContextSimulator()->requestWeatherGrid(weatherGrid, ident); sGui->getIContextSimulator()->requestWeatherGrid(weatherGrid, ident);

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>280</width> <width>307</width>
<height>396</height> <height>459</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -17,6 +17,9 @@
<number>0</number> <number>0</number>
</property> </property>
<layout class="QVBoxLayout" name="vl_WeatherComponent"> <layout class="QVBoxLayout" name="vl_WeatherComponent">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin"> <property name="leftMargin">
<number>3</number> <number>3</number>
</property> </property>
@@ -68,9 +71,40 @@
</property> </property>
<item> <item>
<widget class="QFrame" name="fr_Misc"> <widget class="QFrame" name="fr_Misc">
<layout class="QHBoxLayout" name="hl_Misc"> <layout class="QGridLayout" name="gridLayout">
<item> <property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item row="0" column="2" alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_SetPosition">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show Position</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="cb_UseOwnAcftPosition"> <widget class="QCheckBox" name="cb_UseOwnAcftPosition">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Use own aircraft position</string> <string>Use own aircraft position</string>
</property> </property>
@@ -79,13 +113,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_Coordinate">
<property name="text">
<string>coordinate</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@@ -98,6 +125,9 @@
</item> </item>
<item> <item>
<widget class="QTabWidget" name="tw_weatherGrid"> <widget class="QTabWidget" name="tw_weatherGrid">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tb_temperatureLayers"> <widget class="QWidget" name="tb_temperatureLayers">
<attribute name="title"> <attribute name="title">
<string>Temperature</string> <string>Temperature</string>

View File

@@ -140,6 +140,11 @@ namespace BlackGui
ui->le_LngSecFrag->setReadOnly(readonly); ui->le_LngSecFrag->setReadOnly(readonly);
ui->le_Longitude->setReadOnly(readonly); ui->le_Longitude->setReadOnly(readonly);
ui->rb_E->setEnabled(!readonly);
ui->rb_N->setEnabled(!readonly);
ui->rb_S->setEnabled(!readonly);
ui->rb_W->setEnabled(!readonly);
ui->le_Location->setReadOnly(readonly); ui->le_Location->setReadOnly(readonly);
ui->le_Location->setVisible(!readonly); // does not make sense to show it in ro, no reverse lookup ui->le_Location->setVisible(!readonly); // does not make sense to show it in ro, no reverse lookup
ui->lbl_Location->setVisible(!readonly); ui->lbl_Location->setVisible(!readonly);

View File

@@ -6,10 +6,16 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>740</width> <width>976</width>
<height>144</height> <height>162</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Frame</string> <string>Frame</string>
</property> </property>
@@ -325,7 +331,7 @@
<resources/> <resources/>
<connections/> <connections/>
<buttongroups> <buttongroups>
<buttongroup name="bg_NS"/>
<buttongroup name="bg_EW"/> <buttongroup name="bg_EW"/>
<buttongroup name="bg_NS"/>
</buttongroups> </buttongroups>
</ui> </ui>