mirror of
https://github.com/wassname/sloth.git
synced 2026-07-05 13:45:15 +08:00
add methods to get next and previous image/frame index
This commit is contained in:
@@ -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
|
||||
#######################################################################################
|
||||
|
||||
Reference in New Issue
Block a user