mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Ref T261, Ref T270, Ref T245 aircraft view improvements
* context menu gnd.flag/follow aircraft * display CG
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <QString>
|
||||
#include <QTabBar>
|
||||
#include <QTimer>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Views;
|
||||
@@ -48,16 +49,16 @@ namespace BlackGui
|
||||
ui->tvp_AirportsInRange->setResizeMode(CAirportView::ResizingOnce);
|
||||
|
||||
ui->tvp_AircraftInRange->setAircraftMode(CSimulatedAircraftListModel::NetworkMode);
|
||||
ui->tvp_AircraftInRange->configureMenu(true, false, false);
|
||||
ui->tvp_AircraftInRange->configureMenu(true, false, false, false);
|
||||
|
||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::ps_onRowCountChanged);
|
||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::requestTextMessageWidget, this, &CAircraftComponent::requestTextMessageWidget);
|
||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::requestHighlightInSimulator, this, &CAircraftComponent::ps_onMenuHighlightInSimulator);
|
||||
connect(ui->tvp_AirportsInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::ps_onRowCountChanged);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAircraftComponent::ps_connectionStatusChanged);
|
||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::requestHighlightInSimulator, this, &CAircraftComponent::onMenuHighlightInSimulator);
|
||||
connect(ui->tvp_AirportsInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAircraftComponent::onConnectionStatusChanged);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CAircraftComponent::update);
|
||||
|
||||
this->ps_settingsChanged();
|
||||
this->onSettingsChanged();
|
||||
m_updateTimer.start();
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ namespace BlackGui
|
||||
bool CAircraftComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
|
||||
{
|
||||
CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget);
|
||||
bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CAircraftComponent::ps_infoAreaTabBarChanged);
|
||||
const bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CAircraftComponent::onInfoAreaTabBarChanged);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "failed connect");
|
||||
Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent");
|
||||
return c && parentDockableWidget;
|
||||
@@ -87,7 +88,7 @@ namespace BlackGui
|
||||
|
||||
void CAircraftComponent::update()
|
||||
{
|
||||
if (sGui->isShuttingDown()) { return; }
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
|
||||
Q_ASSERT(ui->tvp_AircraftInRange);
|
||||
Q_ASSERT(sGui->getIContextNetwork());
|
||||
@@ -112,7 +113,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftComponent::ps_infoAreaTabBarChanged(int index)
|
||||
void CAircraftComponent::onInfoAreaTabBarChanged(int index)
|
||||
{
|
||||
// ignore in those cases
|
||||
if (!this->isVisibleWidget()) return;
|
||||
@@ -120,11 +121,16 @@ namespace BlackGui
|
||||
if (!sGui->getIContextNetwork()->isConnected()) return;
|
||||
|
||||
// here I know I am the selected widget, update, but keep GUI responsive (hence I use a timer)
|
||||
QTimer::singleShot(1000, this, &CAircraftComponent::update);
|
||||
QPointer<CAircraftComponent> myself(this);
|
||||
QTimer::singleShot(1000, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
myself->update();
|
||||
});
|
||||
Q_UNUSED(index);
|
||||
}
|
||||
|
||||
void CAircraftComponent::ps_onRowCountChanged(int count, bool withFilter)
|
||||
void CAircraftComponent::onRowCountChanged(int count, bool withFilter)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
@@ -138,7 +144,7 @@ namespace BlackGui
|
||||
this->tabBar()->setTabText(ap, aps);
|
||||
}
|
||||
|
||||
void CAircraftComponent::ps_connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to)
|
||||
void CAircraftComponent::onConnectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to)
|
||||
{
|
||||
Q_UNUSED(from);
|
||||
if (INetwork::isDisconnectedStatus(to))
|
||||
@@ -151,7 +157,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftComponent::ps_onMenuHighlightInSimulator(const CSimulatedAircraft &aircraft)
|
||||
void CAircraftComponent::onMenuHighlightInSimulator(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
if (sGui->getIContextSimulator())
|
||||
{
|
||||
@@ -159,11 +165,11 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftComponent::ps_settingsChanged()
|
||||
void CAircraftComponent::onSettingsChanged()
|
||||
{
|
||||
const CViewUpdateSettings settings = this->m_settings.get();
|
||||
const CViewUpdateSettings settings = m_settings.get();
|
||||
const int ms = settings.getAircraftUpdateTime().toMs();
|
||||
this->m_updateTimer.setInterval(ms);
|
||||
m_updateTimer.setInterval(ms);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -59,33 +59,31 @@ namespace BlackGui
|
||||
//! \copydoc CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea
|
||||
virtual bool setParentDockWidgetInfoArea(BlackGui::CDockWidgetInfoArea *parentDockableWidget) override;
|
||||
|
||||
//! Update aircraft/airport view
|
||||
void update();
|
||||
|
||||
signals:
|
||||
//! Request a text message
|
||||
void requestTextMessageWidget(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
public slots:
|
||||
//! Update aircraft/airport view
|
||||
void update();
|
||||
|
||||
private slots:
|
||||
private:
|
||||
//! Info area tab bar has changed
|
||||
void ps_infoAreaTabBarChanged(int index);
|
||||
void onInfoAreaTabBarChanged(int index);
|
||||
|
||||
//! Number of elements changed
|
||||
void ps_onRowCountChanged(int count, bool withFilter);
|
||||
void onRowCountChanged(int count, bool withFilter);
|
||||
|
||||
//! Connection status has been changed
|
||||
void ps_connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
||||
void onConnectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
||||
|
||||
//! Highlight in simulator
|
||||
void ps_onMenuHighlightInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
void onMenuHighlightInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Settings have been changed
|
||||
void ps_settingsChanged();
|
||||
void onSettingsChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAircraftComponent> ui;
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CAircraftComponent::ps_settingsChanged }; //!< settings changed
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CAircraftComponent::onSettingsChanged }; //!< settings changed
|
||||
QTimer m_updateTimer;
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -92,9 +92,12 @@ namespace BlackGui
|
||||
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::clicked, this, &CMappingComponent::onAircraftSelectedInView);
|
||||
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::requestUpdate, this, &CMappingComponent::tokenBucketUpdate);
|
||||
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::requestTextMessageWidget, this, &CMappingComponent::requestTextMessageWidget);
|
||||
|
||||
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::requestEnableAircraft, this, &CMappingComponent::onMenuToggleEnableAircraft);
|
||||
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::requestFastPositionUpdates, this, &CMappingComponent::onMenuChangeFastPositionUpdates);
|
||||
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::requestHighlightInSimulator, this, &CMappingComponent::onMenuHighlightInSimulator);
|
||||
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::requestFollowInSimulator, this, &CMappingComponent::onMenuFollowAircraftInSimulator);
|
||||
connect(ui->tvp_RenderedAircraft, &CSimulatedAircraftView::requestSupportingGndFlag, this, &CMappingComponent::onMenuSupportGndFLag);
|
||||
|
||||
connect(ui->pb_SaveAircraft, &QPushButton::clicked, this, &CMappingComponent::onSaveAircraft);
|
||||
connect(ui->pb_ResetAircraft, &QPushButton::clicked, this, &CMappingComponent::onResetAircraft);
|
||||
@@ -136,6 +139,7 @@ namespace BlackGui
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftModel, this, &CMappingComponent::onRemoteAircraftModelChanged);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedRemoteAircraftEnabled, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedFastPositionUpdates, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::changedGndFlagCapability, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::removedAircraft, this, &CMappingComponent::tokenBucketUpdate);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CMappingComponent::onConnectionStatusChanged);
|
||||
|
||||
@@ -422,12 +426,28 @@ namespace BlackGui
|
||||
|
||||
void CMappingComponent::onMenuChangeFastPositionUpdates(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
if (sGui->getIContextNetwork())
|
||||
if (sGui && sGui->getIContextNetwork())
|
||||
{
|
||||
sGui->getIContextNetwork()->updateFastPositionEnabled(aircraft.getCallsign(), aircraft.fastPositionUpdates());
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::onMenuFollowAircraftInSimulator(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
if (sGui && sGui->getIContextSimulator())
|
||||
{
|
||||
sGui->getIContextSimulator()->followAircraft(aircraft.getCallsign());
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::onMenuSupportGndFLag(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
if (sGui && sGui->getIContextNetwork())
|
||||
{
|
||||
sGui->getIContextNetwork()->updateAircraftSupportingGndFLag(aircraft.getCallsign(), aircraft.isSupportingGndFlag());
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::onMenuHighlightInSimulator(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
if (sGui && sGui->getIContextSimulator())
|
||||
|
||||
@@ -126,6 +126,12 @@ namespace BlackGui
|
||||
//! Fast position updates onf/off
|
||||
void onMenuChangeFastPositionUpdates(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Follow aircrft in simulator
|
||||
void onMenuFollowAircraftInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Support gnd.flag
|
||||
void onMenuSupportGndFLag(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Enable / disable aircraft
|
||||
void onMenuToggleEnableAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user