src/modeleditcontext.cpp

changeset 26
3a9e761e4faa
parent 24
1a0faaaceb84
child 35
98906a94732f
equal deleted inserted replaced
25:6de5ac1fb471 26:3a9e761e4faa
21 Model::EditContext::EditContext(Model& model) : 21 Model::EditContext::EditContext(Model& model) :
22 model{model} 22 model{model}
23 { 23 {
24 } 24 }
25 25
26 void Model::EditContext::append(std::unique_ptr<linetypes::Object>&& object) 26 linetypes::Id Model::EditContext::append(std::unique_ptr<linetypes::Object>&& object)
27 { 27 {
28 const linetypes::Id id = object->id;
29 this->model.objectsById[id] = object.get();
28 this->model.append(std::move(object)); 30 this->model.append(std::move(object));
31 return id;
29 } 32 }
30 33
31 void Model::EditContext::setObjectProperty( 34 void Model::EditContext::setObjectProperty(
32 linetypes::Object* object, 35 linetypes::Object* object,
33 linetypes::Property property, 36 linetypes::Property property,
34 const QVariant& value) 37 const QVariant& value)
35 { 38 {
36 object->setProperty(property, value); 39 object->setProperty(property, value);
37 } 40 }
41
42 void Model::EditContext::invertObject(linetypes::Id id)
43 {
44 auto it = this->model.objectsById.find(id);
45 if (it != this->model.objectsById.end())
46 {
47 linetypes::Object* object = it->second;
48 object->invert();
49 }
50 }

mercurial