mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #452, removed some classes which will be replaced by new classes
* CAircraftMappings -> will be replace by CAircraftModel * CAircraftIcaoData aircraft ICAO data -> aircraft/airline ICAO code and livery * CAircraft class no longer to be used, but CSimulatedAircraft * removed corresponding GUI model classes / filters
This commit is contained in:
committed by
Mathew Sutcliffe
parent
51e8a6a208
commit
874f29098b
@@ -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<ColumnIndex>();
|
||||
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<CAircraftMapping>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
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
|
||||
@@ -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<CAircraftMapping>
|
||||
{
|
||||
|
||||
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
|
||||
@@ -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<CAircraftMapping> &other) :
|
||||
CSequence<CAircraftMapping>(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
|
||||
@@ -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 <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
//! Value object encapsulating a list of aircraft mappings
|
||||
class BLACKMISC_EXPORT CAircraftMappingList :
|
||||
public CSequence<CAircraftMapping>,
|
||||
public BlackMisc::Mixin::MetaType<CAircraftMappingList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CAircraftMappingList)
|
||||
|
||||
//! Empty constructor.
|
||||
CAircraftMappingList();
|
||||
|
||||
//! Construct from a base class object.
|
||||
CAircraftMappingList(const CSequence<CAircraftMapping> &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<BlackMisc::Network::CAircraftMapping>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Network::CAircraftMapping>)
|
||||
|
||||
#endif //guard
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user