From b26fa651ed47c919abd04f7967f6c95ce279b012 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 22 Dec 2014 21:17:13 +0100 Subject: [PATCH] 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 --- src/blackcore/context_ownaircraft.cpp | 2 +- src/blackcore/context_ownaircraft.h | 3 + src/blackcore/context_ownaircraft_impl.cpp | 25 +++++++ src/blackcore/context_ownaircraft_impl.h | 3 + src/blackcore/context_ownaircraft_proxy.cpp | 5 ++ src/blackcore/context_ownaircraft_proxy.h | 3 + .../components/atcstationcomponent.cpp | 10 +++ src/blackgui/components/atcstationcomponent.h | 18 +++-- .../components/maininfoareacomponent.cpp | 2 +- .../components/maininfoareacomponent.ui | 6 +- src/blackgui/components/settingscomponent.cpp | 4 +- src/blackgui/views/aircraftmodelview.h | 2 +- src/blackgui/views/aircraftview.h | 2 +- src/blackgui/views/airportview.h | 2 +- src/blackgui/views/atcstationview.cpp | 28 +++++++- src/blackgui/views/atcstationview.h | 7 +- src/blackgui/views/clientview.h | 2 +- src/blackgui/views/keyboardkeyview.h | 2 +- src/blackgui/views/namevariantpairview.h | 2 +- src/blackgui/views/serverview.h | 2 +- src/blackgui/views/statusmessageview.h | 2 +- src/blackgui/views/userview.h | 2 +- src/blackgui/views/viewbase.cpp | 65 ++++++++++++------- src/blackgui/views/viewbase.h | 16 ++++- src/blackmisc/aviocomsystem.h | 22 +++++-- 25 files changed, 182 insertions(+), 55 deletions(-) diff --git a/src/blackcore/context_ownaircraft.cpp b/src/blackcore/context_ownaircraft.cpp index b1bf0118e..4f337a54e 100644 --- a/src/blackcore/context_ownaircraft.cpp +++ b/src/blackcore/context_ownaircraft.cpp @@ -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; } } diff --git a/src/blackcore/context_ownaircraft.h b/src/blackcore/context_ownaircraft.h index 75eb89233..b0fd87cf9 100644 --- a/src/blackcore/context_ownaircraft.h +++ b/src/blackcore/context_ownaircraft.h @@ -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; diff --git a/src/blackcore/context_ownaircraft_impl.cpp b/src/blackcore/context_ownaircraft_impl.cpp index b8634b014..765bccc83 100644 --- a/src/blackcore/context_ownaircraft_impl.cpp +++ b/src/blackcore/context_ownaircraft_impl.cpp @@ -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(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; } diff --git a/src/blackcore/context_ownaircraft_impl.h b/src/blackcore/context_ownaircraft_impl.h index 6d7b7c533..895f67b7d 100644 --- a/src/blackcore/context_ownaircraft_impl.h +++ b/src/blackcore/context_ownaircraft_impl.h @@ -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; diff --git a/src/blackcore/context_ownaircraft_proxy.cpp b/src/blackcore/context_ownaircraft_proxy.cpp index 4a1c30586..c4d0b5f28 100644 --- a/src/blackcore/context_ownaircraft_proxy.cpp +++ b/src/blackcore/context_ownaircraft_proxy.cpp @@ -64,6 +64,11 @@ namespace BlackCore return this->m_dBusInterface->callDBusRet(QLatin1Literal("updateOwnCockpit"), com1, com2, transponder, originator); } + bool CContextOwnAircraftProxy::updateComFrequency(const PhysicalQuantities::CFrequency &frequency, int comUnit, const QString &originator) + { + return this->m_dBusInterface->callDBusRet(QLatin1Literal("updateComFrequency"), frequency, comUnit, originator); + } + bool CContextOwnAircraftProxy::updatePilot(const BlackMisc::Network::CUser &pilot, const QString &originator) { return this->m_dBusInterface->callDBusRet(QLatin1Literal("updatePilot"), pilot, originator); diff --git a/src/blackcore/context_ownaircraft_proxy.h b/src/blackcore/context_ownaircraft_proxy.h index 51d6083c7..f6db6e60d 100644 --- a/src/blackcore/context_ownaircraft_proxy.h +++ b/src/blackcore/context_ownaircraft_proxy.h @@ -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; diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index bbca42cc7..f2a796c7f 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -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(unit), originator()); + } + void CAtcStationComponent::ps_onlineAtcStationSelected(QModelIndex index) { this->ui->te_AtcStationsOnlineInfo->setText(""); // reset diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index f9b0d62f2..f06c38164 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -15,9 +15,7 @@ #include "blackgui/components/enableforruntime.h" #include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/components/updatetimer.h" - #include "blackmisc/avatcstation.h" - #include #include #include @@ -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; 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 diff --git a/src/blackgui/components/maininfoareacomponent.cpp b/src/blackgui/components/maininfoareacomponent.cpp index 43677091d..aefccc654 100644 --- a/src/blackgui/components/maininfoareacomponent.cpp +++ b/src/blackgui/components/maininfoareacomponent.cpp @@ -42,7 +42,7 @@ namespace BlackGui CAircraftComponent *CMainInfoAreaComponent::getAircraftComponent() { - return this->ui->comp_Aircrafts; + return this->ui->comp_Aircraft; } CUserComponent *CMainInfoAreaComponent::getUserComponent() diff --git a/src/blackgui/components/maininfoareacomponent.ui b/src/blackgui/components/maininfoareacomponent.ui index c177f4569..8edad7c9b 100644 --- a/src/blackgui/components/maininfoareacomponent.ui +++ b/src/blackgui/components/maininfoareacomponent.ui @@ -78,7 +78,7 @@ - + 127 @@ -97,7 +97,7 @@ 4 - + 0 @@ -121,7 +121,7 @@ 0 - + 0 diff --git a/src/blackgui/components/settingscomponent.cpp b/src/blackgui/components/settingscomponent.cpp index 858c05d99..251d19a9c 100644 --- a/src/blackgui/components/settingscomponent.cpp +++ b/src/blackgui/components/settingscomponent.cpp @@ -141,7 +141,7 @@ namespace BlackGui */ void CSettingsComponent::ps_networkServerSelected(QModelIndex index) { - const CServer clickedServer = this->ui->tvp_SettingsTnServers->at(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(i); + CSettingKeyboardHotkey hotkey = this->ui->tvp_SettingsMiscHotkeys->at(i); CSettingKeyboardHotkey defaultHotkey; defaultHotkey.setFunction(hotkey.getFunction()); this->ui->tvp_SettingsMiscHotkeys->derivedModel()->update(i, defaultHotkey); diff --git a/src/blackgui/views/aircraftmodelview.h b/src/blackgui/views/aircraftmodelview.h index 67610beec..a42740b2f 100644 --- a/src/blackgui/views/aircraftmodelview.h +++ b/src/blackgui/views/aircraftmodelview.h @@ -20,7 +20,7 @@ namespace BlackGui namespace Views { //! Aircrafts view - class CAircraftModelView : public CViewBase + class CAircraftModelView : public CViewBase { public: diff --git a/src/blackgui/views/aircraftview.h b/src/blackgui/views/aircraftview.h index 805e10027..3e80d0124 100644 --- a/src/blackgui/views/aircraftview.h +++ b/src/blackgui/views/aircraftview.h @@ -20,7 +20,7 @@ namespace BlackGui namespace Views { //! Aircrafts view - class CAircraftView : public CViewBase + class CAircraftView : public CViewBase { public: diff --git a/src/blackgui/views/airportview.h b/src/blackgui/views/airportview.h index 173be7414..adcab540d 100644 --- a/src/blackgui/views/airportview.h +++ b/src/blackgui/views/airportview.h @@ -20,7 +20,7 @@ namespace BlackGui namespace Views { //! Airports view - class CAirportView : public CViewBase + class CAirportView : public CViewBase { public: diff --git a/src/blackgui/views/atcstationview.cpp b/src/blackgui/views/atcstationview.cpp index d62040c02..5d7d9e070 100644 --- a/src/blackgui/views/atcstationview.cpp +++ b/src/blackgui/views/atcstationview.cpp @@ -8,10 +8,12 @@ */ #include "atcstationview.h" +#include "blackmisc/avatcstationlist.h" #include "blackmisc/testing.h" #include 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 diff --git a/src/blackgui/views/atcstationview.h b/src/blackgui/views/atcstationview.h index a59a3e2de..1f5a3da3e 100644 --- a/src/blackgui/views/atcstationview.h +++ b/src/blackgui/views/atcstationview.h @@ -21,7 +21,7 @@ namespace BlackGui namespace Views { //! ATC stations view - class CAtcStationView : public CViewBase + class CAtcStationView : public CViewBase { 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(); }; } } diff --git a/src/blackgui/views/clientview.h b/src/blackgui/views/clientview.h index 9f620ef5b..6325bc7a3 100644 --- a/src/blackgui/views/clientview.h +++ b/src/blackgui/views/clientview.h @@ -20,7 +20,7 @@ namespace BlackGui namespace Views { //! Client view - class CClientView : public CViewBase + class CClientView : public CViewBase { public: //! Constructor diff --git a/src/blackgui/views/keyboardkeyview.h b/src/blackgui/views/keyboardkeyview.h index 7d5fafd25..298847dd2 100644 --- a/src/blackgui/views/keyboardkeyview.h +++ b/src/blackgui/views/keyboardkeyview.h @@ -20,7 +20,7 @@ namespace BlackGui namespace Views { //! Keyboard key view - class CKeyboardKeyView : public CViewBase + class CKeyboardKeyView : public CViewBase { public: diff --git a/src/blackgui/views/namevariantpairview.h b/src/blackgui/views/namevariantpairview.h index 370433c8c..911f61185 100644 --- a/src/blackgui/views/namevariantpairview.h +++ b/src/blackgui/views/namevariantpairview.h @@ -20,7 +20,7 @@ namespace BlackGui namespace Views { //! User view - class CNameVariantPairView : public CViewBase + class CNameVariantPairView : public CViewBase { public: diff --git a/src/blackgui/views/serverview.h b/src/blackgui/views/serverview.h index 280dc3884..6f78c466f 100644 --- a/src/blackgui/views/serverview.h +++ b/src/blackgui/views/serverview.h @@ -20,7 +20,7 @@ namespace BlackGui namespace Views { //! Network servers - class CServerView : public CViewBase + class CServerView : public CViewBase { public: diff --git a/src/blackgui/views/statusmessageview.h b/src/blackgui/views/statusmessageview.h index 147197c68..7013bc62f 100644 --- a/src/blackgui/views/statusmessageview.h +++ b/src/blackgui/views/statusmessageview.h @@ -20,7 +20,7 @@ namespace BlackGui namespace Views { //! Status message view - class CStatusMessageView : public CViewBase + class CStatusMessageView : public CViewBase { public: diff --git a/src/blackgui/views/userview.h b/src/blackgui/views/userview.h index 3e7da9ec2..24e8765d2 100644 --- a/src/blackgui/views/userview.h +++ b/src/blackgui/views/userview.h @@ -20,7 +20,7 @@ namespace BlackGui namespace Views { //! User view - class CUserView : public CViewBase + class CUserView : public CViewBase { public: diff --git a/src/blackgui/views/viewbase.cpp b/src/blackgui/views/viewbase.cpp index 3d566c841..a0e8c82e8 100644 --- a/src/blackgui/views/viewbase.cpp +++ b/src/blackgui/views/viewbase.cpp @@ -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 int CViewBase::updateContainer(const ContainerType &container, bool sort, bool resize) + template int CViewBase::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 BlackMisc::CWorker *CViewBase::updateContainerAsync(const ContainerType &container, bool sort, bool resize) + template BlackMisc::CWorker *CViewBase::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 void CViewBase::updateContainerMaybeAsync(const ContainerType &container, bool sort, bool resize) + template void CViewBase::updateContainerMaybeAsync(const ContainerType &container, bool sort, bool resize) { if (container.size() > asyncRowsCountThreshold && sort) { @@ -188,25 +197,37 @@ namespace BlackGui } } - template int CViewBase::rowCount() const + template ContainerType CViewBase::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 int CViewBase::rowCount() const { Q_ASSERT(this->m_model); return this->m_model->rowCount(); } - template int CViewBase::columnCount() const + template int CViewBase::columnCount() const { Q_ASSERT(this->m_model); return this->m_model->columnCount(QModelIndex()); } - template bool CViewBase::isEmpty() const + template bool CViewBase::isEmpty() const { Q_ASSERT(this->m_model); return this->m_model->rowCount() < 1; } - template void CViewBase::setObjectName(const QString &name) + template void CViewBase::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 void CViewBase::setSortIndicator() + template void CViewBase::setSortIndicator() { if (this->m_model->hasValidSortColumn()) { @@ -226,7 +247,7 @@ namespace BlackGui } } - template void CViewBase::standardInit(ModelClass *model) + template void CViewBase::standardInit(ModelClass *model) { Q_ASSERT(model || this->m_model); if (model) @@ -239,7 +260,7 @@ namespace BlackGui this->setSortIndicator(); } - template void CViewBase::performResizeToContents() + template void CViewBase::performResizeToContents() { // small set or large set? if (this->performResizing()) @@ -252,7 +273,7 @@ namespace BlackGui } } - template int CViewBase::performUpdateContainer(const BlackMisc::CVariant &variant, bool sort, bool resize) + template int CViewBase::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; - template class CViewBase; - template class CViewBase; - template class CViewBase; - template class CViewBase; - template class CViewBase; - template class CViewBase; - template class CViewBase; - template class CViewBase; - template class CViewBase; + template class CViewBase; + template class CViewBase; + template class CViewBase; + template class CViewBase; + template class CViewBase; + template class CViewBase; + template class CViewBase; + template class CViewBase; + template class CViewBase; + template class CViewBase; } // namespace } // namespace diff --git a/src/blackgui/views/viewbase.h b/src/blackgui/views/viewbase.h index 76a0f83e4..57f27e522 100644 --- a/src/blackgui/views/viewbase.h +++ b/src/blackgui/views/viewbase.h @@ -20,6 +20,7 @@ #include #include #include +#include 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 CViewBase : public CViewBaseNonTemplate + template class CViewBase : public CViewBaseNonTemplate { public: @@ -166,7 +173,7 @@ namespace BlackGui void updateContainerMaybeAsync(const ContainerType &container, bool sort = true, bool performResizing = true); //! Insert - template 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 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; diff --git a/src/blackmisc/aviocomsystem.h b/src/blackmisc/aviocomsystem.h index 0b7642d45..d4297e3f6 100644 --- a/src/blackmisc/aviocomsystem.h +++ b/src/blackmisc/aviocomsystem.h @@ -30,9 +30,7 @@ namespace BlackMisc namespace Aviation { - /*! - * COM system (aka "radio") - */ + //! COM system (aka "radio") class CComSystem : public CValueObjectStdTuple> { 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)