mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Split of CSimulatorPluginInfo and CSimulatorSetup
refs #404, and discussion https://dev.vatsim-germany.org/issues/404#note-8 * Changed CSimulatorSetup to use CNameVariantPairList as data. The old version was an hack and had to go, CNameVariantPairList would allow complex types in the future and can be already shown in the GUI. * CNameVariantPairList was improved slightly in the same step * Functions to get CSimulatorSetup from driver / context * Removed CSimulatorSetup data from CSimulatorPluginInfo
This commit is contained in:
@@ -12,30 +12,54 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
/*
|
||||
* Empty constructor
|
||||
*/
|
||||
CNameVariantPairList::CNameVariantPairList() { }
|
||||
|
||||
/*
|
||||
* Construct from base class object
|
||||
*/
|
||||
CNameVariantPairList::CNameVariantPairList(const CSequence<CNameVariantPair> &other) :
|
||||
CSequence<CNameVariantPair>(other)
|
||||
{ }
|
||||
|
||||
/*
|
||||
* Name contained?
|
||||
*/
|
||||
bool CNameVariantPairList::containsName(const QString &name)const
|
||||
{
|
||||
return this->contains(&CNameVariantPair::getName, name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Name index
|
||||
*/
|
||||
int CNameVariantPairList::getNameRowIndex(const QString &name) const
|
||||
CNameVariantPair CNameVariantPairList::getValue(const QString &name) const
|
||||
{
|
||||
if (name.isEmpty()) { return CNameVariantPair(); }
|
||||
return this->findBy(&CNameVariantPair::getName, name).frontOrDefault();
|
||||
}
|
||||
|
||||
CVariant CNameVariantPairList::getVariantValue(const QString &name) const
|
||||
{
|
||||
if (name.isEmpty()) { return CVariant(); }
|
||||
return getValue(name).getVariant();
|
||||
}
|
||||
|
||||
QString CNameVariantPairList::getValueAsString(const QString &name) const
|
||||
{
|
||||
if (name.isEmpty()) { return QString(); }
|
||||
CVariant cs(getValue(name).getVariant());
|
||||
if (cs.isNull() || !cs.canConvert<QString>()) { return QString(); }
|
||||
return cs.value<QString>();
|
||||
}
|
||||
|
||||
bool CNameVariantPairList::addOrReplaceValue(const QString &name, const CVariant &value, const CIcon &icon)
|
||||
{
|
||||
if (name.isEmpty()) { return false; }
|
||||
int i = getIndexForName(name);
|
||||
if (i < 0)
|
||||
{
|
||||
this->push_back(CNameVariantPair(name, value, icon));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this)[i] = CNameVariantPair(name, value, icon);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int CNameVariantPairList::getIndexForName(const QString &name) const
|
||||
{
|
||||
for (int i = 0; i < this->size(); i++)
|
||||
{
|
||||
@@ -47,9 +71,6 @@ namespace BlackMisc
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
void CNameVariantPairList::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<BlackMisc::CSequence<CNameVariantPair>>();
|
||||
|
||||
Reference in New Issue
Block a user