mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
refs #780, allow to reset changed rendered aircraft
This commit is contained in:
@@ -84,8 +84,9 @@ namespace BlackGui
|
|||||||
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::requestHighlightInSimulator, this, &CMappingComponent::ps_onMenuHighlightInSimulator);
|
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::requestHighlightInSimulator, this, &CMappingComponent::ps_onMenuHighlightInSimulator);
|
||||||
|
|
||||||
connect(ui->pb_SaveAircraft, &QPushButton::clicked, this, &CMappingComponent::ps_onSaveAircraft);
|
connect(ui->pb_SaveAircraft, &QPushButton::clicked, this, &CMappingComponent::ps_onSaveAircraft);
|
||||||
|
connect(ui->pb_ResetAircraft, &QPushButton::clicked, this, &CMappingComponent::ps_onResetAircraft);
|
||||||
|
connect(ui->pb_LoadModels, &QPushButton::clicked, this, &CMappingComponent::ps_onModelsUpdateRequested);
|
||||||
|
|
||||||
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->m_currentMappingsViewDelegate = new CCheckBoxDelegate(":/diagona/icons/diagona/icons/tick.png", ":/diagona/icons/diagona/icons/cross.png", this);
|
||||||
ui->tvp_RenderedAircraft->setItemDelegateForColumn(0, this->m_currentMappingsViewDelegate);
|
ui->tvp_RenderedAircraft->setItemDelegateForColumn(0, this->m_currentMappingsViewDelegate);
|
||||||
|
|
||||||
@@ -93,6 +94,10 @@ namespace BlackGui
|
|||||||
connect(ui->cb_AircraftIconDisplayed, &QCheckBox::stateChanged, this, &CMappingComponent::ps_onModelPreviewChanged);
|
connect(ui->cb_AircraftIconDisplayed, &QCheckBox::stateChanged, this, &CMappingComponent::ps_onModelPreviewChanged);
|
||||||
ui->lbl_AircraftIconDisplayed->setText("Icon displayed here");
|
ui->lbl_AircraftIconDisplayed->setText("Icon displayed here");
|
||||||
|
|
||||||
|
// model string completer
|
||||||
|
ui->completer_ModelStrings->setSourceVisible(CAircraftModelStringCompleter::OwnModels, false);
|
||||||
|
ui->completer_ModelStrings->selectSource(CAircraftModelStringCompleter::ModelSet);
|
||||||
|
|
||||||
// Updates
|
// Updates
|
||||||
ui->tvp_AircraftModels->setDisplayAutomatically(false);
|
ui->tvp_AircraftModels->setDisplayAutomatically(false);
|
||||||
this->m_updateTimer->setUpdateInterval(10 * 1000);
|
this->m_updateTimer->setUpdateInterval(10 * 1000);
|
||||||
@@ -101,6 +106,7 @@ namespace BlackGui
|
|||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::modelMatchingCompleted, this, &CMappingComponent::ps_markRenderedAircraftForUpdate);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::modelMatchingCompleted, this, &CMappingComponent::ps_markRenderedAircraftForUpdate);
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::aircraftRenderingChanged, this, &CMappingComponent::ps_markRenderedAircraftForUpdate);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::aircraftRenderingChanged, this, &CMappingComponent::ps_markRenderedAircraftForUpdate);
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::airspaceSnapshotHandled, this, &CMappingComponent::ps_markRenderedViewForUpdate);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::airspaceSnapshotHandled, this, &CMappingComponent::ps_markRenderedViewForUpdate);
|
||||||
|
connect(sGui->getIContextSimulator(), &IContextSimulator::addingRemoteModelFailed, this, &CMappingComponent::ps_addingRemoteAircraftFailed);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftModel, this, &CMappingComponent::ps_onRemoteAircraftModelChanged);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftModel, this, &CMappingComponent::ps_onRemoteAircraftModelChanged);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftEnabled, this, &CMappingComponent::ps_markRenderedAircraftForUpdate);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftEnabled, this, &CMappingComponent::ps_markRenderedAircraftForUpdate);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedFastPositionUpdates, this, &CMappingComponent::ps_markRenderedAircraftForUpdate);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::changedFastPositionUpdates, this, &CMappingComponent::ps_markRenderedAircraftForUpdate);
|
||||||
@@ -151,9 +157,9 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
Q_UNUSED(count);
|
Q_UNUSED(count);
|
||||||
Q_UNUSED(withFilter);
|
Q_UNUSED(withFilter);
|
||||||
int am = ui->tw_ListViews->indexOf(ui->tb_AircraftModels);
|
const int am = ui->tw_ListViews->indexOf(ui->tb_AircraftModels);
|
||||||
int cm = ui->tw_ListViews->indexOf(ui->tb_CurrentMappings);
|
const int cm = ui->tw_ListViews->indexOf(ui->tb_CurrentMappings);
|
||||||
QString amf = ui->tvp_AircraftModels->derivedModel()->hasFilter() ? "F" : "";
|
const QString amf = ui->tvp_AircraftModels->derivedModel()->hasFilter() ? "F" : "";
|
||||||
QString a = ui->tw_ListViews->tabBar()->tabText(am);
|
QString a = ui->tw_ListViews->tabBar()->tabText(am);
|
||||||
QString c = ui->tw_ListViews->tabBar()->tabText(cm);
|
QString c = ui->tw_ListViews->tabBar()->tabText(cm);
|
||||||
a = CGuiUtility::replaceTabCountValue(a, this->countAircraftModels()) + amf;
|
a = CGuiUtility::replaceTabCountValue(a, this->countAircraftModels()) + amf;
|
||||||
@@ -220,23 +226,30 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMappingComponent::ps_onSaveAircraft()
|
CCallsign CMappingComponent::validateRenderedCallsign() const
|
||||||
{
|
{
|
||||||
const QString cs = ui->le_Callsign->text().trimmed();
|
const QString cs = ui->le_Callsign->text().trimmed();
|
||||||
if (!CCallsign::isValidAircraftCallsign(cs))
|
if (!CCallsign::isValidAircraftCallsign(cs))
|
||||||
{
|
{
|
||||||
CLogMessage(this).validationError("Invalid callsign for mapping");
|
CLogMessage(this).validationError("Invalid callsign for mapping");
|
||||||
return;
|
return CCallsign();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CCallsign callsign(cs);
|
const CCallsign callsign(cs);
|
||||||
bool hasCallsign = ui->tvp_RenderedAircraft->container().containsCallsign(callsign);
|
const bool hasCallsign = ui->tvp_RenderedAircraft->container().containsCallsign(callsign);
|
||||||
if (!hasCallsign)
|
if (!hasCallsign)
|
||||||
{
|
{
|
||||||
CLogMessage(this).validationError("Unmapped callsign %1 for mapping") << callsign.asString();
|
CLogMessage(this).validationError("Unmapped callsign %1 for mapping") << callsign.asString();
|
||||||
return;
|
return CCallsign();
|
||||||
}
|
}
|
||||||
|
return callsign;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMappingComponent::ps_onSaveAircraft()
|
||||||
|
{
|
||||||
|
if (!sGui->getIContextSimulator()->isSimulatorSimulating()) { return; }
|
||||||
|
const CCallsign callsign(this->validateRenderedCallsign());
|
||||||
|
if (callsign.isEmpty()) { return; }
|
||||||
const QString modelString = ui->completer_ModelStrings->getModelString();
|
const QString modelString = ui->completer_ModelStrings->getModelString();
|
||||||
if (modelString.isEmpty())
|
if (modelString.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -244,15 +257,19 @@ namespace BlackGui
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasModel = ui->tvp_AircraftModels->container().containsModelString(modelString);
|
const bool hasModel = ui->tvp_AircraftModels->container().containsModelString(modelString);
|
||||||
if (!hasModel)
|
if (!hasModel)
|
||||||
{
|
{
|
||||||
CLogMessage(this).validationError("Invalid model for mapping");
|
CLogMessage(this).validationError("Invalid model for mapping, reload models");
|
||||||
|
if (ui->tvp_AircraftModels->isEmpty())
|
||||||
|
{
|
||||||
|
this->ps_onModelsUpdateRequested();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSimulatedAircraft aircraftFromBackend = sGui->getIContextNetwork()->getAircraftInRangeForCallsign(callsign);
|
const CSimulatedAircraft aircraftFromBackend = sGui->getIContextNetwork()->getAircraftInRangeForCallsign(callsign);
|
||||||
bool enabled = ui->cb_AircraftEnabled->isChecked();
|
const bool enabled = ui->cb_AircraftEnabled->isChecked();
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (aircraftFromBackend.getModelString() != modelString)
|
if (aircraftFromBackend.getModelString() != modelString)
|
||||||
{
|
{
|
||||||
@@ -270,19 +287,30 @@ namespace BlackGui
|
|||||||
CAircraftModel model(models.front());
|
CAircraftModel model(models.front());
|
||||||
model.setModelType(CAircraftModel::TypeManuallySet);
|
model.setModelType(CAircraftModel::TypeManuallySet);
|
||||||
CLogMessage(this).info("Requesting changes for %1") << callsign.asString();
|
CLogMessage(this).info("Requesting changes for %1") << callsign.asString();
|
||||||
sGui->getIContextNetwork()->updateAircraftModel(aircraftFromBackend.getCallsign(), model, identifier());
|
changed = sGui->getIContextNetwork()->updateAircraftModel(aircraftFromBackend.getCallsign(), model, identifier());
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
if (aircraftFromBackend.isEnabled() != enabled)
|
if (aircraftFromBackend.isEnabled() != enabled)
|
||||||
{
|
{
|
||||||
sGui->getIContextNetwork()->updateAircraftEnabled(aircraftFromBackend.getCallsign(), enabled);
|
changed = sGui->getIContextNetwork()->updateAircraftEnabled(aircraftFromBackend.getCallsign(), enabled);
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
{
|
{
|
||||||
CLogMessage(this).info("Model mapping, nothing to change");
|
CLogMessage(this).info("Model mapping, nothing to change");
|
||||||
return;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMappingComponent::ps_onResetAircraft()
|
||||||
|
{
|
||||||
|
if (!sGui->getIContextSimulator()->isSimulatorSimulating()) { return; }
|
||||||
|
const CCallsign callsign(this->validateRenderedCallsign());
|
||||||
|
if (callsign.isEmpty()) { return; }
|
||||||
|
const CSimulatedAircraft aircraftFromBackend = sGui->getIContextNetwork()->getAircraftInRangeForCallsign(callsign);
|
||||||
|
if (aircraftFromBackend.getCallsign() != callsign) { return; }
|
||||||
|
bool changed = sGui->getIContextNetwork()->updateAircraftModel(callsign, aircraftFromBackend.getModel(), identifier());
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
CLogMessage(this).info("Model reset for '%1'") << callsign.toQString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,6 +379,13 @@ namespace BlackGui
|
|||||||
m_missedRenderedAircraftUpdate = true;
|
m_missedRenderedAircraftUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMappingComponent::ps_addingRemoteAircraftFailed(const CSimulatedAircraft &aircraft, const CStatusMessage &message)
|
||||||
|
{
|
||||||
|
m_missedRenderedAircraftUpdate = true;
|
||||||
|
Q_UNUSED(aircraft);
|
||||||
|
Q_UNUSED(message);
|
||||||
|
}
|
||||||
|
|
||||||
void CMappingComponent::ps_onMenuEnableAircraft(const CSimulatedAircraft &aircraft)
|
void CMappingComponent::ps_onMenuEnableAircraft(const CSimulatedAircraft &aircraft)
|
||||||
{
|
{
|
||||||
if (sGui->getIContextNetwork())
|
if (sGui->getIContextNetwork())
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ namespace BlackGui
|
|||||||
//! Save changed aircraft
|
//! Save changed aircraft
|
||||||
void ps_onSaveAircraft();
|
void ps_onSaveAircraft();
|
||||||
|
|
||||||
|
//! Reset aircraft
|
||||||
|
void ps_onResetAircraft();
|
||||||
|
|
||||||
//! Model preview
|
//! Model preview
|
||||||
void ps_onModelPreviewChanged(int state);
|
void ps_onModelPreviewChanged(int state);
|
||||||
|
|
||||||
@@ -121,6 +124,8 @@ namespace BlackGui
|
|||||||
//! Update with next cycle
|
//! Update with next cycle
|
||||||
void ps_markRenderedViewForUpdate();
|
void ps_markRenderedViewForUpdate();
|
||||||
|
|
||||||
|
//! Adding a remote aircraft failed
|
||||||
|
void ps_addingRemoteAircraftFailed(const BlackMisc::Simulation::CSimulatedAircraft &aircraft, const BlackMisc::CStatusMessage &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Identifier for data send from this component
|
//! Identifier for data send from this component
|
||||||
@@ -129,10 +134,12 @@ namespace BlackGui
|
|||||||
//! Update simulated aircraft view
|
//! Update simulated aircraft view
|
||||||
void updateRenderedAircraftView(bool forceUpdate = false);
|
void updateRenderedAircraftView(bool forceUpdate = false);
|
||||||
|
|
||||||
|
//! Check callsign entered
|
||||||
|
BlackMisc::Aviation::CCallsign validateRenderedCallsign() const;
|
||||||
|
|
||||||
QScopedPointer<Ui::CMappingComponent> ui;
|
QScopedPointer<Ui::CMappingComponent> ui;
|
||||||
bool m_missedRenderedAircraftUpdate = true;
|
bool m_missedRenderedAircraftUpdate = true;
|
||||||
QScopedPointer<CUpdateTimer> m_updateTimer;
|
QScopedPointer<CUpdateTimer> m_updateTimer;
|
||||||
QCompleter *m_modelCompleter = nullptr;
|
|
||||||
BlackGui::Views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr;
|
BlackGui::Views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr;
|
||||||
BlackMisc::CIdentifier m_identifier;
|
BlackMisc::CIdentifier m_identifier;
|
||||||
|
|
||||||
|
|||||||
@@ -153,26 +153,6 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QLineEdit" name="le_Callsign">
|
|
||||||
<property name="maxLength">
|
|
||||||
<number>15</number>
|
|
||||||
</property>
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>callsign</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="4">
|
|
||||||
<widget class="QPushButton" name="pb_SaveAircraft">
|
|
||||||
<property name="text">
|
|
||||||
<string>save</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QCheckBox" name="cb_AircraftIconDisplayed">
|
<widget class="QCheckBox" name="cb_AircraftIconDisplayed">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@@ -193,6 +173,27 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="5">
|
||||||
|
<widget class="QPushButton" name="pb_SaveAircraft">
|
||||||
|
<property name="text">
|
||||||
|
<string>save</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="5">
|
||||||
|
<widget class="QPushButton" name="pb_ResetAircraft">
|
||||||
|
<property name="text">
|
||||||
|
<string>reset</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2" colspan="2">
|
||||||
|
<widget class="QLabel" name="lbl_AircraftIconDisplayed">
|
||||||
|
<property name="text">
|
||||||
|
<string>icon will go here</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QCheckBox" name="cb_AircraftEnabled">
|
<widget class="QCheckBox" name="cb_AircraftEnabled">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@@ -210,21 +211,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
<item row="2" column="0" colspan="6">
|
||||||
<widget class="QPushButton" name="pb_ResetAircraft">
|
|
||||||
<property name="text">
|
|
||||||
<string>reset</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2" colspan="2">
|
|
||||||
<widget class="QLabel" name="lbl_AircraftIconDisplayed">
|
|
||||||
<property name="text">
|
|
||||||
<string>icon will go here</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="5">
|
|
||||||
<widget class="BlackGui::Components::CAircraftModelStringCompleter" name="completer_ModelStrings">
|
<widget class="BlackGui::Components::CAircraftModelStringCompleter" name="completer_ModelStrings">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
@@ -234,6 +221,26 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QPushButton" name="pb_LoadModels">
|
||||||
|
<property name="text">
|
||||||
|
<string>load models</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2" colspan="3">
|
||||||
|
<widget class="QLineEdit" name="le_Callsign">
|
||||||
|
<property name="maxLength">
|
||||||
|
<number>15</number>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>callsign</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user