mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #328 CAircraftParts value classes
This commit is contained in:
committed by
Klaus Basan
parent
16042c1fb2
commit
0a46a4a0bd
@@ -24,5 +24,10 @@
|
||||
#include "blackmisc/avinformationmessage.h"
|
||||
#include "blackmisc/avselcal.h"
|
||||
#include "blackmisc/avflightplan.h"
|
||||
#include "blackmisc/aviation/aircraftengine.h"
|
||||
#include "blackmisc/aviation/aircraftenginelist.h"
|
||||
#include "blackmisc/aviation/aircraftlights.h"
|
||||
#include "blackmisc/aviation/aircraftparts.h"
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
|
||||
#endif // guard
|
||||
|
||||
23
src/blackmisc/aviation/aircraftengine.cpp
Normal file
23
src/blackmisc/aviation/aircraftengine.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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 "aircraftengine.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
QString CAircraftEngine::convertToQString(bool /** i18n */) const
|
||||
{
|
||||
QString s(m_number);
|
||||
s += m_on;
|
||||
return s;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
64
src/blackmisc/aviation/aircraftengine.h
Normal file
64
src/blackmisc/aviation/aircraftengine.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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_AIRCRAFTENGINES_H
|
||||
#define BLACKMISC_AIRCRAFTENGINES_H
|
||||
|
||||
#include "blackmisc/valueobject.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object encapsulating information about aircraft's engines
|
||||
class CAircraftEngine : public CValueObjectStdTuple<CAircraftEngine>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
CAircraftEngine() = default;
|
||||
|
||||
//! Constructor
|
||||
CAircraftEngine(int number, bool on) : m_number(number), m_on(on) {}
|
||||
|
||||
//! Get engine number
|
||||
int getNumber() const { return m_number; }
|
||||
|
||||
//! Set engine number
|
||||
void setNumber (int number) { m_number = number; }
|
||||
|
||||
//! Is on/off?
|
||||
bool isOn() const { return m_on; }
|
||||
|
||||
//! Set to on/off
|
||||
void setOn(bool on) { m_on = on; }
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftEngine)
|
||||
int m_number = 1;
|
||||
bool m_on = true;
|
||||
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraftEngine, (
|
||||
attr(o.m_number, flags<DisabledForJson>()),
|
||||
attr(o.m_on, "on")
|
||||
))
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftEngine)
|
||||
|
||||
#endif // BLACKMISC_AIRCRAFTENGINES_H
|
||||
31
src/blackmisc/aviation/aircraftenginelist.cpp
Normal file
31
src/blackmisc/aviation/aircraftenginelist.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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 "aircraftenginelist.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
CAircraftEngineList::CAircraftEngineList(const CSequence<CAircraftEngine> &other) :
|
||||
CSequence<CAircraftEngine>(other)
|
||||
{ }
|
||||
|
||||
void CAircraftEngineList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::CSequence<CAircraftEngine>>();
|
||||
qDBusRegisterMetaType<BlackMisc::CSequence<CAircraftEngine>>();
|
||||
qRegisterMetaType<BlackMisc::CCollection<CAircraftEngine>>();
|
||||
qDBusRegisterMetaType<BlackMisc::CCollection<CAircraftEngine>>();
|
||||
qRegisterMetaType<CAircraftEngineList>();
|
||||
qDBusRegisterMetaType<CAircraftEngineList>();
|
||||
registerMetaValueType<CAircraftEngineList>();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
77
src/blackmisc/aviation/aircraftenginelist.h
Normal file
77
src/blackmisc/aviation/aircraftenginelist.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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_AIRCRAFTENGINELIST_H
|
||||
#define BLACKMISC_AIRCRAFTENGINELIST_H
|
||||
|
||||
#include "aircraftengine.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object encapsulating a list of aircraft engines.
|
||||
class CAircraftEngineList : public CSequence<CAircraftEngine>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
CAircraftEngineList() = default;
|
||||
|
||||
//! Construct from a base class object.
|
||||
CAircraftEngineList(const CSequence<CAircraftEngine> &other);
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
//! \copydoc CValueObject::convertFromQVariant
|
||||
virtual void convertFromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(this, variant); }
|
||||
|
||||
virtual QJsonObject toJson() const override
|
||||
{
|
||||
QJsonObject map;
|
||||
|
||||
for (const auto &e : *this)
|
||||
{
|
||||
QJsonObject value = e.toJson();
|
||||
map.insert(QString::number(e.getNumber()), value);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
//! \copydoc CValueObject::convertFromJson
|
||||
virtual void convertFromJson(const QJsonObject &json) override
|
||||
{
|
||||
clear();
|
||||
for (const auto &e : json.keys())
|
||||
{
|
||||
|
||||
CAircraftEngine engine;
|
||||
int number = e.toInt();
|
||||
engine.convertFromJson(json.value(e).toObject());
|
||||
engine.setNumber(number);
|
||||
push_back(engine);
|
||||
}
|
||||
}
|
||||
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftEngineList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Aviation::CAircraftEngine>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Aviation::CAircraftEngine>)
|
||||
|
||||
#endif //guard
|
||||
49
src/blackmisc/aviation/aircraftlights.cpp
Normal file
49
src/blackmisc/aviation/aircraftlights.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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 "aircraftlights.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
CAircraftLights::CAircraftLights(bool strobeOn, bool landingOn, bool taxiOn, bool beaconOn, bool navOn, bool logoOn)
|
||||
: m_strobeOn(strobeOn), m_landingOn(landingOn), m_taxiOn(taxiOn), m_beaconOn(beaconOn), m_navOn(navOn), m_logoOn(logoOn)
|
||||
{
|
||||
}
|
||||
|
||||
CAircraftLights CAircraftLights::allLightsOn()
|
||||
{
|
||||
return CAircraftLights {true, true, true, true, true, true};
|
||||
}
|
||||
|
||||
CAircraftLights CAircraftLights::allLightsOff()
|
||||
{
|
||||
return CAircraftLights {false, false, false, false, false, false};
|
||||
}
|
||||
|
||||
QString CAircraftLights::convertToQString(bool /** i18n */) const
|
||||
{
|
||||
QString s;
|
||||
s += " strobe: ";
|
||||
s += m_strobeOn;
|
||||
s += " landing: ";
|
||||
s += m_landingOn;
|
||||
s += " taxi: ";
|
||||
s += m_taxiOn;
|
||||
s += " beacon: ";
|
||||
s += m_beaconOn;
|
||||
s += " nav: ";
|
||||
s += m_navOn;
|
||||
s += " logo: ";
|
||||
s += m_logoOn;
|
||||
return s;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
102
src/blackmisc/aviation/aircraftlights.h
Normal file
102
src/blackmisc/aviation/aircraftlights.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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_AIRCRAFTLIGHTS_H
|
||||
#define BLACKMISC_AIRCRAFTLIGHTS_H
|
||||
|
||||
#include "blackmisc/valueobject.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object encapsulating information about aircraft's lights
|
||||
class CAircraftLights : public CValueObjectStdTuple<CAircraftLights>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
CAircraftLights() = default;
|
||||
|
||||
//! Constructor
|
||||
CAircraftLights(bool strobeOn, bool landingOn, bool taxiOn, bool beaconOn, bool navOn, bool logoOn);
|
||||
|
||||
//! Strobes lights on?
|
||||
bool isStrobeOn() const { return m_strobeOn; }
|
||||
|
||||
//! Set strobe lights
|
||||
void setStrobeOn(bool on) { m_strobeOn = on; }
|
||||
|
||||
//! Landing lights on?
|
||||
bool isLandingOn() const { return m_landingOn; }
|
||||
|
||||
//! Set landing lights
|
||||
void setLandingOn(bool on) { m_landingOn = on; }
|
||||
|
||||
//! Taxi lights on?
|
||||
bool isTaxiOn() const { return m_taxiOn; }
|
||||
|
||||
//! Set taxi lights
|
||||
void setTaxiOn(bool on) { m_taxiOn = on; }
|
||||
|
||||
//! Beacon lights on?
|
||||
bool isBeaconOn() const { return m_beaconOn; }
|
||||
|
||||
//! Set beacon lights
|
||||
void setBeaconOn(bool on) { m_beaconOn = on; }
|
||||
|
||||
//! Nac lights on?
|
||||
bool isNavOn() const { return m_navOn; }
|
||||
|
||||
//! Set nav lights
|
||||
void setNavOn(bool on) { m_navOn = on; }
|
||||
|
||||
//! Logo lights on?
|
||||
bool isLogoOn() const { return m_logoOn; }
|
||||
|
||||
//! Set logo lights
|
||||
void setLogoOn(bool on) { m_logoOn = on; }
|
||||
|
||||
//! Returns object with all lights switched on
|
||||
static CAircraftLights allLightsOn();
|
||||
|
||||
//! Returns object with all lights switched off
|
||||
static CAircraftLights allLightsOff();
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftLights)
|
||||
bool m_strobeOn = false;
|
||||
bool m_landingOn = false;
|
||||
bool m_taxiOn = false;
|
||||
bool m_beaconOn = false;
|
||||
bool m_navOn = false;
|
||||
bool m_logoOn = false;
|
||||
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraftLights, (
|
||||
attr(o.m_strobeOn, "strobe_on"),
|
||||
attr(o.m_landingOn, "landing_on"),
|
||||
attr(o.m_taxiOn, "taxi_on"),
|
||||
attr(o.m_beaconOn, "beacon_on"),
|
||||
attr(o.m_navOn, "nav_on"),
|
||||
attr(o.m_logoOn, "logo_on")
|
||||
))
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftLights)
|
||||
|
||||
#endif // BLACKMISC_AIRCRAFTLIGHTS_H
|
||||
33
src/blackmisc/aviation/aircraftparts.cpp
Normal file
33
src/blackmisc/aviation/aircraftparts.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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 "aircraftparts.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
QString CAircraftParts::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s;
|
||||
s += m_lights.toQString(i18n);
|
||||
s += " gear down: ";
|
||||
s += m_gearDown;
|
||||
s += " flaps pct: ";
|
||||
s += m_flapsPercent;
|
||||
s += " spoilers out: ";
|
||||
s += m_spoilersOut;
|
||||
s += " engines on: ";
|
||||
s += m_engines.toQString(i18n);
|
||||
s += " on ground: ";
|
||||
s += m_isOnGround;
|
||||
return s;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
146
src/blackmisc/aviation/aircraftparts.h
Normal file
146
src/blackmisc/aviation/aircraftparts.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/* Copyright (c) 2014
|
||||
* 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_AIRCRAFTPARTS_H
|
||||
#define BLACKMISC_AIRCRAFTPARTS_H
|
||||
|
||||
#include "blackmisc/avcallsign.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/timestampbased.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "aircraftlights.h"
|
||||
#include "aircraftenginelist.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object encapsulating information of aircraft's parts
|
||||
class CAircraftParts :
|
||||
public CValueObjectStdTuple<CAircraftParts>,
|
||||
public BlackMisc::ITimestampBased
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexLights = BlackMisc::CPropertyIndex::GlobalIndexCAircraftParts,
|
||||
IndexGearDown,
|
||||
IndexFlapsPercentage,
|
||||
IndexSpoilersOut,
|
||||
IndexEngines,
|
||||
IndexOnGround,
|
||||
IndexCallsign
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CAircraftParts() {}
|
||||
|
||||
//! Constructor
|
||||
CAircraftParts(const CAircraftLights &lights, bool gearDown, int flapsPercent, bool spoilersOut,
|
||||
const CAircraftEngineList &engines, bool onGround)
|
||||
: m_lights(lights), m_engines(engines), m_flapsPercentage(flapsPercent), m_gearDown(gearDown),
|
||||
m_spoilersOut(spoilersOut), m_isOnGround(onGround)
|
||||
{}
|
||||
|
||||
//! Constructor
|
||||
CAircraftParts(const CCallsign &callsign, const CAircraftLights &lights, bool gearDown, int flapsPercent, bool spoilersOut,
|
||||
const CAircraftEngineList &engines, bool onGround)
|
||||
: m_correspondingCallsign(callsign), m_lights(lights), m_engines(engines), m_flapsPercentage(flapsPercent), m_gearDown(gearDown),
|
||||
m_spoilersOut(spoilersOut), m_isOnGround(onGround)
|
||||
{}
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index) override;
|
||||
|
||||
//! Get aircraft lights
|
||||
CAircraftLights getLights() const { return m_lights; }
|
||||
|
||||
//! Set aircraft lights
|
||||
void setLights(const CAircraftLights &lights) { m_lights = lights; }
|
||||
|
||||
//! Is gear down?
|
||||
bool isGearDown() const { return m_gearDown; }
|
||||
|
||||
//! Set gear down
|
||||
void setGearDown(bool down) { m_gearDown = down; }
|
||||
|
||||
//! Get flaps position in percent
|
||||
int getFlapsPercent() const { return m_flapsPercentage; }
|
||||
|
||||
//! Set flaps position in percent
|
||||
void setFlapsPercent(int flapsPercent) { m_flapsPercentage = flapsPercent; }
|
||||
|
||||
//! Are spoilers out?
|
||||
bool isSpoilersOut() const { return m_spoilersOut; }
|
||||
|
||||
//! Set spoilers out
|
||||
void setSpoilersOut(bool out) { m_spoilersOut = out; }
|
||||
|
||||
//! Get engines
|
||||
CAircraftEngineList getEngines() const { return m_engines; }
|
||||
|
||||
//! Engine with number
|
||||
CAircraftEngine getEngine(int number) const;
|
||||
|
||||
//! Is engine with number on?
|
||||
bool isEngineOn(int number) const;
|
||||
|
||||
//! Set engines
|
||||
void setEngines(const CAircraftEngineList &engines) { m_engines = engines; }
|
||||
|
||||
//! Is aircraft on ground?
|
||||
bool isOnGround() const { return m_isOnGround; }
|
||||
|
||||
//! Set aircraft on ground
|
||||
void setOnGround(bool onGround) { m_isOnGround = onGround; }
|
||||
|
||||
//! Corresponding callsign
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return this->m_correspondingCallsign; }
|
||||
|
||||
//! Corresponding callsign
|
||||
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign) { this->m_correspondingCallsign = callsign; }
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftParts)
|
||||
BlackMisc::Aviation::CCallsign m_correspondingCallsign;
|
||||
CAircraftLights m_lights;
|
||||
CAircraftEngineList m_engines;
|
||||
int m_flapsPercentage = 0;
|
||||
bool m_gearDown = false;
|
||||
bool m_spoilersOut = false;
|
||||
bool m_isOnGround = false;
|
||||
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
// FIXME: Use correct JSON names, when tuple bug is fixed
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraftParts, (
|
||||
attr(o.m_correspondingCallsign, flags < DisabledForJson > ()),
|
||||
attr(o.m_lights, "lights"),
|
||||
attr(o.m_gearDown, "gear_down"),
|
||||
attr(o.m_flapsPercentage, "flaps_pct"),
|
||||
attr(o.m_spoilersOut, "spoilers_out"),
|
||||
attr(o.m_engines, "engines"),
|
||||
attr(o.m_isOnGround, "on_ground"),
|
||||
attr(o.m_timestampMSecsSinceEpoch, flags < DisabledForJson | DisabledForComparison > ())
|
||||
))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftParts)
|
||||
|
||||
#endif // guard
|
||||
49
src/blackmisc/aviation/aircraftpartslist.cpp
Normal file
49
src/blackmisc/aviation/aircraftpartslist.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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 "aircraftpartslist.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
CAircraftPartsList::CAircraftPartsList() { }
|
||||
|
||||
CAircraftPartsList::CAircraftPartsList(const CSequence<CAircraftParts> &other) :
|
||||
CSequence<CAircraftParts>(other)
|
||||
{ }
|
||||
|
||||
CAircraftPartsList CAircraftPartsList::findBefore(const QDateTime &dateTime) const
|
||||
{
|
||||
return findBy([&](const CAircraftParts & parts)
|
||||
{
|
||||
return parts.getTimestamp() < dateTime;
|
||||
});
|
||||
}
|
||||
|
||||
void CAircraftPartsList::removeBefore(const QDateTime &dateTime)
|
||||
{
|
||||
removeIf([&](const CAircraftParts &parts)
|
||||
{
|
||||
return parts.getTimestamp() < dateTime;
|
||||
});
|
||||
}
|
||||
|
||||
void CAircraftPartsList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::CSequence<CAircraftParts>>();
|
||||
qDBusRegisterMetaType<BlackMisc::CSequence<CAircraftParts>>();
|
||||
qRegisterMetaType<BlackMisc::CCollection<CAircraftParts>>();
|
||||
qDBusRegisterMetaType<BlackMisc::CCollection<CAircraftParts>>();
|
||||
qRegisterMetaType<CAircraftPartsList>();
|
||||
qDBusRegisterMetaType<CAircraftPartsList>();
|
||||
registerMetaValueType<CAircraftPartsList>();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
57
src/blackmisc/aviation/aircraftpartslist.h
Normal file
57
src/blackmisc/aviation/aircraftpartslist.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Copyright (C) 2014
|
||||
* 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_AIRCRAFTPARTSLIST_H
|
||||
#define BLACKMISC_AIRCRAFTPARTSLIST_H
|
||||
|
||||
#include "aircraftparts.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include <QDateTime>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object encapsulating a list of aircraft parts.
|
||||
class CAircraftPartsList : public CSequence<CAircraftParts>
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
CAircraftPartsList();
|
||||
|
||||
//! Construct from a base class object.
|
||||
CAircraftPartsList(const CSequence<CAircraftParts> &other);
|
||||
|
||||
//! Get a list of situations before dateTime
|
||||
CAircraftPartsList findBefore (const QDateTime& dateTime) const;
|
||||
|
||||
//! Remove parts with timestamp before dateTime
|
||||
void removeBefore(const QDateTime& dateTime);
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
//! \copydoc CValueObject::convertFromQVariant
|
||||
virtual void convertFromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(this, variant); }
|
||||
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftPartsList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Aviation::CAircraftParts>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Aviation::CAircraftParts>)
|
||||
|
||||
#endif //guard
|
||||
@@ -23,10 +23,13 @@ TRANSLATIONS += translations/blackmisc_i18n_de.ts \
|
||||
translations/blackmisc_i18n_fr.ts \
|
||||
translations/blackmisc_i18n_en.ts
|
||||
|
||||
HEADERS += *.h
|
||||
HEADERS += $$PWD/simulation/*.h
|
||||
SOURCES += *.cpp
|
||||
SOURCES += $$PWD/simulation/*.cpp
|
||||
HEADERS += *.h \
|
||||
$$PWD/simulation/*.h \
|
||||
$$PWD/aviation/*.h \
|
||||
|
||||
SOURCES += *.cpp \
|
||||
$$PWD/simulation/*.cpp \
|
||||
$$PWD/aviation/*.cpp \
|
||||
|
||||
DESTDIR = ../../lib
|
||||
OTHER_FILES += $$TRANSLATIONS readme.txt
|
||||
|
||||
@@ -39,4 +39,9 @@ void BlackMisc::Aviation::registerMetadata()
|
||||
CAirportIcao::registerMetadata();
|
||||
CSelcal::registerMetadata();
|
||||
CFlightPlan::registerMetadata();
|
||||
CAircraftEngine::registerMetadata();
|
||||
CAircraftEngineList::registerMetadata();
|
||||
CAircraftLights::registerMetadata();
|
||||
CAircraftParts::registerMetadata();
|
||||
CAircraftPartsList::registerMetadata();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user