Ref T261, Ref T270, Ref T245 aircraft view improvements

* context menu gnd.flag/follow aircraft
* display CG
This commit is contained in:
Klaus Basan
2018-05-17 23:48:52 +02:00
parent 27e9702101
commit 06a4efba51
7 changed files with 155 additions and 49 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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())

View File

@@ -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);

View File

@@ -23,10 +23,11 @@
#include <QtDebug>
#include <QtGlobal>
using namespace BlackMisc::Simulation;
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Network;
using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Simulation;
namespace BlackGui
{
@@ -90,6 +91,7 @@ namespace BlackGui
m_columns.addColumn(CColumn::standardValueObject("cs.", "callsign", { CSimulatedAircraft::IndexCallsign, CCallsign::IndexCallsignString }));
m_columns.addColumn(CColumn("dist.", "distance", CSimulatedAircraft::IndexRelativeDistance, new CAirspaceDistanceFormatter()));
m_columns.addColumn(CColumn("altitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexAltitude }, new CAltitudeFormatter()));
m_columns.addColumn(CColumn("CG", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexCG }, new CPhysiqalQuantiyFormatter<CLengthUnit, CLength>(CLengthUnit::ft(), 1)));
m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundSpeed }, new CSpeedKtsFormatter()));
m_columns.addColumn(CColumn("p.", "parts", CSimulatedAircraft::IndexPartsSynchronized, new CBoolIconFormatter("parts", "no parts"), true));
m_columns.addColumn(CColumn("fp.", "fast position updates", CSimulatedAircraft::IndexFastPositionUpdates, new CBoolIconFormatter("enabled", "disabled"), true));

View File

@@ -34,35 +34,55 @@ namespace BlackGui
CSimulatedAircraftView::CSimulatedAircraftView(QWidget *parent) : CViewWithCallsignObjects(parent)
{
this->standardInit(new CSimulatedAircraftListModel(this));
this->m_menus |= MenuRefresh;
m_menus |= MenuRefresh;
}
void CSimulatedAircraftView::setAircraftMode(CSimulatedAircraftListModel::AircraftMode mode)
{
Q_ASSERT(this->m_model);
this->m_model->setAircraftMode(mode);
Q_ASSERT(m_model);
m_model->setAircraftMode(mode);
this->setSortIndicator();
}
void CSimulatedAircraftView::configureMenu(bool menuHighlight, bool menuEnable, bool menufastPositionUpdates)
void CSimulatedAircraftView::configureMenu(bool menuHighlightAndFollow, bool menuEnableAircraft, bool menuFastPositionUpdates, bool menuGndFlag)
{
this->m_withMenuEnable = menuEnable;
this->m_withMenuFastPosition = menufastPositionUpdates;
this->m_withMenuHighlight = menuHighlight;
m_withMenuEnableAircraft = menuEnableAircraft;
m_withMenuFastPosition = menuFastPositionUpdates;
m_withMenuHighlightAndFollow = menuHighlightAndFollow;
m_withMenuEnableGndFlag = menuGndFlag;
}
void CSimulatedAircraftView::customMenu(CMenuActions &menuActions)
{
if (m_withMenuEnableAircraft)
{
menuActions.addAction(CIcons::appAircraft16(), "Enable all aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::enableAllDisabledAircraft });
menuActions.addAction(CIcons::appAircraft16(), "Re-enable unrendered aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::reEnableAllUnrenderedAircraft });
}
if (this->hasSelection())
{
CSimulatedAircraft aircraft(selectedObject());
Q_ASSERT(!aircraft.getCallsign().isEmpty());
menuActions.addAction(CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(), { this, &CSimulatedAircraftView::requestTextMessage });
menuActions.addAction(CIcons::appAircraft16(), "Enable all aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::enableAllDisabledAircraft });
if (m_withMenuEnable) { menuActions.addAction(CIcons::appAircraft16(), aircraft.isEnabled() ? "Disable aircraft" : "Enabled aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::toggleEnabledAircraft }); }
if (m_withMenuHighlight) { menuActions.addAction(CIcons::appSimulator16(), "Highlight in simulator", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::highlightInSimulator }); }
if (m_withMenuFastPosition) { menuActions.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "Normal updates" : "Fast position updates", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::toggleFastPositionUpdates }); }
const bool any = m_withMenuEnable || m_withMenuFastPosition || m_withMenuHighlight;
if (m_withMenuEnableAircraft)
{
menuActions.addAction(CIcons::appAircraft16(), aircraft.isEnabled() ? "Disable aircraft" : "Enabled aircraft", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::toggleEnabledAircraft });
}
if (m_withMenuHighlightAndFollow)
{
menuActions.addAction(CIcons::appAircraft16(), "Follow in simulator", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::reqFollowInSimulator });
menuActions.addAction(CIcons::appSimulator16(), "Highlight in simulator", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::reqHighlightInSimulator });
}
if (m_withMenuEnableGndFlag)
{
menuActions.addAction(CIcons::geoPosition16(), aircraft.isSupportingGndFlag() ? "Disable gnd.flag" : "Enabled gnd.flag", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::toggleSupportingGndFlag });
}
if (m_withMenuFastPosition)
{
menuActions.addAction(CIcons::globe16(), aircraft.fastPositionUpdates() ? "Normal updates" : "Fast position updates", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::toggleFastPositionUpdates });
}
const bool any = m_withMenuEnableAircraft || m_withMenuFastPosition || m_withMenuHighlightAndFollow || m_withMenuEnableGndFlag;
if (any && (sApp && sApp->isDeveloperFlagSet()))
{
menuActions.addAction(CIcons::appSimulator16(), "Show position log.", CMenuAction::pathClientSimulation(), { this, &CSimulatedAircraftView::showPositionLogInSimulator });
@@ -94,13 +114,28 @@ namespace BlackGui
emit this->requestFastPositionUpdates(aircraft);
}
void CSimulatedAircraftView::highlightInSimulator()
void CSimulatedAircraftView::toggleSupportingGndFlag()
{
CSimulatedAircraft aircraft(selectedObject());
if (aircraft.getCallsign().isEmpty()) { return; }
aircraft.setSupportingGndFlag(!aircraft.isSupportingGndFlag());
emit this->requestSupportingGndFlag(aircraft);
}
void CSimulatedAircraftView::reqHighlightInSimulator()
{
const CSimulatedAircraft aircraft(selectedObject());
if (aircraft.getCallsign().isEmpty()) { return; }
emit this->requestHighlightInSimulator(aircraft);
}
void CSimulatedAircraftView::reqFollowInSimulator()
{
const CSimulatedAircraft aircraft(selectedObject());
if (aircraft.getCallsign().isEmpty()) { return; }
emit this->requestFollowInSimulator(aircraft);
}
void CSimulatedAircraftView::showPositionLogInSimulator()
{
if (!sGui || sGui->isShuttingDown()) { return; }
@@ -132,5 +167,25 @@ namespace BlackGui
});
}
}
void CSimulatedAircraftView::reEnableAllUnrenderedAircraft()
{
if (!sGui || sGui->isShuttingDown()) { return; }
const CSimulatedAircraftList aircraft = this->container().findByRendered(false);
if (aircraft.isEmpty()) { return; }
const QPointer<CSimulatedAircraftView> myself(this);
for (const CSimulatedAircraft &sa : aircraft)
{
QTimer::singleShot(10, this, [ = ]
{
if (!myself) { return; }
if (!sGui || sGui->isShuttingDown()) { return; }
CSimulatedAircraft enabledAircraft(sa);
enabledAircraft.setEnabled(true);
emit this->requestEnableAircraft(enabledAircraft);
});
}
}
} // ns
} // ns

View File

@@ -34,7 +34,7 @@ namespace BlackGui
{
//! Aircraft view
class BLACKGUI_EXPORT CSimulatedAircraftView :
public CViewWithCallsignObjects<Models::CSimulatedAircraftListModel, BlackMisc::Simulation::CSimulatedAircraftList, BlackMisc::Simulation::CSimulatedAircraft>
public CViewWithCallsignObjects<Models::CSimulatedAircraftListModel, BlackMisc::Simulation::CSimulatedAircraftList, BlackMisc::Simulation::CSimulatedAircraft>
{
Q_OBJECT
@@ -46,7 +46,7 @@ namespace BlackGui
void setAircraftMode(Models::CSimulatedAircraftListModel::AircraftMode mode);
//! configure the menu
void configureMenu(bool menuHighlight, bool menuEnable, bool menufastPositionUpdates);
void configureMenu(bool menuHighlightAndFollow, bool menuEnableAircraft, bool menuFastPositionUpdates, bool menuGndFlag);
signals:
//! Request a text message
@@ -58,9 +58,15 @@ namespace BlackGui
//! Request to enable / disable aircraft, \sa CSimulatedAircraft::isEnabled
void requestEnableAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
//! Request to enable / disable gnd.flag, \sa CSimulatedAircraft::isSupportingGndFlag
void requestSupportingGndFlag(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
//! Highlight given aircraft in simulator
void requestHighlightInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
//! Highlight given aircraft in simulator
void requestFollowInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
protected:
//! \copydoc CViewBase::customMenu
virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
@@ -75,8 +81,17 @@ namespace BlackGui
//! Toggle fast position updates for selected aircraft
void toggleFastPositionUpdates();
//! Enable gnd. flag (enable gnd flag capability for given aircraft)
void toggleSupportingGndFlag();
//! Highlight aircraft in simulator
void highlightInSimulator();
void reqHighlightInSimulator();
//! Follow in simulator
void reqFollowInSimulator();
//! Enable gnd. flag capability for server
void reqEnableGndFlagForServer();
//! Show position log for selected aircraft
void showPositionLogInSimulator();
@@ -84,8 +99,12 @@ namespace BlackGui
//! Enable all disabled aircraft
void enableAllDisabledAircraft();
bool m_withMenuHighlight = true;
bool m_withMenuEnable = true;
//! Enable all unrendered aircraft
void reEnableAllUnrenderedAircraft();
bool m_withMenuHighlightAndFollow = true;
bool m_withMenuEnableAircraft = true;
bool m_withMenuEnableGndFlag = true;
bool m_withMenuFastPosition = true;
};
} // ns