mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
* renamed from CSimulatorSetup to CSimulatorInternals * removed the FSX class, no longer needed * utility functions for CNameVariantPair
112 lines
3.6 KiB
C++
112 lines
3.6 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 "blackmisc/dbus.h"
|
|
#include "blackmisc/simulation/simulatorinternals.h"
|
|
|
|
#include <QDBusMetaType>
|
|
#include <QJsonObject>
|
|
|
|
namespace BlackMisc
|
|
{
|
|
namespace Simulation
|
|
{
|
|
void CSimulatorInternals::setValue(const QString &name, const QString &value)
|
|
{
|
|
this->m_data.addOrReplaceValue(name, value);
|
|
}
|
|
|
|
CVariant CSimulatorInternals::getVariantValue(const QString &name) const
|
|
{
|
|
return m_data.getVariantValue(name);
|
|
}
|
|
|
|
QString CSimulatorInternals::getStringValue(const QString &name) const
|
|
{
|
|
return m_data.getValueAsString(name);
|
|
}
|
|
|
|
QStringList CSimulatorInternals::getSortedNames() const
|
|
{
|
|
return m_data.getNames(true);
|
|
}
|
|
|
|
void CSimulatorInternals::setSimulatorVersion(const QString versionInfo)
|
|
{
|
|
this->setValue("all/versionInfo", versionInfo);
|
|
}
|
|
|
|
void CSimulatorInternals::setSimulatorInstallationDirectory(const QString fullFilePath)
|
|
{
|
|
this->setValue("all/installDir", fullFilePath);
|
|
}
|
|
|
|
QString CSimulatorInternals::getSimulatorName() const
|
|
{
|
|
return this->getStringValue("all/simulatorName");
|
|
}
|
|
|
|
void CSimulatorInternals::setSimulatorName(const QString &name)
|
|
{
|
|
this->setValue("all/simulatorName", name);
|
|
}
|
|
|
|
QString CSimulatorInternals::getSimulatorVersion() const
|
|
{
|
|
return this->getStringValue("all/versionInfo");
|
|
}
|
|
|
|
QString CSimulatorInternals::getSimulatorInstallationDirectory() const
|
|
{
|
|
return this->getStringValue("all/installDir");
|
|
}
|
|
|
|
void CSimulatorInternals::registerMetadata()
|
|
{
|
|
qRegisterMetaType<BlackMisc::Simulation::CSimulatorInternals>();
|
|
qDBusRegisterMetaType<BlackMisc::Simulation::CSimulatorInternals>();
|
|
registerMetaValueType<BlackMisc::Simulation::CSimulatorInternals>();
|
|
}
|
|
|
|
QString CSimulatorInternals::convertToQString(bool i18n) const
|
|
{
|
|
return m_data.toQString(i18n);
|
|
}
|
|
|
|
CVariant CSimulatorInternals::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
|
{
|
|
if (index.isMyself()) { return CVariant::from(*this); }
|
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
|
switch (i)
|
|
{
|
|
case IndexData:
|
|
return CVariant::from(m_data);
|
|
default:
|
|
return CValueObject::propertyByIndex(index);
|
|
}
|
|
}
|
|
|
|
void CSimulatorInternals::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
|
{
|
|
if (index.isMyself()) { (*this) = variant.to<CSimulatorInternals>(); return; }
|
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
|
switch (i)
|
|
{
|
|
case IndexData:
|
|
this->m_data = variant.to<CNameVariantPairList>();
|
|
break;
|
|
default:
|
|
CValueObject::setPropertyByIndex(index, variant);
|
|
break;
|
|
}
|
|
}
|
|
|
|
} // ns
|
|
} // ns
|