mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
refs #829, settings for model related properties
This commit is contained in:
@@ -120,11 +120,12 @@ namespace BlackMisc
|
|||||||
GlobalIndexCAircraftModel = 6800,
|
GlobalIndexCAircraftModel = 6800,
|
||||||
GlobalIndexCSimulatedAircraft = 6900,
|
GlobalIndexCSimulatedAircraft = 6900,
|
||||||
GlobalIndexCTextMessage = 7000,
|
GlobalIndexCTextMessage = 7000,
|
||||||
GlobalIndexCSimulatorInternals = 7100,
|
GlobalIndexCSimulatorInternals = 7100,
|
||||||
GlobalIndexCSimulatorSettings = 7200,
|
GlobalIndexCSimulatorSettings = 7200,
|
||||||
GlobalIndexCSimulatorMessageSettings = 7300,
|
GlobalIndexCSimulatorMessageSettings = 7300,
|
||||||
GlobalIndexCAircraftCfgEntries = 7400,
|
GlobalIndexCModelSettings = 7400,
|
||||||
GlobalIndexCDistributor = 7500,
|
GlobalIndexCAircraftCfgEntries = 7500,
|
||||||
|
GlobalIndexCDistributor = 7600,
|
||||||
GlobalIndexCVPilotModelRule = 8000,
|
GlobalIndexCVPilotModelRule = 8000,
|
||||||
GlobalIndexCVoiceRoom = 9000,
|
GlobalIndexCVoiceRoom = 9000,
|
||||||
GlobalIndexCSettingKeyboardHotkey = 10000,
|
GlobalIndexCSettingKeyboardHotkey = 10000,
|
||||||
|
|||||||
55
src/blackmisc/simulation/modelsettings.cpp
Normal file
55
src/blackmisc/simulation/modelsettings.cpp
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/* Copyright (C) 2016
|
||||||
|
* 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 "modelsettings.h"
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
CModelSettings::CModelSettings()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
QString CModelSettings::convertToQString(bool i18n) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(i18n);
|
||||||
|
static const QString ms("Allow exclude: %1");
|
||||||
|
return ms.arg(boolToYesNo(this->m_allowExcludeModels));
|
||||||
|
}
|
||||||
|
|
||||||
|
CVariant CModelSettings::propertyByIndex(const CPropertyIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case IndexAllowExclude:
|
||||||
|
return CVariant::fromValue(this->m_allowExcludeModels);
|
||||||
|
default:
|
||||||
|
return CValueObject::propertyByIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModelSettings::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||||
|
{
|
||||||
|
if (index.isMyself()) { (*this) = variant.to<CModelSettings>(); return; }
|
||||||
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case IndexAllowExclude:
|
||||||
|
this->setAllowExcludedModels(variant.toBool());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CValueObject::setPropertyByIndex(index, variant);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
82
src/blackmisc/simulation/modelsettings.h
Normal file
82
src/blackmisc/simulation/modelsettings.h
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/* Copyright (C) 2016
|
||||||
|
* 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_MODELSETTINGS_H
|
||||||
|
#define BLACKMISC_SIMULATION_MODELSETTINGS_H
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/distributorlistpreferences.h"
|
||||||
|
#include "blackmisc/settingscache.h"
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include "blackmisc/propertyindex.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
//! Settings for models
|
||||||
|
class BLACKMISC_EXPORT CModelSettings :
|
||||||
|
public BlackMisc::CValueObject<CModelSettings>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Properties by index
|
||||||
|
enum ColumnIndex
|
||||||
|
{
|
||||||
|
IndexAllowExclude = BlackMisc::CPropertyIndex::GlobalIndexCSimulatorSettings
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Default constructor
|
||||||
|
CModelSettings();
|
||||||
|
|
||||||
|
//! Allow excluded models?
|
||||||
|
bool getAllowExcludedModels() const { return m_allowExcludeModels; }
|
||||||
|
|
||||||
|
//! Allow excluded models?
|
||||||
|
void setAllowExcludedModels(bool allow) { m_allowExcludeModels = allow; }
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||||
|
BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||||
|
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_allowExcludeModels = false; //!< Allow excluded models in sets
|
||||||
|
|
||||||
|
BLACK_METACLASS(
|
||||||
|
CModelSettings,
|
||||||
|
BLACK_METAMEMBER(allowExcludeModels)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Trait for simulator settings
|
||||||
|
struct TModel : public BlackMisc::TSettingTrait<CModelSettings>
|
||||||
|
{
|
||||||
|
//! Key in data cache
|
||||||
|
static const char *key() { return "settingsmodels"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Mapping preferences for model distributor list
|
||||||
|
struct TDistributorListPreferences : public BlackMisc::TSettingTrait<BlackMisc::Simulation::CDistributorListPreferences>
|
||||||
|
{
|
||||||
|
//! \copydoc BlackMisc::TSettingTrait::key
|
||||||
|
static const char *key() { return "mapping/distributorpreferences"; }
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Simulation::CModelSettings)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Simulation::CModelSettings>)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Simulation::CModelSettings>)
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user