mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
refs #808, CSimulatorInternals
* renamed from CSimulatorSetup to CSimulatorInternals * removed the FSX class, no longer needed * utility functions for CNameVariantPair
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
/* 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 "blackconfig/buildconfig.h"
|
||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||
#include "blackmisc/simulation/fsx/fsxsimulatorsetup.h"
|
||||
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
||||
#include "simulation/simulatorsetup.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
CSimulatorSetup CFsxSimulatorSetup::getInitialSetup()
|
||||
{
|
||||
CSimulatorSetup s;
|
||||
s.setValue(KeyLocalSimConnectCfgFilename(), CSimConnectUtilities::getLocalSimConnectCfgFilename());
|
||||
|
||||
if (CBuildConfig::isCompiledWithFsxSupport())
|
||||
{
|
||||
// set FSX path
|
||||
QString fsxPath = CFsCommonUtil::fsxDirFromRegistry();
|
||||
if (!fsxPath.isEmpty())
|
||||
{
|
||||
s.setSimulatorInstallationDirectory(fsxPath);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CFsxSimulatorSetup::KeyLocalSimConnectCfgFilename()
|
||||
{
|
||||
static const QString k("fsx/simConnectCfgFilename"); return k;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -1,45 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SIMULATION_FSX_SIMSETUP_H
|
||||
#define BLACKMISC_SIMULATION_FSX_SIMSETUP_H
|
||||
|
||||
#include "blackmisc/simulation/simulatorsetup.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
class QString;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
//! Simulator settings for FSX Flight simulators
|
||||
class BLACKMISC_EXPORT CFsxSimulatorSetup
|
||||
{
|
||||
|
||||
public:
|
||||
//! No constructor
|
||||
CFsxSimulatorSetup() = delete;
|
||||
|
||||
//! Init, to be used where FSX runs
|
||||
static BlackMisc::Simulation::CSimulatorSetup getInitialSetup();
|
||||
|
||||
//! Key
|
||||
static const QString &KeyLocalSimConnectCfgFilename();
|
||||
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
@@ -38,7 +38,7 @@ namespace BlackMisc
|
||||
CSimulatorInfoList::registerMetadata();
|
||||
CSimulatorPluginInfo::registerMetadata();
|
||||
CSimulatorPluginInfoList::registerMetadata();
|
||||
CSimulatorSetup::registerMetadata();
|
||||
CSimulatorInternals::registerMetadata();
|
||||
CVPilotModelRule::registerMetadata();
|
||||
CVPilotModelRuleSet::registerMetadata();
|
||||
CSettings::registerMetadata();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "blackmisc/simulation/airspaceaircraftsnapshot.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
#include "blackmisc/simulation/distributorlistpreferences.h"
|
||||
#include "blackmisc/simulation/simulatorsetup.h"
|
||||
#include "blackmisc/simulation/simulatorinternals.h"
|
||||
#include "blackmisc/simulation/simulatorinfolist.h"
|
||||
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/dbus.h"
|
||||
#include "blackmisc/simulation/simulatorsetup.h"
|
||||
#include "blackmisc/simulation/simulatorinternals.h"
|
||||
|
||||
#include <QDBusMetaType>
|
||||
#include <QJsonObject>
|
||||
@@ -17,49 +17,69 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
void CSimulatorSetup::setValue(const QString &name, const QString &value)
|
||||
void CSimulatorInternals::setValue(const QString &name, const QString &value)
|
||||
{
|
||||
this->m_data.addOrReplaceValue(name, value);
|
||||
}
|
||||
|
||||
QString CSimulatorSetup::getStringValue(const QString &name) const
|
||||
CVariant CSimulatorInternals::getVariantValue(const QString &name) const
|
||||
{
|
||||
return m_data.getVariantValue(name);
|
||||
}
|
||||
|
||||
QString CSimulatorInternals::getStringValue(const QString &name) const
|
||||
{
|
||||
return m_data.getValueAsString(name);
|
||||
}
|
||||
|
||||
void CSimulatorSetup::setSimulatorVersion(const QString versionInfo)
|
||||
QStringList CSimulatorInternals::getSortedNames() const
|
||||
{
|
||||
return m_data.getNames(true);
|
||||
}
|
||||
|
||||
void CSimulatorInternals::setSimulatorVersion(const QString versionInfo)
|
||||
{
|
||||
this->setValue("all/versionInfo", versionInfo);
|
||||
}
|
||||
|
||||
void CSimulatorSetup::setSimulatorInstallationDirectory(const QString fullFilePath)
|
||||
void CSimulatorInternals::setSimulatorInstallationDirectory(const QString fullFilePath)
|
||||
{
|
||||
this->setValue("all/installDir", fullFilePath);
|
||||
}
|
||||
|
||||
QString CSimulatorSetup::getSimulatorVersion() const
|
||||
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 CSimulatorSetup::getSimulatorInstallationDirectory() const
|
||||
QString CSimulatorInternals::getSimulatorInstallationDirectory() const
|
||||
{
|
||||
return this->getStringValue("all/installDir");
|
||||
}
|
||||
|
||||
void CSimulatorSetup::registerMetadata()
|
||||
void CSimulatorInternals::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::Simulation::CSimulatorSetup>();
|
||||
qDBusRegisterMetaType<BlackMisc::Simulation::CSimulatorSetup>();
|
||||
registerMetaValueType<BlackMisc::Simulation::CSimulatorSetup>();
|
||||
qRegisterMetaType<BlackMisc::Simulation::CSimulatorInternals>();
|
||||
qDBusRegisterMetaType<BlackMisc::Simulation::CSimulatorInternals>();
|
||||
registerMetaValueType<BlackMisc::Simulation::CSimulatorInternals>();
|
||||
}
|
||||
|
||||
QString CSimulatorSetup::convertToQString(bool i18n) const
|
||||
QString CSimulatorInternals::convertToQString(bool i18n) const
|
||||
{
|
||||
return m_data.toQString(i18n);
|
||||
}
|
||||
|
||||
CVariant CSimulatorSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CSimulatorInternals::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
@@ -72,9 +92,9 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorSetup::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
void CSimulatorInternals::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CSimulatorSetup>(); return; }
|
||||
if (index.isMyself()) { (*this) = variant.to<CSimulatorInternals>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_SIMULATION_SIMULATORSETUP_H
|
||||
#define BLACKMISC_SIMULATION_SIMULATORSETUP_H
|
||||
#ifndef BLACKMISC_SIMULATION_SIMULATORINTERNALS_H
|
||||
#define BLACKMISC_SIMULATION_SIMULATORINTERNALS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/containerbase.h"
|
||||
@@ -30,19 +30,19 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
//! Simulator settings for flight simulators.
|
||||
//! Simulator internals for flight simulators.
|
||||
//! Those are set up at runtime and represent information about the simulator (like a small registry)
|
||||
class BLACKMISC_EXPORT CSimulatorSetup : public CValueObject<CSimulatorSetup>
|
||||
class BLACKMISC_EXPORT CSimulatorInternals : public CValueObject<CSimulatorInternals>
|
||||
{
|
||||
public:
|
||||
//! Specific values
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexData = BlackMisc::CPropertyIndex::GlobalIndexCSimulatorSetup
|
||||
IndexData = BlackMisc::CPropertyIndex::GlobalIndexCSimulatorInternals
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CSimulatorSetup() {}
|
||||
CSimulatorInternals() {}
|
||||
|
||||
//! All values
|
||||
BlackMisc::CNameVariantPairList getData() const { return this->m_data;}
|
||||
@@ -53,20 +53,32 @@ namespace BlackMisc
|
||||
//! Set value
|
||||
void setValue(const QString &name, const QString &value);
|
||||
|
||||
//! Get value
|
||||
CVariant getVariantValue(const QString &name) const;
|
||||
|
||||
//! Get string value
|
||||
QString getStringValue(const QString &name) const;
|
||||
|
||||
//! Simulator version info, something like "FSX 10.3.2"
|
||||
//! Get sorted names
|
||||
QStringList getSortedNames() const;
|
||||
|
||||
//! Get the simulator name
|
||||
QString getSimulatorName() const;
|
||||
|
||||
//! Set simulator name
|
||||
void setSimulatorName(const QString &name);
|
||||
|
||||
//! Simulator version info, something like "10.3.2"
|
||||
QString getSimulatorVersion() const;
|
||||
|
||||
//! Simulator version info, something like "10.3.2"
|
||||
void setSimulatorVersion(const QString versionInfo);
|
||||
|
||||
//! Path where simulator is installed
|
||||
void setSimulatorInstallationDirectory(const QString fullFilePath);
|
||||
|
||||
//! Simulator version info, something like "FSX 10.3.2"
|
||||
QString getSimulatorVersion() const;
|
||||
QString getSimulatorInstallationDirectory() const;
|
||||
|
||||
//! Path where simulator is installed
|
||||
QString getSimulatorInstallationDirectory() const;
|
||||
void setSimulatorInstallationDirectory(const QString fullFilePath);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
@@ -84,13 +96,13 @@ namespace BlackMisc
|
||||
BlackMisc::CNameVariantPairList m_data;
|
||||
|
||||
BLACK_METACLASS(
|
||||
CSimulatorSetup,
|
||||
CSimulatorInternals,
|
||||
BLACK_METAMEMBER(data)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorSetup)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorInternals)
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user