Make items change color according to unconfirmed property

This commit is contained in:
Mika Fischer
2011-06-30 14:11:22 +02:00
parent 5c62ef4ad3
commit 4b7aaf2356
+16 -6
View File
@@ -22,20 +22,30 @@ class BaseItem(QAbstractGraphicsShapeItem):
QGraphicsItem.ItemIsMovable | \
QGraphicsItem.ItemSendsGeometryChanges | \
QGraphicsItem.ItemSendsScenePositionChanges)
if model_item is not None:
c = model_item.getColor()
if c is not None:
self.setColor(c)
else:
self.setColor(Qt.yellow)
self._model_item = model_item
if self._model_item is not None:
self._model_item.model().dataChanged.connect(self.onDataChanged)
self.changeColor()
# initialize members
self.text_ = ""
self.text_bg_brush_ = None
self.auto_text_keys_ = []
def changeColor(self):
if self._model_item is not None:
c = self._model_item.getColor()
if c is not None:
self.setColor(c)
return
self.setColor(Qt.yellow)
def onDataChanged(self, indexFrom, indexTo):
if indexFrom == self._model_item.index():
self.changeColor()
def modelItem(self):
"""
Returns the model item of this items.