Ejemplo n.º 1
0
 def moveCursor(self, action, modifiers):
     orig = self.currentIndex()
     index = QTableView.moveCursor(self, action, modifiers)
     if action == QTableView.MovePageDown:
         moved = index.row() - orig.row()
         try:
             rows = self.row_at_bottom() - self.row_at_top()
         except TypeError:
             rows = moved
         if moved > rows:
             index = self.model().index(orig.row() + rows, index.column())
     elif action == QTableView.MovePageUp:
         moved = orig.row() - index.row()
         try:
             rows = self.row_at_bottom() - self.row_at_top()
         except TypeError:
             rows = moved
         if moved > rows:
             index = self.model().index(orig.row() - rows, index.column())
     elif action == QTableView.MoveHome and modifiers & Qt.ControlModifier:
         return self.model().index(0, orig.column())
     elif action == QTableView.MoveEnd and modifiers & Qt.ControlModifier:
         return self.model().index(self.model().rowCount(QModelIndex()) - 1,
                                   orig.column())
     return index
Ejemplo n.º 2
0
 def moveCursor(self, action, modifiers):
     orig = self.currentIndex()
     index = QTableView.moveCursor(self, action, modifiers)
     if action == QTableView.MovePageDown:
         moved = index.row() - orig.row()
         try:
             rows = self.row_at_bottom() - self.row_at_top()
         except TypeError:
             rows = moved
         if moved > rows:
             index = self.model().index(orig.row() + rows, index.column())
     elif action == QTableView.MovePageUp:
         moved = orig.row() - index.row()
         try:
             rows = self.row_at_bottom() - self.row_at_top()
         except TypeError:
             rows = moved
         if moved > rows:
             index = self.model().index(orig.row() - rows, index.column())
     elif action == QTableView.MoveHome and modifiers & Qt.ControlModifier:
         return self.model().index(0, orig.column())
     elif action == QTableView.MoveEnd and modifiers & Qt.ControlModifier:
         return self.model().index(self.model().rowCount(QModelIndex()) - 1, orig.column())
     return index