diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-12-01 11:36:45 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-12-01 15:25:55 -0300 |
commit | 6ea32275b157bcf3a97725172a06122b4ff98d0a (patch) | |
tree | 66f8117318e275b211c067f0e908e8c12ec7097e /tests/libsample/objecttypelayout.cpp | |
parent | 64cda5a441fd912469c4ad2c7afcc39f0da6819c (diff) |
Updated ObjectType and ObjectTypeLayout to resemble the Qt's QLayout class.
Also added more test cases that use ObjectTypeLayout.
Diffstat (limited to 'tests/libsample/objecttypelayout.cpp')
-rw-r--r-- | tests/libsample/objecttypelayout.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/libsample/objecttypelayout.cpp b/tests/libsample/objecttypelayout.cpp index 06c4555b4..92180418f 100644 --- a/tests/libsample/objecttypelayout.cpp +++ b/tests/libsample/objecttypelayout.cpp @@ -33,9 +33,26 @@ */ #include "objecttypelayout.h" +#include <iostream> + +using namespace std; void ObjectTypeLayout::addObject(ObjectType* obj) { + if (obj->isLayoutType()) { + ObjectTypeLayout* l = reinterpret_cast<ObjectTypeLayout*>(obj); + if (l->parent()) { + cerr << "[WARNING] ObjectTypeLayout::addObject: layout '" << l->objectName().cstring(); + cerr << "' already has a parent." << endl; + return; + } + + l->setParent(this); + + if (parent() && !parent()->isLayoutType()) + l->reparentChildren(parent()); + } + m_objects.push_back(obj); } @@ -43,3 +60,15 @@ std::list< ObjectType* > ObjectTypeLayout::objects() const { return m_objects; } + +void ObjectTypeLayout::reparentChildren(ObjectType* parent) +{ + std::list<ObjectType*>::const_iterator it = m_objects.begin(); + for (; it != m_objects.end(); ++it) { + if ((*it)->isLayoutType()) + reinterpret_cast<ObjectTypeLayout*>(*it)->reparentChildren(parent); + else + (*it)->setParent(parent); + } +} + |