Minor tweaks:

* Altitude formatter for GUI
* borders for CDockWidget
* homebase for ATC
This commit is contained in:
Klaus Basan
2015-04-30 00:31:17 +02:00
committed by Mathew Sutcliffe
parent 3c15f2ad89
commit 6570a0c966
9 changed files with 58 additions and 16 deletions

View File

@@ -9,11 +9,13 @@
#include "columnformatters.h" #include "columnformatters.h"
#include "blackmisc/geo/latitude.h" #include "blackmisc/geo/latitude.h"
#include "blackmisc/aviation/altitude.h"
#include "blackmisc/variant.h" #include "blackmisc/variant.h"
#include "blackmisc/iconlist.h" #include "blackmisc/iconlist.h"
#include "blackmisc/icons.h" #include "blackmisc/icons.h"
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Aviation;
namespace BlackGui namespace BlackGui
{ {
@@ -357,5 +359,13 @@ namespace BlackGui
return CBoolTextFormatter::displayRole(dataCVariant); return CBoolTextFormatter::displayRole(dataCVariant);
} }
CVariant CAltitudeFormatter::displayRole(const CVariant &altitude) const
{
CAltitude alt;
alt.convertFromCVariant(altitude);
if (m_flightLevel) { alt.toFlightLevel(); }
return alt.toQString(this->m_useI18n);
}
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -268,12 +268,26 @@ namespace BlackGui
QString m_formatString = "yyyy-MM-dd HH:mm"; //!< how the value is displayed QString m_formatString = "yyyy-MM-dd HH:mm"; //!< how the value is displayed
}; };
//! Formatter when column contains an altitude
class CAltitudeFormatter : public CDefaultFormatter
{
public:
//! Constructor
CAltitudeFormatter(bool flightlevel = false, int alignment = alignDefault(), bool i18n = true) : CDefaultFormatter(alignment, i18n), m_flightLevel(flightlevel) {}
//! \copydoc CDefaultFormatter::displayRole
virtual BlackMisc::CVariant displayRole(const BlackMisc::CVariant &altitude) const override;
private:
bool m_flightLevel = false;
};
//! Formatter for physical quantities //! Formatter for physical quantities
template<class MU, class PQ> class CPhysiqalQuantiyFormatter : public CValueObjectFormatter template<class MU, class PQ> class CPhysiqalQuantiyFormatter : public CValueObjectFormatter
{ {
public: public:
//! Constructor //! Constructor
CPhysiqalQuantiyFormatter(MU unit = MU::defaultUnit(), int digits = 2, int alignment = alignRightVCenter(), bool withUnit = true, bool i18n = true, QList<int> supportedRoles = roleDisplay() ) : CValueObjectFormatter(alignment, i18n, supportedRoles), m_unit(unit), m_digits(digits), m_withUnit(withUnit) {} CPhysiqalQuantiyFormatter(MU unit = MU::defaultUnit(), int digits = 2, int alignment = alignRightVCenter(), bool withUnit = true, bool i18n = true, QList<int> supportedRoles = roleDisplay()) : CValueObjectFormatter(alignment, i18n, supportedRoles), m_unit(unit), m_digits(digits), m_withUnit(withUnit) {}
//! \copydoc CDefaultFormatter::displayRole //! \copydoc CDefaultFormatter::displayRole
virtual BlackMisc::CVariant displayRole(const BlackMisc::CVariant &physicalQuantity) const override virtual BlackMisc::CVariant displayRole(const BlackMisc::CVariant &physicalQuantity) const override

View File

@@ -59,7 +59,7 @@ namespace BlackGui
this->m_columns.addColumn(CColumn::standardString("transponder", { CSimulatedAircraft::IndexTransponder, CTransponder::IndexTransponderCodeAndModeFormatted })); this->m_columns.addColumn(CColumn::standardString("transponder", { CSimulatedAircraft::IndexTransponder, CTransponder::IndexTransponderCodeAndModeFormatted }));
this->m_columns.addColumn(CColumn("latitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexLatitude }, new CLatLonFormatter())); this->m_columns.addColumn(CColumn("latitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexLatitude }, new CLatLonFormatter()));
this->m_columns.addColumn(CColumn("longitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexLongitude }, new CLatLonFormatter())); this->m_columns.addColumn(CColumn("longitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexLongitude }, new CLatLonFormatter()));
this->m_columns.addColumn(CColumn::standardValueObject("altitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexAltitude }, CDefaultFormatter::alignRightVCenter())); this->m_columns.addColumn(CColumn("altitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexAltitude }, new CAltitudeFormatter()));
this->m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundspeed }, new CAircraftSpeedFormatter())); this->m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundspeed }, new CAircraftSpeedFormatter()));
// default sort order // default sort order
@@ -83,7 +83,7 @@ namespace BlackGui
this->m_columns.addColumn(CColumn::standardString("model", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexModelString})); this->m_columns.addColumn(CColumn::standardString("model", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexModelString}));
this->m_columns.addColumn(CColumn::standardString("desc.", "description", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexDescription})); this->m_columns.addColumn(CColumn::standardString("desc.", "description", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexDescription}));
this->m_columns.addColumn(CColumn::standardString("type", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexModelTypeAsString})); this->m_columns.addColumn(CColumn::standardString("type", { CSimulatedAircraft::IndexModel, CAircraftModel::IndexModelTypeAsString}));
this->m_columns.addColumn(CColumn::standardValueObject("altitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexAltitude }, CDefaultFormatter::alignRightVCenter())); this->m_columns.addColumn(CColumn("altitude", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexAltitude }, new CAltitudeFormatter()));
this->m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundspeed }, new CAircraftSpeedFormatter())); this->m_columns.addColumn(CColumn("gs.", { CSimulatedAircraft::IndexSituation, CAircraftSituation::IndexGroundspeed }, new CAircraftSpeedFormatter()));
// default sort order // default sort order

View File

@@ -16,7 +16,7 @@ margindocked.bottom = 0
; why the odd numbers?? ; why the odd numbers??
marginfloating.left = 0 marginfloating.left = 0
marginfloating.right = 15 marginfloating.right = 15
marginfloating.top = 0 marginfloating.top = 3
marginfloating.bottom = 35 marginfloating.bottom = 35
marginfloating.frameless.left = 0 marginfloating.frameless.left = 0

View File

@@ -33,10 +33,14 @@ namespace BlackMisc
} }
else else
{ {
QString s = this->CLength::valueRoundedWithUnit(4, i18n); QString s;
if (this->getUnit() != CLengthUnit::ft()) if (this->getUnit() == CLengthUnit::m())
{ {
s.append(" (").append(this->valueRoundedWithUnit(CLengthUnit::ft(), 4, i18n)).append(")"); s = this->CLength::valueRoundedWithUnit(1, i18n);
}
else
{
s = this->CLength::valueRoundedWithUnit(CLengthUnit::ft(), 0, i18n);
} }
return s.append(this->isMeanSeaLevel() ? " MSL" : " AGL"); return s.append(this->isMeanSeaLevel() ? " MSL" : " AGL");
} }

View File

@@ -25,12 +25,14 @@ namespace BlackMisc
CUser::CUser(const QString &id, const QString &realname, const CCallsign &callsign) CUser::CUser(const QString &id, const QString &realname, const CCallsign &callsign)
: m_id(id.trimmed()), m_realname(realname), m_callsign(callsign) : m_id(id.trimmed()), m_realname(realname), m_callsign(callsign)
{ {
this->setRealName(realname); // extracts homebase this->deriveHomeBaseFromCallsign();
this->setRealName(realname); // extracts homebase if this is included in real name
} }
CUser::CUser(const QString &id, const QString &realname, const QString &email, const QString &password, const CCallsign &callsign) CUser::CUser(const QString &id, const QString &realname, const QString &email, const QString &password, const CCallsign &callsign)
: m_id(id.trimmed()), m_realname(realname), m_email(email), m_password(password), m_callsign(callsign) : m_id(id.trimmed()), m_realname(realname), m_email(email), m_password(password), m_callsign(callsign)
{ {
this->deriveHomeBaseFromCallsign();
this->setRealName(realname); // extracts homebase this->setRealName(realname); // extracts homebase
} }
@@ -50,9 +52,20 @@ namespace BlackMisc
return s; return s;
} }
void CUser::deriveHomeBaseFromCallsign()
{
if (this->m_callsign.isEmpty()) { return; }
if (this->m_homebase.isEmpty())
{
if (this->m_callsign.isAtcCallsign())
{
this->m_homebase = this->m_callsign.getIcaoCode();
}
}
}
void CUser::setRealName(const QString &realname) void CUser::setRealName(const QString &realname)
{ {
QString rn(realname.trimmed().simplified()); QString rn(realname.trimmed().simplified());
if (rn.isEmpty()) if (rn.isEmpty())
{ {

View File

@@ -142,6 +142,9 @@ namespace BlackMisc
private: private:
BLACK_ENABLE_TUPLE_CONVERSION(CUser) BLACK_ENABLE_TUPLE_CONVERSION(CUser)
//! derive homebase from callsign
void deriveHomeBaseFromCallsign();
QString m_id; QString m_id;
QString m_realname; QString m_realname;
QString m_email; QString m_email;

View File

@@ -34,8 +34,8 @@ namespace BlackMisc
CLength(const QString &unitString) : CPhysicalQuantity(unitString) {} CLength(const QString &unitString) : CPhysicalQuantity(unitString) {}
}; };
} } // ns
} } // ns
Q_DECLARE_METATYPE(BlackMisc::PhysicalQuantities::CLength) Q_DECLARE_METATYPE(BlackMisc::PhysicalQuantities::CLength)

View File

@@ -69,11 +69,9 @@ namespace BlackMisc
//! Unit //! Unit
MU getUnit() const; MU getUnit() const;
/*! //! Simply set unit, do no calclulate conversion
* \brief Simply set unit, do no calclulate conversion //! \sa switchUnit
* \sa switchUnit void setUnit(const MU &unit) { this->m_unit = unit; }
*/
void setUnit(const MU &unit);
//! Set unit by string //! Set unit by string
void setUnitBySymbol(const QString &unitName); void setUnitBySymbol(const QString &unitName);