mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
refs #395, signatures for max.aircraft and max.range
(!) This in an intermediate step, the feature is not yet fully operational * max distance for rendering as simulator property * set max distance / aircraft from GUI As result of the latest meeting * changed CCallsignList to CCollection * fixed some warning with elevated compiler settings (e.g. removed qint values -> int)
This commit is contained in:
@@ -28,7 +28,7 @@ namespace BlackMisc
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const qint16 index, const QString &name) :
|
||||
CAudioDeviceInfo::CAudioDeviceInfo(DeviceType type, const int index, const QString &name) :
|
||||
m_type(type), m_deviceIndex(index),
|
||||
m_deviceName(name), m_hostName(BlackMisc::localHostName())
|
||||
{
|
||||
@@ -38,8 +38,9 @@ namespace BlackMisc
|
||||
/*
|
||||
* As String
|
||||
*/
|
||||
QString CAudioDeviceInfo::convertToQString(bool /* i18n */) const
|
||||
QString CAudioDeviceInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
if (this->m_hostName.isEmpty()) return m_deviceName;
|
||||
QString s(this->m_deviceName);
|
||||
s.append(" [");
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace BlackMisc
|
||||
{
|
||||
public:
|
||||
//! Type
|
||||
enum DeviceType : uint
|
||||
enum DeviceType
|
||||
{
|
||||
InputDevice,
|
||||
OutputDevice,
|
||||
@@ -44,10 +44,10 @@ namespace BlackMisc
|
||||
CAudioDeviceInfo();
|
||||
|
||||
//! Constructor.
|
||||
CAudioDeviceInfo(DeviceType type, const qint16 index, const QString &getName);
|
||||
CAudioDeviceInfo(DeviceType type, const int index, const QString &getName);
|
||||
|
||||
//! Get the device index
|
||||
qint16 getIndex() const { return m_deviceIndex; }
|
||||
int getIndex() const { return m_deviceIndex; }
|
||||
|
||||
//! Get the device name
|
||||
const QString &getName() const { return m_deviceName; }
|
||||
@@ -62,10 +62,10 @@ namespace BlackMisc
|
||||
bool isValid() const { return m_deviceIndex >= -1 && !m_deviceName.isEmpty(); }
|
||||
|
||||
//! Device index for default device
|
||||
static qint16 defaultDeviceIndex() {return -1;}
|
||||
static int defaultDeviceIndex() {return -1;}
|
||||
|
||||
//! Invalid device index
|
||||
static qint16 invalidDeviceIndex() {return -2;}
|
||||
static int invalidDeviceIndex() {return -2;}
|
||||
|
||||
//! Default output device
|
||||
static CAudioDeviceInfo getDefaultOutputDevice()
|
||||
@@ -91,7 +91,7 @@ namespace BlackMisc
|
||||
* deviceIndex is the number is the reference for the VVL. The device is selected by this index.
|
||||
* The managing class needs to take care, that indexes are valid.
|
||||
*/
|
||||
qint16 m_deviceIndex;
|
||||
int m_deviceIndex;
|
||||
//! Device name
|
||||
QString m_deviceName;
|
||||
//! We use a DBus based system. Hence an audio device can reside on a differen computers, this here is its name
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKMISC_ATCSTATIONLIST_H
|
||||
#define BLACKMISC_ATCSTATIONLIST_H
|
||||
|
||||
#include "geoobjectlist.h"
|
||||
#include "nwuserlist.h"
|
||||
#include "avatcstation.h"
|
||||
#include "avcallsignobjectlist.h"
|
||||
@@ -30,7 +31,8 @@ namespace BlackMisc
|
||||
*/
|
||||
class CAtcStationList :
|
||||
public CSequence<CAtcStation>,
|
||||
public ICallsignObjectList<CAtcStation, CAtcStationList>
|
||||
public BlackMisc::Aviation::ICallsignObjectList<CAtcStation, CAtcStationList>,
|
||||
public BlackMisc::Geo::IGeoObjectWithRelativePositionList<CAtcStation, CAtcStationList>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
|
||||
@@ -14,21 +14,12 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
/*
|
||||
* Empty constructor
|
||||
*/
|
||||
CCallsignList::CCallsignList() { }
|
||||
|
||||
/*
|
||||
* Construct from base class object
|
||||
*/
|
||||
CCallsignList::CCallsignList(const CSequence<CCallsign> &other) :
|
||||
CSequence<CCallsign>(other)
|
||||
CCallsignList::CCallsignList(const CCollection<CCallsign> &other) :
|
||||
CCollection<CCallsign>(other)
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
void CCallsignList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::CSequence<CCallsign>>();
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace BlackMisc
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object for a list of callsigns.
|
||||
class CCallsignList : public CSequence<CCallsign>
|
||||
class CCallsignList : public CCollection<CCallsign>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
CCallsignList();
|
||||
|
||||
//! Construct from a base class object.
|
||||
CCallsignList(const CSequence<CCallsign> &other);
|
||||
CCallsignList(const CCollection<CCallsign> &other);
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
@@ -44,6 +44,9 @@ namespace BlackMisc
|
||||
|
||||
//! Initializer list constructor.
|
||||
QOrderedSet(std::initializer_list<T> il) { for (const auto &v : il) { insert(v); } }
|
||||
|
||||
//! Constructor from QList
|
||||
QOrderedSet(const QList<T> &list) { for (const auto &v : list) { insert(v); }}
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -85,6 +88,11 @@ namespace BlackMisc
|
||||
*/
|
||||
CCollection(const CCollection &other) : m_pimpl(other.pimpl() ? other.pimpl()->clone() : nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor from QList.
|
||||
*/
|
||||
CCollection(const QList<T> &list) : m_pimpl(new Pimpl<QOrderedSet<T>>(QOrderedSet<T>(list))) {}
|
||||
|
||||
/*!
|
||||
* \brief Move constructor.
|
||||
*/
|
||||
|
||||
@@ -71,6 +71,17 @@ namespace BlackMisc
|
||||
this->container().sort([ & ](const OBJ & a, const OBJ & b) { return a.getDistanceToOwnAircraft() < b.getDistanceToOwnAircraft(); });
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
CONTAINER IGeoObjectWithRelativePositionList<OBJ, CONTAINER>::getClosestObjects(int number) const
|
||||
{
|
||||
if (number < 1) { return CONTAINER(); }
|
||||
if (this->container().size() >= number) { return (this->container()); }
|
||||
CONTAINER closest(this->container());
|
||||
closest.sortByDistanceToOwnAircraft();
|
||||
closest.truncate(number);
|
||||
return closest;
|
||||
}
|
||||
|
||||
// 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<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
|
||||
@@ -56,6 +56,9 @@ namespace BlackMisc
|
||||
//! If distance is already set, just sort
|
||||
void sortByDistanceToOwnAircraft();
|
||||
|
||||
//! Get n closest objects
|
||||
CONTAINER getClosestObjects(int number) const;
|
||||
|
||||
//! Calculate distances, remove if outside range
|
||||
void removeIfOutsideRange(const BlackMisc::Geo::ICoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &maxDistance, bool updateValues);
|
||||
|
||||
|
||||
@@ -234,6 +234,20 @@ namespace BlackMisc
|
||||
return unit.roundValue(this->value(unit), digits);
|
||||
}
|
||||
|
||||
/*
|
||||
* Value rounded as integer
|
||||
*/
|
||||
template <class MU, class PQ> int CPhysicalQuantity<MU, PQ>::valueInteger(const MU &unit) const
|
||||
{
|
||||
double v = unit.roundValue(this->value(unit), 0);
|
||||
return static_cast<int>(v);
|
||||
}
|
||||
|
||||
template <class MU, class PQ> double CPhysicalQuantity<MU, PQ>::valueRounded(int digits) const
|
||||
{
|
||||
return this->valueRounded(this->m_unit, digits);
|
||||
}
|
||||
|
||||
/*
|
||||
* Value in unit
|
||||
*/
|
||||
|
||||
@@ -115,11 +115,11 @@ namespace BlackMisc
|
||||
//! Rounded value in given unit
|
||||
double valueRounded(const MU &unit, int digits = -1) const;
|
||||
|
||||
//! As integer value
|
||||
int valueInteger(const MU &unit) const;
|
||||
|
||||
//! Rounded value in current unit
|
||||
double valueRounded(int digits = -1) const
|
||||
{
|
||||
return this->valueRounded(this->m_unit, digits);
|
||||
}
|
||||
double valueRounded(int digits = -1) const;
|
||||
|
||||
//! Value to QString with the given unit, e.g. "5.00m"
|
||||
QString valueRoundedWithUnit(const MU &unit, int digits = -1, bool i18n = false) const;
|
||||
|
||||
Reference in New Issue
Block a user