mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
* Added json files along with FILE macro for all drivers * Get CSimulatorInfo from JSON rather than from ISimulatorFactory
60 lines
2.0 KiB
C++
60 lines
2.0 KiB
C++
/* Copyright (C) 2013
|
|
* 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 "simulatorinfo.h"
|
|
#include "blackmisc/blackmiscfreefunctions.h"
|
|
|
|
using namespace BlackMisc;
|
|
|
|
namespace BlackSim
|
|
{
|
|
CSimulatorInfo::CSimulatorInfo(const QString &shortname, const QString &fullname) : m_fullName(fullname), m_shortName(shortname)
|
|
{ }
|
|
|
|
CSimulatorInfo::CSimulatorInfo() : m_fullName("Unknown"), m_shortName("Unknown")
|
|
{}
|
|
|
|
CSimulatorInfo::CSimulatorInfo(const QJsonObject &json)
|
|
{
|
|
Q_ASSERT(json["IID"].toString() == "net.vatsim.PilotClient.BlackCore.SimulatorInterface");
|
|
QJsonObject data = json["MetaData"].toObject();
|
|
m_fullName = data["full_name"].toString("Unknown");
|
|
m_shortName = data["short_name"].toString("Unknown");
|
|
}
|
|
|
|
CVariant CSimulatorInfo::getSimulatorSetupValue(int index) const
|
|
{
|
|
return this->m_simsetup.value(index);
|
|
}
|
|
|
|
QString CSimulatorInfo::getSimulatorSetupValueAsString(int index) const
|
|
{
|
|
CVariant qv = getSimulatorSetupValue(index);
|
|
Q_ASSERT(qv.canConvert<QString>());
|
|
return qv.toQString();
|
|
}
|
|
|
|
void CSimulatorInfo::setSimulatorSetup(const BlackMisc::CPropertyIndexVariantMap &setup)
|
|
{
|
|
this->m_simsetup = setup;
|
|
}
|
|
|
|
bool CSimulatorInfo::isSameSimulator(const CSimulatorInfo &otherSimulator) const
|
|
{
|
|
return this->getFullName() == otherSimulator.getFullName() &&
|
|
this->getShortName() == otherSimulator.getShortName();
|
|
}
|
|
|
|
QString CSimulatorInfo::convertToQString(bool i18n) const
|
|
{
|
|
Q_UNUSED(i18n);
|
|
return QString(this->m_shortName).append(" (").append(this->m_fullName).append(")");
|
|
}
|
|
}
|