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);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
this->noDefaultButtons();
connect(ui->editor_Coordinate, &CCoordinateForm::changedCoordinate, this, &CCoordinateDialog::changedCoordinate);
connect(this, &QDialog::accepted, this, &CCoordinateDialog::changedCoordinate);
}
CCoordinateDialog::~CCoordinateDialog()

View File

@@ -6,26 +6,41 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>150</height>
<width>599</width>
<height>158</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>150</height>
</size>
</property>
<property name="windowTitle">
<string>Coordinates</string>
</property>
<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">
<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">
<size>
<width>0</width>
<height>75</height>
<height>0</height>
</size>
</property>
<property name="frameShape">

View File

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

View File

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

View File

@@ -140,6 +140,11 @@ namespace BlackGui
ui->le_LngSecFrag->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->setVisible(!readonly); // does not make sense to show it in ro, no reverse lookup
ui->lbl_Location->setVisible(!readonly);

View File

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