mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
refs #893, formatting
This commit is contained in:
committed by
Mathew Sutcliffe
parent
056d205488
commit
e90c65a33a
@@ -149,7 +149,7 @@ namespace BlackMisc
|
||||
CVariant CCallsign::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsignString:
|
||||
@@ -168,7 +168,7 @@ namespace BlackMisc
|
||||
void CCallsign::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CCallsign>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsignString:
|
||||
@@ -188,7 +188,7 @@ namespace BlackMisc
|
||||
int CCallsign::comparePropertyByIndex(const CPropertyIndex &index, const CCallsign &compareValue) const
|
||||
{
|
||||
if (index.isMyself()) { return this->m_callsign.compare(compareValue.m_callsign, Qt::CaseInsensitive); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsignString:
|
||||
|
||||
@@ -119,18 +119,6 @@ namespace BlackMisc
|
||||
//! Equals callsign string?
|
||||
bool equalsString(const QString &callsignString) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return convertToIcon(*this); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CCallsign &compareValue) const;
|
||||
|
||||
//! Valid callsign?
|
||||
bool isValid() const;
|
||||
|
||||
@@ -158,6 +146,18 @@ namespace BlackMisc
|
||||
//! Representing icon
|
||||
static const CIcon &convertToIcon(const CCallsign &callsign);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Icon::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return convertToIcon(*this); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const CCallsign &compareValue) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString()
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
void CComSystem::registerMetadata()
|
||||
{
|
||||
Mixin::MetaType<CComSystem>::registerMetadata();
|
||||
@@ -68,6 +67,67 @@ namespace BlackMisc
|
||||
this->CModulator::setFrequencyStandby(fRounded);
|
||||
}
|
||||
|
||||
bool CComSystem::isActiveFrequencyWithin8_33kHzChannel(const CFrequency &comFrequency) const
|
||||
{
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing8_33KHz);
|
||||
}
|
||||
|
||||
bool CComSystem::isActiveFrequencyWithin25kHzChannel(const CFrequency &comFrequency) const
|
||||
{
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing25KHz);
|
||||
}
|
||||
|
||||
void CComSystem::setActiveUnicom()
|
||||
{
|
||||
this->toggleActiveStandby();
|
||||
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||
}
|
||||
|
||||
void CComSystem::setActiveInternationalAirDistress()
|
||||
{
|
||||
this->toggleActiveStandby();
|
||||
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress());
|
||||
}
|
||||
|
||||
CComSystem CComSystem::getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom1(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||
}
|
||||
|
||||
CComSystem CComSystem::getCom1System(CFrequency activeFrequency, CFrequency standbyFrequency)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom1(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||
}
|
||||
|
||||
CComSystem CComSystem::getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom2(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||
}
|
||||
|
||||
CComSystem CComSystem::getCom2System(CFrequency activeFrequency, CFrequency standbyFrequency)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom2(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||
}
|
||||
|
||||
bool CComSystem::isValidCivilAviationFrequency(const CFrequency &f)
|
||||
{
|
||||
if (f.isNull()) return false;
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
||||
return fr >= 118.0 && fr <= 136.975;
|
||||
}
|
||||
|
||||
bool CComSystem::isValidMilitaryFrequency(const CFrequency &f)
|
||||
{
|
||||
if (f.isNull()) return false;
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
||||
return fr >= 220.0 && fr <= 399.95;
|
||||
}
|
||||
|
||||
bool CComSystem::isValidComFrequency(const CFrequency &f)
|
||||
{
|
||||
return isValidCivilAviationFrequency(f) || isValidMilitaryFrequency(f);
|
||||
}
|
||||
|
||||
void CComSystem::roundToChannelSpacing(PhysicalQuantities::CFrequency &frequency, ChannelSpacing channelSpacing)
|
||||
{
|
||||
double channelSpacingKHz = CComSystem::channelSpacingToFrequencyKHz(channelSpacing);
|
||||
@@ -101,6 +161,5 @@ namespace BlackMisc
|
||||
default: qFatal("Wrong channel spacing"); return 0.0; // return just supressing compiler warning
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
//! COM system (aka "radio")
|
||||
class BLACKMISC_EXPORT CComSystem :
|
||||
public CModulator<CComSystem>,
|
||||
@@ -64,9 +63,6 @@ namespace BlackMisc
|
||||
Com2
|
||||
};
|
||||
|
||||
//! \copydoc BlackMisc::CValueObject::registerMetadata
|
||||
static void registerMetadata();
|
||||
|
||||
//! Default constructor
|
||||
CComSystem() {}
|
||||
|
||||
@@ -92,76 +88,37 @@ namespace BlackMisc
|
||||
virtual void setFrequencyStandby(const BlackMisc::PhysicalQuantities::CFrequency &frequency) override;
|
||||
|
||||
//! Is active frequency within 8.3383kHz channel?
|
||||
bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const
|
||||
{
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing8_33KHz);
|
||||
}
|
||||
bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Is active frequency within 25kHz channel?
|
||||
bool isActiveFrequencyWithin25kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const
|
||||
{
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing25KHz);
|
||||
}
|
||||
bool isActiveFrequencyWithin25kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Set UNICOM frequency as active
|
||||
void setActiveUnicom()
|
||||
{
|
||||
this->toggleActiveStandby();
|
||||
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||
}
|
||||
void setActiveUnicom();
|
||||
|
||||
//! Set International Air Distress 121.5MHz
|
||||
void setActiveInternationalAirDistress()
|
||||
{
|
||||
this->toggleActiveStandby();
|
||||
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress());
|
||||
}
|
||||
void setActiveInternationalAirDistress();
|
||||
|
||||
//! COM1 unit
|
||||
static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom1(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||
}
|
||||
static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz = -1);
|
||||
|
||||
//! COM1 unit
|
||||
static CComSystem getCom1System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
||||
{
|
||||
return CComSystem(CModulator::NameCom1(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||
}
|
||||
static CComSystem getCom1System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet());
|
||||
|
||||
//! COM2 unit
|
||||
static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom2(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||
}
|
||||
static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz = -1);
|
||||
|
||||
//! COM2 unit
|
||||
static CComSystem getCom2System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
||||
{
|
||||
return CComSystem(CModulator::NameCom2(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||
}
|
||||
static CComSystem getCom2System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet());
|
||||
|
||||
//! Valid civil aviation frequency?
|
||||
static bool isValidCivilAviationFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f)
|
||||
{
|
||||
if (f.isNull()) return false;
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
||||
return fr >= 118.0 && fr <= 136.975;
|
||||
}
|
||||
static bool isValidCivilAviationFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f);
|
||||
|
||||
//! Valid military aviation frequency?
|
||||
static bool isValidMilitaryFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f)
|
||||
{
|
||||
if (f.isNull()) return false;
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
||||
return fr >= 220.0 && fr <= 399.95;
|
||||
}
|
||||
static bool isValidMilitaryFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f);
|
||||
|
||||
//! Valid COM frequency (either civil or military)
|
||||
static bool isValidComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f)
|
||||
{
|
||||
return isValidCivilAviationFrequency(f) || isValidMilitaryFrequency(f);
|
||||
}
|
||||
static bool isValidComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f);
|
||||
|
||||
//! Round to channel spacing, set MHz as unit
|
||||
//! \see ChannelSpacing
|
||||
@@ -170,6 +127,9 @@ namespace BlackMisc
|
||||
//! Is compareFrequency within channel spacing of setFrequency
|
||||
static bool isWithinChannelSpacing(const BlackMisc::PhysicalQuantities::CFrequency &setFrequency, const BlackMisc::PhysicalQuantities::CFrequency &compareFrequency, ChannelSpacing channelSpacing);
|
||||
|
||||
//! \copydoc BlackMisc::CValueObject::registerMetadata
|
||||
static void registerMetadata();
|
||||
|
||||
protected:
|
||||
//! \copydoc CModulator::validValues
|
||||
virtual bool validValues() const override;
|
||||
@@ -186,7 +146,6 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(channelSpacing)
|
||||
);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace BlackMisc
|
||||
CVariant CModulator<AVIO>::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*derived()); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexActiveFrequency:
|
||||
@@ -131,7 +131,7 @@ namespace BlackMisc
|
||||
void CModulator<AVIO>::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { Q_ASSERT_X(false, Q_FUNC_INFO, "Wrong index to base template"); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexActiveFrequency:
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace BlackMisc
|
||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyStandby; //!< standby frequency
|
||||
int m_volumeInput = 0; //!< volume input
|
||||
int m_volumeOutput = 0; //!< volume output
|
||||
bool m_enabled = true; //!< is enabled, used e.g. for mute etc.
|
||||
bool m_enabled = true; //!< is enabled, used e.g. for mute etc.
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
AVIO const *derived() const;
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace BlackMisc
|
||||
//! Index list
|
||||
QList<int> indexList() const;
|
||||
|
||||
//! Shif existing indexes to right and insert given index at front
|
||||
//! Shift existing indexes to right and insert given index at front
|
||||
void prepend(int newLeftIndex);
|
||||
|
||||
//! Contains index?
|
||||
@@ -196,7 +196,7 @@ namespace BlackMisc
|
||||
template<class EnumType> bool contains(EnumType ev) const
|
||||
{
|
||||
static_assert(std::is_enum<EnumType>::value, "Argument must be an enum");
|
||||
return contains(static_cast<int>(ev));
|
||||
return this->contains(static_cast<int>(ev));
|
||||
}
|
||||
|
||||
//! Front to integer
|
||||
@@ -221,7 +221,7 @@ namespace BlackMisc
|
||||
//! Return a predicate function which can compare two objects based on this index
|
||||
auto comparator() const
|
||||
{
|
||||
return [index = *this](const auto &a, const auto &b)
|
||||
return [index = *this](const auto & a, const auto & b)
|
||||
{
|
||||
using T = std::decay_t<decltype(a)>;
|
||||
return Private::compareByProperty(a, b, index, THasCompareByPropertyIndex<T>(), THasPropertyByIndex<T>());
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace BlackMisc
|
||||
|
||||
namespace Mixin
|
||||
{
|
||||
|
||||
/*!
|
||||
* CRTP class template from which a derived class can inherit common methods dealing with the metatype of the class.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user