Issue #77 All classes propertyindex methods use CPropertyIndexRef and QVariant

This commit is contained in:
Mat Sutcliffe
2020-11-01 20:05:34 +00:00
parent d9e3d1dccc
commit 0971c8ce68
190 changed files with 1298 additions and 1293 deletions

View File

@@ -74,36 +74,36 @@ namespace BlackMisc
return CAudioDeviceInfo(InputDevice, QAudioDeviceInfo::defaultInputDevice().deviceName());
}
CVariant CAudioDeviceInfo::propertyByIndex(const CPropertyIndex &index) const
QVariant CAudioDeviceInfo::propertyByIndex(CPropertyIndexRef index) const
{
if (index.isMyself()) { return CVariant::fromValue(*this); }
if (index.isMyself()) { return QVariant::fromValue(*this); }
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexDeviceType: return CVariant::fromValue(this->getType());
case IndexDeviceTypeAsString: return CVariant::fromValue(this->getTypeAsString());
case IndexName: return CVariant::fromValue(this->getName());
case IndexDeviceType: return QVariant::fromValue(this->getType());
case IndexDeviceTypeAsString: return QVariant::fromValue(this->getTypeAsString());
case IndexName: return QVariant::fromValue(this->getName());
case IndexIdentifier: return m_identifier.propertyByIndex(index.copyFrontRemoved());
default: break;
}
return CValueObject::propertyByIndex(index);
}
void CAudioDeviceInfo::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
void CAudioDeviceInfo::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
{
if (index.isMyself()) { (*this) = variant.to<CAudioDeviceInfo>(); return; }
if (index.isMyself()) { (*this) = variant.value<CAudioDeviceInfo>(); return; }
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexDeviceType: m_type = static_cast<DeviceType>(variant.toInt()); return;
case IndexName: m_deviceName = variant.toQString(); return;
case IndexName: m_deviceName = variant.toString(); return;
case IndexIdentifier: m_identifier.setPropertyByIndex(index.copyFrontRemoved(), variant); return;
default: break;
}
CValueObject::setPropertyByIndex(index, variant);
}
int CAudioDeviceInfo::comparePropertyByIndex(const CPropertyIndex &index, const CAudioDeviceInfo &compareValue) const
int CAudioDeviceInfo::comparePropertyByIndex(CPropertyIndexRef index, const CAudioDeviceInfo &compareValue) const
{
if (index.isMyself()) { return m_deviceName.compare(compareValue.m_deviceName, Qt::CaseInsensitive); }
const ColumnIndex i = index.frontCasted<ColumnIndex>();

View File

@@ -98,16 +98,16 @@ namespace BlackMisc
static CAudioDeviceInfo getDefaultInputDevice();
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
QVariant propertyByIndex(BlackMisc::CPropertyIndexRef index) const;
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
void setPropertyByIndex(BlackMisc::CPropertyIndexRef index, const QVariant &variant);
//! \copydoc BlackMisc::Mixin::String::toQString
QString convertToQString(bool i18n = false) const;
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
int comparePropertyByIndex(const CPropertyIndex &index, const CAudioDeviceInfo &compareValue) const;
int comparePropertyByIndex(CPropertyIndexRef index, const CAudioDeviceInfo &compareValue) const;
//! Device type as string
static const QString &deviceTypeToString(DeviceType t);

View File

@@ -45,33 +45,33 @@ namespace BlackMisc
m_afvVoiceServerUrl(afvVoiceServerUrl), m_afvMapUrl(afvMapUrl)
{ }
CVariant CVoiceSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
QVariant CVoiceSetup::propertyByIndex(BlackMisc::CPropertyIndexRef index) const
{
if (index.isMyself()) { return CVariant::from(*this); }
if (index.isMyself()) { return QVariant::fromValue(*this); }
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexAfvVoiceServerUrl: return CVariant::fromValue(m_afvVoiceServerUrl);
case IndexAfvMapUrl: return CVariant::fromValue(m_afvMapUrl);
case IndexAfvVoiceServerUrl: return QVariant::fromValue(m_afvVoiceServerUrl);
case IndexAfvMapUrl: return QVariant::fromValue(m_afvMapUrl);
default: return CValueObject::propertyByIndex(index);
}
}
void CVoiceSetup::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
void CVoiceSetup::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
{
if (index.isMyself()) { (*this) = variant.to<CVoiceSetup>(); return; }
if (index.isMyself()) { (*this) = variant.value<CVoiceSetup>(); return; }
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexAfvVoiceServerUrl: m_afvVoiceServerUrl = variant.toQString(); break;
case IndexAfvMapUrl: m_afvMapUrl = variant.toQString(); break;
case IndexAfvVoiceServerUrl: m_afvVoiceServerUrl = variant.toString(); break;
case IndexAfvMapUrl: m_afvMapUrl = variant.toString(); break;
default:
CValueObject::setPropertyByIndex(index, variant);
break;
}
}
int CVoiceSetup::comparePropertyByIndex(const CPropertyIndex &index, const CVoiceSetup &compareValue) const
int CVoiceSetup::comparePropertyByIndex(CPropertyIndexRef index, const CVoiceSetup &compareValue) const
{
if (index.isMyself()) { return this->convertToQString(true).compare(compareValue.convertToQString()); }
const ColumnIndex i = index.frontCasted<ColumnIndex>();

View File

@@ -56,13 +56,13 @@ namespace BlackMisc
const QString &getAfvMapUrl() const { return m_afvMapUrl; }
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const CPropertyIndex &index) const;
QVariant propertyByIndex(CPropertyIndexRef index) const;
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
int comparePropertyByIndex(const CPropertyIndex &index, const CVoiceSetup &compareValue) const;
int comparePropertyByIndex(CPropertyIndexRef index, const CVoiceSetup &compareValue) const;
//! \copydoc BlackMisc::Mixin::String::toQString()
QString convertToQString(bool i18n = false) const;