refs #322, included context menu and methods for injecting test data (ATC stations) in GUI

This commit is contained in:
Klaus Basan
2014-09-04 01:31:28 +02:00
parent 87e87013f9
commit e4545f23d2
14 changed files with 124 additions and 5 deletions

View File

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

View File

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

View File

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

View File

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

View File

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