mirror of
https://github.com/wassname/sloth.git
synced 2026-07-10 00:18:30 +08:00
Fix going to next/previous image
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user