src/modeleditcontext.cpp

changeset 26
3a9e761e4faa
parent 24
1a0faaaceb84
child 35
98906a94732f
--- a/src/modeleditcontext.cpp	Sun Jan 19 14:25:57 2020 +0200
+++ b/src/modeleditcontext.cpp	Wed Jan 22 00:23:29 2020 +0200
@@ -23,9 +23,12 @@
 {
 }
 
-void Model::EditContext::append(std::unique_ptr<linetypes::Object>&& object)
+linetypes::Id Model::EditContext::append(std::unique_ptr<linetypes::Object>&& object)
 {
+	const linetypes::Id id = object->id;
+	this->model.objectsById[id] = object.get();
 	this->model.append(std::move(object));
+	return id;
 }
 
 void Model::EditContext::setObjectProperty(
@@ -35,3 +38,13 @@
 {
 	object->setProperty(property, value);
 }
+
+void Model::EditContext::invertObject(linetypes::Id id)
+{
+	auto it = this->model.objectsById.find(id);
+	if (it != this->model.objectsById.end())
+	{
+		linetypes::Object* object = it->second;
+		object->invert();
+	}
+}

mercurial