Fix going to next/previous image

This commit is contained in:
Mika Fischer
2011-06-14 10:24:16 +02:00
parent d463adaece
commit f7a38da383
2 changed files with 22 additions and 6 deletions
+16
View File
@@ -34,6 +34,22 @@ class ModelItem(QObject):
assert self.parent_ is None
self.parent_ = parent
def getPreviousSibling(self):
if self.parent_ is not None:
c = self.parent().children()
row = c.index(self)
if row > 0:
return c[row-1]
return None
def getNextSibling(self):
if self.parent_ is not None:
c = self.parent().children()
row = c.index(self)
if row < len(c) - 2:
return c[row+1]
return None
def setIndex(self, index):
assert self._pindex is None
self._pindex = QPersistentModelIndex(index)
+6 -6
View File
@@ -139,15 +139,15 @@ class LabelTool(QObject):
def gotoNext(self):
# TODO move this to the scene
if self._model is not None and self.current_index_ is not None:
next_index = self._model.getNextIndex(self.current_index_)
self.setCurrentIndex(next_index)
if self._model is not None and self._current_image is not None:
next_image = self._current_image.getNextSibling()
self.setCurrentImage(next_image)
def gotoPrevious(self):
# TODO move this to the scene
if self._model is not None and self.current_index_ is not None:
prev_index = self._model.getPreviousIndex(self.current_index_)
self.setCurrentIndex(prev_index)
if self._model is not None and self._current_image is not None:
prev_image = self._current_image.getPreviousSibling()
self.setCurrentImage(prev_image)
def updateModified(self):
"""update all GUI elements which depend on the state of the model,