mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Make ncols calculation a little more robust
This commit is contained in:
parent
9537bfeff2
commit
d0cf78b717
@ -987,9 +987,9 @@ class GridView(QListView):
|
|||||||
def number_of_columns(self):
|
def number_of_columns(self):
|
||||||
# Number of columns currently visible in the grid
|
# Number of columns currently visible in the grid
|
||||||
if self._ncols is None:
|
if self._ncols is None:
|
||||||
step = self.spacing()
|
step = max(10, self.spacing())
|
||||||
for y in range(step, 300, step):
|
for y in range(step, 500, step):
|
||||||
for x in range(step, 300, step):
|
for x in range(step, 500, step):
|
||||||
i = self.indexAt(QPoint(x, y))
|
i = self.indexAt(QPoint(x, y))
|
||||||
if i.isValid():
|
if i.isValid():
|
||||||
for x in range(self.viewport().width() - step, self.viewport().width() - 300, -step):
|
for x in range(self.viewport().width() - step, self.viewport().width() - 300, -step):
|
||||||
@ -997,7 +997,6 @@ class GridView(QListView):
|
|||||||
if j.isValid():
|
if j.isValid():
|
||||||
self._ncols = j.row() - i.row() + 1
|
self._ncols = j.row() - i.row() + 1
|
||||||
return self._ncols
|
return self._ncols
|
||||||
break
|
|
||||||
return self._ncols
|
return self._ncols
|
||||||
|
|
||||||
def keyPressEvent(self, ev):
|
def keyPressEvent(self, ev):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user