mirror of
https://github.com/wassname/sloth.git
synced 2026-07-19 11:28:06 +08:00
Make items change color according to unconfirmed property
This commit is contained in:
+16
-6
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user