refs #319, added column formatters

* Specialized formatters (e.g. for bool, for PQs etc.) allow specialized look and feel for each column
* Fixed isValidComFrequency used for formatters
* Changed models to use formatters
* Outdated propertyByIndexAsString methods removed
* During the above tasks: fixed override keyword in some places
* Column tooltips
* refs #323, wrong column name fix
This commit is contained in:
Klaus Basan
2014-08-31 15:31:19 +02:00
parent c54fa0fd43
commit 9567d1aedf
21 changed files with 893 additions and 303 deletions

View File

@@ -351,10 +351,7 @@ namespace BlackMisc
case IndexVoiceRoom:
return QVariant(this->m_voiceRoom.propertyByIndex(index.copyFrontRemoved()));
default:
if (ICoordinateGeodetic::canHandleIndex(index))
{
return ICoordinateGeodetic::propertyByIndex(index);
}
if (ICoordinateGeodetic::canHandleIndex(index)) { return ICoordinateGeodetic::propertyByIndex(index); }
return CValueObject::propertyByIndex(index);
}
}
@@ -424,49 +421,8 @@ namespace BlackMisc
bool CAtcStation::isA(int metaTypeId) const
{
if (metaTypeId == qMetaTypeId<CAtcStation>()) { return true; }
return this->CValueObject::isA(metaTypeId);
}
/*
* Property as string by index
*/
QString CAtcStation::propertyByIndexAsString(const BlackMisc::CPropertyIndex &index, bool i18n) const
{
QVariant qv = this->propertyByIndex(index);
ColumnIndex i = index.frontCasted<ColumnIndex>();
// special treatment
// this is required as it is possible an ATC station is not containing all
// properties
switch (i)
{
case IndexFrequency:
if (!CComSystem::isValidCivilAviationFrequency(qv.value<CFrequency>()))
return "";
else
return qv.value<CFrequency>().valueRoundedWithUnit(3, i18n);
break;
case IndexDistance:
{
CLength distance = qv.value<CLength>();
if (distance.isNegativeWithEpsilonConsidered()) return "";
return distance.toQString(i18n);
}
case IndexBookedFrom:
case IndexBookedUntil:
{
QDateTime dt = qv.value<QDateTime>();
if (dt.isNull() || !dt.isValid()) return "";
return dt.toString("yyyy-MM-dd HH:mm");
break;
}
default:
break;
}
return BlackMisc::qVariantToString(qv, i18n);
}
} // namespace
} // namespace

View File

@@ -278,9 +278,6 @@ namespace BlackMisc
//! \copydoc CValueObject::setPropertyByIndex(variant, index)
virtual void setPropertyByIndex(const QVariant &variant, const CPropertyIndex &index) override;
//! \copydoc CValueObject::propertyByIndexAsString()
virtual QString propertyByIndexAsString(const BlackMisc::CPropertyIndex &index, bool i18n = false) const override;
//! \copydoc CValueObject::toJson
virtual QJsonObject toJson() const override;

View File

@@ -130,6 +130,7 @@ namespace BlackMisc
//! 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;
}
@@ -137,10 +138,17 @@ namespace BlackMisc
//! 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;
}
//! Valid COM frequency (either civil or military)
static bool isValidComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f)
{
return isValidCivilAviationFrequency(f) || isValidMilitaryFrequency(f);
}
/*!
* Round to channel spacing, set MHz as unit
* \see ChannelSpacing