summaryrefslogtreecommitdiffstats
path: root/src/object-set.cpp
diff options
context:
space:
mode:
authorAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-06-06 10:29:05 +0000
committerAdrian Boguszewski <adrbogus1@student.pg.gda.pl>2016-06-06 10:29:05 +0000
commitb98472931f26e998969d9ffa49dbe12c4fada097 (patch)
tree1858b70f0c09c71d3031893b459c5e70b712e418 /src/object-set.cpp
parentAdded object set (diff)
parent[Bug #1588983] Finish up German tutorials for 0.92. (diff)
downloadinkscape-b98472931f26e998969d9ffa49dbe12c4fada097.tar.gz
inkscape-b98472931f26e998969d9ffa49dbe12c4fada097.zip
Replaced Object by SPObject
(bzr r14954.1.2)
Diffstat (limited to 'src/object-set.cpp')
-rw-r--r--src/object-set.cpp67
1 files changed, 35 insertions, 32 deletions
diff --git a/src/object-set.cpp b/src/object-set.cpp
index f071aa4d6..df4bc1435 100644
--- a/src/object-set.cpp
+++ b/src/object-set.cpp
@@ -11,14 +11,14 @@
#include "object-set.h"
-bool ObjectSet::add(Object* object) {
+bool ObjectSet::add(SPObject* object) {
// any ancestor is in the set - do nothing
if (_anyAncestorIsInSet(object)) {
return false;
}
// check if there is mutual ancestor for some elements, which can replace all of them in the set
- Object* o = _getMutualAncestor(object);
+ SPObject* o = _getMutualAncestor(object);
// remove all descendants from the set
_removeDescendantsFromSet(o);
@@ -27,24 +27,27 @@ bool ObjectSet::add(Object* object) {
return true;
}
-bool ObjectSet::remove(Object* object) {
+void ObjectSet::remove(SPObject* object) {
// object is the top of subtree
if (contains(object)) {
_remove(object);
- return true;
+ // TODO
+// return true;
}
// any ancestor of object is in the set
if (_anyAncestorIsInSet(object)) {
_removeAncestorsFromSet(object);
- return true;
+ // TODO
+// return true;
}
// no object nor any parent in the set
- return false;
+ // TODO
+// return false;
}
-bool ObjectSet::contains(Object* object) {
+bool ObjectSet::contains(SPObject* object) {
return container.get<hashed>().find(object) != container.get<hashed>().end();
}
@@ -58,48 +61,48 @@ int ObjectSet::size() {
return container.size();
}
-bool ObjectSet::_anyAncestorIsInSet(Object *object) {
- Object* o = object;
+bool ObjectSet::_anyAncestorIsInSet(SPObject *object) {
+ SPObject* o = object;
while (o != nullptr) {
if (contains(o)) {
return true;
}
- o = o->getParent();
+ o = o->parent;
}
return false;
}
-void ObjectSet::_removeDescendantsFromSet(Object *object) {
- for (auto& child: object->getChildren()) {
- if (contains(&child)) {
- _remove(&child);
+void ObjectSet::_removeDescendantsFromSet(SPObject *object) {
+ for (auto& child: object->childList(false)) {
+ if (contains(child)) {
+ _remove(child);
// there is certainly no children of this child in the set
continue;
}
- _removeDescendantsFromSet(&child);
+ _removeDescendantsFromSet(child);
}
}
-void ObjectSet::_remove(Object *object) {
+void ObjectSet::_remove(SPObject *object) {
releaseConnections[object].disconnect();
releaseConnections.erase(object);
container.get<hashed>().erase(object);
}
-void ObjectSet::_add(Object *object) {
+void ObjectSet::_add(SPObject *object) {
releaseConnections[object] = object->connectRelease(sigc::mem_fun(*this, &ObjectSet::remove));
container.push_back(object);
}
-Object *ObjectSet::_getMutualAncestor(Object *object) {
- Object *o = object;
+SPObject *ObjectSet::_getMutualAncestor(SPObject *object) {
+ SPObject *o = object;
bool flag = true;
- while (o->getParent() != nullptr) {
- for (auto &child: o->getParent()->getChildren()) {
- if(&child != o && !contains(&child)) {
+ while (o->parent != nullptr) {
+ for (auto &child: o->parent->childList(false)) {
+ if(child != o && !contains(child)) {
flag = false;
break;
}
@@ -107,24 +110,24 @@ Object *ObjectSet::_getMutualAncestor(Object *object) {
if (!flag) {
break;
}
- o = o->getParent();
+ o = o->parent;
}
return o;
}
-void ObjectSet::_removeAncestorsFromSet(Object *object) {
- Object* o = object;
- while (o->getParent() != nullptr) {
- for (auto &child: o->getParent()->getChildren()) {
- if (&child != o) {
- _add(&child);
+void ObjectSet::_removeAncestorsFromSet(SPObject *object) {
+ SPObject* o = object;
+ while (o->parent != nullptr) {
+ for (auto &child: o->parent->childList(false)) {
+ if (child != o) {
+ _add(child);
}
}
- if (contains(o->getParent())) {
- _remove(o->getParent());
+ if (contains(o->parent)) {
+ _remove(o->parent);
break;
}
- o = o->getParent();
+ o = o->parent;
}
}