/* Copyright (C) 2013 * swift project Community / Contributors * * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, * including this file, may be copied, modified, propagated, or distributed except according to the terms * contained in the LICENSE file. */ #include "icon.h" namespace BlackMisc { /* * Compare */ int CIcon::compareImpl(const CValueObject &otherBase) const { const auto &other = static_cast(otherBase); return compare(TupleConverter::toTuple(*this), TupleConverter::toTuple(other)); } /* * Marshall to DBus */ void CIcon::marshallToDbus(QDBusArgument &argument) const { argument << TupleConverter::toTuple(*this); } /* * Unmarshall from DBus */ void CIcon::unmarshallFromDbus(const QDBusArgument &argument) { argument >> TupleConverter::toTuple(*this); } /* * Hash */ uint CIcon::getValueHash() const { return qHash(TupleConverter::toTuple(*this)); } /* * Pixmap */ QPixmap CIcon::toPixmap() const { return CIcons::pixmapByIndex(getIndex(), this->m_rotateDegrees); } /* * Rotate */ void CIcon::setRotation(const PhysicalQuantities::CAngle &rotate) { this->m_rotateDegrees = rotate.valueRounded(PhysicalQuantities::CAngleUnit::deg(), 0); } /* * Equal? */ bool CIcon::operator ==(const CIcon &other) const { if (this == &other) return true; return TupleConverter::toTuple(*this) == TupleConverter::toTuple(other); } /* * Unequal? */ bool CIcon::operator !=(const CIcon &other) const { return !((*this) == other); } /* * metaTypeId */ int CIcon::getMetaTypeId() const { return qMetaTypeId(); } /* * is a */ bool CIcon::isA(int metaTypeId) const { if (metaTypeId == qMetaTypeId()) { return true; } return this->CValueObject::isA(metaTypeId); } /* * Register metadata */ void CIcon::registerMetadata() { qRegisterMetaType(); qDBusRegisterMetaType(); } /* * Members */ const QStringList &CIcon::jsonMembers() { return TupleConverter::jsonMembers(); } /* * String */ QString CIcon::convertToQString(bool i18n) const { Q_UNUSED(i18n); QString s = QString(this->m_descriptiveText).append(" ").append(this->m_index); return s; } /* * To JSON */ QJsonObject CIcon::toJson() const { return BlackMisc::serializeJson(CIcon::jsonMembers(), TupleConverter::toTuple(*this)); } /* * From Json */ void CIcon::convertFromJson(const QJsonObject &json) { BlackMisc::deserializeJson(json, CIcon::jsonMembers(), TupleConverter::toTuple(*this)); } } // namespace