mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
refs #314, fromQVariant / location of toQVariant
* renamed fromQVariant to convertFromQVariant, the "from" methods imply the object is changed (fromJson, fromString ..) * implemented fromQVariant - changing the object by QVariant * moved toQVariant into PQ template * free function setFromQVariant
This commit is contained in:
@@ -12,10 +12,10 @@
|
||||
#ifndef BLACKMISC_AVIOMODULATORUNIT_H
|
||||
#define BLACKMISC_AVIOMODULATORUNIT_H
|
||||
|
||||
#include <QDBusMetaType>
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/aviobase.h"
|
||||
#include "blackmisc/mathematics.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
|
||||
using namespace BlackMisc::Math;
|
||||
|
||||
@@ -96,6 +96,12 @@ namespace BlackMisc
|
||||
//! Enabled?
|
||||
void setEnabled(bool enable) { this->m_enabled = enable;}
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this->derived()); }
|
||||
|
||||
//! \copydoc CValueObject::fromQVariant
|
||||
virtual void fromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(derived(), variant); }
|
||||
|
||||
//! \copydoc CValueObject::toJson
|
||||
virtual QJsonObject toJson() const override;
|
||||
|
||||
@@ -249,6 +255,12 @@ namespace BlackMisc
|
||||
qint32 m_volumeOutput; //!< volume output
|
||||
bool m_enabled; //!< is enabled, used e.g. for mute etc.
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
AVIO const *derived() const { return static_cast<AVIO const *>(this); }
|
||||
|
||||
//! Easy access to derived class (CRTP template parameter)
|
||||
AVIO *derived() { return static_cast<AVIO *>(this); }
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user