allow removing of selected items via del key

This commit is contained in:
Martin Baeuml
2010-12-09 16:10:15 +01:00
parent 2f460f4f86
commit 902993bdf5
2 changed files with 4 additions and 4 deletions
+1 -2
View File
@@ -364,14 +364,13 @@ class AnnotationModel(QAbstractItemModel):
return True
def removeAnnotation(self, annidx):
# TODO fix to work with ImageFileModelItem
annidx = QModelIndex(annidx) # explicitly convert from QPersistentModelIndex
item = self.itemFromIndex(annidx)
assert isinstance(item, AnnotationModelItem)
parent = item.parent_
parentidx = annidx.parent()
assert isinstance(parent, FrameModelItem)
assert isinstance(parent, FrameModelItem) or isinstance(parent, ImageFileModelItem)
pos = parent.rowOfChild(item)
self.beginRemoveRows(parentidx, pos, pos)
+3 -2
View File
@@ -195,6 +195,7 @@ class AnnotationScene(QGraphicsScene):
num_items = self.model_.rowCount(self.root_)
self.insertItems(0, num_items)
self.update()
def insertItems(self, first, last):
assert self.model_ is not None
@@ -303,8 +304,8 @@ class AnnotationScene(QGraphicsScene):
# selection mode
if event.key() == Qt.Key_Delete:
for item in self.selectedItems():
index = self.model_.mapFromSource(QModelIndex(item.index()))
self.model_.removeRow(index.row(), QModelIndex(index.parent()))
index = item.index()
index.model().removeAnnotation(index)
event.accept()
return