mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
refs #345 First wave of value classes using the CValueObjectStdTuple CRTP class template.
This commit is contained in:
@@ -23,102 +23,11 @@ namespace BlackMisc
|
||||
m_key(key), m_hotkeyFunction(function)
|
||||
{}
|
||||
|
||||
void CSettingKeyboardHotkey::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CSettingKeyboardHotkey>();
|
||||
qDBusRegisterMetaType<CSettingKeyboardHotkey>();
|
||||
}
|
||||
|
||||
/*
|
||||
* To JSON
|
||||
*/
|
||||
QJsonObject CSettingKeyboardHotkey::toJson() const
|
||||
{
|
||||
return BlackMisc::serializeJson(TupleConverter<CSettingKeyboardHotkey>::toMetaTuple(*this));
|
||||
}
|
||||
|
||||
/*
|
||||
* From Json
|
||||
*/
|
||||
void CSettingKeyboardHotkey::convertFromJson(const QJsonObject &json)
|
||||
{
|
||||
BlackMisc::deserializeJson(json, TupleConverter<CSettingKeyboardHotkey>::toMetaTuple(*this));
|
||||
}
|
||||
|
||||
|
||||
QString CSettingKeyboardHotkey::convertToQString(bool /* i18n */) const
|
||||
{
|
||||
return m_key.toQString();
|
||||
}
|
||||
|
||||
int CSettingKeyboardHotkey::getMetaTypeId() const
|
||||
{
|
||||
return qMetaTypeId<CSettingKeyboardHotkey>();
|
||||
}
|
||||
|
||||
bool CSettingKeyboardHotkey::isA(int metaTypeId) const
|
||||
{
|
||||
return (metaTypeId == qMetaTypeId<CSettingKeyboardHotkey>());
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare
|
||||
*/
|
||||
int CSettingKeyboardHotkey::compareImpl(const CValueObject &otherBase) const
|
||||
{
|
||||
const auto &other = static_cast<const CSettingKeyboardHotkey &>(otherBase);
|
||||
return compare(TupleConverter<CSettingKeyboardHotkey>::toMetaTuple(*this), TupleConverter<CSettingKeyboardHotkey>::toMetaTuple(other));
|
||||
}
|
||||
|
||||
/*
|
||||
* Marshall to DBus
|
||||
*/
|
||||
void CSettingKeyboardHotkey::marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
argument << TupleConverter<CSettingKeyboardHotkey>::toMetaTuple(*this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmarshall from DBus
|
||||
*/
|
||||
void CSettingKeyboardHotkey::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
argument >> TupleConverter<CSettingKeyboardHotkey>::toMetaTuple(*this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hash
|
||||
*/
|
||||
uint CSettingKeyboardHotkey::getValueHash() const
|
||||
{
|
||||
return qHash(TupleConverter<CSettingKeyboardHotkey>::toMetaTuple(*this));
|
||||
}
|
||||
|
||||
/*
|
||||
* Equal?
|
||||
*/
|
||||
bool CSettingKeyboardHotkey::operator ==(const CSettingKeyboardHotkey &other) const
|
||||
{
|
||||
if (this == &other) return true;
|
||||
return TupleConverter<CSettingKeyboardHotkey>::toMetaTuple(*this) == TupleConverter<CSettingKeyboardHotkey>::toMetaTuple(other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unequal?
|
||||
*/
|
||||
bool CSettingKeyboardHotkey::operator !=(const CSettingKeyboardHotkey &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
bool CSettingKeyboardHotkey::operator< (CSettingKeyboardHotkey const &other) const
|
||||
{
|
||||
if (this->getKey() < other.getKey())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSettingKeyboardHotkey::setKey(const Hardware::CKeyboardKey &key)
|
||||
{
|
||||
m_key = key;
|
||||
|
||||
Reference in New Issue
Block a user