mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-24 06:25:37 +08:00
Formatting, comments, typos only
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#ifndef BLACKGUI_QWITRANSPONDERMODESELECTOR_H
|
#ifndef BLACKGUI_TRANSPONDERMODESELECTOR_H
|
||||||
#define BLACKGUI_QWITRANSPONDERMODESELECTOR_H
|
#define BLACKGUI_TRANSPONDERMODESELECTOR_H
|
||||||
|
|
||||||
#include "../blackmisc/aviotransponder.h"
|
#include "blackmisc/aviotransponder.h"
|
||||||
#include "blackmisc/aviotransponder.h"
|
#include "blackmisc/aviotransponder.h"
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
|||||||
@@ -3,10 +3,6 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
/*!
|
|
||||||
\file
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BLACKMISC_CALLSIGN_H
|
#ifndef BLACKMISC_CALLSIGN_H
|
||||||
#define BLACKMISC_CALLSIGN_H
|
#define BLACKMISC_CALLSIGN_H
|
||||||
#include "valueobject.h"
|
#include "valueobject.h"
|
||||||
@@ -20,15 +16,15 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \brief Default constructor.
|
//! Default constructor.
|
||||||
CCallsign() {}
|
CCallsign() {}
|
||||||
|
|
||||||
//! \brief Constructor
|
//! Constructor
|
||||||
CCallsign(const QString &callsign, const QString &telephonyDesignator = "")
|
CCallsign(const QString &callsign, const QString &telephonyDesignator = "")
|
||||||
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign.trimmed())), m_telephonyDesignator(telephonyDesignator.trimmed())
|
: m_callsignAsSet(callsign.trimmed()), m_callsign(CCallsign::unifyCallsign(callsign.trimmed())), m_telephonyDesignator(telephonyDesignator.trimmed())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! \brief Constructor, needed to disambiguate implicit conversion from string literal.
|
//! Constructor, needed to disambiguate implicit conversion from string literal.
|
||||||
CCallsign(const char *callsign)
|
CCallsign(const char *callsign)
|
||||||
: m_callsignAsSet(callsign), m_callsign(CCallsign::unifyCallsign(callsign))
|
: m_callsignAsSet(callsign), m_callsign(CCallsign::unifyCallsign(callsign))
|
||||||
{}
|
{}
|
||||||
@@ -45,34 +41,34 @@ namespace BlackMisc
|
|||||||
return CCallsign::convertToIcon(*this);
|
return CCallsign::convertToIcon(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Is empty?
|
//! Is empty?
|
||||||
bool isEmpty() const { return this->m_callsignAsSet.isEmpty(); }
|
bool isEmpty() const { return this->m_callsignAsSet.isEmpty(); }
|
||||||
|
|
||||||
//! \brief Get callsign.
|
//! Get callsign.
|
||||||
const QString &asString() const { return this->m_callsign; }
|
const QString &asString() const { return this->m_callsign; }
|
||||||
|
|
||||||
//! \brief Get callsign.
|
//! Get callsign.
|
||||||
const QString &getStringAsSet() const { return this->m_callsignAsSet; }
|
const QString &getStringAsSet() const { return this->m_callsignAsSet; }
|
||||||
|
|
||||||
//! \brief Get callsign telephony designator (how callsign is pronounced)
|
//! Get callsign telephony designator (how callsign is pronounced)
|
||||||
const QString &getTelephonyDesignator() const { return this->m_telephonyDesignator; }
|
const QString &getTelephonyDesignator() const { return this->m_telephonyDesignator; }
|
||||||
|
|
||||||
//! \brief Get ICAO code, if this makes sense (EDDF_TWR -> EDDF)
|
//! Get ICAO code, if this makes sense (EDDF_TWR -> EDDF)
|
||||||
QString getIcaoCode() const { return m_callsign.left(4).toUpper(); }
|
QString getIcaoCode() const { return m_callsign.left(4).toUpper(); }
|
||||||
|
|
||||||
//! \brief Makes this callsign looking like an observer callsign (DAMBZ -> DAMBZ_OBS)
|
//! Makes this callsign looking like an observer callsign (DAMBZ -> DAMBZ_OBS)
|
||||||
QString getAsObserverCallsignString() const;
|
QString getAsObserverCallsignString() const;
|
||||||
|
|
||||||
//! \brief Equals callsign string?
|
//! Equals callsign string?
|
||||||
bool equalsString(const QString &callsignString) const;
|
bool equalsString(const QString &callsignString) const;
|
||||||
|
|
||||||
//! \brief Equal operator ==
|
//! Equal operator ==
|
||||||
bool operator ==(const CCallsign &other) const;
|
bool operator ==(const CCallsign &other) const;
|
||||||
|
|
||||||
//! \brief Unequal operator !=
|
//! Unequal operator !=
|
||||||
bool operator !=(const CCallsign &other) const;
|
bool operator !=(const CCallsign &other) const;
|
||||||
|
|
||||||
//! \brief Less than operator < for sorting
|
//! Less than operator < for sorting
|
||||||
bool operator <(const CCallsign &other) const;
|
bool operator <(const CCallsign &other) const;
|
||||||
|
|
||||||
//! \copydoc CValueObject::getValueHash()
|
//! \copydoc CValueObject::getValueHash()
|
||||||
@@ -84,10 +80,10 @@ namespace BlackMisc
|
|||||||
//! \copydoc CValueObject::fromJson
|
//! \copydoc CValueObject::fromJson
|
||||||
virtual void fromJson(const QJsonObject &json) override;
|
virtual void fromJson(const QJsonObject &json) override;
|
||||||
|
|
||||||
//! \brief Register metadata
|
//! Register metadata
|
||||||
static void registerMetadata();
|
static void registerMetadata();
|
||||||
|
|
||||||
//! \brief Members
|
//! Members
|
||||||
static const QStringList &jsonMembers();
|
static const QStringList &jsonMembers();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -110,13 +106,13 @@ namespace BlackMisc
|
|||||||
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Unify the callsign
|
* Unify the callsign
|
||||||
* \param callsign
|
* \param callsign
|
||||||
* \return unified callsign
|
* \return unified callsign
|
||||||
*/
|
*/
|
||||||
static QString unifyCallsign(const QString &callsign);
|
static QString unifyCallsign(const QString &callsign);
|
||||||
|
|
||||||
//! \brief representing icon
|
//! representing icon
|
||||||
static const QPixmap &convertToIcon(const CCallsign &callsign);
|
static const QPixmap &convertToIcon(const CCallsign &callsign);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -29,26 +29,26 @@ namespace BlackMisc
|
|||||||
double m_value; //!< numeric part
|
double m_value; //!< numeric part
|
||||||
MU m_unit; //!< unit part
|
MU m_unit; //!< unit part
|
||||||
|
|
||||||
//! \brief Which subclass of CMeasurementUnit is used?
|
//! Which subclass of CMeasurementUnit is used?
|
||||||
typedef MU UnitClass;
|
typedef MU UnitClass;
|
||||||
|
|
||||||
//! \brief Easy access to derived class (CRTP template parameter)
|
//! Easy access to derived class (CRTP template parameter)
|
||||||
PQ const *derived() const
|
PQ const *derived() const
|
||||||
{
|
{
|
||||||
return static_cast<PQ const *>(this);
|
return static_cast<PQ const *>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Easy access to derived class (CRTP template parameter)
|
//! Easy access to derived class (CRTP template parameter)
|
||||||
PQ *derived()
|
PQ *derived()
|
||||||
{
|
{
|
||||||
return static_cast<PQ *>(this);
|
return static_cast<PQ *>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \brief Constructor with double
|
//! Constructor with double
|
||||||
CPhysicalQuantity(double value, const MU &unit);
|
CPhysicalQuantity(double value, const MU &unit);
|
||||||
|
|
||||||
//! \brief Copy constructor
|
//! Copy constructor
|
||||||
CPhysicalQuantity(const CPhysicalQuantity &other);
|
CPhysicalQuantity(const CPhysicalQuantity &other);
|
||||||
|
|
||||||
//! \copydoc CValueObject::convertToQString
|
//! \copydoc CValueObject::convertToQString
|
||||||
@@ -64,10 +64,10 @@ namespace BlackMisc
|
|||||||
virtual int compareImpl(const CValueObject &other) const override;
|
virtual int compareImpl(const CValueObject &other) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \brief Virtual destructor
|
//! Virtual destructor
|
||||||
virtual ~CPhysicalQuantity() {}
|
virtual ~CPhysicalQuantity() {}
|
||||||
|
|
||||||
//! \brief Unit
|
//! Unit
|
||||||
MU getUnit() const
|
MU getUnit() const
|
||||||
{
|
{
|
||||||
return this->m_unit;
|
return this->m_unit;
|
||||||
@@ -77,36 +77,27 @@ namespace BlackMisc
|
|||||||
* \brief Simply set unit, do no calclulate conversion
|
* \brief Simply set unit, do no calclulate conversion
|
||||||
* \sa switchUnit
|
* \sa switchUnit
|
||||||
*/
|
*/
|
||||||
void setUnit(const MU &unit)
|
void setUnit(const MU &unit) { this->m_unit = unit; }
|
||||||
{
|
|
||||||
this->m_unit = unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Set unit by string
|
//! Set unit by string
|
||||||
void setUnitBySymbol(const QString &unitName)
|
void setUnitBySymbol(const QString &unitName)
|
||||||
{
|
{
|
||||||
this->m_unit = CMeasurementUnit::unitFromSymbol<MU>(unitName);
|
this->m_unit = CMeasurementUnit::unitFromSymbol<MU>(unitName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Unit
|
//! Unit
|
||||||
QString getUnitSymbol() const
|
QString getUnitSymbol() const { return this->m_unit.getSymbol(true); }
|
||||||
{
|
|
||||||
return this->m_unit.getSymbol(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Change unit, and convert value to maintain the same quantity
|
//! Change unit, and convert value to maintain the same quantity
|
||||||
PQ &switchUnit(const MU &newUnit);
|
PQ &switchUnit(const MU &newUnit);
|
||||||
|
|
||||||
//! Is quantity null?
|
//! Is quantity null?
|
||||||
bool isNull() const
|
bool isNull() const { return this->m_unit.isNull(); }
|
||||||
{
|
|
||||||
return this->m_unit.isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Value in given unit
|
//! Value in given unit
|
||||||
double value(const MU &unit) const;
|
double value(const MU &unit) const;
|
||||||
|
|
||||||
//! \brief Value in current unit
|
//! Value in current unit
|
||||||
double value() const
|
double value() const
|
||||||
{
|
{
|
||||||
if (this->isNull())
|
if (this->isNull())
|
||||||
@@ -116,103 +107,104 @@ namespace BlackMisc
|
|||||||
return this->m_value;
|
return this->m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Set value in current unit
|
//! Set value in current unit
|
||||||
void setCurrentUnitValue(double value)
|
void setCurrentUnitValue(double value)
|
||||||
{
|
{
|
||||||
if (! this->isNull())
|
if (!this->isNull())
|
||||||
{
|
{
|
||||||
this->m_value = value;
|
this->m_value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Rounded value in given unit
|
//! \brief Rounded value in given unit
|
||||||
|
//! Rounded value in given unit
|
||||||
double valueRounded(const MU &unit, int digits = -1) const;
|
double valueRounded(const MU &unit, int digits = -1) const;
|
||||||
|
|
||||||
//! \brief Rounded value in current unit
|
//! Rounded value in current unit
|
||||||
double valueRounded(int digits = -1) const
|
double valueRounded(int digits = -1) const
|
||||||
{
|
{
|
||||||
return this->valueRounded(this->m_unit, digits);
|
return this->valueRounded(this->m_unit, digits);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Value to QString with the given unit, e.g. "5.00m"
|
//! Value to QString with the given unit, e.g. "5.00m"
|
||||||
QString valueRoundedWithUnit(const MU &unit, int digits = -1, bool i18n = false) const;
|
QString valueRoundedWithUnit(const MU &unit, int digits = -1, bool i18n = false) const;
|
||||||
|
|
||||||
//! \brief Value to QString with the current unit, e.g. "5.00m"
|
//! Value to QString with the current unit, e.g. "5.00m"
|
||||||
QString valueRoundedWithUnit(int digits = -1, bool i18n = false) const
|
QString valueRoundedWithUnit(int digits = -1, bool i18n = false) const
|
||||||
{
|
{
|
||||||
return this->valueRoundedWithUnit(this->m_unit, digits, i18n);
|
return this->valueRoundedWithUnit(this->m_unit, digits, i18n);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Change value without changing unit
|
//! Change value without changing unit
|
||||||
void setValueSameUnit(double value);
|
void setValueSameUnit(double value);
|
||||||
|
|
||||||
//! \brief Add to the value in the current unit.
|
//! Add to the value in the current unit.
|
||||||
void addValueSameUnit(double value);
|
void addValueSameUnit(double value);
|
||||||
|
|
||||||
//! \brief Substract from the value in the current unit.
|
//! Substract from the value in the current unit.
|
||||||
void substractValueSameUnit(double value);
|
void substractValueSameUnit(double value);
|
||||||
|
|
||||||
//! \brief Multiply operator *=
|
//! Multiply operator *=
|
||||||
CPhysicalQuantity &operator *=(double multiply);
|
CPhysicalQuantity &operator *=(double multiply);
|
||||||
|
|
||||||
//! \brief Divide operator /=
|
//! Divide operator /=
|
||||||
CPhysicalQuantity &operator /=(double divide);
|
CPhysicalQuantity &operator /=(double divide);
|
||||||
|
|
||||||
//! \brief Operator *
|
//! Operator *
|
||||||
PQ operator *(double multiply) const;
|
PQ operator *(double multiply) const;
|
||||||
|
|
||||||
//! \brief Operator to support commutative multiplication
|
//! Operator to support commutative multiplication
|
||||||
friend PQ operator *(double factor, const PQ &other)
|
friend PQ operator *(double factor, const PQ &other)
|
||||||
{
|
{
|
||||||
return other * factor;
|
return other * factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Operator /
|
//! Operator /
|
||||||
PQ operator /(double divide) const;
|
PQ operator /(double divide) const;
|
||||||
|
|
||||||
//! \brief Equal operator ==
|
//! Equal operator ==
|
||||||
bool operator==(const CPhysicalQuantity &other) const;
|
bool operator==(const CPhysicalQuantity &other) const;
|
||||||
|
|
||||||
//! \brief Not equal operator !=
|
//! Not equal operator !=
|
||||||
bool operator!=(const CPhysicalQuantity &other) const;
|
bool operator!=(const CPhysicalQuantity &other) const;
|
||||||
|
|
||||||
//! \brief Plus operator +=
|
//! Plus operator +=
|
||||||
CPhysicalQuantity &operator +=(const CPhysicalQuantity &other);
|
CPhysicalQuantity &operator +=(const CPhysicalQuantity &other);
|
||||||
|
|
||||||
//! \brief Minus operator-=
|
//! Minus operator-=
|
||||||
CPhysicalQuantity &operator -=(const CPhysicalQuantity &other);
|
CPhysicalQuantity &operator -=(const CPhysicalQuantity &other);
|
||||||
|
|
||||||
//! \brief Greater operator >
|
//! Greater operator >
|
||||||
bool operator >(const CPhysicalQuantity &other) const;
|
bool operator >(const CPhysicalQuantity &other) const;
|
||||||
|
|
||||||
//! \brief Less operator <
|
//! Less operator <
|
||||||
bool operator <(const CPhysicalQuantity &other) const;
|
bool operator <(const CPhysicalQuantity &other) const;
|
||||||
|
|
||||||
//! \brief Less equal operator <=
|
//! Less equal operator <=
|
||||||
bool operator <=(const CPhysicalQuantity &other) const;
|
bool operator <=(const CPhysicalQuantity &other) const;
|
||||||
|
|
||||||
//! \brief Greater equal operator >=
|
//! Greater equal operator >=
|
||||||
bool operator >=(const CPhysicalQuantity &other) const;
|
bool operator >=(const CPhysicalQuantity &other) const;
|
||||||
|
|
||||||
//! \brief Plus operator +
|
//! Plus operator +
|
||||||
PQ operator +(const PQ &other) const;
|
PQ operator +(const PQ &other) const;
|
||||||
|
|
||||||
//! \brief Minus operator -
|
//! Minus operator -
|
||||||
PQ operator -(const PQ &other) const;
|
PQ operator -(const PQ &other) const;
|
||||||
|
|
||||||
//! \brief Quantity value <= epsilon
|
//! Quantity value <= epsilon
|
||||||
bool isZeroEpsilonConsidered() const
|
bool isZeroEpsilonConsidered() const
|
||||||
{
|
{
|
||||||
return this->m_unit.isEpsilon(this->m_value);
|
return this->m_unit.isEpsilon(this->m_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Value >= 0 epsilon considered
|
//! Value >= 0 epsilon considered
|
||||||
bool isPositiveWithEpsilonConsidered() const
|
bool isPositiveWithEpsilonConsidered() const
|
||||||
{
|
{
|
||||||
return !this->isZeroEpsilonConsidered() && this->m_value > 0;
|
return !this->isZeroEpsilonConsidered() && this->m_value > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Value <= 0 epsilon considered
|
//! Value <= 0 epsilon considered
|
||||||
bool isNegativeWithEpsilonConsidered() const
|
bool isNegativeWithEpsilonConsidered() const
|
||||||
{
|
{
|
||||||
return !this->isZeroEpsilonConsidered() && this->m_value < 0;
|
return !this->isZeroEpsilonConsidered() && this->m_value < 0;
|
||||||
@@ -233,7 +225,7 @@ namespace BlackMisc
|
|||||||
//! \copydoc CValueObject::fromJson
|
//! \copydoc CValueObject::fromJson
|
||||||
virtual void fromJson(const QJsonObject &json) override;
|
virtual void fromJson(const QJsonObject &json) override;
|
||||||
|
|
||||||
//! \brief Register metadata of unit and quantity
|
//! Register metadata of unit and quantity
|
||||||
static void registerMetadata();
|
static void registerMetadata();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ namespace BlackMisc
|
|||||||
virtual bool isA(int metaTypeId) const override;
|
virtual bool isA(int metaTypeId) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \brief Default constructor
|
//! Default constructor
|
||||||
CPqString() {}
|
CPqString() {}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor
|
* Constructor
|
||||||
* \param value such as 10km/h
|
* \param value such as 10km/h
|
||||||
*/
|
*/
|
||||||
CPqString(const QString &value) : m_string(value) {}
|
CPqString(const QString &value) : m_string(value) {}
|
||||||
@@ -65,13 +65,13 @@ namespace BlackMisc
|
|||||||
//! \copydoc CValueObject::getValueHash
|
//! \copydoc CValueObject::getValueHash
|
||||||
virtual uint getValueHash() const override;
|
virtual uint getValueHash() const override;
|
||||||
|
|
||||||
//! \brief Equal operator ==
|
//! Equal operator ==
|
||||||
bool operator ==(const CPqString &other) const;
|
bool operator ==(const CPqString &other) const;
|
||||||
|
|
||||||
//! \brief Unequal operator !=
|
//! Unequal operator !=
|
||||||
bool operator !=(const CPqString &other) const;
|
bool operator !=(const CPqString &other) const;
|
||||||
|
|
||||||
//! \brief Register metadata
|
//! Register metadata
|
||||||
static void registerMetadata();
|
static void registerMetadata();
|
||||||
|
|
||||||
//! Parse a string value like "100m", "10.3Mhz"
|
//! Parse a string value like "100m", "10.3Mhz"
|
||||||
|
|||||||
@@ -15,34 +15,26 @@ namespace BlackMisc
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Time class, e.g. "ms", "hour", "s", "day"
|
* \brief Time class, e.g. "ms", "hour", "s", "day"
|
||||||
* \author KWB
|
|
||||||
*/
|
*/
|
||||||
class CTime : public CPhysicalQuantity<CTimeUnit, CTime>
|
class CTime : public CPhysicalQuantity<CTimeUnit, CTime>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
//! Default constructor
|
||||||
* \brief Default constructor
|
|
||||||
*/
|
|
||||||
CTime() : CPhysicalQuantity(0, CTimeUnit::defaultUnit()) {}
|
CTime() : CPhysicalQuantity(0, CTimeUnit::defaultUnit()) {}
|
||||||
|
|
||||||
/*!
|
//! Init by double value
|
||||||
*\brief Init by double value
|
|
||||||
* \param value
|
|
||||||
* \param unit
|
|
||||||
*/
|
|
||||||
CTime(double value, const CTimeUnit &unit) : CPhysicalQuantity(value, unit) {}
|
CTime(double value, const CTimeUnit &unit) : CPhysicalQuantity(value, unit) {}
|
||||||
|
|
||||||
/*!
|
//! By Qt time
|
||||||
* \copydoc CValueObject::toQVariant
|
CTime(const QTime &time);
|
||||||
*/
|
|
||||||
virtual QVariant toQVariant() const override
|
|
||||||
{
|
|
||||||
return QVariant::fromValue(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
//! By string hh:mm or hh:mm:ss
|
||||||
* \brief Destructor
|
CTime(const QString &time);
|
||||||
*/
|
|
||||||
|
//! \copydoc CValueObject::toQVariant
|
||||||
|
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
virtual ~CTime() {}
|
virtual ~CTime() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,112 +28,57 @@ namespace BlackMisc
|
|||||||
class CValueObject
|
class CValueObject
|
||||||
{
|
{
|
||||||
|
|
||||||
/*!
|
//! Stream << overload to be used in debugging messages
|
||||||
* \brief Stream << overload to be used in debugging messages
|
|
||||||
* \param debug
|
|
||||||
* \param uc
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend QDebug operator<<(QDebug debug, const CValueObject &uc)
|
friend QDebug operator<<(QDebug debug, const CValueObject &uc)
|
||||||
{
|
{
|
||||||
debug << uc.stringForStreaming();
|
debug << uc.stringForStreaming();
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Operator << based on text stream
|
||||||
* \brief Operator << based on text stream
|
|
||||||
* \param textStream
|
|
||||||
* \param uc
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend QTextStream &operator<<(QTextStream &textStream, const CValueObject &uc)
|
friend QTextStream &operator<<(QTextStream &textStream, const CValueObject &uc)
|
||||||
{
|
{
|
||||||
textStream << uc.stringForStreaming();
|
textStream << uc.stringForStreaming();
|
||||||
return textStream;
|
return textStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Operator << when there is no debug stream
|
||||||
* \brief Operator << when there is no debug stream
|
|
||||||
* \param nodebug
|
|
||||||
* \param valueObject
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend QNoDebug operator<<(QNoDebug nodebug, const CValueObject &valueObject)
|
friend QNoDebug operator<<(QNoDebug nodebug, const CValueObject &valueObject)
|
||||||
{
|
{
|
||||||
Q_UNUSED(valueObject);
|
Q_UNUSED(valueObject);
|
||||||
return nodebug;
|
return nodebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Operator << for QDataStream
|
||||||
* \brief Stream operator << for QDataStream
|
|
||||||
* \param stream
|
|
||||||
* \param valueObject
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend QDataStream &operator<<(QDataStream &stream, const CValueObject &valueObject)
|
friend QDataStream &operator<<(QDataStream &stream, const CValueObject &valueObject)
|
||||||
{
|
{
|
||||||
stream << valueObject.stringForStreaming();
|
stream << valueObject.stringForStreaming();
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Stream operator << for std::cout
|
||||||
* \brief Stream operator << for std::cout
|
|
||||||
* \param ostr
|
|
||||||
* \param uc
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend std::ostream &operator<<(std::ostream &ostr, const CValueObject &uc)
|
friend std::ostream &operator<<(std::ostream &ostr, const CValueObject &uc)
|
||||||
{
|
{
|
||||||
ostr << uc.stringForStreaming().toStdString();
|
ostr << uc.stringForStreaming().toStdString();
|
||||||
return ostr;
|
return ostr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Unmarshalling operator >>, DBus to object
|
||||||
* \brief Unmarshalling operator >>, DBus to object
|
|
||||||
* \param argument
|
|
||||||
* \param valueObject
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend const QDBusArgument &operator>>(const QDBusArgument &argument, CValueObject &valueObject);
|
friend const QDBusArgument &operator>>(const QDBusArgument &argument, CValueObject &valueObject);
|
||||||
|
|
||||||
/*!
|
//! Marshalling operator <<, object to DBus
|
||||||
* \brief Marshalling operator <<, object to DBus
|
|
||||||
* \param argument
|
|
||||||
* \param valueObject
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend QDBusArgument &operator<<(QDBusArgument &argument, const CValueObject &valueObject);
|
friend QDBusArgument &operator<<(QDBusArgument &argument, const CValueObject &valueObject);
|
||||||
|
|
||||||
/*!
|
//! Operator == with value map
|
||||||
* \brief Operator == with value map
|
|
||||||
* \param valueMap
|
|
||||||
* \param valueObject
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend bool operator==(const CIndexVariantMap &valueMap, const CValueObject &valueObject);
|
friend bool operator==(const CIndexVariantMap &valueMap, const CValueObject &valueObject);
|
||||||
|
|
||||||
/*!
|
//! Operator != with value map
|
||||||
* \brief Operator != with value map
|
|
||||||
* \param valueMap
|
|
||||||
* \param valueObject
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend bool operator!=(const CIndexVariantMap &valueMap, const CValueObject &valueObject);
|
friend bool operator!=(const CIndexVariantMap &valueMap, const CValueObject &valueObject);
|
||||||
|
|
||||||
/*!
|
//! Operator == with value map
|
||||||
* \brief operator == with value map
|
|
||||||
* \param valueObject
|
|
||||||
* \param valueMap
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend bool operator==(const CValueObject &valueObject, const CIndexVariantMap &valueMap);
|
friend bool operator==(const CValueObject &valueObject, const CIndexVariantMap &valueMap);
|
||||||
|
|
||||||
/*!
|
//! Operator != with value map
|
||||||
* \brief Operator != with value map
|
|
||||||
* \param valueObject
|
|
||||||
* \param valueMap
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
friend bool operator!=(const CValueObject &valueObject, const CIndexVariantMap &valueMap);
|
friend bool operator!=(const CValueObject &valueObject, const CIndexVariantMap &valueMap);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -146,57 +91,34 @@ namespace BlackMisc
|
|||||||
friend int compare(const CValueObject &v1, const CValueObject &v2);
|
friend int compare(const CValueObject &v1, const CValueObject &v2);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
//! Virtual destructor
|
||||||
* \brief Virtual destructor
|
|
||||||
*/
|
|
||||||
virtual ~CValueObject() {}
|
virtual ~CValueObject() {}
|
||||||
|
|
||||||
/*!
|
//! Cast as QString
|
||||||
* \brief Cast as QString
|
|
||||||
*/
|
|
||||||
QString toQString(bool i18n = false) const;
|
QString toQString(bool i18n = false) const;
|
||||||
|
|
||||||
/*!
|
//! Cast to pretty-printed QString
|
||||||
* \brief Cast to pretty-printed QString
|
|
||||||
*/
|
|
||||||
virtual QString toFormattedQString(bool i18n = false) const;
|
virtual QString toFormattedQString(bool i18n = false) const;
|
||||||
|
|
||||||
/*!
|
//! To std string
|
||||||
* \brief To std string
|
|
||||||
*/
|
|
||||||
std::string toStdString(bool i18n = false) const;
|
std::string toStdString(bool i18n = false) const;
|
||||||
|
|
||||||
/*!
|
//! Update by variant map
|
||||||
* \brief Update by variant map
|
|
||||||
*/
|
|
||||||
int apply(const BlackMisc::CIndexVariantMap &indexMap);
|
int apply(const BlackMisc::CIndexVariantMap &indexMap);
|
||||||
|
|
||||||
/*!
|
//! Value hash, allows comparisons between QVariants
|
||||||
* \brief Value hash, allows comparisons between QVariants
|
|
||||||
*/
|
|
||||||
virtual uint getValueHash() const = 0;
|
virtual uint getValueHash() const = 0;
|
||||||
|
|
||||||
/*!
|
//! Virtual method to return QVariant, used with DBus QVariant lists
|
||||||
* \brief Virtual method to return QVariant, used with DBus QVariant lists
|
|
||||||
*/
|
|
||||||
virtual QVariant toQVariant() const = 0;
|
virtual QVariant toQVariant() const = 0;
|
||||||
|
|
||||||
/*!
|
//! Contribute to JSON object
|
||||||
* \brief Contribute to JSON object
|
|
||||||
* \return updated JSON object
|
|
||||||
*/
|
|
||||||
virtual QJsonObject toJson() const { QJsonObject json; return json;}
|
virtual QJsonObject toJson() const { QJsonObject json; return json;}
|
||||||
|
|
||||||
/*!
|
//! Initialize from JSON object
|
||||||
* \brief Initialize from JSOn object
|
|
||||||
* \param json
|
|
||||||
*/
|
|
||||||
virtual void fromJson(const QJsonObject &json) { Q_UNUSED(json); }
|
virtual void fromJson(const QJsonObject &json) { Q_UNUSED(json); }
|
||||||
|
|
||||||
/*!
|
//! As icon, not implement by all classes
|
||||||
* \brief As icon, not implement by all classes
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
virtual const QPixmap &toIcon() const { static const QPixmap p; return p; }
|
virtual const QPixmap &toIcon() const { static const QPixmap p; return p; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -224,43 +146,26 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
virtual QString propertyByIndexAsString(int index, bool i18n = false) const;
|
virtual QString propertyByIndexAsString(int index, bool i18n = false) const;
|
||||||
|
|
||||||
/*!
|
//! \brief The stored object as CValueObject
|
||||||
* \brief The stored object as CValueObject
|
|
||||||
*/
|
|
||||||
static const CValueObject *fromQVariant(const QVariant &qv);
|
static const CValueObject *fromQVariant(const QVariant &qv);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*!
|
//! Default constructor
|
||||||
* \brief Default constructor
|
|
||||||
*/
|
|
||||||
CValueObject() {}
|
CValueObject() {}
|
||||||
|
|
||||||
/*!
|
//! Copy constructor
|
||||||
* \brief Copy constructor
|
|
||||||
*/
|
|
||||||
CValueObject(const CValueObject &) {}
|
CValueObject(const CValueObject &) {}
|
||||||
|
|
||||||
/*!
|
//! Copy assignment operator =
|
||||||
* \brief Copy assignment operator =
|
|
||||||
*/
|
|
||||||
CValueObject &operator=(const CValueObject &) { return *this; }
|
CValueObject &operator=(const CValueObject &) { return *this; }
|
||||||
|
|
||||||
/*!
|
//! String for streaming operators
|
||||||
* \brief String for streaming operators
|
|
||||||
*/
|
|
||||||
virtual QString stringForStreaming() const;
|
virtual QString stringForStreaming() const;
|
||||||
|
|
||||||
/*!
|
//! String for QString conversion
|
||||||
* \brief String for QString conversion
|
|
||||||
* \param i18n
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
virtual QString convertToQString(bool i18n = false) const = 0;
|
virtual QString convertToQString(bool i18n = false) const = 0;
|
||||||
|
|
||||||
/*!
|
//! Returns the Qt meta type ID of this object.
|
||||||
* \brief Returns the Qt meta type ID of this object.
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
virtual int getMetaTypeId() const = 0;
|
virtual int getMetaTypeId() const = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -281,16 +186,15 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
virtual int compareImpl(const CValueObject &other) const = 0;
|
virtual int compareImpl(const CValueObject &other) const = 0;
|
||||||
|
|
||||||
/*!
|
//! Marshall to DBus
|
||||||
* \brief Marshall to DBus
|
|
||||||
*/
|
|
||||||
virtual void marshallToDbus(QDBusArgument &) const = 0;
|
virtual void marshallToDbus(QDBusArgument &) const = 0;
|
||||||
|
|
||||||
/*!
|
//! Unmarshall from DBus
|
||||||
* \brief Unmarshall from DBus
|
|
||||||
*/
|
|
||||||
virtual void unmarshallFromDbus(const QDBusArgument &) = 0;
|
virtual void unmarshallFromDbus(const QDBusArgument &) = 0;
|
||||||
|
|
||||||
|
//! Parse from string, e.g. 100km/h
|
||||||
|
virtual void parseFromString(const QString &) { qFatal("Not implemented"); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -331,36 +235,21 @@ namespace BlackMisc
|
|||||||
return argument << static_cast<CValueObject const &>(valueObject);
|
return argument << static_cast<CValueObject const &>(valueObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Non member, non friend operator >> for JSON
|
||||||
* \brief Non member, non friend operator >> for JSON
|
|
||||||
* \param json
|
|
||||||
* \param valueObject
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
inline const QJsonObject &operator>>(const QJsonObject &json, CValueObject &valueObject)
|
inline const QJsonObject &operator>>(const QJsonObject &json, CValueObject &valueObject)
|
||||||
{
|
{
|
||||||
valueObject.fromJson(json);
|
valueObject.fromJson(json);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Non member, non friend operator >> for JSON
|
||||||
* \brief Non member, non friend operator >> for JSON
|
|
||||||
* \param json
|
|
||||||
* \param valueObject
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
inline const QJsonValue &operator>>(const QJsonValue &json, CValueObject &valueObject)
|
inline const QJsonValue &operator>>(const QJsonValue &json, CValueObject &valueObject)
|
||||||
{
|
{
|
||||||
valueObject.fromJson(json.toObject());
|
valueObject.fromJson(json.toObject());
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Non member, non friend operator >> for JSON
|
||||||
* \brief Non member, non friend operator >> for JSON
|
|
||||||
* \param json
|
|
||||||
* \param valueObject
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
inline const QJsonValueRef &operator>>(const QJsonValueRef &json, CValueObject &valueObject)
|
inline const QJsonValueRef &operator>>(const QJsonValueRef &json, CValueObject &valueObject)
|
||||||
{
|
{
|
||||||
valueObject.fromJson(json.toObject());
|
valueObject.fromJson(json.toObject());
|
||||||
@@ -382,7 +271,7 @@ namespace BlackMisc
|
|||||||
/*!
|
/*!
|
||||||
* \brief Non member, non friend operator >> for JSON
|
* \brief Non member, non friend operator >> for JSON
|
||||||
* \param json
|
* \param json
|
||||||
* \param value
|
* \param value as pair name/value
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, QJsonObject>::type &
|
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, QJsonObject>::type &
|
||||||
@@ -392,11 +281,7 @@ namespace BlackMisc
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Allow comparison with QVariant, e.g. QVariant == CFrequency ?
|
||||||
* Allow comparison with QVariant, e.g. QVariant == CFrequency ?
|
|
||||||
* \param variant
|
|
||||||
* \param valueObject
|
|
||||||
*/
|
|
||||||
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, bool>::type
|
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, bool>::type
|
||||||
operator==(const QVariant &variant, const T &valueObject)
|
operator==(const QVariant &variant, const T &valueObject)
|
||||||
{
|
{
|
||||||
@@ -405,45 +290,28 @@ namespace BlackMisc
|
|||||||
return vuc == valueObject;
|
return vuc == valueObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Allow comparison with QVariant, e.g. QVariant != CFrequency ?
|
||||||
* \brief Allow comparison with QVariant, e.g. QVariant != CFrequency ?
|
|
||||||
* \param variant
|
|
||||||
* \param valueObject
|
|
||||||
*/
|
|
||||||
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, bool>::type
|
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, bool>::type
|
||||||
operator!=(const QVariant &variant, const T &valueObject)
|
operator!=(const QVariant &variant, const T &valueObject)
|
||||||
{
|
{
|
||||||
return !(variant == valueObject);
|
return !(variant == valueObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Allow comparison with QVariant, e.g. QVariant == CFrequency ?
|
||||||
* \brief Allow comparison with QVariant, e.g. QVariant == CFrequency ?
|
|
||||||
* \param valueObject
|
|
||||||
* \param variant
|
|
||||||
*/
|
|
||||||
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, bool>::type
|
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, bool>::type
|
||||||
operator==(const T &valueObject, const QVariant &variant)
|
operator==(const T &valueObject, const QVariant &variant)
|
||||||
{
|
{
|
||||||
return variant == valueObject;
|
return variant == valueObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Allow comparison with QVariant, e.g. QVariant != CFrequency ?
|
||||||
* \brief Allow comparison with QVariant, e.g. QVariant != CFrequency ?
|
|
||||||
* \param valueObject
|
|
||||||
* \param variant
|
|
||||||
*/
|
|
||||||
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, bool>::type
|
template <class T> typename std::enable_if<std::is_base_of<CValueObject, T>::value, bool>::type
|
||||||
operator!=(const T &valueObject, const QVariant &variant)
|
operator!=(const T &valueObject, const QVariant &variant)
|
||||||
{
|
{
|
||||||
return variant != valueObject;
|
return variant != valueObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! qHash overload, needed for storing CValueObject in a QSet.
|
||||||
* qHash overload, needed for storing CValueObject in a QSet.
|
|
||||||
* \param value
|
|
||||||
* \param seed
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
inline uint qHash(const BlackMisc::CValueObject &value, uint seed = 0)
|
inline uint qHash(const BlackMisc::CValueObject &value, uint seed = 0)
|
||||||
{
|
{
|
||||||
return ::qHash(value.getValueHash(), seed);
|
return ::qHash(value.getValueHash(), seed);
|
||||||
|
|||||||
Reference in New Issue
Block a user