mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #322, included context menu and methods for injecting test data (ATC stations) in GUI
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "airspace_monitor.h"
|
||||
#include "blackcore/blackcorefreefunctions.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include "blackmisc/testing.h"
|
||||
#include "blackmisc/indexvariantmap.h"
|
||||
|
||||
namespace BlackCore
|
||||
@@ -218,6 +219,14 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::testCreateDummyOnlineAtcStations(int number)
|
||||
{
|
||||
this->m_atcStationsOnline.push_back(
|
||||
BlackMisc::Aviation::CTesting::createAtcStations(number)
|
||||
);
|
||||
emit this->changedAtcStationsOnline();
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::ps_realNameReplyReceived(const CCallsign &callsign, const QString &realname)
|
||||
{
|
||||
if (realname.isEmpty()) return;
|
||||
|
||||
@@ -72,6 +72,9 @@ namespace BlackCore
|
||||
//! Request to update ATC stations' ATIS data from the network
|
||||
void requestAtisUpdates();
|
||||
|
||||
//! Create dummy entries for performance tests
|
||||
void testCreateDummyOnlineAtcStations(int number);
|
||||
|
||||
signals:
|
||||
//! Online ATC stations were changed
|
||||
void changedAtcStationsOnline();
|
||||
|
||||
@@ -183,6 +183,9 @@ namespace BlackCore
|
||||
//! Request ATIS updates (for all stations)
|
||||
virtual void requestAtisUpdates() = 0;
|
||||
|
||||
//! Create dummy ATC stations for performance tests etc.
|
||||
virtual void testCreateDummyOnlineAtcStations(int number) = 0;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IContextNetwork(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
|
||||
@@ -381,6 +381,14 @@ namespace BlackCore
|
||||
this->m_airspace->requestAtisUpdates();
|
||||
}
|
||||
|
||||
/*
|
||||
* Create dummy ATC stations
|
||||
*/
|
||||
void CContextNetwork::testCreateDummyOnlineAtcStations(int number)
|
||||
{
|
||||
this->m_airspace->testCreateDummyOnlineAtcStations(number);
|
||||
}
|
||||
|
||||
/*
|
||||
* Request METAR
|
||||
*/
|
||||
|
||||
@@ -128,6 +128,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::requestAtisUpdates
|
||||
virtual void requestAtisUpdates() override;
|
||||
|
||||
//! \copydoc IContextNetwork::testCreateDummyOnlineAtcStations
|
||||
virtual void testCreateDummyOnlineAtcStations(int number) override;
|
||||
|
||||
//! Gracefully shut down, e.g. for thread safety
|
||||
void gracefulShutdown();
|
||||
|
||||
|
||||
@@ -126,6 +126,11 @@ namespace BlackCore
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("requestAtisUpdates"));
|
||||
}
|
||||
|
||||
void CContextNetworkProxy::testCreateDummyOnlineAtcStations(int number)
|
||||
{
|
||||
this->m_dBusInterface->callDBus(QLatin1Literal("testCreateDummyOnlineAtcStations"), number);
|
||||
}
|
||||
|
||||
BlackMisc::CStatusMessageList CContextNetworkProxy::connectToNetwork(uint loginMode)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("connectToNetwork"), loginMode);
|
||||
|
||||
@@ -106,6 +106,10 @@ namespace BlackCore
|
||||
|
||||
//! \copydoc IContextNetwork::requestAtisUpdates
|
||||
virtual void requestAtisUpdates() override;
|
||||
|
||||
//! \copydoc IContextNetwork::testCreateDummyOnlineAtcStations
|
||||
virtual void testCreateDummyOnlineAtcStations(int number) override;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
|
||||
#include "blackmisc/avinformationmessage.h"
|
||||
#include "atcstationcomponent.h"
|
||||
#include "../views/atcstationview.h"
|
||||
#include "ui_atcstationcomponent.h"
|
||||
|
||||
//! \file
|
||||
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackCore;
|
||||
|
||||
@@ -36,10 +38,11 @@ namespace BlackGui
|
||||
Q_ASSERT(connected);
|
||||
connected = this->connect(this->ui->pb_AtcStationsLoadMetar, SIGNAL(clicked()), this, SLOT(getMetar()));
|
||||
Q_ASSERT(connected);
|
||||
this->connect(this, &QTabWidget::currentChanged, this, &CAtcStationComponent::ps_atcStationsTabChanged);
|
||||
this->connect(this->ui->tvp_AtcStationsOnline, &QTableView::clicked, this, &CAtcStationComponent::ps_onlineAtcStationSelected);
|
||||
this->connect(this->ui->pb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::ps_requestAtis);
|
||||
this->connect(this->ui->pb_ReloadAtcStationsBooked, &QPushButton::clicked, this, &CAtcStationComponent::ps_reloadAtcStationsBooked);
|
||||
connect(this, &QTabWidget::currentChanged, this, &CAtcStationComponent::ps_atcStationsTabChanged);
|
||||
connect(this->ui->tvp_AtcStationsOnline, &QTableView::clicked, this, &CAtcStationComponent::ps_onlineAtcStationSelected);
|
||||
connect(this->ui->pb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::ps_requestAtis);
|
||||
connect(this->ui->pb_ReloadAtcStationsBooked, &QPushButton::clicked, this, &CAtcStationComponent::ps_reloadAtcStationsBooked);
|
||||
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::testRequestDummyAtcOnlineStations, this, &CAtcStationComponent::ps_testCreateDummyOnlineAtcStations);
|
||||
}
|
||||
|
||||
CAtcStationComponent::~CAtcStationComponent()
|
||||
@@ -137,6 +140,14 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CAtcStationComponent::ps_testCreateDummyOnlineAtcStations(int number)
|
||||
{
|
||||
if (this->getIContextNetwork())
|
||||
{
|
||||
this->getIContextNetwork()->testCreateDummyOnlineAtcStations(number);
|
||||
}
|
||||
}
|
||||
|
||||
void CAtcStationComponent::changedAtcStationOnlineConnectionStatus(const CAtcStation &station, bool added)
|
||||
{
|
||||
this->ui->tvp_AtcStationsOnline->changedAtcStationConnectionStatus(station, added);
|
||||
|
||||
@@ -88,6 +88,9 @@ namespace BlackGui
|
||||
//! Connection status has been changed
|
||||
void ps_connectionStatusChanged(uint from, uint to, const QString &message);
|
||||
|
||||
//! Request dummy ATC online stations
|
||||
void ps_testCreateDummyOnlineAtcStations(int number);
|
||||
|
||||
private:
|
||||
Ui::CAtcStationComponent *ui;
|
||||
CTimerBasedComponent *m_timerComponent;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "atcstationview.h"
|
||||
#include "blackmisc/testing.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
@@ -48,5 +49,15 @@ namespace BlackGui
|
||||
this->resizeColumnsToContents();
|
||||
this->resizeRowsToContents();
|
||||
}
|
||||
|
||||
void CAtcStationView::customMenu(QMenu &menu) const
|
||||
{
|
||||
if (BlackMisc::CProject::isDebugBuild())
|
||||
{
|
||||
menu.addAction("Test: 1k ATC online stations", this, SLOT(ps_testRequest1kAtcOnlineDummies()));
|
||||
menu.addAction("Test: 3k ATC online stations", this, SLOT(ps_testRequest3kAtcOnlineDummies()));
|
||||
}
|
||||
CViewBase::customMenu(menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/atcstationlistmodel.h"
|
||||
#include "blackmisc/project.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -22,6 +23,7 @@ namespace BlackGui
|
||||
//! ATC stations view
|
||||
class CAtcStationView : public CViewBase<Models::CAtcStationListModel>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
@@ -31,10 +33,21 @@ namespace BlackGui
|
||||
//! Set station mode
|
||||
void setStationMode(Models::CAtcStationListModel::AtcStationMode stationMode);
|
||||
|
||||
signals:
|
||||
//! Request some dummy ATC stations
|
||||
void testRequestDummyAtcOnlineStations(int number);
|
||||
|
||||
public slots:
|
||||
//! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus
|
||||
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
|
||||
|
||||
protected:
|
||||
//! \copydoc CViewBase::customMenu
|
||||
virtual void customMenu(QMenu &menu) const override;
|
||||
|
||||
private slots:
|
||||
void ps_testRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); }
|
||||
void ps_testRequest3kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(3000); }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
//! \file
|
||||
|
||||
#include <QTableView>
|
||||
#include <QMenu>
|
||||
#include <QPoint>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -101,6 +103,8 @@ namespace BlackGui
|
||||
{
|
||||
this->setSortingEnabled(true);
|
||||
if (model) { this->setModel(this->m_model); }
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, &QWidget::customContextMenuRequested, this, &CViewBase::ps_customMenuRequested);
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
@@ -134,8 +138,24 @@ namespace BlackGui
|
||||
this->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
|
||||
ModelClass *m_model = nullptr; //!< corresponding model
|
||||
//! Method creating the menu
|
||||
//! \remarks override this method to contribute to the menu
|
||||
virtual void customMenu(QMenu &menu) const
|
||||
{
|
||||
Q_UNUSED(menu);
|
||||
}
|
||||
|
||||
private slots:
|
||||
//! Custom menu was requested
|
||||
void ps_customMenuRequested(QPoint pos)
|
||||
{
|
||||
QMenu menu;
|
||||
this->customMenu(menu);
|
||||
if (menu.isEmpty()) { return; }
|
||||
|
||||
QPoint globalPos = this->mapToGlobal(pos);
|
||||
menu.exec(globalPos);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,26 @@ namespace BlackMisc
|
||||
return getMajorMinor(1);
|
||||
}
|
||||
|
||||
bool CProject::isDebugBuild()
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CProject::isReleaseBuild()
|
||||
{
|
||||
#ifdef QT_NO_DEBUG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CProject::getMajorMinor(int index)
|
||||
{
|
||||
QString v = version();
|
||||
|
||||
@@ -66,6 +66,12 @@ namespace BlackMisc
|
||||
//! Version minor
|
||||
static int versionMinor();
|
||||
|
||||
//! Debug build?
|
||||
static bool isDebugBuild();
|
||||
|
||||
//! Release build?
|
||||
static bool isReleaseBuild();
|
||||
|
||||
private:
|
||||
//! Constructor
|
||||
CProject() {}
|
||||
|
||||
Reference in New Issue
Block a user