@@ -2028,22 +2028,19 @@ void GameListGridView::setZoomPct(int int_scale)
20282028
20292029void GameListGridView::updateLayout ()
20302030{
2031- const QScrollBar* const vertical_scrollbar = verticalScrollBar ();
2032- const int scrollbar_width = vertical_scrollbar->isVisible () ? vertical_scrollbar->width () : 0 ;
20332031 const int icon_width = m_model->getCoverArtSize ();
20342032 const int item_spacing = m_model->getCoverArtSpacing ();
2035- const int item_margin = style ()->pixelMetric (QStyle::PM_FocusFrameHMargin, nullptr , this );
2036-
2037- // Split margin+spacing evenly across both sides of each item.
2038- // I hate this +2. Not sure what's not being accounted for, but without it the calculation is off by 2 pixels...
2039- const int item_width = icon_width + item_margin + item_spacing + 2 ;
2033+ const int item_margin = style ()->pixelMetric (QStyle::PM_DefaultFrameWidth, nullptr , this ) * 2 ;
2034+ const int item_width = icon_width + item_margin + item_spacing;
20402035
20412036 // one line of text
20422037 const int item_height = item_width + (m_model->getShowCoverTitles () ? fontMetrics ().height () : 0 );
20432038
2044- const int available_width = width () - scrollbar_width;
2045- const int num_columns = available_width / item_width;
2046- const int num_rows = (height () + (item_height - 1 )) / item_height;
2039+ // the -1 here seems to be necessary otherwise we calculate too many columns..
2040+ // can't see where in qlistview.cpp it's coming from though.
2041+ const int available_width = viewport ()->width ();
2042+ const int num_columns = (available_width - 1 ) / item_width;
2043+ const int num_rows = (viewport ()->height () + (item_height - 1 )) / item_height;
20472044 const int margin = (available_width - (num_columns * item_width)) / 2 ;
20482045
20492046 setGridSize (QSize (item_width, item_height));
0 commit comments