mirror of
https://github.com/wassname/sloth.git
synced 2026-08-01 12:51:00 +08:00
handle dirty changes for saving correctly
This commit is contained in:
+3
-1
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user