mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'kovidgoyal:master' into master
This commit is contained in:
commit
2d667819f1
@ -1319,19 +1319,35 @@ class BooksView(QTableView): # {{{
|
|||||||
vertical_offset = vh.offset()
|
vertical_offset = vh.offset()
|
||||||
vertical_position = vh.sectionPosition(row)
|
vertical_position = vh.sectionPosition(row)
|
||||||
cell_height = vh.sectionSize(row)
|
cell_height = vh.sectionSize(row)
|
||||||
|
|
||||||
pos = 'center'
|
pos = 'center'
|
||||||
if vertical_position - vertical_offset < 0 or cell_height > viewport_height:
|
if vertical_position - vertical_offset < 0 or cell_height > viewport_height:
|
||||||
pos = 'top'
|
pos = 'top'
|
||||||
elif vertical_position - vertical_offset + cell_height > viewport_height:
|
elif vertical_position - vertical_offset + cell_height > viewport_height:
|
||||||
pos = 'bottom'
|
pos = 'bottom'
|
||||||
vsb = self.verticalScrollBar()
|
vsb = self.verticalScrollBar()
|
||||||
if pos == 'top':
|
|
||||||
vsb.setValue(vertical_position)
|
if self.verticalScrollMode() == QAbstractItemView.ScrollMode.ScrollPerPixel:
|
||||||
elif pos == 'bottom':
|
if pos == 'top':
|
||||||
vsb.setValue(vertical_position - viewport_height + cell_height)
|
vsb.setValue(vertical_position)
|
||||||
|
elif pos == 'bottom':
|
||||||
|
vsb.setValue(vertical_position - viewport_height + cell_height)
|
||||||
|
else:
|
||||||
|
vsb.setValue(vertical_position - ((viewport_height - cell_height) // 2))
|
||||||
else:
|
else:
|
||||||
vsb.setValue(vertical_position - ((viewport_height - cell_height) // 2))
|
vertical_index = vh.visualIndex(row)
|
||||||
|
if pos in ('bottom', 'center'):
|
||||||
|
h = (viewport_height // 2) if pos == 'center' else viewport_height
|
||||||
|
y = cell_height
|
||||||
|
while vertical_index > 0:
|
||||||
|
y += vh.sectionSize(vh.logicalIndex(vertical_index -1))
|
||||||
|
if y > h:
|
||||||
|
break
|
||||||
|
vertical_index -= 1
|
||||||
|
if vh.sectionsHidden():
|
||||||
|
for s in range(vertical_index - 1, -1, -1):
|
||||||
|
if vh.isSectionHidden(vh.logicalIndex(s)):
|
||||||
|
vertical_index -= 1
|
||||||
|
vsb.setValue(vertical_index)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_book(self):
|
def current_book(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user