mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
refs #452, added color formatter for models
This commit is contained in:
committed by
Mathew Sutcliffe
parent
fb4baa0ef8
commit
7100072820
@@ -10,6 +10,7 @@
|
|||||||
#include "columnformatters.h"
|
#include "columnformatters.h"
|
||||||
#include "blackmisc/geo/latitude.h"
|
#include "blackmisc/geo/latitude.h"
|
||||||
#include "blackmisc/aviation/altitude.h"
|
#include "blackmisc/aviation/altitude.h"
|
||||||
|
#include "blackmisc/rgbcolor.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"
|
||||||
@@ -302,7 +303,7 @@ namespace BlackGui
|
|||||||
CVariant CBoolLedFormatter::displayRole(const CVariant &dataCVariant) const
|
CVariant CBoolLedFormatter::displayRole(const CVariant &dataCVariant) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(dataCVariant);
|
Q_UNUSED(dataCVariant);
|
||||||
Q_ASSERT_X(false, "CBoolLedFormatter", "this role should be disabled with led boolean");
|
Q_ASSERT_X(false, Q_FUNC_INFO, "this role should be disabled with led boolean");
|
||||||
return CVariant();
|
return CVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,5 +367,30 @@ namespace BlackGui
|
|||||||
return alt.toQString(this->m_useI18n);
|
return alt.toQString(this->m_useI18n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CColorFormatter::CColorFormatter(int alignment, bool i18n) : CDefaultFormatter(alignment, i18n, rolesDecorationAndToolTip())
|
||||||
|
{}
|
||||||
|
|
||||||
|
CVariant CColorFormatter::displayRole(const CVariant &dataCVariant) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(dataCVariant);
|
||||||
|
Q_ASSERT_X(false, Q_FUNC_INFO, "this role should be disabled with RGB color");
|
||||||
|
return CVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
CVariant CColorFormatter::decorationRole(const CVariant &dataCVariant) const
|
||||||
|
{
|
||||||
|
static const CVariant empty(CVariant::fromValue(QPixmap()));
|
||||||
|
CRgbColor rgbColor(dataCVariant.to<CRgbColor>());
|
||||||
|
if (!rgbColor.isValid()) { return empty; }
|
||||||
|
return CVariant::fromValue(rgbColor.toPixmap());
|
||||||
|
}
|
||||||
|
|
||||||
|
CVariant CColorFormatter::tooltipRole(const CVariant &dataCVariant) const
|
||||||
|
{
|
||||||
|
CRgbColor rgbColor(dataCVariant.to<CRgbColor>());
|
||||||
|
if (!rgbColor.isValid()) { return ""; }
|
||||||
|
return rgbColor.hex(true);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -282,6 +282,23 @@ namespace BlackGui
|
|||||||
bool m_flightLevel = false;
|
bool m_flightLevel = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Formatter when column contains a color
|
||||||
|
class CColorFormatter : public CDefaultFormatter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
CColorFormatter(int alignment = alignCentered(), bool i18n = true);
|
||||||
|
|
||||||
|
//! \copydoc CDefaultFormatter::displayRole
|
||||||
|
virtual BlackMisc::CVariant displayRole(const BlackMisc::CVariant &dataCVariant) const override;
|
||||||
|
|
||||||
|
//! Display the icon
|
||||||
|
virtual BlackMisc::CVariant decorationRole(const BlackMisc::CVariant &dataCVariant) const override;
|
||||||
|
|
||||||
|
//! \copydoc CDefaultFormatter::tooltipRole
|
||||||
|
virtual BlackMisc::CVariant tooltipRole(const BlackMisc::CVariant &dataCVariant) const override;
|
||||||
|
};
|
||||||
|
|
||||||
//! 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
|
||||||
{
|
{
|
||||||
@@ -361,7 +378,7 @@ namespace BlackGui
|
|||||||
virtual BlackMisc::CVariant displayRole(const BlackMisc::CVariant &dataCVariant) const override;
|
virtual BlackMisc::CVariant displayRole(const BlackMisc::CVariant &dataCVariant) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Airspace distance
|
//! Airspeed
|
||||||
class CAircraftSpeedFormatter : public CPhysiqalQuantiyFormatter<BlackMisc::PhysicalQuantities::CSpeedUnit, BlackMisc::PhysicalQuantities::CSpeed>
|
class CAircraftSpeedFormatter : public CPhysiqalQuantiyFormatter<BlackMisc::PhysicalQuantities::CSpeedUnit, BlackMisc::PhysicalQuantities::CSpeed>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user