Make the handling of the "maximum text lines" setting in Icons View more robust

Review Request #113871 - Created Nov. 15, 2013 and submitted

Frank Reininghaus
308022, 323841
If the user sets a maximum number of text lines in the settings, this number is translated into a maximum height in pixels using QFontMetrics::lineSpacing().
In In KStandardItemListWidgetInformant::itemSizeHint(int, const KItemListView*), this maximum height limits the size that is reserved for the item.

However, in KStandardItemListWidget::updateIconsLayoutTextCache(), the maximum height is translated back into a maximum number of lines, which limits the number of lines that are created using the QTextLayout.

This approach can lead to problems if the real height of the layouted text is 1 pixel more or less than QFontMetrics::lineSpacing() times "number of lines". According to Christoph's analysis, this is the reason for the blurry icons in bug 323841.

I propose to change this by not storing a "maximum height" inside the "maximum size" explicitly, but store a maximum number of lines and a maximum with (for Compact View) separately, and then use the number of lines also to calculate the required size in KStandardItemListWidgetInformant::itemSizeHint(int, const KItemListView*). This should make sure that the correct height is reserved for each item. It also makes the code a bit simpler IMHO.
I could not see any regressions. I was not able to reproduce the bug, so I cannot really verify if this patch really fixes it.

@Christoph: your comment in bug 323841 sounds like you could reproduce the problem? Could you have a look at this patch? Thanks in advance!
Christoph Feck
Emmanuel Pescosta
Commit Hook
This review has been submitted with commit 70cfa627e5a402f209c2eb1f3cfbc839d61740ad by Frank Reininghaus to branch master.
Frank Reininghaus
Review request changed

Status: Closed (submitted)