mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
Allow to select COM frequencies from ATC view (context menu)
* added functions in component to select COM frequencies * changed views to contain ObjectType in template * function to obtain selected objects in view base class
This commit is contained in:
@@ -20,7 +20,7 @@ namespace BlackCore
|
||||
case CRuntimeConfig::Remote:
|
||||
return new BlackCore::CContextOwnAircraftProxy(BlackCore::CDBusServer::ServiceName, conn, mode, parent);
|
||||
default:
|
||||
qFatal("Always initialize an ownaircraft context");
|
||||
qFatal("Always initialize an ownAircraft context");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,9 @@ namespace BlackCore
|
||||
//! \todo remove "own", left over from past
|
||||
virtual bool updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const QString &originator) = 0;
|
||||
|
||||
//! Tune in a com frequency
|
||||
virtual bool updateComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, int comUnit, const QString &originator) = 0;
|
||||
|
||||
//! Set current pilot
|
||||
virtual bool updatePilot(const BlackMisc::Network::CUser &pilot, const QString &originator) = 0;
|
||||
|
||||
|
||||
@@ -179,6 +179,31 @@ namespace BlackCore
|
||||
return changed;
|
||||
}
|
||||
|
||||
/*
|
||||
* COM frequency
|
||||
*/
|
||||
bool CContextOwnAircraft::updateComFrequency(const CFrequency &frequency, int comUnit, const QString &originator)
|
||||
{
|
||||
CComSystem::ComUnit unit = static_cast<CComSystem::ComUnit>(comUnit);
|
||||
if (unit != CComSystem::Com1 && unit != CComSystem::Com2) { return false; }
|
||||
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
|
||||
CComSystem com1 = this->m_ownAircraft.getCom1System();
|
||||
CComSystem com2 = this->m_ownAircraft.getCom2System();
|
||||
CTransponder xpdr = this->m_ownAircraft.getTransponder();
|
||||
if (unit == CComSystem::Com1)
|
||||
{
|
||||
com1.setFrequencyActive(frequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
com2.setFrequencyActive(frequency);
|
||||
}
|
||||
return updateOwnCockpit(com1, com2, xpdr, originator);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pilot
|
||||
*/
|
||||
bool CContextOwnAircraft::updatePilot(const CUser &pilot, const QString &originator)
|
||||
{
|
||||
if (this->m_ownAircraft.getPilot() == pilot) { return false; }
|
||||
|
||||
@@ -55,6 +55,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextOwnAircraft::updateOwnCockpit
|
||||
virtual bool updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const QString &originator) override;
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateComFrequency
|
||||
virtual bool updateComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, int comUnit, const QString &originator) override;
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updatePilot
|
||||
virtual bool updatePilot(const BlackMisc::Network::CUser &pilot, const QString &originator) override;
|
||||
|
||||
|
||||
@@ -64,6 +64,11 @@ namespace BlackCore
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("updateOwnCockpit"), com1, com2, transponder, originator);
|
||||
}
|
||||
|
||||
bool CContextOwnAircraftProxy::updateComFrequency(const PhysicalQuantities::CFrequency &frequency, int comUnit, const QString &originator)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("updateComFrequency"), frequency, comUnit, originator);
|
||||
}
|
||||
|
||||
bool CContextOwnAircraftProxy::updatePilot(const BlackMisc::Network::CUser &pilot, const QString &originator)
|
||||
{
|
||||
return this->m_dBusInterface->callDBusRet<bool>(QLatin1Literal("updatePilot"), pilot, originator);
|
||||
|
||||
@@ -61,6 +61,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextOwnAircraft::updateOwnCockpit
|
||||
virtual bool updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const QString &originator) override;
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateComFrequency
|
||||
virtual bool updateComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, int comUnit, const QString &originator) override;
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updatePilot
|
||||
virtual bool updatePilot(const BlackMisc::Network::CUser &pilot, const QString &originator) override;
|
||||
|
||||
|
||||
@@ -14,12 +14,14 @@
|
||||
#include "blackmisc/avinformationmessage.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_ownaircraft.h"
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackGui
|
||||
@@ -57,6 +59,7 @@ namespace BlackGui
|
||||
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::ps_requestOnlineStationsUpdate);
|
||||
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged);
|
||||
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged);
|
||||
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::requestComFrequency, this, &CAtcStationComponent::ps_setComFrequency);
|
||||
|
||||
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::ps_reloadAtcStationsBooked);
|
||||
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged);
|
||||
@@ -241,6 +244,13 @@ namespace BlackGui
|
||||
this->tabBar()->setTabText(ib, b);
|
||||
}
|
||||
|
||||
void CAtcStationComponent::ps_setComFrequency(const PhysicalQuantities::CFrequency &frequency, CComSystem::ComUnit unit)
|
||||
{
|
||||
if (unit != CComSystem::Com1 && unit != CComSystem::Com2) { return; }
|
||||
if (!CComSystem::isValidComFrequency(frequency)) { return; }
|
||||
this->getIContextOwnAircraft()->updateComFrequency(frequency, static_cast<int>(unit), originator());
|
||||
}
|
||||
|
||||
void CAtcStationComponent::ps_onlineAtcStationSelected(QModelIndex index)
|
||||
{
|
||||
this->ui->te_AtcStationsOnlineInfo->setText(""); // reset
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
#include "blackgui/components/enableforruntime.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
|
||||
#include "blackmisc/avatcstation.h"
|
||||
|
||||
#include <QTabWidget>
|
||||
#include <QModelIndex>
|
||||
#include <QScopedPointer>
|
||||
@@ -111,6 +109,9 @@ namespace BlackGui
|
||||
//! Count has been changed
|
||||
void ps_countChanged(int count);
|
||||
|
||||
//! Set COM frequency
|
||||
void ps_setComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAtcStationComponent> ui;
|
||||
CUpdateTimer *m_updateTimer = nullptr;
|
||||
@@ -118,7 +119,16 @@ namespace BlackGui
|
||||
QDateTime m_timestampOnlineStationsChanged = CUpdateTimer::epoch(); //!< stations marked as changed
|
||||
QDateTime m_timestampLastReadBookedStations = CUpdateTimer::epoch(); //!< stations read
|
||||
QDateTime m_timestampBookedStationsChanged = CUpdateTimer::epoch(); //!< stations marked as changed
|
||||
|
||||
const QString &originator()
|
||||
{
|
||||
// string is generated once, the timestamp allows to use multiple
|
||||
// components (as long as they are not generated at the same ms)
|
||||
static const QString o = QString("ATCSTATIOCOMPONENT:").append(QString::number(QDateTime::currentMSecsSinceEpoch()));
|
||||
return o;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
#endif // guard
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace BlackGui
|
||||
|
||||
CAircraftComponent *CMainInfoAreaComponent::getAircraftComponent()
|
||||
{
|
||||
return this->ui->comp_Aircrafts;
|
||||
return this->ui->comp_Aircraft;
|
||||
}
|
||||
|
||||
CUserComponent *CMainInfoAreaComponent::getUserComponent()
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Aircrafts">
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Aircraft">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>127</width>
|
||||
@@ -97,7 +97,7 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="qw_AircraftsInner">
|
||||
<widget class="QWidget" name="qw_AircraftInner">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -121,7 +121,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CAircraftComponent" name="comp_Aircrafts">
|
||||
<widget class="BlackGui::Components::CAircraftComponent" name="comp_Aircraft">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace BlackGui
|
||||
*/
|
||||
void CSettingsComponent::ps_networkServerSelected(QModelIndex index)
|
||||
{
|
||||
const CServer clickedServer = this->ui->tvp_SettingsTnServers->at<CServer>(index);
|
||||
const CServer clickedServer = this->ui->tvp_SettingsTnServers->at(index);
|
||||
this->ui->frp_ServerForm->setServer(clickedServer);
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace BlackGui
|
||||
{
|
||||
QModelIndex i = this->ui->tvp_SettingsMiscHotkeys->currentIndex();
|
||||
if (i.row() < 0 || i.row() >= this->ui->tvp_SettingsMiscHotkeys->rowCount()) return;
|
||||
CSettingKeyboardHotkey hotkey = this->ui->tvp_SettingsMiscHotkeys->at<CSettingKeyboardHotkey>(i);
|
||||
CSettingKeyboardHotkey hotkey = this->ui->tvp_SettingsMiscHotkeys->at(i);
|
||||
CSettingKeyboardHotkey defaultHotkey;
|
||||
defaultHotkey.setFunction(hotkey.getFunction());
|
||||
this->ui->tvp_SettingsMiscHotkeys->derivedModel()->update(i, defaultHotkey);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Aircrafts view
|
||||
class CAircraftModelView : public CViewBase<Models::CAircraftModelListModel, BlackMisc::Network::CAircraftModelList>
|
||||
class CAircraftModelView : public CViewBase<Models::CAircraftModelListModel, BlackMisc::Network::CAircraftModelList, BlackMisc::Network::CAircraftModel>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Aircrafts view
|
||||
class CAircraftView : public CViewBase<Models::CAircraftListModel, BlackMisc::Aviation::CAircraftList>
|
||||
class CAircraftView : public CViewBase<Models::CAircraftListModel, BlackMisc::Aviation::CAircraftList, BlackMisc::Aviation::CAircraft>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Airports view
|
||||
class CAirportView : public CViewBase<Models::CAirportListModel, BlackMisc::Aviation::CAirportList>
|
||||
class CAirportView : public CViewBase<Models::CAirportListModel, BlackMisc::Aviation::CAirportList, BlackMisc::Aviation::CAirport>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
*/
|
||||
|
||||
#include "atcstationview.h"
|
||||
#include "blackmisc/avatcstationlist.h"
|
||||
#include "blackmisc/testing.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
@@ -59,7 +61,29 @@ namespace BlackGui
|
||||
menu.addAction(CIcons::tableSheet16(), "Test: 3k ATC online stations", this, SLOT(ps_testRequest3kAtcOnlineDummies()));
|
||||
menu.addSeparator();
|
||||
}
|
||||
|
||||
if (this->hasSelection())
|
||||
{
|
||||
menu.addAction(CIcons::appCockpit16(), "Tune in COM1", this, SLOT(ps_tuneInAtcCom1()));
|
||||
menu.addAction(CIcons::appCockpit16(), "Tune in COM2", this, SLOT(ps_tuneInAtcCom2()));
|
||||
menu.addSeparator();
|
||||
}
|
||||
CViewBase::customMenu(menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAtcStationView::ps_tuneInAtcCom1()
|
||||
{
|
||||
CAtcStationList l = this->selectedObjects();
|
||||
if (l.isEmpty()) { return; }
|
||||
emit this->requestComFrequency(l.front().getFrequency(), CComSystem::Com1);
|
||||
}
|
||||
|
||||
void CAtcStationView::ps_tuneInAtcCom2()
|
||||
{
|
||||
CAtcStationList l = this->selectedObjects();
|
||||
if (l.isEmpty()) { return; }
|
||||
emit this->requestComFrequency(l.front().getFrequency(), CComSystem::Com2);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! ATC stations view
|
||||
class CAtcStationView : public CViewBase<Models::CAtcStationListModel, BlackMisc::Aviation::CAtcStationList>
|
||||
class CAtcStationView : public CViewBase<Models::CAtcStationListModel, BlackMisc::Aviation::CAtcStationList, BlackMisc::Aviation::CAtcStation>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -37,6 +37,9 @@ namespace BlackGui
|
||||
//! Request some dummy ATC stations
|
||||
void testRequestDummyAtcOnlineStations(int number);
|
||||
|
||||
//! Request COM frequency
|
||||
void requestComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit);
|
||||
|
||||
public slots:
|
||||
//! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus
|
||||
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
|
||||
@@ -48,6 +51,8 @@ namespace BlackGui
|
||||
private slots:
|
||||
void ps_testRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); }
|
||||
void ps_testRequest3kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(3000); }
|
||||
void ps_tuneInAtcCom1();
|
||||
void ps_tuneInAtcCom2();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Client view
|
||||
class CClientView : public CViewBase<Models::CClientListModel, BlackMisc::Network::CClientList>
|
||||
class CClientView : public CViewBase<Models::CClientListModel, BlackMisc::Network::CClientList, BlackMisc::Network::CClient>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Keyboard key view
|
||||
class CKeyboardKeyView : public CViewBase<Models::CKeyboardKeyListModel, BlackMisc::Settings::CSettingKeyboardHotkeyList>
|
||||
class CKeyboardKeyView : public CViewBase<Models::CKeyboardKeyListModel, BlackMisc::Settings::CSettingKeyboardHotkeyList, BlackMisc::Settings::CSettingKeyboardHotkey>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! User view
|
||||
class CNameVariantPairView : public CViewBase<Models::CNameVariantPairModel, BlackMisc::CNameVariantPairList>
|
||||
class CNameVariantPairView : public CViewBase<Models::CNameVariantPairModel, BlackMisc::CNameVariantPairList, BlackMisc::CNameVariantPair>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Network servers
|
||||
class CServerView : public CViewBase<Models::CServerListModel, BlackMisc::Network::CServerList>
|
||||
class CServerView : public CViewBase<Models::CServerListModel, BlackMisc::Network::CServerList, BlackMisc::Network::CServer>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! Status message view
|
||||
class CStatusMessageView : public CViewBase<Models::CStatusMessageListModel, BlackMisc::CStatusMessageList>
|
||||
class CStatusMessageView : public CViewBase<Models::CStatusMessageListModel, BlackMisc::CStatusMessageList, BlackMisc::CStatusMessage>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackGui
|
||||
namespace Views
|
||||
{
|
||||
//! User view
|
||||
class CUserView : public CViewBase<Models::CUserListModel, BlackMisc::Network::CUserList>
|
||||
class CUserView : public CViewBase<Models::CUserListModel, BlackMisc::Network::CUserList, BlackMisc::Network::CUser>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace BlackGui
|
||||
// scroll modes
|
||||
this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::customMenu(QMenu &menu) const
|
||||
@@ -77,6 +76,16 @@ namespace BlackGui
|
||||
return h;
|
||||
}
|
||||
|
||||
bool CViewBaseNonTemplate::hasSelection() const
|
||||
{
|
||||
return this->selectionModel()->hasSelection();
|
||||
}
|
||||
|
||||
QModelIndexList CViewBaseNonTemplate::selectedRows() const
|
||||
{
|
||||
return this->selectionModel()->selectedRows();
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::init()
|
||||
{
|
||||
int fh = qRound(1.5 * this->getHorizontalHeaderFontHeight());
|
||||
@@ -152,7 +161,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> int CViewBase<ModelClass, ContainerType>::updateContainer(const ContainerType &container, bool sort, bool resize)
|
||||
template <class ModelClass, class ContainerType, class ObjectType> int CViewBase<ModelClass, ContainerType, ObjectType>::updateContainer(const ContainerType &container, bool sort, bool resize)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
int c = this->m_model->update(container, sort);
|
||||
@@ -160,7 +169,7 @@ namespace BlackGui
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> BlackMisc::CWorker *CViewBase<ModelClass, ContainerType>::updateContainerAsync(const ContainerType &container, bool sort, bool resize)
|
||||
template <class ModelClass, class ContainerType, class ObjectType> BlackMisc::CWorker *CViewBase<ModelClass, ContainerType, ObjectType>::updateContainerAsync(const ContainerType &container, bool sort, bool resize)
|
||||
{
|
||||
ModelClass *model = this->derivedModel();
|
||||
auto sortColumn = model->getSortColumn();
|
||||
@@ -175,7 +184,7 @@ namespace BlackGui
|
||||
return worker;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::updateContainerMaybeAsync(const ContainerType &container, bool sort, bool resize)
|
||||
template <class ModelClass, class ContainerType, class ObjectType> void CViewBase<ModelClass, ContainerType, ObjectType>::updateContainerMaybeAsync(const ContainerType &container, bool sort, bool resize)
|
||||
{
|
||||
if (container.size() > asyncRowsCountThreshold && sort)
|
||||
{
|
||||
@@ -188,25 +197,37 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> int CViewBase<ModelClass, ContainerType>::rowCount() const
|
||||
template <class ModelClass, class ContainerType, class ObjectType> ContainerType CViewBase<ModelClass, ContainerType, ObjectType>::selectedObjects() const
|
||||
{
|
||||
if (!this->hasSelection()) { return ContainerType(); }
|
||||
ContainerType c;
|
||||
QModelIndexList indexes = this->selectedRows();
|
||||
for (QModelIndex &i : indexes)
|
||||
{
|
||||
c.push_back(this->at(i));
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType> int CViewBase<ModelClass, ContainerType, ObjectType>::rowCount() const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->rowCount();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> int CViewBase<ModelClass, ContainerType>::columnCount() const
|
||||
template <class ModelClass, class ContainerType, class ObjectType> int CViewBase<ModelClass, ContainerType, ObjectType>::columnCount() const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->columnCount(QModelIndex());
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> bool CViewBase<ModelClass, ContainerType>::isEmpty() const
|
||||
template <class ModelClass, class ContainerType, class ObjectType> bool CViewBase<ModelClass, ContainerType, ObjectType>::isEmpty() const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->rowCount() < 1;
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::setObjectName(const QString &name)
|
||||
template <class ModelClass, class ContainerType, class ObjectType> void CViewBase<ModelClass, ContainerType, ObjectType>::setObjectName(const QString &name)
|
||||
{
|
||||
// then name here is mainly set for debugging purposes so each model can be identified
|
||||
Q_ASSERT(m_model);
|
||||
@@ -215,7 +236,7 @@ namespace BlackGui
|
||||
this->m_model->setObjectName(modelName);
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::setSortIndicator()
|
||||
template <class ModelClass, class ContainerType, class ObjectType> void CViewBase<ModelClass, ContainerType, ObjectType>::setSortIndicator()
|
||||
{
|
||||
if (this->m_model->hasValidSortColumn())
|
||||
{
|
||||
@@ -226,7 +247,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::standardInit(ModelClass *model)
|
||||
template <class ModelClass, class ContainerType, class ObjectType> void CViewBase<ModelClass, ContainerType, ObjectType>::standardInit(ModelClass *model)
|
||||
{
|
||||
Q_ASSERT(model || this->m_model);
|
||||
if (model)
|
||||
@@ -239,7 +260,7 @@ namespace BlackGui
|
||||
this->setSortIndicator();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::performResizeToContents()
|
||||
template <class ModelClass, class ContainerType, class ObjectType> void CViewBase<ModelClass, ContainerType, ObjectType>::performResizeToContents()
|
||||
{
|
||||
// small set or large set?
|
||||
if (this->performResizing())
|
||||
@@ -252,7 +273,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType> int CViewBase<ModelClass, ContainerType>::performUpdateContainer(const BlackMisc::CVariant &variant, bool sort, bool resize)
|
||||
template <class ModelClass, class ContainerType, class ObjectType> int CViewBase<ModelClass, ContainerType, ObjectType>::performUpdateContainer(const BlackMisc::CVariant &variant, bool sort, bool resize)
|
||||
{
|
||||
ContainerType c;
|
||||
c.convertFromCVariant(variant);
|
||||
@@ -261,16 +282,16 @@ namespace BlackGui
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||
template class CViewBase<BlackGui::Models::CStatusMessageListModel, BlackMisc::CStatusMessageList>;
|
||||
template class CViewBase<BlackGui::Models::CNameVariantPairModel, BlackMisc::CNameVariantPairList>;
|
||||
template class CViewBase<BlackGui::Models::CAtcStationListModel, BlackMisc::Aviation::CAtcStationList>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftListModel, BlackMisc::Aviation::CAircraftList>;
|
||||
template class CViewBase<BlackGui::Models::CAirportListModel, BlackMisc::Aviation::CAirportList>;
|
||||
template class CViewBase<BlackGui::Models::CServerListModel, BlackMisc::Network::CServerList>;
|
||||
template class CViewBase<BlackGui::Models::CUserListModel, BlackMisc::Network::CUserList>;
|
||||
template class CViewBase<BlackGui::Models::CClientListModel, BlackMisc::Network::CClientList>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftModelListModel, BlackMisc::Network::CAircraftModelList>;
|
||||
template class CViewBase<BlackGui::Models::CKeyboardKeyListModel, BlackMisc::Settings::CSettingKeyboardHotkeyList>;
|
||||
template class CViewBase<BlackGui::Models::CStatusMessageListModel, BlackMisc::CStatusMessageList, BlackMisc::CStatusMessage>;
|
||||
template class CViewBase<BlackGui::Models::CNameVariantPairModel, BlackMisc::CNameVariantPairList, BlackMisc::CNameVariantPair>;
|
||||
template class CViewBase<BlackGui::Models::CAtcStationListModel, BlackMisc::Aviation::CAtcStationList, BlackMisc::Aviation::CAtcStation>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftListModel, BlackMisc::Aviation::CAircraftList, BlackMisc::Aviation::CAircraft>;
|
||||
template class CViewBase<BlackGui::Models::CAirportListModel, BlackMisc::Aviation::CAirportList, BlackMisc::Aviation::CAirport>;
|
||||
template class CViewBase<BlackGui::Models::CServerListModel, BlackMisc::Network::CServerList, BlackMisc::Network::CServer>;
|
||||
template class CViewBase<BlackGui::Models::CUserListModel, BlackMisc::Network::CUserList, BlackMisc::Network::CUser>;
|
||||
template class CViewBase<BlackGui::Models::CClientListModel, BlackMisc::Network::CClientList, BlackMisc::Network::CClient>;
|
||||
template class CViewBase<BlackGui::Models::CAircraftModelListModel, BlackMisc::Network::CAircraftModelList, BlackMisc::Network::CAircraftModel>;
|
||||
template class CViewBase<BlackGui::Models::CKeyboardKeyListModel, BlackMisc::Settings::CSettingKeyboardHotkeyList, BlackMisc::Settings::CSettingKeyboardHotkey>;
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <QMenu>
|
||||
#include <QPoint>
|
||||
#include <QFont>
|
||||
#include <QList>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -63,6 +64,12 @@ namespace BlackGui
|
||||
//! Horizontal font height
|
||||
int getHorizontalHeaderFontHeight() const;
|
||||
|
||||
//! Selection (selected rows)
|
||||
bool hasSelection() const;
|
||||
|
||||
//! Selected rows if any
|
||||
QModelIndexList selectedRows() const;
|
||||
|
||||
signals:
|
||||
//! Ask for new data
|
||||
void requestUpdate();
|
||||
@@ -140,7 +147,7 @@ namespace BlackGui
|
||||
};
|
||||
|
||||
//! Base class for views
|
||||
template <class ModelClass, class ContainerType> class CViewBase : public CViewBaseNonTemplate
|
||||
template <class ModelClass, class ContainerType, class ObjectType> class CViewBase : public CViewBaseNonTemplate
|
||||
{
|
||||
|
||||
public:
|
||||
@@ -166,7 +173,7 @@ namespace BlackGui
|
||||
void updateContainerMaybeAsync(const ContainerType &container, bool sort = true, bool performResizing = true);
|
||||
|
||||
//! Insert
|
||||
template<class ObjectType> void insert(const ObjectType &value, bool resize = true)
|
||||
void insert(const ObjectType &value, bool resize = true)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
this->m_model->insert(value);
|
||||
@@ -174,12 +181,15 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
//! Value object at
|
||||
template<class ObjectType> const ObjectType &at(const QModelIndex &index) const
|
||||
const ObjectType &at(const QModelIndex &index) const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->at(index);
|
||||
}
|
||||
|
||||
//! Selected objects
|
||||
ContainerType selectedObjects() const;
|
||||
|
||||
//! Row count
|
||||
int rowCount() const;
|
||||
|
||||
|
||||
@@ -30,9 +30,7 @@ namespace BlackMisc
|
||||
|
||||
namespace Aviation
|
||||
{
|
||||
/*!
|
||||
* COM system (aka "radio")
|
||||
*/
|
||||
//! COM system (aka "radio")
|
||||
class CComSystem : public CValueObjectStdTuple<CComSystem, CModulator<CComSystem>>
|
||||
{
|
||||
public:
|
||||
@@ -44,6 +42,14 @@ namespace BlackMisc
|
||||
ChannelSpacing8_33KHz
|
||||
};
|
||||
|
||||
//! COM unit
|
||||
enum ComUnit
|
||||
{
|
||||
Com1,
|
||||
Com2,
|
||||
Com3
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CComSystem() : m_channelSpacing(ChannelSpacing25KHz) {}
|
||||
|
||||
@@ -166,17 +172,19 @@ namespace BlackMisc
|
||||
virtual bool validValues() const override;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CComSystem)
|
||||
ChannelSpacing m_channelSpacing;
|
||||
ChannelSpacing m_channelSpacing; //!< channel spacing
|
||||
|
||||
/*!
|
||||
* Give me channel spacing in KHz
|
||||
* \remarks Just a helper method, that is why no CFrequency is returned
|
||||
*/
|
||||
static double channelSpacingToFrequencyKHz(ChannelSpacing channelSpacing);
|
||||
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CComSystem)
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CComSystem, (o.m_channelSpacing))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CComSystem)
|
||||
|
||||
Reference in New Issue
Block a user