mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
Fixed updates of view when simulated aircraft values are updated.
* renamed view to simulated aircraft view * utility function for bool -> on/off
This commit is contained in:
@@ -521,7 +521,8 @@ namespace BlackCore
|
||||
bool c = this->m_airspace->updateAircraftEnabled(callsign, enabledForRedering, originator);
|
||||
if (c)
|
||||
{
|
||||
emit this->changedAircraftEnabled(this->remoteAircraft().findFirstByCallsign(callsign), originator);
|
||||
CSimulatedAircraft aircraft(this->remoteAircraft().findFirstByCallsign(callsign));
|
||||
emit this->changedAircraftEnabled(aircraft, originator);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -532,7 +533,8 @@ namespace BlackCore
|
||||
bool c = this->m_airspace->updateAircraftModel(callsign, model, originator);
|
||||
if (c)
|
||||
{
|
||||
emit this->changedRenderedAircraftModel(this->remoteAircraft().findFirstByCallsign(callsign), originator);
|
||||
CSimulatedAircraft aircraft(this->remoteAircraft().findFirstByCallsign(callsign));
|
||||
emit this->changedRenderedAircraftModel(aircraft, originator);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -543,7 +545,9 @@ namespace BlackCore
|
||||
bool c = this->m_airspace->updateFastPositionUpdates(callsign, enableFastPositonUpdates, originator);
|
||||
if (c)
|
||||
{
|
||||
emit this->changedFastPositionUpdates(this->remoteAircraft().findFirstByCallsign(callsign), originator);
|
||||
CSimulatedAircraft aircraft(this->remoteAircraft().findFirstByCallsign(callsign));
|
||||
CLogMessage(this).info("Callsign %1 sets fast positions ") << aircraft.getCallsign() << BlackMisc::boolToOnOff(aircraft.fastPositionUpdates());
|
||||
emit this->changedFastPositionUpdates(aircraft, originator);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -39,26 +39,26 @@ namespace BlackGui
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->tvp_AircraftModels->setAircraftModelMode(CAircraftModelListModel::ModelOnly);
|
||||
this->ui->tvp_CurrentMappings->setAircraftMode(CSimulatedAircraftListModel::ModelMode);
|
||||
this->ui->tvp_CurrentMappings->setResizeMode(CAircraftModelView::ResizingOnce);
|
||||
this->ui->tvp_SimulatedAircraft->setAircraftMode(CSimulatedAircraftListModel::ModelMode);
|
||||
this->ui->tvp_SimulatedAircraft->setResizeMode(CAircraftModelView::ResizingOnce);
|
||||
this->ui->tvp_AircraftModels->setResizeMode(CAircraftModelView::ResizingOff);
|
||||
|
||||
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::requestUpdate, this, &CMappingComponent::ps_onModelsUpdateRequested);
|
||||
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::rowCountChanged, this, &CMappingComponent::ps_onRowCountChanged);
|
||||
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::clicked, this, &CMappingComponent::ps_onModelSelectedInView);
|
||||
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView::rowCountChanged, this, &CMappingComponent::ps_onRowCountChanged);
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView::clicked, this, &CMappingComponent::ps_onAircraftSelectedInView);
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView::requestUpdate, this, &CMappingComponent::ps_onMappingsUpdateRequested);
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView::requestTextMessageWidget, this, &CMappingComponent::requestTextMessageWidget);
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView::requestEnableAircraft, this, &CMappingComponent::ps_onMenuEnableAircraft);
|
||||
connect(this->ui->tvp_CurrentMappings, &CSimulatedAircraftView::requestFastPositionUpdates, this, &CMappingComponent::ps_onMenuChangeFastPositionUpdates);
|
||||
connect(this->ui->tvp_SimulatedAircraft, &CSimulatedAircraftView::rowCountChanged, this, &CMappingComponent::ps_onRowCountChanged);
|
||||
connect(this->ui->tvp_SimulatedAircraft, &CSimulatedAircraftView::clicked, this, &CMappingComponent::ps_onAircraftSelectedInView);
|
||||
connect(this->ui->tvp_SimulatedAircraft, &CSimulatedAircraftView::requestUpdate, this, &CMappingComponent::ps_onSimulatedAircraftUpdateRequested);
|
||||
connect(this->ui->tvp_SimulatedAircraft, &CSimulatedAircraftView::requestTextMessageWidget, this, &CMappingComponent::requestTextMessageWidget);
|
||||
connect(this->ui->tvp_SimulatedAircraft, &CSimulatedAircraftView::requestEnableAircraft, this, &CMappingComponent::ps_onMenuEnableAircraft);
|
||||
connect(this->ui->tvp_SimulatedAircraft, &CSimulatedAircraftView::requestFastPositionUpdates, this, &CMappingComponent::ps_onMenuChangeFastPositionUpdates);
|
||||
|
||||
connect(this->ui->pb_SaveAircraft, &QPushButton::clicked, this, &CMappingComponent::ps_onSaveAircraft);
|
||||
|
||||
this->m_modelCompleter = new QCompleter(this);
|
||||
this->m_currentMappingsViewDelegate = new CCheckBoxDelegate(":/diagona/icons/diagona/icons/tick.png", ":/diagona/icons/diagona/icons/cross.png", this);
|
||||
this->ui->tvp_CurrentMappings->setItemDelegateForColumn(0, this->m_currentMappingsViewDelegate);
|
||||
this->ui->tvp_SimulatedAircraft->setItemDelegateForColumn(0, this->m_currentMappingsViewDelegate);
|
||||
|
||||
//! Aircraft previews
|
||||
connect(this->ui->cb_AircraftIconDisplayed, &QCheckBox::stateChanged, this, &CMappingComponent::ps_onModelPreviewChanged);
|
||||
@@ -70,8 +70,8 @@ namespace BlackGui
|
||||
|
||||
int CMappingComponent::countCurrentMappings() const
|
||||
{
|
||||
Q_ASSERT(this->ui->tvp_CurrentMappings);
|
||||
return this->ui->tvp_CurrentMappings->rowCount();
|
||||
Q_ASSERT(this->ui->tvp_SimulatedAircraft);
|
||||
return this->ui->tvp_SimulatedAircraft->rowCount();
|
||||
}
|
||||
|
||||
int CMappingComponent::countAircraftModels() const
|
||||
@@ -94,10 +94,11 @@ namespace BlackGui
|
||||
connect(getIContextSimulator(), &IContextSimulator::modelMatchingCompleted, this, &CMappingComponent::ps_onModelMatchingCompleted);
|
||||
connect(getIContextNetwork(), &IContextNetwork::changedRenderedAircraftModel, this, &CMappingComponent::ps_onRenderedAircraftModelChanged);
|
||||
connect(getIContextNetwork(), &IContextNetwork::changedAircraftEnabled, this, &CMappingComponent::ps_onChangedAircraftEnabled);
|
||||
connect(getIContextNetwork(), &IContextNetwork::changedFastPositionUpdates, this, &CMappingComponent::ps_onFastPositionUpdatesEnabled);
|
||||
connect(getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMappingComponent::ps_onConnectionStatusChanged);
|
||||
|
||||
// requires simulator context
|
||||
connect(this->ui->tvp_CurrentMappings, &CAircraftModelView::objectChanged, this, &CMappingComponent::ps_onChangedSimulatedAircraftInView);
|
||||
connect(this->ui->tvp_SimulatedAircraft, &CAircraftModelView::objectChanged, this, &CMappingComponent::ps_onChangedSimulatedAircraftInView);
|
||||
|
||||
// with external core models might be already available
|
||||
this->ps_onAircraftModelsLoaded();
|
||||
@@ -111,7 +112,7 @@ namespace BlackGui
|
||||
void CMappingComponent::ps_onModelMatchingCompleted(const BlackMisc::Simulation::CSimulatedAircraft &aircraft)
|
||||
{
|
||||
Q_UNUSED(aircraft);
|
||||
this->ps_onMappingsUpdateRequested();
|
||||
this->ps_onSimulatedAircraftUpdateRequested();
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_onRowCountChanged(int count, bool withFilter)
|
||||
@@ -149,7 +150,7 @@ namespace BlackGui
|
||||
|
||||
void CMappingComponent::ps_onAircraftSelectedInView(const QModelIndex &index)
|
||||
{
|
||||
const CSimulatedAircraft simAircraft = this->ui->tvp_CurrentMappings->at(index);
|
||||
const CSimulatedAircraft simAircraft = this->ui->tvp_SimulatedAircraft->at(index);
|
||||
this->ui->cb_AircraftEnabled->setChecked(simAircraft.isEnabled());
|
||||
this->ui->le_Callsign->setText(simAircraft.getCallsign().asString());
|
||||
this->ui->le_AircraftModel->setText(simAircraft.getModel().getModelString());
|
||||
@@ -198,7 +199,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
const CCallsign callsign(cs);
|
||||
bool hasCallsign = this->ui->tvp_CurrentMappings->getContainer().containsCallsign(callsign);
|
||||
bool hasCallsign = this->ui->tvp_SimulatedAircraft->getContainer().containsCallsign(callsign);
|
||||
if (!hasCallsign)
|
||||
{
|
||||
CLogMessage(this).validationError("Unmapped callsign %1 for mapping") << callsign.asString();
|
||||
@@ -270,11 +271,9 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_onMappingsUpdateRequested()
|
||||
void CMappingComponent::ps_onSimulatedAircraftUpdateRequested()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
const CSimulatedAircraftList aircraft = getIContextNetwork()->getAircraftInRange();
|
||||
this->ui->tvp_CurrentMappings->updateContainer(aircraft);
|
||||
this->updateSimulatedAircraftView();
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_onModelsUpdateRequested()
|
||||
@@ -294,22 +293,22 @@ namespace BlackGui
|
||||
|
||||
void CMappingComponent::ps_onRenderedAircraftModelChanged(const CSimulatedAircraft &aircraft, const QString &originator)
|
||||
{
|
||||
if (originator == mappingtOriginator()) { return; }
|
||||
this->ps_onMappingsUpdateRequested();
|
||||
this->updateSimulatedAircraftView();
|
||||
Q_UNUSED(originator);
|
||||
Q_UNUSED(aircraft);
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_onChangedAircraftEnabled(const CSimulatedAircraft &aircraft, const QString &originator)
|
||||
{
|
||||
if (originator == mappingtOriginator()) { return; }
|
||||
this->ps_onMappingsUpdateRequested();
|
||||
this->updateSimulatedAircraftView();
|
||||
Q_UNUSED(originator);
|
||||
Q_UNUSED(aircraft);
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_onFastPositionUpdatesEnabled(const CSimulatedAircraft &aircraft, const QString &originator)
|
||||
{
|
||||
if (originator == mappingtOriginator()) { return; }
|
||||
this->ps_onMappingsUpdateRequested();
|
||||
this->updateSimulatedAircraftView();
|
||||
Q_UNUSED(originator);
|
||||
Q_UNUSED(aircraft);
|
||||
}
|
||||
|
||||
@@ -320,7 +319,7 @@ namespace BlackGui
|
||||
Q_UNUSED(fromStatus);
|
||||
if (INetwork::isDisconnectedStatus(toStatus))
|
||||
{
|
||||
this->ui->tvp_CurrentMappings->clear();
|
||||
this->ui->tvp_SimulatedAircraft->clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,5 +347,12 @@ namespace BlackGui
|
||||
return o;
|
||||
}
|
||||
|
||||
void CMappingComponent::updateSimulatedAircraftView()
|
||||
{
|
||||
Q_ASSERT_X(getIContextNetwork(), "updateSimulatedAircraftView", "missing network context");
|
||||
const CSimulatedAircraftList aircraft = getIContextNetwork()->getAircraftInRange();
|
||||
this->ui->tvp_SimulatedAircraft->updateContainer(aircraft);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace BlackGui
|
||||
//! Changed count
|
||||
void ps_onRowCountChanged(int count, bool withFilter);
|
||||
|
||||
//! Simulated aircraft did change in model
|
||||
//! Simulated aircraft did change in view
|
||||
//! \sa CViewBaseNonTemplate::objectChanged
|
||||
void ps_onChangedSimulatedAircraftInView(const BlackMisc::CVariant &simulatedAircraft, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace BlackGui
|
||||
void ps_onModelPreviewChanged(int state);
|
||||
|
||||
//! Request update for mappings from backend
|
||||
void ps_onMappingsUpdateRequested();
|
||||
void ps_onSimulatedAircraftUpdateRequested();
|
||||
|
||||
//! Request update for models from backend
|
||||
void ps_onModelsUpdateRequested();
|
||||
@@ -111,6 +111,7 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
static const QString &mappingtOriginator();
|
||||
void updateSimulatedAircraftView();
|
||||
QScopedPointer<Ui::CMappingComponent> ui;
|
||||
QCompleter *m_modelCompleter = nullptr;
|
||||
BlackGui::Views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr;
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CSimulatedAircraftView" name="tvp_CurrentMappings">
|
||||
<widget class="BlackGui::Views::CSimulatedAircraftView" name="tvp_SimulatedAircraft">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace BlackGui
|
||||
CSimulatedAircraft aircraft(selectedObject());
|
||||
if (aircraft.getCallsign().isEmpty()) { return; }
|
||||
aircraft.setEnabled(!aircraft.isEnabled());
|
||||
emit requestFastPositionUpdates(aircraft);
|
||||
emit requestEnableAircraft(aircraft);
|
||||
}
|
||||
|
||||
void CSimulatedAircraftView::ps_fastPositionUpdates()
|
||||
|
||||
@@ -396,12 +396,12 @@ QJsonObject BlackMisc::getIncrementalObject(const QJsonObject &previousObject, c
|
||||
QJsonObject BlackMisc::applyIncrementalObject(const QJsonObject &previousObject, const QJsonObject &incrementalObject)
|
||||
{
|
||||
QJsonObject currentObject = previousObject;
|
||||
for(const auto &key : incrementalObject.keys())
|
||||
for (const auto &key : incrementalObject.keys())
|
||||
{
|
||||
// If it is not an object, just insert the value
|
||||
if (!incrementalObject.value(key).isObject())
|
||||
{
|
||||
currentObject.insert(key,incrementalObject.value(key));
|
||||
currentObject.insert(key, incrementalObject.value(key));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -411,3 +411,17 @@ QJsonObject BlackMisc::applyIncrementalObject(const QJsonObject &previousObject,
|
||||
}
|
||||
return currentObject;
|
||||
}
|
||||
|
||||
|
||||
QString BlackMisc::boolToOnOff(bool v, bool i18n)
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return v ? "on" : "off";
|
||||
}
|
||||
|
||||
|
||||
QString BlackMisc::boolToYesNo(bool v, bool i18n)
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return v ? "yes" : "no";
|
||||
}
|
||||
|
||||
@@ -171,6 +171,12 @@ namespace BlackMisc
|
||||
//! A map converted to string
|
||||
template<class K, class V> QString qmapToString(const QMap<K, V> &map);
|
||||
|
||||
//! Bool to on/off
|
||||
QString boolToOnOff(bool v, bool i18n = false);
|
||||
|
||||
//! Bool to yes / no
|
||||
QString boolToYesNo(bool v, bool i18n = false);
|
||||
|
||||
//! Get local host name
|
||||
const QString &localHostName();
|
||||
|
||||
|
||||
@@ -154,10 +154,10 @@ namespace BlackMisc
|
||||
{
|
||||
QString s = CAircraft::convertToQString(i18n);
|
||||
s += " enabled: ";
|
||||
s += this->isEnabled() ? "yes" : "no";
|
||||
s += BlackMisc::boolToYesNo(this->isEnabled());
|
||||
s += " ";
|
||||
s += " rendered: ";
|
||||
s += this->isRendered() ? "yes" : "no";
|
||||
s += BlackMisc::boolToYesNo(this->isRendered());
|
||||
s += " ";
|
||||
s += this->m_model.toQString(i18n);
|
||||
s += " ";
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace BlackMiscTest
|
||||
while (line != "x" && runtime)
|
||||
{
|
||||
qtout << "-------------" << endl;
|
||||
qtout << "Connected with network: " << (runtime->getIContextNetwork()->isConnected() ? "yes" : "no") << endl;
|
||||
qtout << "Connected with network: " << BlackMisc::boolToYesNo(runtime->getIContextNetwork()->isConnected()) << endl;
|
||||
qtout << "Thread id: " << QThread::currentThreadId() << endl;
|
||||
qtout << "-------------" << endl;
|
||||
qtout << "x .. to exit" << endl;
|
||||
|
||||
Reference in New Issue
Block a user