Sun, 22 Sep 2019 11:51:41 +0300
Added lots of code
#include "modelobject.h" static Uuid &getUuidForNewObject() { static Uuid running_uuid {0, 0}; incrementUuid(running_uuid); return running_uuid; } modelobjects::BaseObject::BaseObject() : id {getUuidForNewObject()} { } modelobjects::BaseObject::~BaseObject() { } bool modelobjects::BaseObject::hasColor() const { return false; } QVariant modelobjects::BaseObject::getProperty(Property id) const { Q_UNUSED(id); return {}; } auto modelobjects::BaseObject::setProperty(Property id, const QVariant& value) -> SetPropertyResult { Q_UNUSED(id) Q_UNUSED(value) return SetPropertyResult::PropertyNotHandled; } modelobjects::ColoredBaseObject::ColoredBaseObject(const Color color_index) : color_index{color_index} { } bool modelobjects::ColoredBaseObject::hasColor() const { return true; } QVariant modelobjects::ColoredBaseObject::getProperty(Property id) const { switch (id) { case Property::Color: return color_index.index; default: return BaseObject::getProperty(id); } } auto modelobjects::ColoredBaseObject::setProperty(Property id, const QVariant& value) -> SetPropertyResult { switch (id) { case Property::Color: { bool ok; const int value_int = value.toInt(&ok); if (ok) { color_index.index = value_int; return SetPropertyResult::Success; } else { return SetPropertyResult::InvalidValue; } } default: return BaseObject::setProperty(id, value); } }