Do not layout hidden widgets

This commit is contained in:
Kovid Goyal 2016-12-19 13:49:04 +05:30
parent 81ea515070
commit a11488322b

View File

@ -381,6 +381,8 @@ class FlowLayout(QLayout): # {{{
gmap = {} gmap = {}
for item in self.items: for item in self.items:
isz, wid = item.sizeHint(), item.widget() isz, wid = item.sizeHint(), item.widget()
if isz.isEmpty() or (wid is not None and not wid.isVisible()):
continue
hs, vs = layout_spacing(wid), layout_spacing(wid, False) hs, vs = layout_spacing(wid), layout_spacing(wid, False)
next_x = x + isz.width() + hs next_x = x + isz.width() + hs
@ -402,10 +404,10 @@ class FlowLayout(QLayout): # {{{
if apply_geometry: if apply_geometry:
for line_height, items in lines: for line_height, items in lines:
for item, item_height in items: for item, item_height in items:
x, y, isz = gmap[item] x, wy, isz = gmap[item]
if item_height < line_height: if item_height < line_height:
y += (line_height - item_height) // 2 wy += (line_height - item_height) // 2
item.setGeometry(QRect(QPoint(x, y), isz)) item.setGeometry(QRect(QPoint(x, wy), isz))
return y + line_height - rect.y() + bottom return y + line_height - rect.y() + bottom