mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
Issue #77 All classes propertyindex methods use CPropertyIndexRef and QVariant
This commit is contained in:
@@ -64,36 +64,36 @@ namespace BlackMisc
|
||||
m_combination = obj.m_combination;
|
||||
}
|
||||
|
||||
CVariant CActionHotkey::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
QVariant CActionHotkey::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 IndexIdentifier: return CVariant::from(m_identifier);
|
||||
case IndexIdentifierAsString: return CVariant::from(m_identifier.getMachineName());
|
||||
case IndexAction: return CVariant::from(m_action);
|
||||
case IndexActionAsString: return CVariant::from(m_action);
|
||||
case IndexCombination: return CVariant::from(m_combination);
|
||||
case IndexCombinationAsString: return CVariant::from(QString(m_combination.toQString()));
|
||||
case IndexIdentifier: return QVariant::fromValue(m_identifier);
|
||||
case IndexIdentifierAsString: return QVariant::fromValue(m_identifier.getMachineName());
|
||||
case IndexAction: return QVariant::fromValue(m_action);
|
||||
case IndexActionAsString: return QVariant::fromValue(m_action);
|
||||
case IndexCombination: return QVariant::fromValue(m_combination);
|
||||
case IndexCombinationAsString: return QVariant::fromValue(QString(m_combination.toQString()));
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CActionHotkey::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
void CActionHotkey::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CActionHotkey>(); return; }
|
||||
if (index.isMyself()) { (*this) = variant.value<CActionHotkey>(); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAction:
|
||||
{
|
||||
m_action = variant.to<QString>();
|
||||
m_action = variant.value<QString>();
|
||||
break;
|
||||
}
|
||||
case IndexCombination:
|
||||
case IndexCombinationAsString:
|
||||
m_combination = variant.to<CHotkeyCombination>();
|
||||
m_combination = variant.value<CHotkeyCombination>();
|
||||
break;
|
||||
case IndexObject:
|
||||
this->setObject(variant.value<CActionHotkey>());
|
||||
|
||||
@@ -91,10 +91,10 @@ namespace BlackMisc
|
||||
bool isValid() const { return !m_identifier.getMachineName().isEmpty() && !m_combination.isEmpty() && !m_action.isEmpty(); }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
QVariant propertyByIndex(CPropertyIndexRef index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace BlackMisc
|
||||
m_buttonIndex = button.m_buttonIndex;
|
||||
}
|
||||
|
||||
void CJoystickButton::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
void CJoystickButton::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CJoystickButton>(); return; }
|
||||
if (index.isMyself()) { (*this) = variant.value<CJoystickButton>(); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
@@ -60,21 +60,21 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
CVariant CJoystickButton::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
QVariant CJoystickButton::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 IndexDeviceName: return CVariant::from(this->getDeviceName());
|
||||
case IndexButton: return CVariant::from(this->getButtonIndex());
|
||||
case IndexButtonAsString: return CVariant::from(this->getButtonAsString());
|
||||
case IndexButtonObject: return CVariant::from(*this);
|
||||
case IndexDeviceName: return QVariant::fromValue(this->getDeviceName());
|
||||
case IndexButton: return QVariant::fromValue(this->getButtonIndex());
|
||||
case IndexButtonAsString: return QVariant::fromValue(this->getButtonAsString());
|
||||
case IndexButtonObject: return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, "CJoystickButton", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return CVariant::fromValue(m);
|
||||
return QVariant::fromValue(m);
|
||||
}
|
||||
|
||||
QString CJoystickButton::buttonIndexToString(qint32 buttonIndex)
|
||||
|
||||
@@ -69,10 +69,10 @@ namespace BlackMisc
|
||||
void setButtonObject(CJoystickButton button);
|
||||
|
||||
//! \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::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
QVariant propertyByIndex(CPropertyIndexRef index) const;
|
||||
|
||||
//! Button index to string
|
||||
static QString buttonIndexToString(qint32 buttonIndex);
|
||||
|
||||
@@ -103,25 +103,25 @@ namespace BlackMisc
|
||||
return allModifiers;
|
||||
}
|
||||
|
||||
CVariant CKeyboardKey::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
QVariant CKeyboardKey::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 IndexKey: return CVariant::from(m_keyCode);
|
||||
case IndexKeyAsString: return CVariant::from(getKeyAsString());
|
||||
case IndexKey: return QVariant::fromValue(m_keyCode);
|
||||
case IndexKeyAsString: return QVariant::fromValue(getKeyAsString());
|
||||
default: break;
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, "CKeyboardKey", "index unknown");
|
||||
QString m = QString("no property, index ").append(index.toQString());
|
||||
return CVariant::fromValue(m);
|
||||
return QVariant::fromValue(m);
|
||||
}
|
||||
|
||||
void CKeyboardKey::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
void CKeyboardKey::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CKeyboardKey>(); return; }
|
||||
if (index.isMyself()) { (*this) = variant.value<CKeyboardKey>(); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
|
||||
@@ -78,10 +78,10 @@ namespace BlackMisc
|
||||
void setKeyObject(CKeyboardKey key);
|
||||
|
||||
//! \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::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
QVariant propertyByIndex(BlackMisc::CPropertyIndexRef index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
Reference in New Issue
Block a user