mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T658, matching scriot exchange object (QObject)
This commit is contained in:
64
src/blackmisc/simulation/matchingscript.cpp
Normal file
64
src/blackmisc/simulation/matchingscript.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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. 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 "matchingscript.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
void MSNetworkValues::setCallsign(const QString &callsign)
|
||||
{
|
||||
if (m_callsign == callsign) { return; }
|
||||
m_callsign = callsign;
|
||||
emit this->callsignChanged();
|
||||
}
|
||||
|
||||
void MSNetworkValues::setDbAircraftIcaoId(int id)
|
||||
{
|
||||
if (id == m_dbAircraftIcaoId) { return; }
|
||||
m_dbAircraftIcaoId = id;
|
||||
emit this->dbAircraftIcaoIdChanged();
|
||||
}
|
||||
|
||||
void MSNetworkValues::setDbAirlineIcaoId(int id)
|
||||
{
|
||||
if (id == m_dbAirlineIcaoId) { return; }
|
||||
m_dbAirlineIcaoId = id;
|
||||
emit this->dbAirlineIcaoIdChanged();
|
||||
}
|
||||
|
||||
void MSNetworkValues::setDbLiveryId(int id)
|
||||
{
|
||||
if (id == m_dbLiveryId) { return; }
|
||||
m_dbLiveryId = id;
|
||||
emit this->dbLiveryIdChanged();
|
||||
}
|
||||
|
||||
void MSNetworkValues::setAircraftIcao(const QString &aircraftIcao)
|
||||
{
|
||||
if (aircraftIcao == m_aircraftIcao) { return; }
|
||||
m_aircraftIcao = aircraftIcao;
|
||||
emit this->aircraftIcaoChanged();
|
||||
}
|
||||
|
||||
void MSNetworkValues::setAirlineIcao(const QString &airlineIcao)
|
||||
{
|
||||
if (airlineIcao == m_airlineIcao) { return; }
|
||||
m_airlineIcao = airlineIcao;
|
||||
emit this->airlineIcaoChanged();
|
||||
}
|
||||
|
||||
void MSNetworkValues::setLivery(const QString &livery)
|
||||
{
|
||||
if (livery == m_livery) { return; }
|
||||
m_livery = livery;
|
||||
emit this->liveryChanged();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
97
src/blackmisc/simulation/matchingscript.h
Normal file
97
src/blackmisc/simulation/matchingscript.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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. 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_SIMULATION_MATCHINGSCRIPT_H
|
||||
#define BLACKMISC_SIMULATION_MATCHINGSCRIPT_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
//! The network values
|
||||
class BLACKMISC_EXPORT MSNetworkValues : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
//! MSNetworkValues properties @{
|
||||
Q_PROPERTY(QString callsign READ getCallsign WRITE setCallsign NOTIFY callsignChanged)
|
||||
Q_PROPERTY(int dbAircraftIcaoId READ getDbAircraftIcaoId WRITE setDbAircraftIcaoId NOTIFY dbAircraftIcaoIdChanged)
|
||||
Q_PROPERTY(int dbAirlineIcaoId READ getDbAirlineIcaoId WRITE setDbAirlineIcaoId NOTIFY dbAirlineIcaoIdChanged)
|
||||
Q_PROPERTY(int dbLiveryId READ getDbLiveryId WRITE setDbLiveryId NOTIFY dbLiveryIdChanged)
|
||||
Q_PROPERTY(QString aircraftIcao READ getAircraftIcao WRITE setAircraftIcao NOTIFY aircraftIcaoChanged)
|
||||
Q_PROPERTY(QString airlineIcao READ getAirlineIcao WRITE setAirlineIcao NOTIFY airlineIcaoChanged)
|
||||
Q_PROPERTY(QString livery READ getLivery WRITE setLivery NOTIFY liveryChanged)
|
||||
//! @}
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
Q_INVOKABLE MSNetworkValues() {}
|
||||
|
||||
//! Get callsign
|
||||
const QString &getCallsign() const { return m_callsign; }
|
||||
|
||||
//! Set callsign
|
||||
void setCallsign(const QString &callsign);
|
||||
|
||||
//! Values found in DB? @{
|
||||
bool isFoundDbAircraftIcao() const { return m_dbAircraftIcaoId >= 0; }
|
||||
bool isFoundDbAirlineIcao() const { return m_dbAirlineIcaoId >= 0; }
|
||||
bool isFoundDbLivery() const { return m_dbLiveryId >= 0; }
|
||||
int getDbAircraftIcaoId() const { return m_dbAircraftIcaoId; }
|
||||
int getDbAirlineIcaoId() const { return m_dbAirlineIcaoId; }
|
||||
int getDbLiveryId() const { return m_dbLiveryId; }
|
||||
void setDbAircraftIcaoId(int id);
|
||||
void setDbAirlineIcaoId(int id);
|
||||
void setDbLiveryId(int id);
|
||||
//! @}
|
||||
|
||||
//! Livery, airline, aircraft @{
|
||||
const QString &getAircraftIcao() const { return m_aircraftIcao; }
|
||||
const QString &getAirlineIcao() const { return m_airlineIcao; }
|
||||
const QString &getLivery() const { return m_livery; }
|
||||
void setAircraftIcao(const QString &aircraftIcao);
|
||||
void setAirlineIcao(const QString &airlineIcao);
|
||||
void setLivery(const QString &livery);
|
||||
//! @}
|
||||
|
||||
signals:
|
||||
//! Callsign changed
|
||||
void callsignChanged();
|
||||
|
||||
//! Livery, airline, aircraft changed @{
|
||||
void aircraftIcaoChanged();
|
||||
void airlineIcaoChanged();
|
||||
void liveryChanged();
|
||||
//! @}
|
||||
|
||||
//! DB id changed @{
|
||||
void dbAircraftIcaoIdChanged();
|
||||
void dbAirlineIcaoIdChanged();
|
||||
void dbLiveryIdChanged();
|
||||
//! @}
|
||||
|
||||
private:
|
||||
QString m_callsign;
|
||||
QString m_aircraftIcao;
|
||||
QString m_airlineIcao;
|
||||
QString m_livery;
|
||||
int m_dbAircraftIcaoId = -1;
|
||||
int m_dbAirlineIcaoId = -1;
|
||||
int m_dbLiveryId = -1;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user