src/linetypes/object.cpp

changeset 86
4bec0525ef1b
parent 81
62373840e33a
child 89
7abaf1d64719
equal deleted inserted replaced
85:40e2940605a3 86:4bec0525ef1b
27 { 27 {
28 Q_UNUSED(id); 28 Q_UNUSED(id);
29 return {}; 29 return {};
30 } 30 }
31 31
32 auto ldraw::Object::setProperty(Property id, const QVariant& value) 32 void ldraw::Object::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair)
33 -> SetPropertyResult
34 { 33 {
35 Q_UNUSED(id) 34 Q_UNUSED(result)
36 Q_UNUSED(value) 35 Q_UNUSED(pair)
37 return SetPropertyResult::PropertyNotHandled; 36 }
37
38 /**
39 * @brief public interface to setProperty
40 */
41 ldraw::Object::SetPropertyResult ldraw::Object::setProperty(const PropertyKeyValue& pair)
42 {
43 SetPropertyResult result;
44 this->setProperty(&result, pair);
45 return result;
38 } 46 }
39 47
40 QBrush ldraw::Object::textRepresentationForeground() const 48 QBrush ldraw::Object::textRepresentationForeground() const
41 { 49 {
42 return {}; 50 return {};
58 Q_UNUSED(context) 66 Q_UNUSED(context)
59 } 67 }
60 68
61 const glm::vec3& ldraw::Object::getPoint(int index) const 69 const glm::vec3& ldraw::Object::getPoint(int index) const
62 { 70 {
71 Q_UNUSED(index);
63 throw BadPointIndex{}; 72 throw BadPointIndex{};
64 } 73 }
65 74
66 ldraw::ColoredObject::ColoredObject(const Color color_index) : 75 ldraw::ColoredObject::ColoredObject(const Color color_index) :
67 colorIndex{color_index} 76 colorIndex{color_index}
82 default: 91 default:
83 return Object::getProperty(id); 92 return Object::getProperty(id);
84 } 93 }
85 } 94 }
86 95
87 auto ldraw::ColoredObject::setProperty(Property id, const QVariant& value) 96 void ldraw::ColoredObject::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair)
88 -> SetPropertyResult
89 { 97 {
90 switch (id) 98 LDRAW_OBJECT_HANDLE_SET_PROPERTY(Color, {colorIndex.index = value;});
91 { 99 Object::setProperty(result, pair);
92 case Property::Color:
93 {
94 bool ok;
95 const int value_int = value.toInt(&ok);
96 if (ok)
97 {
98 colorIndex.index = value_int;
99 return SetPropertyResult::Success;
100 }
101 else
102 {
103 return SetPropertyResult::InvalidValue;
104 }
105 }
106 default:
107 return Object::setProperty(id, value);
108 }
109 } 100 }
110 101
111 QString ldraw::Empty::textRepresentation() const 102 QString ldraw::Empty::textRepresentation() const
112 { 103 {
113 return ""; 104 return "";

mercurial