handle dirty changes for saving correctly

This commit is contained in:
Martin Baeuml
2010-12-10 15:17:46 +01:00
parent 0c34bee4e8
commit 1e077e31e1
2 changed files with 5 additions and 1 deletions
+3 -1
View File
@@ -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()
+2
View File
@@ -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)