From 96e61b07a2be9bb7c3f02d61b6dce447357031d5 Mon Sep 17 00:00:00 2001 From: Mika Fischer Date: Wed, 15 Jun 2011 10:20:33 +0200 Subject: [PATCH] Don't emit dataChanged if a key is set to its current value --- sloth/annotations/model.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sloth/annotations/model.py b/sloth/annotations/model.py index 52ba844..e5bc429 100644 --- a/sloth/annotations/model.py +++ b/sloth/annotations/model.py @@ -285,15 +285,15 @@ class AnnotationModelItem(ModelItem): self.deleteChild(child) del self._annotation[key] else: - self._annotation[key] = ann[key] - if self.model() is not None: - for child in [e for e in self.children() if e.key() == key]: - self.model().dataChanged.emit(child.index(1), child.index(1)) + self.setValue(key, ann[key]) def setValue(self, key, value): - self._annotation[key] = value - if self.model() is not None: - self.model().dataChanged.emit(self.index(), self.index()) + if key not in self._annotation or self._annotation[key] != value: + self._annotation[key] = value + if self.model() is not None: + # TODO: This should only emit dataChanged for the value that + # was actually changed, not for the whole annotation + self.model().dataChanged.emit(self.index(), self.index()) def value(self, key): return self._annotation[key]