From c0fd6536df81e8e9da2df31a0481c047cfd3466d Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Wed, 14 Sep 2011 16:07:52 +0200 Subject: [PATCH] add GroupItem A group item delegates displaying and modification to the different basic items. --- sloth/items/items.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sloth/items/items.py b/sloth/items/items.py index 6ec58b5..5dae29a 100644 --- a/sloth/items/items.py +++ b/sloth/items/items.py @@ -334,6 +334,29 @@ class RectItem(BaseItem): self.updateModel() event.accept() +class GroupItem(BaseItem): + items = [] + + def __init__(self, model_item=None, prefix="", parent=None): + self._children = [] + BaseItem.__init__(self, model_item, prefix, parent) + self.setFlag(QGraphicsItem.ItemIsMovable, False) + + self.createChildren() + + def createChildren(self): + for callable_, prefix in self.items: + child = callable_(self._model_item, prefix, self) + self._children.append(child) + + def setColor(self, *args, **kwargs): + for c in self._children: + c.setColor(*args, **kwargs) + BaseItem.setColor(self, *args, **kwargs) + + def boundingRect(self): + return self.childrenBoundingRect() + class ControlItem(QGraphicsItem): def __init__(self, parent=None):