From 1e077e31e1628eb44030130725c16761f92aa42f Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Fri, 10 Dec 2010 15:17:46 +0100 Subject: [PATCH] handle dirty changes for saving correctly --- annotationmodel.py | 4 +++- labeltool.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/annotationmodel.py b/annotationmodel.py index 88a3f8d..05f4086 100644 --- a/annotationmodel.py +++ b/annotationmodel.py @@ -315,6 +315,8 @@ class AnnotationModel(QAbstractItemModel): if role == DataRole: item = self.itemFromIndex(index) if item.setData(index, value, role): + self.setDirty(True) + # TODO check why this is needed (should be done by item.setData() anyway) self.emit(SIGNAL("dataChanged(QModelIndex,QModelIndex)"), index, index.sibling(index.row(), 1)) return True @@ -382,7 +384,7 @@ class AnnotationModel(QAbstractItemModel): def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: - if section == 0: return QVariant("File/Type") + if section == 0: return QVariant("File/Type/Key") elif section == 1: return QVariant("Value") return QVariant() diff --git a/labeltool.py b/labeltool.py index 64cbd6d..0b623ca 100755 --- a/labeltool.py +++ b/labeltool.py @@ -53,6 +53,7 @@ class MainWindow(QMainWindow): self.connect(self.buttonarea, SIGNAL("stateChanged(state)"), self.scene.setMode) self.treeview = AnnotationTreeView() + self.treeview.setAlternatingRowColors(True) self.ui.dockInformation.setWidget(self.treeview) ## create action group for tools @@ -123,6 +124,7 @@ class MainWindow(QMainWindow): msg = "Successfully saved %s (%d files, %d annotations)" % \ (fname, self.anno_container.numFiles(), self.anno_container.numAnnotations()) success = True + self.model_.setDirty(False) except Exception as e: msg = "Error: Saving failed (%s)" % str(e)