From 4cec9846288874a41dfb8227c719ff1276d07bcd Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Thu, 9 Dec 2010 11:23:33 +0100 Subject: [PATCH] add methods to get next and previous image/frame index --- annotationmodel.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/annotationmodel.py b/annotationmodel.py index 881f1d3..c77778c 100644 --- a/annotationmodel.py +++ b/annotationmodel.py @@ -378,6 +378,30 @@ class AnnotationModel(QAbstractItemModel): elif section == 1: return QVariant("Value") return QVariant() + def getNextIndex(self, index): + """returns index of next *image* or *frame*""" + if not index.isValid(): + return QModelIndex() + + assert index == self.imageIndex(index) + num_images = self.rowCount(index.parent()) + if index.row() < num_images - 1: + return index.sibling(index.row()+1, 0) + + return index + + def getPreviousIndex(self, index): + """returns index of previous *image* or *frame*""" + if not index.isValid(): + return QModelIndex() + + assert index == self.imageIndex(index) + if index.row() > 0: + return index.sibling(index.row()-1, 0) + + return index + + ####################################################################################### # proxy model #######################################################################################