Ref T786, UI weather component aligned to identifier

This commit is contained in:
Klaus Basan
2020-04-19 02:45:21 +02:00
committed by Mat Sutcliffe
parent 579a3b28e1
commit 42cd7b9ad8
2 changed files with 13 additions and 8 deletions

View File

@@ -192,7 +192,7 @@ namespace BlackGui
const bool useOwnAcftPosition = ui->cb_UseOwnAcftPosition->isChecked();
CCoordinateGeodetic position;
Q_ASSERT(ui->cb_weatherScenario->currentData().canConvert<CWeatherScenario>());
CWeatherScenario scenario = ui->cb_weatherScenario->currentData().value<CWeatherScenario>();
const CWeatherScenario scenario = ui->cb_weatherScenario->currentData().value<CWeatherScenario>();
if (useOwnAcftPosition)
{
@@ -225,9 +225,16 @@ namespace BlackGui
}
}
void CWeatherComponent::weatherGridReceived(const CWeatherGrid &weatherGrid, const CIdentifier &identifier)
void CWeatherComponent::onWeatherGridReceived(const CWeatherGrid &weatherGrid, const CIdentifier &identifier)
{
if (!isMyIdentifier(identifier)) { return; }
if (!isMyIdentifier(identifier))
{
// not from myself
const CWeatherScenario scenario = ui->cb_weatherScenario->currentData().value<CWeatherScenario>();
if (!CWeatherScenario::isRealWeatherScenario(scenario)) { return; }
// we have received weather grid data and assume those are real weather updates
}
ui->lbl_Status->setText({});
setWeatherGrid(weatherGrid);
}
@@ -243,7 +250,7 @@ namespace BlackGui
// Context connections
Q_ASSERT(sGui->getIContextSimulator());
connect(sGui->getIContextSimulator(), &IContextSimulator::weatherGridReceived, this, &CWeatherComponent::weatherGridReceived, Qt::QueuedConnection);
connect(sGui->getIContextSimulator(), &IContextSimulator::weatherGridReceived, this, &CWeatherComponent::onWeatherGridReceived, Qt::QueuedConnection);
}
void CWeatherComponent::setWeatherGrid(const CWeatherGrid &weatherGrid)
@@ -262,9 +269,7 @@ namespace BlackGui
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }
ui->lbl_Status->setText(QStringLiteral("Loading around %1 %2").arg(position.latitude().toWgs84(), position.longitude().toWgs84()));
const CWeatherGrid weatherGrid { { {}, position } };
const auto ident = identifier();
sGui->getIContextSimulator()->requestWeatherGrid(weatherGrid, ident);
sGui->getIContextSimulator()->requestWeatherGrid(position, this->identifier());
}
void CWeatherComponent::onScenarioChanged()

View File

@@ -67,7 +67,7 @@ namespace BlackGui
void updateWeatherInfoLine();
void updateWeatherInformation();
void weatherGridReceived(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier);
void onWeatherGridReceived(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier);
void setupConnections();