diff --git a/src/blackmisc/statusmessage.cpp b/src/blackmisc/statusmessage.cpp index 464f3e56a..ed74490a8 100644 --- a/src/blackmisc/statusmessage.cpp +++ b/src/blackmisc/statusmessage.cpp @@ -23,6 +23,23 @@ namespace BlackMisc : m_type(type), m_severity(severity), m_message(message), m_timestamp(QDateTime::currentDateTimeUtc()) { } + /* + * Equal? + */ + bool CStatusMessage::operator ==(const CStatusMessage &other) const + { + if (this == &other) return true; + return TupleConverter::toTuple(*this) == TupleConverter::toTuple(other); + } + + /* + * Unequal? + */ + bool CStatusMessage::operator !=(const CStatusMessage &other) const + { + return !((*this) == other); + } + /* * Constructor */ @@ -49,32 +66,6 @@ namespace BlackMisc return s; } - /* - * metaTypeId - */ - int CStatusMessage::getMetaTypeId() const - { - return qMetaTypeId(); - } - - /* - * is a - */ - bool CStatusMessage::isA(int metaTypeId) const - { - if (metaTypeId == qMetaTypeId()) { return true; } - return this->CValueObject::isA(metaTypeId); - } - - /* - * Metadata - */ - void CStatusMessage::registerMetadata() - { - qRegisterMetaType(); - qDBusRegisterMetaType(); - } - /* * Validation Error */ @@ -121,30 +112,6 @@ namespace BlackMisc } } - /* - * To JSON - */ - QJsonObject CStatusMessage::toJson() const - { - return BlackMisc::serializeJson(CStatusMessage::jsonMembers(), TupleConverter::toTuple(*this)); - } - - /* - * From JSON - */ - void CStatusMessage::convertFromJson(const QJsonObject &json) - { - BlackMisc::deserializeJson(json, CStatusMessage::jsonMembers(), TupleConverter::toTuple(*this)); - } - - /* - * Members - */ - const QStringList &CStatusMessage::jsonMembers() - { - return TupleConverter::jsonMembers(); - } - /* * Type */ @@ -238,56 +205,6 @@ namespace BlackMisc } } - /* - * Compare - */ - int CStatusMessage::compareImpl(const CValueObject &otherBase) const - { - const auto &other = static_cast(otherBase); - return compare(TupleConverter::toTuple(*this), TupleConverter::toTuple(other)); - } - - /* - * Marshall to DBus - */ - void CStatusMessage::marshallToDbus(QDBusArgument &argument) const - { - argument << TupleConverter::toTuple(*this); - } - - /* - * Unmarshall from DBus - */ - void CStatusMessage::unmarshallFromDbus(const QDBusArgument &argument) - { - argument >> TupleConverter::toTuple(*this); - } - - /* - * Hash - */ - uint CStatusMessage::getValueHash() const - { - return qHash(TupleConverter::toTuple(*this)); - } - - /* - * Equal? - */ - bool CStatusMessage::operator ==(const CStatusMessage &other) const - { - if (this == &other) return true; - return TupleConverter::toTuple(*this) == TupleConverter::toTuple(other); - } - - /* - * Unequal - */ - bool CStatusMessage::operator !=(const CStatusMessage &other) const - { - return !(other == (*this)); - } - /* * Property by index */ diff --git a/src/blackmisc/statusmessage.h b/src/blackmisc/statusmessage.h index d1622d21e..de447a154 100644 --- a/src/blackmisc/statusmessage.h +++ b/src/blackmisc/statusmessage.h @@ -22,7 +22,7 @@ namespace BlackMisc /*! * Streamable status message, e.g. from Core -> GUI */ - class CStatusMessage : public CValueObject + class CStatusMessage : public CValueObjectStdTuple { public: //! Status types @@ -69,6 +69,12 @@ namespace BlackMisc //! Constructor CStatusMessage(StatusType type, StatusSeverity severity, const QString &message); + //! Equal operator == + bool operator ==(const CStatusMessage &other) const; + + //! Unequal operator != + bool operator !=(const CStatusMessage &other) const; + //! Status type StatusType getType() const { return this->m_type; } @@ -81,15 +87,6 @@ namespace BlackMisc //! Message empty bool isEmpty() const { return this->m_message.isEmpty(); } - //! \copydoc CValueObject::getValueHash() - virtual uint getValueHash() const override; - - //! \copydoc CValueObject::toQVariant() - virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); } - - //! \copydoc CValueObject::convertFromQVariant - virtual void convertFromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(this, variant); } - //! Type as string const QString &getTypeAsString() const; @@ -102,12 +99,6 @@ namespace BlackMisc //! Type as string const QString &getSeverityAsString() const; - //! \copydoc CValueObject::toJson - virtual QJsonObject toJson() const override; - - //! \copydoc CValueObject::convertFromJson - virtual void convertFromJson(const QJsonObject &json) override; - //! \copydoc CValueObject::propertyByIndex(int) virtual QVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override; @@ -117,18 +108,6 @@ namespace BlackMisc //! To HTML QString toHtml() const; - //! Equal operator == - bool operator ==(const CStatusMessage &other) const; - - //! Unequal operator != - bool operator !=(const CStatusMessage &other) const; - - //! Register metadata - static void registerMetadata(); - - //! JSON member names - static const QStringList &jsonMembers(); - //! Validation error static CStatusMessage getValidationError(const QString &message); @@ -145,24 +124,9 @@ namespace BlackMisc static const CIcon &convertToIcon(const CStatusMessage &statusMessage); protected: - //! \copydoc CValueObject::marshallToDbus - virtual void marshallToDbus(QDBusArgument &arg) const override; - - //! \copydoc CValueObject::unmarshallFromDbus - virtual void unmarshallFromDbus(const QDBusArgument &arg) override; - //! \copydoc CValueObject::convertToQString virtual QString convertToQString(bool i18n = false) const override; - //! \copydoc CValueObject::getMetaTypeId - virtual int getMetaTypeId() const override; - - //! \copydoc CValueObject::isA - virtual bool isA(int metaTypeId) const override; - - //! \copydoc CValueObject::compareImpl - virtual int compareImpl(const CValueObject &other) const override; - private: BLACK_ENABLE_TUPLE_CONVERSION(CStatusMessage) StatusType m_type; @@ -171,7 +135,8 @@ namespace BlackMisc QDateTime m_timestamp; }; -} +} // namespace + BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::CStatusMessage, (o.m_type, o.m_severity, o.m_message, o.m_timestamp)) Q_DECLARE_METATYPE(BlackMisc::CStatusMessage)