mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
refs #768, fixed reverse lookup on login page (model changes in SIM are reflected here)
* use reverse lookup function * complete model when web services have read the DB data (before that no reverse lookup is possible) * use new model changed signature Remark: Temp adjustement when signal allSwiftDbDataRead is sent. As soon #748 is ready needs to be changed to include airport entities
This commit is contained in:
committed by
Mathew Sutcliffe
parent
cda3ece82b
commit
74173a734e
@@ -754,8 +754,9 @@ namespace BlackCore
|
||||
CLogMessage(cats).info("Read data %1 entries: %2 state: %3") << CEntityFlags::flagToString(entity) << number << CEntityFlags::flagToString(state);
|
||||
}
|
||||
|
||||
this->m_swiftDbEntitiesReaad |= entity;
|
||||
if (this->m_swiftDbEntitiesReaad == CEntityFlags::AllDbEntitiesNoInfoObjects || this->m_swiftDbEntitiesReaad == CEntityFlags::AllDbEntities)
|
||||
//! \todo adjust value when airports are ready
|
||||
this->m_swiftDbEntitiesRead |= entity;
|
||||
if (((static_cast<int>(this->m_swiftDbEntitiesRead)) & static_cast<int>(CEntityFlags::AllDbEntitiesNoInfoObjectsNoAirports)) > 0)
|
||||
{
|
||||
emit allSwiftDbDataRead();
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ namespace BlackCore
|
||||
CWebReaderFlags::WebReader m_readers = CWebReaderFlags::WebReaderFlag::None; //!< which readers are available
|
||||
BlackCore::Db::CDatabaseReaderConfigList m_dbReaderConfig; //!< how to read DB data
|
||||
BlackMisc::Network::CEntityFlags::Entity m_entitiesPeriodicallyRead = BlackMisc::Network::CEntityFlags::NoEntity; //!< those entities which are permanently updated by timers
|
||||
BlackMisc::Network::CEntityFlags::Entity m_swiftDbEntitiesReaad = BlackMisc::Network::CEntityFlags::NoEntity; //!< entities read
|
||||
BlackMisc::Network::CEntityFlags::Entity m_swiftDbEntitiesRead = BlackMisc::Network::CEntityFlags::NoEntity; //!< entities read
|
||||
bool m_initialRead = false; //!< Initial read started
|
||||
int m_infoObjectTrials = 0; //!< Tried to read info objects
|
||||
|
||||
|
||||
@@ -132,6 +132,11 @@ namespace BlackGui
|
||||
connect(ui->le_AircraftIcaoDesignator, &QLineEdit::editingFinished, this, &CLoginComponent::ps_validateAircraftValues);
|
||||
connect(ui->tb_SimulatorIcaoReverseLookup, &QToolButton::clicked, this, &CLoginComponent::ps_reverseLookupModel);
|
||||
|
||||
if (sGui && sGui->getIContextSimulator())
|
||||
{
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::ownAircraftModelChanged, this, &CLoginComponent::ps_simulatorModelChanged);
|
||||
}
|
||||
|
||||
// server GUI element
|
||||
ui->frp_CurrentServer->setReadOnly(true);
|
||||
ui->frp_CurrentServer->showPasswordField(false);
|
||||
@@ -176,7 +181,7 @@ namespace BlackGui
|
||||
else
|
||||
{
|
||||
this->m_visible = true;
|
||||
bool isConnected = sGui->getIContextNetwork()->isConnected();
|
||||
const bool isConnected = sGui->getIContextNetwork()->isConnected();
|
||||
this->setGuiVisibility(isConnected);
|
||||
this->setOkButtonString(isConnected);
|
||||
if (isConnected) { this->startLogoffTimerCountdown(); }
|
||||
@@ -198,7 +203,7 @@ namespace BlackGui
|
||||
CLogMessage(this).validationError("No login possible from this very tab, use VATSIM or other servers");
|
||||
return;
|
||||
}
|
||||
const bool isConnected = sGui->getIContextNetwork()->isConnected();
|
||||
const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected();
|
||||
const bool vatsimLogin = (ui->tw_Network->currentWidget() == ui->pg_NetworkVatsim);
|
||||
CServer currentServer; // used for login
|
||||
CSimulatedAircraft ownAircraft; // used own aircraft
|
||||
@@ -335,15 +340,6 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CLoginComponent::setGuiValuesFromAircraft(const CSimulatedAircraft &ownAircraft)
|
||||
{
|
||||
const CAircraftIcaoCode aircraftIcao = ownAircraft.getAircraftIcaoCode();
|
||||
ui->le_Callsign->setText(ownAircraft.getCallsignAsString());
|
||||
ui->le_AircraftIcaoDesignator->setText(aircraftIcao.getDesignator());
|
||||
ui->le_AirlineIcaoDesignator->setText(ownAircraft.getAirlineIcaoCodeDesignator());
|
||||
ui->le_AircraftCombinedType->setText(aircraftIcao.getCombinedType());
|
||||
}
|
||||
|
||||
void CLoginComponent::loadRememberedVatsimData()
|
||||
{
|
||||
const CServer lastServer = this->m_currentVatsimServer.get();
|
||||
@@ -465,6 +461,7 @@ namespace BlackGui
|
||||
|
||||
void CLoginComponent::setGuiIcaoValues(const CAircraftModel &model, bool onlyIfEmpty)
|
||||
{
|
||||
ui->le_SimulatorModel->setText(model.getModelStringAndDbKey());
|
||||
if (!onlyIfEmpty || ui->le_AircraftIcaoDesignator->text().trimmed().isEmpty())
|
||||
{
|
||||
ui->le_AircraftIcaoDesignator->setText(model.getAircraftIcaoCode().getDesignator());
|
||||
@@ -544,11 +541,11 @@ namespace BlackGui
|
||||
void CLoginComponent::ps_reverseLookupModel()
|
||||
{
|
||||
if (!sGui->getIContextSimulator()->isSimulatorAvailable()) { return; }
|
||||
CAircraftModel model(sGui->getIContextOwnAircraft()->getOwnAircraft().getModel());
|
||||
QString modelStr(model.hasModelString() ? model.getModelString() : "<unknown>");
|
||||
const CAircraftModel model(sGui->getIContextOwnAircraft()->getOwnAircraft().getModel());
|
||||
const QString modelStr(model.hasModelString() ? model.getModelString() : "<unknown>");
|
||||
if (model.getAircraftIcaoCode().hasDesignator())
|
||||
{
|
||||
CLogMessage(this).validationInfo("Reverse lookup for '%1'") << modelStr;
|
||||
CLogMessage(this).validationInfo("Reverse lookup for '%1' successful: %2") << modelStr << model.toQString();
|
||||
|
||||
// update GUI
|
||||
this->setGuiIcaoValues(model, false);
|
||||
@@ -559,6 +556,14 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CLoginComponent::ps_simulatorModelChanged(const CAircraftModel &model)
|
||||
{
|
||||
const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected();
|
||||
if (isConnected) { return; }
|
||||
this->setGuiIcaoValues(model, false);
|
||||
this->ps_reverseLookupModel();
|
||||
}
|
||||
|
||||
void CLoginComponent::initCompleters(CEntityFlags::Entity entity)
|
||||
{
|
||||
// completers where possible
|
||||
|
||||
@@ -100,6 +100,9 @@ namespace BlackGui
|
||||
//! Reverse lookup model
|
||||
void ps_reverseLookupModel();
|
||||
|
||||
//! Simulator model has been changed
|
||||
void ps_simulatorModelChanged(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
private:
|
||||
//! GUI aircraft values, formatted
|
||||
struct CGuiAircraftValues
|
||||
@@ -120,9 +123,6 @@ namespace BlackGui
|
||||
QString vatsimHomeAirport;
|
||||
};
|
||||
|
||||
//! GUI values from aircraft
|
||||
void setGuiValuesFromAircraft(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft);
|
||||
|
||||
//! Load from settings
|
||||
void loadRememberedVatsimData();
|
||||
|
||||
|
||||
@@ -448,6 +448,9 @@
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>unique model identifier</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
|
||||
@@ -49,8 +49,9 @@ namespace BlackMisc
|
||||
AllIcaoEntities = AircraftIcaoEntity | AirlineIcaoEntity, //!< all ICAO codes
|
||||
AllIcaoAndCountries = AircraftIcaoEntity | AirlineIcaoEntity | CountryEntity, //!< all ICAO codes and countries
|
||||
DistributorLiveryModel = DistributorEntity | LiveryEntity | ModelEntity, //!< Combinded
|
||||
AllDbEntities = AllIcaoAndCountries | DistributorLiveryModel | InfoObjectEntity | AirportEntity, //!< All DB stuff
|
||||
AllDbEntitiesNoInfoObjects = AllIcaoAndCountries | DistributorLiveryModel | AirportEntity //!< All DB entities, no info objects
|
||||
AllDbEntities = AllIcaoAndCountries | DistributorLiveryModel | InfoObjectEntity | AirportEntity, //!< All DB stuff
|
||||
AllDbEntitiesNoInfoObjects = AllIcaoAndCountries | DistributorLiveryModel | AirportEntity, //!< All DB entities, no info objects
|
||||
AllDbEntitiesNoInfoObjectsNoAirports = AllIcaoAndCountries | DistributorLiveryModel //!< All DB entities, no info objects and airports
|
||||
};
|
||||
Q_DECLARE_FLAGS(Entity, EntityFlag)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user