mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
refs #396 move Blackmisc Aviation classes into subfolder
This commit is contained in:
50
src/blackmisc/aviation/airportlist.cpp
Normal file
50
src/blackmisc/aviation/airportlist.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / authors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "blackmisc/aviation/airportlist.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
CAirportList::CAirportList() { }
|
||||
|
||||
CAirportList::CAirportList(const CSequence<CAirport> &other) :
|
||||
CSequence<CAirport>(other)
|
||||
{ }
|
||||
|
||||
void CAirportList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::CSequence<CAirport>>();
|
||||
qDBusRegisterMetaType<BlackMisc::CSequence<CAirport>>();
|
||||
qRegisterMetaType<BlackMisc::CCollection<CAirport>>();
|
||||
qDBusRegisterMetaType<BlackMisc::CCollection<CAirport>>();
|
||||
qRegisterMetaType<CAirportList>();
|
||||
qDBusRegisterMetaType<CAirportList>();
|
||||
registerMetaValueType<CAirportList>();
|
||||
}
|
||||
|
||||
CAirportList CAirportList::findByIcao(const CAirportIcao &icao) const
|
||||
{
|
||||
return this->findBy(&CAirport::getIcao, icao);
|
||||
}
|
||||
|
||||
void CAirportList::replaceOrAddByIcao(const CAirport &addedOrReplacedAirport)
|
||||
{
|
||||
if (!addedOrReplacedAirport.hasValidIcaoCode()) return; // ignore invalid airport
|
||||
this->replaceOrAdd(&CAirport::getIcao, addedOrReplacedAirport.getIcao(), addedOrReplacedAirport);
|
||||
}
|
||||
|
||||
CAirport CAirportList::findFirstByIcao(const CAirportIcao &icao, const CAirport &ifNotFound) const
|
||||
{
|
||||
return this->findByIcao(icao).frontOrDefault(ifNotFound);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user