mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
Ref T412, Ref T407, Ref T227, update aircraft UI if aircraft was moved
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include "blackgui/views/viewbase.h"
|
#include "blackgui/views/viewbase.h"
|
||||||
#include "blackcore/context/contextnetwork.h"
|
#include "blackcore/context/contextnetwork.h"
|
||||||
#include "blackcore/context/contextsimulator.h"
|
#include "blackcore/context/contextsimulator.h"
|
||||||
|
#include "blackcore/context/contextownaircraft.h"
|
||||||
#include "blackcore/network.h"
|
#include "blackcore/network.h"
|
||||||
#include "blackmisc/network/server.h"
|
#include "blackmisc/network/server.h"
|
||||||
#include "blackmisc/network/fsdsetup.h"
|
#include "blackmisc/network/fsdsetup.h"
|
||||||
@@ -46,18 +47,23 @@ namespace BlackGui
|
|||||||
ui(new Ui::CAircraftComponent)
|
ui(new Ui::CAircraftComponent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
Q_ASSERT(sGui->getIContextNetwork());
|
||||||
|
Q_ASSERT(sGui->getIContextSimulator());
|
||||||
|
Q_ASSERT(sGui->getIContextOwnAircraft());
|
||||||
|
|
||||||
this->setCurrentIndex(0);
|
this->setCurrentIndex(0);
|
||||||
this->tabBar()->setExpanding(false);
|
this->tabBar()->setExpanding(false);
|
||||||
this->tabBar()->setUsesScrollButtons(true);
|
this->tabBar()->setUsesScrollButtons(true);
|
||||||
ui->tvp_AirportsInRange->setResizeMode(CAirportView::ResizingOnce);
|
ui->tvp_AirportsInRange->setResizeMode(CAirportView::ResizingOnce);
|
||||||
|
|
||||||
ui->tvp_AircraftInRange->setAircraftMode(CSimulatedAircraftListModel::NetworkMode);
|
ui->tvp_AircraftInRange->setAircraftMode(CSimulatedAircraftListModel::NetworkMode);
|
||||||
ui->tvp_AircraftInRange->configureMenu(true, false, true, true);
|
ui->tvp_AircraftInRange->configureMenu(true, false, true, true);
|
||||||
|
|
||||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
||||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::requestTextMessageWidget, this, &CAircraftComponent::requestTextMessageWidget);
|
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::requestTextMessageWidget, this, &CAircraftComponent::requestTextMessageWidget);
|
||||||
connect(ui->tvp_AirportsInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
connect(ui->tvp_AirportsInRange, &CSimulatedAircraftView::modelDataChangedDigest, this, &CAircraftComponent::onRowCountChanged);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAircraftComponent::onConnectionStatusChanged);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAircraftComponent::onConnectionStatusChanged, Qt::QueuedConnection);
|
||||||
|
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::movedAircraft, this, &CAircraftComponent::onOwnAircraftMoved, Qt::QueuedConnection);
|
||||||
connect(&m_updateTimer, &QTimer::timeout, this, &CAircraftComponent::update);
|
connect(&m_updateTimer, &QTimer::timeout, this, &CAircraftComponent::update);
|
||||||
|
|
||||||
this->onSettingsChanged();
|
this->onSettingsChanged();
|
||||||
@@ -92,10 +98,6 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
|
|
||||||
Q_ASSERT(ui->tvp_AircraftInRange);
|
|
||||||
Q_ASSERT(sGui->getIContextNetwork());
|
|
||||||
Q_ASSERT(sGui->getIContextSimulator());
|
|
||||||
|
|
||||||
// count < 1 checks if view already has been updated
|
// count < 1 checks if view already has been updated
|
||||||
if (sGui->getIContextNetwork()->isConnected())
|
if (sGui->getIContextNetwork()->isConnected())
|
||||||
{
|
{
|
||||||
@@ -124,6 +126,13 @@ namespace BlackGui
|
|||||||
this->setCurrentIndex(tabIndex);
|
this->setCurrentIndex(tabIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAircraftComponent::updateViews()
|
||||||
|
{
|
||||||
|
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork() || !sGui->getIContextSimulator()) { return; }
|
||||||
|
ui->tvp_AircraftInRange->updateContainerMaybeAsync(sGui->getIContextNetwork()->getAircraftInRange());
|
||||||
|
ui->tvp_AirportsInRange->updateContainerMaybeAsync(sGui->getIContextSimulator()->getAirportsInRange(true));
|
||||||
|
}
|
||||||
|
|
||||||
void CAircraftComponent::onInfoAreaTabBarChanged(int index)
|
void CAircraftComponent::onInfoAreaTabBarChanged(int index)
|
||||||
{
|
{
|
||||||
// ignore in those cases
|
// ignore in those cases
|
||||||
@@ -179,5 +188,10 @@ namespace BlackGui
|
|||||||
const int ms = settings.getAircraftUpdateTime().toMs();
|
const int ms = settings.getAircraftUpdateTime().toMs();
|
||||||
m_updateTimer.setInterval(ms);
|
m_updateTimer.setInterval(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAircraftComponent::onOwnAircraftMoved()
|
||||||
|
{
|
||||||
|
this->updateViews();
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace Ui { class CAircraftComponent; }
|
|||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
class CDockWidgetInfoArea;
|
class CDockWidgetInfoArea;
|
||||||
|
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
//! Aircraft widget
|
//! Aircraft widget
|
||||||
@@ -76,6 +77,9 @@ namespace BlackGui
|
|||||||
void requestTextMessageWidget(const BlackMisc::Aviation::CCallsign &callsign);
|
void requestTextMessageWidget(const BlackMisc::Aviation::CCallsign &callsign);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Update the views
|
||||||
|
void updateViews();
|
||||||
|
|
||||||
//! Info area tab bar has changed
|
//! Info area tab bar has changed
|
||||||
void onInfoAreaTabBarChanged(int index);
|
void onInfoAreaTabBarChanged(int index);
|
||||||
|
|
||||||
@@ -88,6 +92,9 @@ namespace BlackGui
|
|||||||
//! Settings have been changed
|
//! Settings have been changed
|
||||||
void onSettingsChanged();
|
void onSettingsChanged();
|
||||||
|
|
||||||
|
//! Own aircraft has been moved
|
||||||
|
void onOwnAircraftMoved();
|
||||||
|
|
||||||
QScopedPointer<Ui::CAircraftComponent> ui;
|
QScopedPointer<Ui::CAircraftComponent> ui;
|
||||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CAircraftComponent::onSettingsChanged }; //!< settings changed
|
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CAircraftComponent::onSettingsChanged }; //!< settings changed
|
||||||
QTimer m_updateTimer;
|
QTimer m_updateTimer;
|
||||||
|
|||||||
Reference in New Issue
Block a user