From d39896815e50b0d93a8fdb65819df1bf349d7d19 Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Wed, 8 Dec 2010 16:57:33 +0100 Subject: [PATCH] correctly find image index --- annotationmodel.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/annotationmodel.py b/annotationmodel.py index 52e6500..634f1a1 100644 --- a/annotationmodel.py +++ b/annotationmodel.py @@ -209,15 +209,19 @@ class AnnotationModel(QAbstractItemModel): child_item = parent_item.children()[row] return self.createIndex(row, column, child_item) - def fileIndex(self, index): - """return index that points to the (maybe parental) file object""" + def imageIndex(self, index): + """return index that points to the (maybe parental) image/frame object""" if not index.isValid(): return QModelIndex() + index = QModelIndex(index) # explicitly convert from QPersistentModelIndex item = self.itemFromIndex(index) - if isinstance(item, FileAnnotationModelItem): + if isinstance(item, ImageFileModelItem) or \ + isinstance(item, FrameModelItem): return index - return self.fileIndex(index.parent()) + + # try with next hierarchy up + return self.imageIndex(index.parent()) def data(self, index, role): if not index.isValid():