Ref T275, CAircraftSituationChange view/model

* added some more indexes
* CAircraftSituationChangeListModel
* CAircraftSituationChangeListView
This commit is contained in:
Klaus Basan
2018-06-10 02:15:00 +02:00
parent 169dca8d84
commit 69e1c3f4c2
17 changed files with 309 additions and 15 deletions

View File

@@ -14,6 +14,7 @@
#include "blackmisc/pq/angle.h"
#include "blackmisc/pq/units.h"
#include "blackmisc/math/mathutils.h"
#include "blackmisc/comparefunctions.h"
#include "blackmisc/propertyindex.h"
#include "blackmisc/variant.h"
#include "blackmisc/verify.h"
@@ -113,22 +114,27 @@ namespace BlackMisc
CVariant CAircraftSituationChange::propertyByIndex(const CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
if (index.isMyself()) { return CVariant::fromValue(*this); }
if (ITimestampWithOffsetBased::canHandleIndex(index)) { return ITimestampWithOffsetBased::propertyByIndex(index); }
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexCallsign: return m_correspondingCallsign.propertyByIndex(index.copyFrontRemoved());
case IndexConstAscending: return CVariant::from(m_constAscending);
case IndexConstDescending: return CVariant::from(m_constDescending);
case IndexConstNotOnGround: return CVariant::from(m_constNotOnGround);
case IndexConstOnGround: return CVariant::from(m_constOnGround);
case IndexIsNull: return CVariant::from(this->isNull());
case IndexJustTakingOff: return CVariant::from(m_justTakeoff);
case IndexJustTouchingDown: return CVariant::from(m_justTouchdown);
case IndexRotatingUp: return CVariant::from(m_rotateUp);
case IndexContainsPushBack: return CVariant::from(m_containsPushBack);
case IndexSituationsCount: return CVariant::fromValue(m_situationsCount);
case IndexConstAscending: return CVariant::fromValue(m_constAscending);
case IndexConstDescending: return CVariant::fromValue(m_constDescending);
case IndexConstNotOnGround: return CVariant::fromValue(m_constNotOnGround);
case IndexConstOnGround: return CVariant::fromValue(m_constOnGround);
case IndexIsNull: return CVariant::fromValue(this->isNull());
case IndexJustTakingOff: return CVariant::fromValue(m_justTakeoff);
case IndexJustTouchingDown: return CVariant::fromValue(m_justTouchdown);
case IndexRotatingUp: return CVariant::fromValue(m_rotateUp);
case IndexContainsPushBack: return CVariant::fromValue(m_containsPushBack);
case IndexAltitudeMean: return CVariant::fromValue(m_altMean);
case IndexAltitudeStdDev: return CVariant::fromValue(m_altStdDev);
case IndexElevationMean: return CVariant::fromValue(m_elvMean);
case IndexElevationStdDev: return CVariant::fromValue(m_elvStdDev);
default: return CValueObject::propertyByIndex(index);
}
}
@@ -142,6 +148,7 @@ namespace BlackMisc
switch (i)
{
case IndexCallsign: m_correspondingCallsign.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
case IndexSituationsCount: m_situationsCount = variant.toInt(); break;
case IndexConstAscending: m_constAscending = variant.toBool(); break;
case IndexConstDescending: m_constDescending = variant.toBool(); break;
case IndexConstNotOnGround: m_constNotOnGround = variant.toBool(); break;
@@ -150,11 +157,45 @@ namespace BlackMisc
case IndexJustTouchingDown: m_justTouchdown = variant.toBool(); break;
case IndexRotatingUp: m_rotateUp = variant.toBool(); break;
case IndexContainsPushBack: m_containsPushBack = variant.toBool(); break;
case IndexIsNull: break;
case IndexIsNull:
case IndexAltitudeMean:
case IndexAltitudeStdDev:
case IndexElevationMean:
case IndexElevationStdDev:
break; // read only
default: CValueObject::setPropertyByIndex(index, variant); break;
}
}
int CAircraftSituationChange::comparePropertyByIndex(const CPropertyIndex &index, const CAircraftSituationChange &compareValue) const
{
if (index.isMyself()) { return ITimestampWithOffsetBased::comparePropertyByIndex(CPropertyIndex(), compareValue); }
if (ITimestampWithOffsetBased::canHandleIndex(index)) { return ITimestampWithOffsetBased::comparePropertyByIndex(index, compareValue); }
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexCallsign: return m_correspondingCallsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
case IndexSituationsCount: return Compare::compare(this->getSituationsCount(), compareValue.getSituationsCount());
case IndexConstAscending: return Compare::compare(this->isConstAscending(), compareValue.isConstAscending());
case IndexConstDescending: return Compare::compare(this->isConstDescending(), compareValue.isConstDescending());
case IndexConstNotOnGround: return Compare::compare(this->isConstNotOnGround(), compareValue.isConstNotOnGround());
case IndexConstOnGround: return Compare::compare(this->isConstOnGround(), compareValue.isConstOnGround());
case IndexJustTakingOff: return Compare::compare(this->isJustTakingOff(), compareValue.isJustTakingOff());
case IndexJustTouchingDown: return Compare::compare(this->isJustTouchingDown(), compareValue.isJustTouchingDown());
case IndexRotatingUp: return Compare::compare(this->isRotatingUp(), compareValue.isRotatingUp());
case IndexContainsPushBack: return Compare::compare(this->containsPushBack(), compareValue.containsPushBack());
case IndexIsNull: return Compare::compare(this->isNull(), compareValue.isNull());
case IndexAltitudeMean: return m_altMean.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_altMean);
case IndexAltitudeStdDev: return m_altStdDev.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_altStdDev);
case IndexElevationMean: return m_elvMean.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_elvMean);
case IndexElevationStdDev: return m_elvStdDev.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.m_elvStdDev);
default: return CValueObject::comparePropertyByIndex(index, *this);
}
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
return 0;
}
bool CAircraftSituationChange::calculateStdDeviations(const CAircraftSituationList &situations, const CLength &cg)
{
if (situations.isEmpty()) { return false; }

View File

@@ -50,7 +50,11 @@ namespace BlackMisc
IndexJustTakingOff,
IndexJustTouchingDown,
IndexRotatingUp,
IndexContainsPushBack
IndexContainsPushBack,
IndexAltitudeMean,
IndexAltitudeStdDev,
IndexElevationMean,
IndexElevationStdDev,
};
//! Hint about the guessed scenery deviation
@@ -157,6 +161,9 @@ namespace BlackMisc
//! \copydoc Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
//! \copydoc Mixin::Index::comparePropertyByIndex
int comparePropertyByIndex(const CPropertyIndex &index, const CAircraftSituationChange &compareValue) const;
//! Calculate the standard deviiations
bool calculateStdDeviations(const CAircraftSituationList &situations, const PhysicalQuantities::CLength &cg);

View File

@@ -0,0 +1,28 @@
/* Copyright (C) 2018
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "blackmisc/aviation/aircraftsituationchangelist.h"
#include <tuple>
namespace BlackMisc
{
namespace Aviation
{
CAircraftSituationChangeList::CAircraftSituationChangeList() { }
CAircraftSituationChangeList::CAircraftSituationChangeList(const CSequence<CAircraftSituationChange> &other) :
CSequence<CAircraftSituationChange>(other)
{ }
CAircraftSituationChangeList::CAircraftSituationChangeList(std::initializer_list<CAircraftSituationChange> il) :
CSequence<CAircraftSituationChange>(il)
{ }
} // namespace
} // namespace

View File

@@ -0,0 +1,53 @@
/* Copyright (C) 2018
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISC_AVIATION_AIRCRAFTSITUATIONCHANGELIST_H
#define BLACKMISC_AVIATION_AIRCRAFTSITUATIONCHANGELIST_H
#include "blackmisc/blackmiscexport.h"
#include "blackmisc/collection.h"
#include "blackmisc/sequence.h"
#include "blackmisc/aviation/aircraftsituationchange.h"
#include "blackmisc/timestampobjectlist.h"
#include "blackmisc/variant.h"
#include <QMetaType>
namespace BlackMisc
{
namespace Aviation
{
//! Value object encapsulating a list of aircraft parts.
class BLACKMISC_EXPORT CAircraftSituationChangeList :
public CSequence<CAircraftSituationChange>,
public ITimestampWithOffsetObjectList<CAircraftSituationChange, CAircraftSituationChangeList>,
public Mixin::MetaType<CAircraftSituationChangeList>
{
public:
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CAircraftSituationChangeList)
//! Default constructor.
CAircraftSituationChangeList();
//! Construct from a base class object.
CAircraftSituationChangeList(const CSequence<CAircraftSituationChange> &other);
//! Construct from initializer list.
CAircraftSituationChangeList(std::initializer_list<CAircraftSituationChange> il);
};
} //namespace
} // namespace
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftSituationChangeList)
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Aviation::CAircraftSituationChange>)
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Aviation::CAircraftSituationChange>)
#endif //guard