23#include <QObjectBindableProperty>
26#include "units/Distance.h"
27#include "TrafficFactorAircraftType.h"
29using namespace std::chrono_literals;
226 [[nodiscard]]
int alarmLevel()
const {
return m_alarmLevel.value();}
256 [[nodiscard]]
auto color() const -> QString
258 if (m_alarmLevel == 0) {
259 return QStringLiteral(
"green");
261 if (m_alarmLevel == 1) {
262 return QStringLiteral(
"yellow");
264 return QStringLiteral(
"red");
273 return m_description;
292 [[nodiscard]]
auto ID() const -> QString
301 [[nodiscard]]
bool relevant()
const {
return m_relevant.value();}
325 [[nodiscard]] Traffic::AircraftType
type()
const {
return m_type.value();}
331 [[nodiscard]] QBindable<Traffic::AircraftType>
bindableType() {
return &m_type;}
337 [[nodiscard]] QString
typeString()
const {
return m_typeString.value();}
349 [[nodiscard]]
bool valid()
const {
return m_valid.value();}
381 if ((newAlarmLevel < 0) || (newAlarmLevel > 3)) {
385 m_alarmLevel = newAlarmLevel;
393 if (m_animate == newAnimate) {
396 m_animate = newAnimate;
405 if (m_callSign == newCallSign) {
408 m_callSign = newCallSign;
434 void setType(Traffic::AircraftType newType) {m_type = newType;}
497 virtual void updateValid();
498 void dispatchUpdateValid();
504 virtual void updateDescription();
505 void dispatchUpdateDescription();
506 QString m_description;
515 bool m_animate {
false};
517 QString m_color{QStringLiteral(
"red")};
521 QProperty<bool> m_relevant {
false};
522 QProperty<QString> m_relevantString;
523 QProperty<QString> m_typeString;
528 QTimer lifeTimeCounter;
Abstract base class for traffic factors.
QString typeString() const
Getter method for property with the same name.
void typeChanged()
Notifier signal.
QBindable< QString > bindableTypeString()
Getter method for property with the same name.
QString ID
Identifier string of the traffic.
Units::Distance vDist
Vertical distance from own position to the traffic, at the time of report.
void setCallSign(const QString &newCallSign)
Setter function for property with the same name.
auto description() const -> QString
Getter method for property with the same name.
void callSignChanged()
Notifier signal.
auto ID() const -> QString
Getter method for property with the same name.
QString description
Description of the traffic, for use in GUI.
auto hasHigherPriorityThan(const TrafficFactor_Abstract &rhs) const -> bool
Estimates if this traffic object has higher priority than other traffic object.
auto color() const -> QString
Getter method for property with the same name.
void startLiveTime()
Starts or extends the lifetime of this object.
void setVDist(Units::Distance newVDist)
Setter function for property with the same name.
int alarmLevel
Alarm Level.
void alarmLevelChanged()
Notifier signal.
void vDistChanged()
Notifier signal.
static constexpr auto lifeTime
Length of lifetime for objects of this class.
bool relevant
Indicates relevant traffic.
QString relevantString() const
Getter method for property with the same name.
auto callSign() const -> QString
Getter method for property with the same name.
AircraftType type
Type of aircraft, as reported by the traffic receiver.
QString relevantString
Translated string containing the 'relevant' property.
void colorChanged()
Notifier signal.
void setHDist(Units::Distance newHDist)
Setter function for property with the same name.
void setAlarmLevel(int newAlarmLevel)
Setter function for property with the same name.
bool relevant() const
Getter method for property with the same name.
QBindable< Units::Distance > bindableVDist()
Getter method for property with the same name.
Units::Distance hDist
Horizontal distance from own position to the traffic, at the time of report.
void animateChanged()
Notifier signal.
QString color
Suggested color for GUI representation of the traffic.
Units::Distance hDist() const
Getter method for property with the same name.
void setAnimate(bool newAnimate)
Setter function for property with the same name.
QString callSign
Call sign.
QBindable< bool > bindableValid()
Getter method for property with the same name.
QBindable< bool > bindableRelevantString()
Getter method for property with the same name.
QBindable< Units::Distance > bindableHDist()
Getter method for property with the same name.
QBindable< int > bindableAlarmLevel()
Getter method for property with the same name.
static constexpr Units::Distance maxVerticalDistance
Maximal vertical distance for relevant traffic.
QBindable< bool > bindableRelevant()
Getter method for property with the same name.
QBindable< Traffic::AircraftType > bindableType()
Getter method for property with the same name.
QString typeString
Type of aircraft, as reported by the traffic receiver.
TrafficFactor_Abstract(QObject *parent=nullptr)
Default constructor.
void descriptionChanged()
Notifier signal.
void validChanged()
Notifier signal.
void setType(Traffic::AircraftType newType)
Setter function for property with the same name.
static constexpr Units::Distance maxHorizontalDistance
Maximal horizontal distance for relevant traffic.
Units::Distance vDist() const
Getter method for property with the same name.
void hDistChanged()
Notifier signal.
bool valid() const
Getter method for property with the same name.
auto animate() const -> bool
Getter method for property with the same name.
Traffic::AircraftType type() const
Getter method for property with the same name.
void copyFrom(const TrafficFactor_Abstract &other)
Copy data from other object.
bool animate
Indicates if changes in properties should be animated in the GUI.
void setID(const QString &newID)
Setter function for property with the same name.
void IDChanged()
Notifier signal.
Convenience class for distance computations.
static Q_INVOKABLE constexpr Units::Distance fromNM(double distanceInNM)
Constructs a distance.
static Q_INVOKABLE constexpr Units::Distance fromM(double distanceInM)
Constructs a distance.
Conversion between units used in aviation.