diff --git a/src/blackgui/models/listmodelfilter.cpp b/src/blackgui/models/listmodelfilter.cpp deleted file mode 100644 index f06a05dfc..000000000 --- a/src/blackgui/models/listmodelfilter.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2015 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "listmodelfilter.h" -#include "blackmisc/simulation/aircraftmodellist.h" - -namespace BlackGui -{ - namespace Models - { - template - bool IModelFilter::stringMatchesFilterExpression(const QString &value, const QString &filter, Qt::CaseSensitivity cs) const - { - QString v = value.trimmed(); - QString f = filter.trimmed(); - - if (v.isEmpty() && f.isEmpty()) { return true; } - if (v.isEmpty()) { return false; } - - // no wildcard, just string matching - if (!filter.contains('*')) - { - return (v.indexOf(f, 0, cs) == 0) && - (v.length() == f.length()); - } - - const QString filterNoWildcard = stripWildcard(f); - - // included? - if (f.startsWith('*') && f.endsWith('*')) - { - return v.contains(filterNoWildcard, cs); - } - - // starting with - if (f.startsWith('*')) - { - return v.endsWith(filterNoWildcard, cs); - } - - if (f.endsWith('*')) - { - return v.startsWith(filterNoWildcard, cs); - } - - // should never happen - Q_ASSERT(false); - return false; - } - - template - QString IModelFilter::stripWildcard(const QString &value) const - { - QString sw(value); - return sw.remove('*'); - } - - // Forward instantiations - template class IModelFilter; - - } // namespace -} // namespace diff --git a/src/blackgui/models/listmodelfilter.h b/src/blackgui/models/listmodelfilter.h deleted file mode 100644 index 8e6dbeab6..000000000 --- a/src/blackgui/models/listmodelfilter.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2015 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKGUI_LISTMODELFILTER_H -#define BLACKGUI_LISTMODELFILTER_H - -#include "blackgui/blackguiexport.h" -#include - -namespace BlackGui -{ - namespace Models - { - //! Model filter interface - template class IModelFilter - { - - public: - //! Destructor - virtual ~IModelFilter() {} - - //! Used container data - virtual ContainerType filter(const ContainerType &container) const = 0; - - //! Anything to do? - virtual bool isValid() const = 0; - - protected: - - //! Standard string search supporting wildcard at begin and end: "*xyz", "abc*" - bool stringMatchesFilterExpression(const QString &value, const QString &filter, Qt::CaseSensitivity cs = Qt::CaseInsensitive) const; - - //! Remove the * wildcards - QString stripWildcard(const QString &value) const; - - }; - - } // namespace -} // namespace -#endif // guard diff --git a/src/blackgui/views/aircraftmodelfilterform.cpp b/src/blackgui/views/aircraftmodelfilterform.cpp deleted file mode 100644 index 3de254a80..000000000 --- a/src/blackgui/views/aircraftmodelfilterform.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "aircraftmodelfilterform.h" -#include "ui_aircraftmodelfilterform.h" - -using namespace BlackGui::Models; - -namespace BlackGui -{ - namespace Views - { - - CAircraftModelFilterForm::CAircraftModelFilterForm(QWidget *parent) : - CFilterDialog(parent), - ui(new Ui::CAircraftModelFilterForm) - { - ui->setupUi(this); - this->setWindowTitle("Filter models"); - } - - CAircraftModelFilterForm::~CAircraftModelFilterForm() - { } - - std::unique_ptr CAircraftModelFilterForm::getFilter() const - { - QString model(this->ui->le_ModelString->text()); - QString desc(this->ui->le_ModelDescription->text()); - return std::unique_ptr(new CAircraftModelFilter(model, desc)); - } - - } // namespace -} // namespace diff --git a/src/blackgui/views/aircraftmodelfilterform.h b/src/blackgui/views/aircraftmodelfilterform.h deleted file mode 100644 index 97159fe3a..000000000 --- a/src/blackgui/views/aircraftmodelfilterform.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKGUI_AIRCRAFTMODELFILTERFORM_H -#define BLACKGUI_AIRCRAFTMODELFILTERFORM_H - -#include "blackgui/blackguiexport.h" -#include "filterdialog.h" -#include "blackgui/models/aircraftmodelfilter.h" -#include -#include -#include -#include - -namespace Ui { class CAircraftModelFilterForm; } - -namespace BlackGui -{ - namespace Views - { - //! Form for a aircraft model filter - class BLACKGUI_EXPORT CAircraftModelFilterForm : public CFilterDialog - { - Q_OBJECT - - public: - //! Constructor - explicit CAircraftModelFilterForm(QWidget *parent = nullptr); - - //! Destructor - ~CAircraftModelFilterForm(); - - //! Get created filter - std::unique_ptr getFilter() const; - - private: - QScopedPointer ui; - }; - - } // namespace -} // namespace - -#endif // guard diff --git a/src/blackgui/views/aircraftmodelfilterform.ui b/src/blackgui/views/aircraftmodelfilterform.ui deleted file mode 100644 index 637cb30f8..000000000 --- a/src/blackgui/views/aircraftmodelfilterform.ui +++ /dev/null @@ -1,91 +0,0 @@ - - - CAircraftModelFilterForm - - - - 0 - 0 - 336 - 95 - - - - Dialog - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Model - - - - - - - - - - Description - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - bb_ButtonBox - accepted() - CAircraftModelFilterForm - accept() - - - 248 - 254 - - - 157 - 274 - - - - - bb_ButtonBox - rejected() - CAircraftModelFilterForm - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/blackgui/views/filterdialog.cpp b/src/blackgui/views/filterdialog.cpp deleted file mode 100644 index 4a2defa35..000000000 --- a/src/blackgui/views/filterdialog.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "filterdialog.h" -#include "blackgui/stylesheetutility.h" - -namespace BlackGui -{ - namespace Views - { - - CFilterDialog::CFilterDialog(QWidget *parent) : QDialog(parent, Qt::Tool) - { - this->setWindowTitle("Filter dialog"); - ps_onStyleSheetChanged(); - connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CFilterDialog::ps_onStyleSheetChanged); - } - - CFilterDialog::~CFilterDialog() - { } - - void CFilterDialog::ps_onStyleSheetChanged() - { - const QString qss = CStyleSheetUtility::instance().style(CStyleSheetUtility::fileNameFilterDialog()); - this->setStyleSheet(qss); - } - - } // namespace -} // namespace - - diff --git a/src/blackgui/views/filterdialog.h b/src/blackgui/views/filterdialog.h deleted file mode 100644 index 80fa5c3c0..000000000 --- a/src/blackgui/views/filterdialog.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKGUI_FILTERDIALOG_H -#define BLACKGUI_FILTERDIALOG_H - -#include "blackgui/blackguiexport.h" -#include - -namespace BlackGui -{ - namespace Views - { - //! Base for filter dialog - class BLACKGUI_EXPORT CFilterDialog : public QDialog - { - public: - //! Constructor - CFilterDialog(QWidget *parent = nullptr); - - //! Destructor - virtual ~CFilterDialog(); - - private slots: - //! Stylesheet changed - void ps_onStyleSheetChanged(); - }; - - } // namespace -} // namespace - -#endif // guard diff --git a/src/blackmisc/aviation/aircraft.cpp b/src/blackmisc/aviation/aircraft.cpp deleted file mode 100644 index 1d5a44059..000000000 --- a/src/blackmisc/aviation/aircraft.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "blackmisc/aviation/aircraft.h" -#include "blackmisc/blackmiscfreefunctions.h" -#include "blackmisc/pq/constants.h" -#include "blackmisc/icon.h" -#include "blackmisc/propertyindex.h" - -using namespace BlackMisc::PhysicalQuantities; - -namespace BlackMisc -{ - namespace Aviation - { - - CAircraft::CAircraft(const CCallsign &callsign, const Network::CUser &user, const CAircraftSituation &situation) - : m_callsign(callsign), m_pilot(user), m_situation(situation) - { - // sync callsigns - this->m_callsign.setTypeHint(CCallsign::Aircraft); - if (!callsign.isEmpty()) - { - this->setCallsign(callsign); - } - else if (!user.getCallsign().isEmpty()) - { - this->setCallsign(user.getCallsign()); - } - } - - void CAircraft::setCallsign(const CCallsign &callsign) - { - this->m_callsign = callsign; - this->m_callsign.setTypeHint(CCallsign::Aircraft); - this->m_pilot.setCallsign(this->m_callsign); - this->m_situation.setCallsign(this->m_callsign); - } - - QString CAircraft::convertToQString(bool i18n) const - { - QString s(this->m_callsign.toQString(i18n)); - s.append(" ").append(this->m_pilot.toQString(i18n)); - s.append(" ").append(this->m_situation.toQString(i18n)); - s.append(" ").append(this->m_com1system.toQString(i18n)); - s.append(" ").append(this->m_com2system.toQString(i18n)); - s.append(" ").append(this->m_transponder.toQString(i18n)); - s.append(" ").append(this->m_parts.toQString(i18n)); - return s; - } - - void CAircraft::setCockpit(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder) - { - this->setCom1System(com1); - this->setCom2System(com2); - this->setTransponder(transponder); - } - - void CAircraft::setCockpit(const CComSystem &com1, const CComSystem &com2, int transponderCode, CTransponder::TransponderMode transponderMode) - { - this->setCom1System(com1); - this->setCom2System(com2); - this->m_transponder.setTransponderCode(transponderCode); - this->m_transponder.setTransponderMode(transponderMode); - } - - bool CAircraft::hasChangedCockpitData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder) const - { - return this->getCom1System() != com1 || this->getCom2System() != com2 || this->getTransponder() != transponder; - } - - bool CAircraft::hasSameComData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder) - { - return this->getCom1System() == com1 && this->getCom2System() == com2 && this->getTransponder() == transponder; - } - - bool CAircraft::isValidForLogin() const - { - if (this->m_callsign.asString().isEmpty()) { return false; } - if (!this->m_pilot.isValid()) { return false; } - return true; - } - - void CAircraft::setSituation(const CAircraftSituation &situation) - { - m_situation = situation; - m_situation.setCallsign(this->getCallsign()); - } - - void CAircraft::setPilot(const Network::CUser &user) - { - m_pilot = user; - this->m_pilot.setCallsign(this->m_callsign); - } - - const CComSystem CAircraft::getComSystem(CComSystem::ComUnit unit) const - { - switch (unit) - { - case CComSystem::Com1: return this->getCom1System(); - case CComSystem::Com2: return this->getCom2System(); - default: break; - } - Q_ASSERT(false); - return CComSystem(); // avoid warning - } - - void CAircraft::setComSystem(const CComSystem &com, CComSystem::ComUnit unit) - { - switch (unit) - { - case CComSystem::Com1: this->setCom1System(com); break; - case CComSystem::Com2: this->setCom2System(com); break; - } - } - - bool CAircraft::setCom1ActiveFrequency(const CFrequency &frequency) - { - if (!CComSystem::isValidComFrequency(frequency)) { return false; } - this->m_com1system.setFrequencyActive(frequency); - return true; - } - - bool CAircraft::setCom2ActiveFrequency(const CFrequency &frequency) - { - if (!CComSystem::isValidComFrequency(frequency)) { return false; } - this->m_com2system.setFrequencyActive(frequency); - return true; - } - - bool CAircraft::setComActiveFrequency(const CFrequency &frequency, CComSystem::ComUnit unit) - { - if (!CComSystem::isValidComFrequency(frequency)) { return false; } - switch (unit) - { - case CComSystem::Com1: return this->setCom1ActiveFrequency(frequency); - case CComSystem::Com2: return this->setCom2ActiveFrequency(frequency); - } - return false; - } - - void CAircraft::initComSystems() - { - CComSystem com1("COM1", CPhysicalQuantitiesConstants::FrequencyUnicom(), CPhysicalQuantitiesConstants::FrequencyUnicom()); - CComSystem com2("COM2", CPhysicalQuantitiesConstants::FrequencyUnicom(), CPhysicalQuantitiesConstants::FrequencyUnicom()); - this->setCom1System(com1); - this->setCom2System(com2); - } - - void CAircraft::initTransponder() - { - CTransponder xpdr(7000, CTransponder::StateStandby); - this->setTransponder(xpdr); - } - - CAircraftLights CAircraft::getLights() const - { - return m_parts.getLights(); - } - - void CAircraft::setParts(const CAircraftParts &parts) - { - m_parts = parts; - } - - void CAircraft::setLights(CAircraftLights &lights) - { - m_parts.setLights(lights); - } - - void CAircraft::setAllLightsOn() - { - m_parts.setAllLightsOn(); - } - - void CAircraft::setAllLightsOff() - { - m_parts.setAllLightsOff(); - } - - bool CAircraft::isVtol() const - { - return m_icao.isVtol(); - } - - CVariant CAircraft::propertyByIndex(const BlackMisc::CPropertyIndex &index) const - { - if (index.isMyself()) { return CVariant::from(*this); } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexCallsign: - return this->m_callsign.propertyByIndex(index.copyFrontRemoved()); - case IndexPilot: - return this->m_pilot.propertyByIndex(index.copyFrontRemoved()); - case IndexDistanceToOwnAircraft: - return this->m_distanceToOwnAircraft.propertyByIndex(index.copyFrontRemoved()); - case IndexCom1System: - return this->m_com1system.propertyByIndex(index.copyFrontRemoved()); - case IndexCom2System: - return this->m_com2system.propertyByIndex(index.copyFrontRemoved()); - case IndexTransponder: - return this->m_transponder.propertyByIndex(index.copyFrontRemoved()); - case IndexSituation: - return this->m_situation.propertyByIndex(index.copyFrontRemoved()); - case IndexIcao: - return this->m_icao.propertyByIndex(index.copyFrontRemoved()); - case IndexLivery: - return this->m_livery.propertyByIndex(index.copyFrontRemoved()); - case IndexParts: - return this->m_parts.propertyByIndex(index.copyFrontRemoved()); - case IndexIsVtol: - return CVariant::fromValue(this->isVtol()); - default: - return (ICoordinateGeodetic::canHandleIndex(index)) ? - ICoordinateGeodetic::propertyByIndex(index) : - CValueObject::propertyByIndex(index); - } - } - - void CAircraft::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) - { - if (index.isMyself()) { (*this) = variant.to(); return; } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexCallsign: - this->m_callsign.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexPilot: - this->m_pilot.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexDistanceToOwnAircraft: - this->m_distanceToOwnAircraft.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexCom1System: - this->m_com1system.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexCom2System: - this->m_com2system.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexTransponder: - this->m_transponder.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexIcao: - this->m_icao.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexLivery: - this->m_livery.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexSituation: - this->m_situation.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexParts: - this->m_parts.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - default: - CValueObject::setPropertyByIndex(variant, index); - break; - } - } - - } // namespace -} // namespace diff --git a/src/blackmisc/aviation/aircraft.h b/src/blackmisc/aviation/aircraft.h deleted file mode 100644 index 506da56fc..000000000 --- a/src/blackmisc/aviation/aircraft.h +++ /dev/null @@ -1,321 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKMISC_AVIATION_AIRCRAFT_H -#define BLACKMISC_AVIATION_AIRCRAFT_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/network/user.h" -#include "blackmisc/aviation/aircraftsituation.h" -#include "blackmisc/aviation/aircrafticaodata.h" -#include "blackmisc/aviation/callsign.h" -#include "blackmisc/aviation/selcal.h" -#include "blackmisc/aviation/transponder.h" -#include "blackmisc/aviation/comsystem.h" -#include "blackmisc/aviation/aircraftparts.h" -#include "blackmisc/aviation/livery.h" -#include "blackmisc/valueobject.h" -#include "blackmisc/namevariantpairlist.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/blackmiscfreefunctions.h" - -namespace BlackMisc -{ - namespace Aviation - { - //! Value object encapsulating information of an aircraft - class BLACKMISC_EXPORT CAircraft : - public CValueObject, - public BlackMisc::Geo::ICoordinateWithRelativePosition - { - public: - //! Properties by index - enum ColumnIndex - { - IndexCallsign = BlackMisc::CPropertyIndex::GlobalIndexCAircraft, - IndexPilot, - IndexDistanceToOwnAircraft, - IndexCom1System, - IndexCom2System, - IndexTransponder, - IndexSituation, - IndexIcao, - IndexLivery, - IndexParts, - IndexIsVtol - }; - - //! Default constructor. - CAircraft() {} - - //! Constructor. - CAircraft(const CCallsign &callsign, const BlackMisc::Network::CUser &user, const CAircraftSituation &situation); - - //! \copydoc CValueObject::toIcon() - BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); } - - //! Get callsign. - const CCallsign &getCallsign() const { return m_callsign; } - - //! Get callsign. - QString getCallsignAsString() const { return m_callsign.asString(); } - - //! Set callsign - virtual void setCallsign(const CCallsign &callsign); - - //! Get situation. - const CAircraftSituation &getSituation() const { return m_situation; } - - //! Set situation. - void setSituation(const CAircraftSituation &situation); - - //! Get user - const BlackMisc::Network::CUser &getPilot() const { return m_pilot; } - - //! Get user's real name - QString getPilotRealname() const { return m_pilot.getRealName(); } - - //! Get user's real id - QString getPilotId() { return m_pilot.getId(); } - - //! Set pilot (user) - virtual void setPilot(const BlackMisc::Network::CUser &user); - - //! Get ICAO info - const CAircraftIcaoData &getIcaoInfo() const { return m_icao; } - - //! Set ICAO info - virtual void setIcaoInfo(const CAircraftIcaoData &icao) { m_icao = icao; } - - //! Get livery - const BlackMisc::Aviation::CLivery &getLivery() const { return m_livery; } - - //! Livery - virtual void setLivery(const BlackMisc::Aviation::CLivery &livery) { this->m_livery = livery; } - - //! Set aircraft ICAO designator - virtual void setAircraftIcaoDesignator(const QString &designator) { m_icao.setAircraftDesignator(designator); } - - //! Has valid realname? - bool hasValidRealName() const { return this->m_pilot.hasValidRealName(); } - - //! Has valid id? - bool hasValidId() const { return this->m_pilot.hasValidId(); } - - //! Valid designator? - bool hasValidAircraftDesignator() const { return this->m_icao.hasAircraftDesignator(); } - - //! Valid designators? - bool hasValidAircraftAndAirlineDesignator() const { return this->m_icao.hasAircraftAndAirlineDesignator(); } - - //! Valid callsign - bool hasValidCallsign() const { return CCallsign::isValidCallsign(this->getCallsign().asString()); } - - //! Get position - BlackMisc::Geo::CCoordinateGeodetic getPosition() const { return this->m_situation.getPosition(); } - - //! Set position - void setPosition(const BlackMisc::Geo::CCoordinateGeodetic &position) { this->m_situation.setPosition(position); } - - //! Get altitude - const BlackMisc::Aviation::CAltitude &getAltitude() const { return this->m_situation.getAltitude(); } - - //! Set altitude - void setAltitude(const BlackMisc::Aviation::CAltitude &altitude) { this->m_situation.setAltitude(altitude); } - - //! Get groundspeed - const BlackMisc::PhysicalQuantities::CSpeed &getGroundSpeed() const { return this->m_situation.getGroundSpeed(); } - - //! \copydoc ICoordinateGeodetic::latitude - virtual const BlackMisc::Geo::CLatitude &latitude() const override { return this->m_situation.latitude(); } - - //! \copydoc ICoordinateGeodetic::longitude - virtual const BlackMisc::Geo::CLongitude &longitude() const override { return this->m_situation.longitude(); } - - //! \copydoc ICoordinateGeodetic::geodeticHeight - //! \remarks this should be used for elevation as depicted here: http://en.wikipedia.org/wiki/Altitude#mediaviewer/File:Vertical_distances.svg - const BlackMisc::PhysicalQuantities::CLength &geodeticHeight() const override { return this->m_situation.geodeticHeight(); } - - //! Elevation - //! \sa geodeticHeight - const BlackMisc::PhysicalQuantities::CLength getElevation() const { return this->geodeticHeight(); } - - //! Elevation - //! \sa setGeodeticHeight - void setElevation(const BlackMisc::PhysicalQuantities::CLength &elevation) { return this->m_situation.setElevation(elevation); } - - //! Get heading - const BlackMisc::Aviation::CHeading &getHeading() const { return this->m_situation.getHeading(); } - - //! Get pitch - const BlackMisc::PhysicalQuantities::CAngle &getPitch() const { return this->m_situation.getPitch(); } - - //! Get bank - const BlackMisc::PhysicalQuantities::CAngle &getBank() const { return this->m_situation.getBank(); } - - //! Get COM1 system - const CComSystem &getCom1System() const { return this->m_com1system; } - - //! Get COM2 system - const CComSystem &getCom2System() const { return this->m_com2system; } - - //! Get COM unit - const CComSystem getComSystem(CComSystem::ComUnit unit) const; - - //! Set COM unit - void setComSystem(const CComSystem &com, CComSystem::ComUnit unit); - - //! Set COM1 system - void setCom1System(const CComSystem &comSystem) { this->m_com1system = comSystem; } - - //! Set COM2 system - void setCom2System(const CComSystem &comSystem) { this->m_com2system = comSystem; } - - //! Set COM1 frequency - bool setCom1ActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency); - - //! Set COM2 frequency - bool setCom2ActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency); - - //! Set COM frequency - bool setComActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, CComSystem::ComUnit unit); - - //! Given SELCAL selected? - bool isSelcalSelected(const BlackMisc::Aviation::CSelcal &selcal) const { return this->m_selcal == selcal; } - - //! Valid SELCAL? - bool hasValidSelcal() const { return this->m_selcal.isValid(); } - - //! SELCAL - const CSelcal getSelcal() const { return m_selcal; } - - //! Cockpit data - void setCockpit(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder); - - //! Cockpit data - void setCockpit(const CComSystem &com1, const CComSystem &com2, int transponderCode, CTransponder::TransponderMode mode); - - //! Own SELCAL code - void setSelcal(const BlackMisc::Aviation::CSelcal &selcal) { this->m_selcal = selcal; } - - //! Changed cockpit data? - bool hasChangedCockpitData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder) const; - - //! Identical COM system? - bool hasSameComData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder); - - //! Is any (COM1/2) active frequency within 8.3383kHz channel? - bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const - { - return this->m_com1system.isActiveFrequencyWithin8_33kHzChannel(comFrequency) || - this->m_com2system.isActiveFrequencyWithin8_33kHzChannel(comFrequency); - } - - //! Is any (COM1/2) active frequency within 25kHz channel? - bool isActiveFrequencyWithin25kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const - { - return this->m_com1system.isActiveFrequencyWithin25kHzChannel(comFrequency) || - this->m_com2system.isActiveFrequencyWithin25kHzChannel(comFrequency); - } - - //! Get transponder - const BlackMisc::Aviation::CTransponder &getTransponder() const { return this->m_transponder; } - - //! Set transponder - void setTransponder(const CTransponder &transponder) { this->m_transponder = transponder; } - - //! Set transponder mode - void setTransponderMode(CTransponder::TransponderMode mode) { this->m_transponder.setTransponderMode(mode); } - - //! Set transponder code - void setTransponderCode(int code) { this->m_transponder.setTransponderCode(code); } - - //! Get transponder code - QString getTransponderCodeFormatted() const { return this->m_transponder.getTransponderCodeFormatted(); } - - //! Get transponder code - qint32 getTransponderCode() const { return this->m_transponder.getTransponderCode(); } - - //! Get transponder mode - BlackMisc::Aviation::CTransponder::TransponderMode getTransponderMode() const { return this->m_transponder.getTransponderMode(); } - - //! Is valid for login? - bool isValidForLogin() const; - - //! Meaningful default settings for COM Systems - void initComSystems(); - - //! Meaningful default settings for Transponder - void initTransponder(); - - //! Get aircraft parts - const BlackMisc::Aviation::CAircraftParts &getParts() const { return m_parts; } - - //! Get aircraft parts - CAircraftLights getLights() const; - - //! Set aircraft parts - void setParts(const BlackMisc::Aviation::CAircraftParts &parts); - - //! Set aircraft lights - void setLights(BlackMisc::Aviation::CAircraftLights &lights); - - //! Set aircraft lights on - void setAllLightsOn(); - - //! Set aircraft lights off - void setAllLightsOff(); - - //! VTOL aircraft? - bool isVtol() const; - - //! \copydoc CValueObject::propertyByIndex - CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const; - - //! \copydoc CValueObject::setPropertyByIndex - void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index); - - //! \copydoc CValueObject::convertToQString() - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CAircraft) - CCallsign m_callsign; - BlackMisc::Network::CUser m_pilot; - CAircraftSituation m_situation; - CComSystem m_com1system; - CComSystem m_com2system; - CTransponder m_transponder; - CAircraftParts m_parts; - CSelcal m_selcal; - CAircraftIcaoData m_icao; - CLivery m_livery; - }; - } // namespace -} // namespace - -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraft, ( - o.m_callsign, - o.m_pilot, - o.m_situation, - o.m_com1system, - o.m_com2system, - o.m_transponder, - o.m_parts, - o.m_icao, - o.m_livery, - o.m_distanceToOwnAircraft, - o.m_bearingToOwnAircraft - )) - -Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraft) - -#endif // guard diff --git a/src/blackmisc/aviation/aircrafticaodata.cpp b/src/blackmisc/aviation/aircrafticaodata.cpp deleted file mode 100644 index 4e561c553..000000000 --- a/src/blackmisc/aviation/aircrafticaodata.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "blackmisc/aviation/aircrafticaodata.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/blackmiscfreefunctions.h" -#include "blackmisc/variant.h" - -#include -#include - -namespace BlackMisc -{ - namespace Aviation - { - - CAircraftIcaoData::CAircraftIcaoData(const QString &aircraftIcao, const QString &airlineIcao) - : m_aircraftIcao(aircraftIcao), m_airlineIcao(airlineIcao) - {} - - CAircraftIcaoData::CAircraftIcaoData(const CAircraftIcaoCode &aircraftIcao, const CAirlineIcaoCode &airlineIcao) - : m_aircraftIcao(aircraftIcao), m_airlineIcao(airlineIcao) - {} - - QString CAircraftIcaoData::convertToQString(bool i18n) const - { - Q_UNUSED(i18n); - QString s(this->m_aircraftIcao.toQString(i18n)); - s.append(" ").append(this->m_airlineIcao.toQString(i18n)); - return s; - } - - QString CAircraftIcaoData::asString() const - { - if (!this->hasAircraftDesignator()) { return ""; } - QString s(this->getAircraftDesignator()); - if (this->hasAirlineDesignator()) - { - s.append(" (").append(this->getAirlineDesignator()).append(")"); - return s; - } - return s; - } - - void CAircraftIcaoData::updateMissingParts(const CAircraftIcaoData &icao) - { - if (!this->hasAircraftDesignator()) { this->setAircraftDesignator(icao.getAircraftDesignator()); } - if (!this->hasAirlineDesignator()) { this->setAirlineDesignator(icao.getAirlineDesignator()); } - if (!this->hasAircraftCombinedType()) { this->setAircraftCombinedType(icao.getAircraftCombinedType()); } - } - - bool CAircraftIcaoData::matchesWildcardIcao(const CAircraftIcaoData &otherIcao) const - { - if ((*this) == otherIcao) { return true; } - if (otherIcao.hasAircraftDesignator() && otherIcao.getAircraftDesignator() != this->getAircraftDesignator()) { return false; } - if (otherIcao.hasAirlineDesignator() && otherIcao.getAirlineDesignator() != this->getAirlineDesignator()) { return false; } - if (otherIcao.hasAircraftCombinedType() && otherIcao.getAircraftCombinedType() != this->getAircraftCombinedType()) { return false; } - return true; - } - - CVariant CAircraftIcaoData::propertyByIndex(const BlackMisc::CPropertyIndex &index) const - { - if (index.isMyself()) { return CVariant::from(*this); } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexAircraftIcao: - return CVariant::fromValue(this->m_aircraftIcao); - case IndexAirlineIcao: - return CVariant::fromValue(this->m_airlineIcao); - case IndexAsString: - return CVariant::fromValue(this->asString()); - default: - return CValueObject::propertyByIndex(index); - } - } - - void CAircraftIcaoData::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) - { - if (index.isMyself()) { (*this) = variant.to(); return; } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexAircraftIcao: - this->m_aircraftIcao.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexAirlineIcao: - this->m_airlineIcao.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - default: - CValueObject::setPropertyByIndex(variant, index); - break; - } - } - - } // namespace -} // namespace diff --git a/src/blackmisc/aviation/aircrafticaodata.h b/src/blackmisc/aviation/aircrafticaodata.h deleted file mode 100644 index 2e4a75487..000000000 --- a/src/blackmisc/aviation/aircrafticaodata.h +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKMISC_AVIATION_AIRCRAFTICAODATA_H -#define BLACKMISC_AVIATION_AIRCRAFTICAODATA_H - -#include "blackmisc/aviation/aircrafticaocode.h" -#include "blackmisc/aviation/airlineicaocode.h" -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/valueobject.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/blackmiscfreefunctions.h" - -namespace BlackMisc -{ - namespace Aviation - { - //! Value object for ICAO classification (airline ICAO, aircraft ICAO) - class BLACKMISC_EXPORT CAircraftIcaoData : public CValueObject - { - public: - //! Properties by index - enum ColumnIndex - { - IndexAircraftIcao = BlackMisc::CPropertyIndex::GlobalIndexCAircraftIcaoData, - IndexAirlineIcao, - IndexAsString, - }; - - //! Default constructor. - CAircraftIcaoData() = default; - - //! Constructor. - //! \param aircraftIcao "B737" - //! \param airlineIcao "DLH" - CAircraftIcaoData(const QString &aircraftIcao, const QString &airlineIcao = ""); - - //! Constructor - CAircraftIcaoData(const CAircraftIcaoCode &aircraftIcao, const CAirlineIcaoCode &airlineIcao); - - //! Get ICAO designator, e.g. "B737" - const QString &getAircraftDesignator() const { return m_aircraftIcao.getDesignator(); } - - //! Get aircraft ICAO object - const BlackMisc::Aviation::CAircraftIcaoCode &getAircraftIcaoCode() const { return this->m_aircraftIcao; } - - //! Set ICAO designator, e.g. "B737" - void setAircraftDesignator(const QString &icaoDesignator) { this->m_aircraftIcao.setDesignator(icaoDesignator); } - - //! Aircraft designator? - bool hasAircraftDesignator() const { return this->m_aircraftIcao.hasDesignator(); } - - //! Has designator and designator is not "ZZZZ" - bool hasKnownAircraftDesignator() const { return (this->m_aircraftIcao.hasKnownDesignator()); } - - //! Get airline, e.g. "DLH" - const QString &getAirlineDesignator() const { return this->m_airlineIcao.getDesignator(); } - - //! Get airline ICAO object - const BlackMisc::Aviation::CAirlineIcaoCode &getAirlineIcaoCode() const { return this->m_airlineIcao; } - - //! Set airline, e.g. "DLH" - void setAirlineDesignator(const QString &icaoDesignator) { this->m_airlineIcao.setDesignator(icaoDesignator); } - - //! Airline available? - bool hasAirlineDesignator() const { return this->m_airlineIcao.hasDesignator(); } - - //! Airline and Aircraft designator? - bool hasAircraftAndAirlineDesignator() const { return this->hasAirlineDesignator() && this->hasAircraftDesignator(); } - - //! Get type, e.g. "L2J" - const QString &getAircraftCombinedType() const { return this->m_aircraftIcao.getCombinedType(); } - - //! Combined type available? - bool hasAircraftCombinedType() const { return this->m_aircraftIcao.hasCombinedType(); } - - //! Get engine type, e.g. "J" - QString getEngineType() const { return this->m_aircraftIcao.getEngineType(); } - - //! As string for GUI representation by index - //! \remarks Different from toQString() - QString asString() const; - - //! Set type - void setAircraftCombinedType(const QString &type) { this->m_aircraftIcao.setCombinedType(type); } - - //! Missing parts from another ICAO object - void updateMissingParts(const CAircraftIcaoData &icao); - - //! Matches wildcard icao object - bool matchesWildcardIcao(const CAircraftIcaoData &otherIcao) const; - - //! Is VTOL aircraft - bool isVtol() const { return m_aircraftIcao.isVtol(); } - - //! \copydoc CValueObject::propertyByIndex - CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const; - - //! \copydoc CValueObject::setPropertyByIndex - void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index); - - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CAircraftIcaoData) - BlackMisc::Aviation::CAircraftIcaoCode m_aircraftIcao; //!< "B737", ... - BlackMisc::Aviation::CAirlineIcaoCode m_airlineIcao; //!< "DLH", ... - }; - } // namespace -} // namespace - -Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftIcaoData) -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraftIcaoData, ( - o.m_aircraftIcao, - o.m_airlineIcao - )) - -#endif // guard diff --git a/src/blackmisc/aviation/aircraftlist.cpp b/src/blackmisc/aviation/aircraftlist.cpp deleted file mode 100644 index c58ba92bd..000000000 --- a/src/blackmisc/aviation/aircraftlist.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "blackmisc/aviation/aircraftlist.h" -#include "blackmisc/network/user.h" -#include "blackmisc/predicates.h" -#include "blackmisc/propertyindexallclasses.h" - -using namespace BlackMisc; -using namespace BlackMisc::PhysicalQuantities; -using namespace BlackMisc::Network; - -namespace BlackMisc -{ - namespace Aviation - { - - CAircraftList::CAircraftList() { } - - CAircraftList::CAircraftList(const CSequence &other) : - CSequence(other) - { } - - CUserList CAircraftList::getPilots() const - { - return this->findBy(Predicates::MemberValid(&CAircraft::getPilot)).transform(Predicates::MemberTransform(&CAircraft::getPilot)); - } - - bool CAircraftList::updateWithVatsimDataFileData(CAircraft &aircraftToBeUpdated) const - { - if (this->isEmpty()) return false; - if (aircraftToBeUpdated.hasValidRealName() && aircraftToBeUpdated.hasValidId() && aircraftToBeUpdated.hasValidAircraftAndAirlineDesignator()) return false; - - CAircraft currentDataFileAircraft = this->findFirstByCallsign(aircraftToBeUpdated.getCallsign()); - if (currentDataFileAircraft.getCallsign().isEmpty()) return false; - - CUser user = aircraftToBeUpdated.getPilot(); - if (!aircraftToBeUpdated.hasValidRealName()) user.setRealName(currentDataFileAircraft.getPilotRealname()); - if (!aircraftToBeUpdated.hasValidId()) user.setId(currentDataFileAircraft.getPilotId()); - aircraftToBeUpdated.setPilot(user); - - CAircraftIcaoData icao = aircraftToBeUpdated.getIcaoInfo(); - CAircraftIcaoData dataFileIcao = currentDataFileAircraft.getIcaoInfo(); - if (!icao.hasAircraftDesignator()) icao.setAircraftDesignator(dataFileIcao.getAircraftDesignator()); - if (!icao.hasAirlineDesignator()) icao.setAirlineDesignator(dataFileIcao.getAirlineDesignator()); - if (!icao.hasAircraftCombinedType()) icao.setAircraftCombinedType(dataFileIcao.getAircraftCombinedType()); - aircraftToBeUpdated.setIcaoInfo(icao); - return true; - } - - } // namespace -} // namespace diff --git a/src/blackmisc/aviation/aircraftlist.h b/src/blackmisc/aviation/aircraftlist.h deleted file mode 100644 index 975ba0820..000000000 --- a/src/blackmisc/aviation/aircraftlist.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKMISC_AVIATION_AIRCRAFTLIST_H -#define BLACKMISC_AVIATION_AIRCRAFTLIST_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/aviation/aircraft.h" -#include "blackmisc/aviation/callsignset.h" -#include "blackmisc/aviation/callsignobjectlist.h" -#include "blackmisc/geo/geoobjectlist.h" -#include "blackmisc/network/userlist.h" -#include "blackmisc/collection.h" -#include "blackmisc/propertyindexvariantmap.h" -#include -#include -#include - -namespace BlackMisc -{ - namespace Aviation - { - //! Value object encapsulating a list of aircraft. - //! \deprecated consider using CSimulatedAircraftList - class BLACKMISC_EXPORT CAircraftList : - public CSequence, - public ICallsignObjectList, - public BlackMisc::Geo::IGeoObjectWithRelativePositionList, - public BlackMisc::Mixin::MetaType - { - public: - BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CAircraftList) - - //! Default constructor. - CAircraftList(); - - //! Construct from a base class object. - CAircraftList(const CSequence &other); - - //! All pilots (with valid data) - BlackMisc::Network::CUserList getPilots() const; - - //! Update aircraft with data from VATSIM data file - //! \remarks The list used ("this") needs to contain the VATSIM data file objects - bool updateWithVatsimDataFileData(CAircraft &aircraftToBeUpdated) const; - - }; - - } //namespace -} // namespace - -Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftList) -Q_DECLARE_METATYPE(BlackMisc::CCollection) -Q_DECLARE_METATYPE(BlackMisc::CSequence) - -#endif //guard diff --git a/src/blackmisc/aviation/blackmiscfreefunctions_avmeta.cpp b/src/blackmisc/aviation/blackmiscfreefunctions_avmeta.cpp index 04fcdf896..545cd996f 100644 --- a/src/blackmisc/aviation/blackmiscfreefunctions_avmeta.cpp +++ b/src/blackmisc/aviation/blackmiscfreefunctions_avmeta.cpp @@ -30,8 +30,6 @@ void BlackMisc::Aviation::registerMetadata() CCallsignSet::registerMetadata(); CAtcStation::registerMetadata(); CAtcStationList::registerMetadata(); - CAircraft::registerMetadata(); - CAircraftList::registerMetadata(); CAirport::registerMetadata(); CAirportList::registerMetadata(); CAirportIcaoCode::registerMetadata(); @@ -39,7 +37,6 @@ void BlackMisc::Aviation::registerMetadata() CAircraftSituationList::registerMetadata(); CAircraftIcaoCode::registerMetadata(); CAircraftIcaoCodeList::registerMetadata(); - CAircraftIcaoData::registerMetadata(); CAirlineIcaoCode::registerMetadata(); CAirlineIcaoCodeList::registerMetadata(); CSelcal::registerMetadata(); diff --git a/src/blackmisc/aviation/callsignobjectlist.cpp b/src/blackmisc/aviation/callsignobjectlist.cpp index 55bcbb16a..ee65fd1ff 100644 --- a/src/blackmisc/aviation/callsignobjectlist.cpp +++ b/src/blackmisc/aviation/callsignobjectlist.cpp @@ -10,7 +10,6 @@ #include "blackmisc/aviation/callsignobjectlist.h" #include "blackmisc/predicates.h" #include "blackmisc/aviation/atcstationlist.h" -#include "blackmisc/aviation/aircraftlist.h" #include "blackmisc/aviation/aircraftsituationlist.h" #include "blackmisc/aviation/aircraftpartslist.h" #include "blackmisc/network/clientlist.h" @@ -201,7 +200,6 @@ namespace BlackMisc // see here for the reason of thess forward instantiations // http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html template class ICallsignObjectList; - template class ICallsignObjectList; template class ICallsignObjectList; template class ICallsignObjectList; template class ICallsignObjectList; diff --git a/src/blackmisc/blackmiscfreefunctions_nwmeta.cpp b/src/blackmisc/blackmiscfreefunctions_nwmeta.cpp index 0fa177f5f..4a8bbf899 100644 --- a/src/blackmisc/blackmiscfreefunctions_nwmeta.cpp +++ b/src/blackmisc/blackmiscfreefunctions_nwmeta.cpp @@ -27,6 +27,4 @@ void BlackMisc::Network::registerMetadata() CClient::registerMetadata(); CClientList::registerMetadata(); CVoiceCapabilities::registerMetadata(); - CAircraftMapping::registerMetadata(); - CAircraftMappingList::registerMetadata(); } diff --git a/src/blackmisc/geo/geoobjectlist.cpp b/src/blackmisc/geo/geoobjectlist.cpp index 0e4f68088..5790c27e9 100644 --- a/src/blackmisc/geo/geoobjectlist.cpp +++ b/src/blackmisc/geo/geoobjectlist.cpp @@ -10,7 +10,6 @@ #include "blackmisc/geo/geoobjectlist.h" #include "blackmisc/predicates.h" #include "blackmisc/aviation/atcstationlist.h" -#include "blackmisc/aviation/aircraftlist.h" #include "blackmisc/aviation/airportlist.h" #include "blackmisc/simulation/simulatedaircraftlist.h" @@ -97,12 +96,10 @@ namespace BlackMisc // see here for the reason of thess forward instantiations // http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html template class IGeoObjectList; - template class IGeoObjectList; template class IGeoObjectList; template class IGeoObjectList; template class IGeoObjectWithRelativePositionList; - template class IGeoObjectWithRelativePositionList; template class IGeoObjectWithRelativePositionList; template class IGeoObjectWithRelativePositionList; diff --git a/src/blackmisc/network/aircraftmapping.cpp b/src/blackmisc/network/aircraftmapping.cpp deleted file mode 100644 index b19229751..000000000 --- a/src/blackmisc/network/aircraftmapping.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "blackmisc/network/aircraftmapping.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/variant.h" - -using namespace BlackMisc::Aviation; -using namespace BlackMisc::Network; - -namespace BlackMisc -{ - namespace Network - { - - CAircraftMapping::CAircraftMapping(const QString &source, const QString &packageName, const QString &aircraftDesignator, const QString &airlineDesignator, const QString &model) : - m_source(source.trimmed()), m_packageName(packageName.trimmed()), m_icao(aircraftDesignator, airlineDesignator), m_model(model, BlackMisc::Simulation::CAircraftModel::TypeModelMapping) - { } - - QString CAircraftMapping::convertToQString(bool i18n) const - { - QString s = QString(this->m_model.toQString(i18n)).append(' ').append(this->m_icao.toQString(i18n)); - return s; - } - - bool CAircraftMapping::matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const - { - return this->m_model.matchesModelString(modelString, sensitivity); - } - - CVariant CAircraftMapping::propertyByIndex(const BlackMisc::CPropertyIndex &index) const - { - if (index.isMyself()) { return CVariant::from(*this); } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexModel: - return this->m_model.propertyByIndex(index.copyFrontRemoved()); - case IndexIcao: - return this->m_model.propertyByIndex(index.copyFrontRemoved()); - case IndexPackageName: - return QVariant::fromValue(this->m_packageName); - case IndexSource: - return QVariant::fromValue(this->m_source); - default: - return CValueObject::propertyByIndex(index); - } - } - - void CAircraftMapping::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) - { - if (index.isMyself()) { (*this) = variant.to(); return; } - ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexModel: - this->m_model.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexIcao: - this->m_icao.setPropertyByIndex(variant, index.copyFrontRemoved()); - break; - case IndexPackageName: - this->m_packageName = variant.toQString(); - break; - case IndexSource: - this->m_source = variant.toQString(); - break; - default: - CValueObject::setPropertyByIndex(variant, index); - break; - } - } - - } // namespace -} // namespace diff --git a/src/blackmisc/network/aircraftmapping.h b/src/blackmisc/network/aircraftmapping.h deleted file mode 100644 index 8a99ad5e8..000000000 --- a/src/blackmisc/network/aircraftmapping.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKMISC_NETWORK_AIRCRAFTMAPPING_H -#define BLACKMISC_NETWORK_AIRCRAFTMAPPING_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/aviation/aircrafticaodata.h" -#include "blackmisc/simulation/aircraftmodel.h" -#include "blackmisc/valueobject.h" - -namespace BlackMisc -{ - namespace Network - { - //! Mapping - class BLACKMISC_EXPORT CAircraftMapping : public CValueObject - { - - public: - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - //! Properties - enum ColumnIndex - { - IndexModel = BlackMisc::CPropertyIndex::GlobalIndexCAircraftMapping, - IndexIcao, - IndexPackageName, - IndexSource - }; - - //! Default constructor - CAircraftMapping() = default; - - //! Constructor - CAircraftMapping(const QString &source, const QString &packageName, const QString &aircraftDesignator, const QString &airlineDesignator, const QString &model); - - //! \copydoc CValueObject::propertyByIndex - CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const; - - //! \copydoc CValueObject::setPropertyByIndex - void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index); - - //! ICAO - void setIcao(const BlackMisc::Aviation::CAircraftIcaoData &icao) { this->m_icao = icao; } - - //! ICAO - const BlackMisc::Aviation::CAircraftIcaoData &getIcao() const { return this->m_icao; } - - //! Model - void setModel(const BlackMisc::Simulation::CAircraftModel &model) { this->m_model = model; } - - //! Model - const BlackMisc::Simulation::CAircraftModel &getModel() const { return this->m_model; } - - //! Matches model string? - bool matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const; - - //! Matches wildcard icao object - bool matchesWildcardIcao(const BlackMisc::Aviation::CAircraftIcaoData &otherIcao) const { return m_icao.matchesWildcardIcao(otherIcao); } - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CAircraftMapping) - - QString m_source; //!< source, e.g. database, vPilot - QString m_packageName; //!< something like WoA, .. - BlackMisc::Aviation::CAircraftIcaoData m_icao; //!< ICAO code - BlackMisc::Simulation::CAircraftModel m_model; //!< aircraft model - - // BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorInfo; //!< Mapping is for simulator - }; - } -} - -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Network::CAircraftMapping, (o.m_icao, o.m_model)) -Q_DECLARE_METATYPE(BlackMisc::Network::CAircraftMapping) - -#endif // guard diff --git a/src/blackmisc/network/aircraftmappinglist.cpp b/src/blackmisc/network/aircraftmappinglist.cpp deleted file mode 100644 index 2c5cb3d9d..000000000 --- a/src/blackmisc/network/aircraftmappinglist.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "blackmisc/network/aircraftmappinglist.h" -#include "blackmisc/predicates.h" - -using namespace BlackMisc::Network; -using namespace BlackMisc::Aviation; - -namespace BlackMisc -{ - namespace Network - { - CAircraftMappingList::CAircraftMappingList() { } - - CAircraftMappingList::CAircraftMappingList(const CSequence &other) : - CSequence(other) - { } - - CAircraftMappingList CAircraftMappingList::findByIcaoCodeWildcard(const CAircraftIcaoData &searchIcao) const - { - return this->findBy([ = ](const CAircraftMapping & mapping) - { - return mapping.matchesWildcardIcao(searchIcao); - }); - } - - CAircraftMappingList CAircraftMappingList::findByIcaoAircraftDesignator(const CAircraftIcaoData &searchIcao) const - { - const QString aircraftIcao = searchIcao.getAircraftDesignator(); - if (aircraftIcao.isEmpty()) { return CAircraftMappingList(); } - return this->findBy([ = ](const CAircraftMapping & mapping) - { - return mapping.getIcao().getAircraftDesignator() == aircraftIcao; - }); - } - - CAircraftMappingList CAircraftMappingList::findByIcaoAirlineDesignator(const CAircraftIcaoData &searchIcao) const - { - const QString airlineIcao = searchIcao.getAircraftDesignator(); - if (airlineIcao.isEmpty()) { return CAircraftMappingList(); } - return this->findBy([ = ](const CAircraftMapping & mapping) - { - return mapping.getIcao().getAirlineDesignator() == airlineIcao; - }); - } - - CAircraftMappingList CAircraftMappingList::findByIcaoAircraftAndAirlineDesignator(const CAircraftIcaoData &searchIcao, bool allowRelaxedAirline) const - { - CAircraftMappingList aircraftSearch = findByIcaoAircraftDesignator(searchIcao); - if (aircraftSearch.isEmpty()) { return aircraftSearch; } - - CAircraftMappingList aircraftAndAirlineSearch = aircraftSearch.findByIcaoAirlineDesignator(searchIcao); - if (!aircraftAndAirlineSearch.isEmpty()) { return aircraftAndAirlineSearch; } - return allowRelaxedAirline ? aircraftSearch : aircraftAndAirlineSearch; - } - - CAircraftMappingList CAircraftMappingList::findByIcaoCodeExact(const CAircraftIcaoData &searchIcao) const - { - return this->findBy(&CAircraftMapping::getIcao, searchIcao); - } - - CAircraftMappingList CAircraftMappingList::findByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const - { - return this->findBy([ = ](const CAircraftMapping & mapping) - { - return mapping.matchesModelString(modelString, sensitivity); - }); - } - - } // namespace -} // namespace diff --git a/src/blackmisc/network/aircraftmappinglist.h b/src/blackmisc/network/aircraftmappinglist.h deleted file mode 100644 index 2c5d3c748..000000000 --- a/src/blackmisc/network/aircraftmappinglist.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKMISC_NETWORK_AIRCRAFTMAPPINGLIST_H -#define BLACKMISC_NETWORK_AIRCRAFTMAPPINGLIST_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/network/aircraftmapping.h" -#include "blackmisc/collection.h" -#include "blackmisc/sequence.h" -#include -#include -#include - -namespace BlackMisc -{ - namespace Network - { - //! Value object encapsulating a list of aircraft mappings - class BLACKMISC_EXPORT CAircraftMappingList : - public CSequence, - public BlackMisc::Mixin::MetaType - { - public: - BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CAircraftMappingList) - - //! Empty constructor. - CAircraftMappingList(); - - //! Construct from a base class object. - CAircraftMappingList(const CSequence &other); - - //! Find by ICAO code, empty fields treated as wildcards - CAircraftMappingList findByIcaoCodeWildcard(const BlackMisc::Aviation::CAircraftIcaoData &searchIcao) const; - - //! Find by ICAO aircraft designator - CAircraftMappingList findByIcaoAircraftDesignator(const BlackMisc::Aviation::CAircraftIcaoData &searchIcao) const; - - //! Find by ICAO airline designator - CAircraftMappingList findByIcaoAirlineDesignator(const BlackMisc::Aviation::CAircraftIcaoData &searchIcao) const; - - //! Find by ICAO aircraft and airline designator - CAircraftMappingList findByIcaoAircraftAndAirlineDesignator(const BlackMisc::Aviation::CAircraftIcaoData &searchIcao, bool allowRelaxedAirline) const; - - //! Find by ICAO code, empty fields treated literally - CAircraftMappingList findByIcaoCodeExact(const BlackMisc::Aviation::CAircraftIcaoData &searchIcao) const; - - //! Find by model string - CAircraftMappingList findByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const; - }; - - } //namespace -} // namespace - -Q_DECLARE_METATYPE(BlackMisc::Network::CAircraftMappingList) -Q_DECLARE_METATYPE(BlackMisc::CCollection) -Q_DECLARE_METATYPE(BlackMisc::CSequence) - -#endif //guard diff --git a/src/blackmisc/network/network.h b/src/blackmisc/network/network.h index 52ed3f808..0b7b90c20 100644 --- a/src/blackmisc/network/network.h +++ b/src/blackmisc/network/network.h @@ -14,7 +14,7 @@ /*! * \namespace BlackMisc::Network - * \brief Classes related to the traffic network such as VATSIM user etc. + * \brief Classes related to the traffic network and swift DB, such as VATSIM user etc. */ #include "blackmisc/network/user.h" @@ -24,7 +24,5 @@ #include "blackmisc/network/client.h" #include "blackmisc/network/clientlist.h" #include "blackmisc/network/voicecapabilities.h" -#include "blackmisc/network/aircraftmapping.h" -#include "blackmisc/network/aircraftmappinglist.h" #endif // guard diff --git a/src/blackmisc/propertyindex.h b/src/blackmisc/propertyindex.h index 943aab358..8218f41dc 100644 --- a/src/blackmisc/propertyindex.h +++ b/src/blackmisc/propertyindex.h @@ -52,7 +52,6 @@ namespace BlackMisc GlobalIndexTimestampBased = 400, GlobalIndexIdentifier = 500, GlobalIndexCCallsign = 1000, - GlobalIndexCAircraft = 1100, GlobalIndexCAircraftSituation = 1200, GlobalIndexCAtcStation = 1300, GlobalIndexCAirport = 1400, @@ -76,7 +75,6 @@ namespace BlackMisc GlobalIndexCServer = 4200, GlobalIndexCAircraftModel = 4300, GlobalIndexCSimulatedAircraft = 4400, - GlobalIndexCAircraftMapping = 4500, GlobalIndexCTextMessage = 4600, GlobalIndexCSimulatorSetup = 4700, GlobalIndexCAircraftCfgEntries = 4800,