From 631f97a6d98b426960ceee4cac7e6b3e56d741aa Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Mon, 24 Sep 2012 23:32:51 +0200 Subject: [PATCH] Revert part of 20b0cb68bf5cc1099fd6e61982817d9e2ae0130c That commit, which disregarded roles with empty text for the row number calculation in Icons View, caused the problem that icons might jump around while information was retrieved asynchronously because previously empty roles could get a non-empty value, and the corresponding items would need an additional row in the view. Thanks to Hrvoje Senjan for testing this feature in master and reporting this issue early, such that we could fix it quickly and prevent that other users suffer from this bug! CCBUG: 304752 --- src/kitemviews/kstandarditemlistwidget.cpp | 28 +++------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index 97c8a038b..72d10cf40 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -68,14 +68,6 @@ QSizeF KStandardItemListWidgetInformant::itemSizeHint(int index, const KItemList const qreal maxWidth = itemWidth - 2 * option.padding; QTextLine line; - int emptyRolesCount = 0; - foreach (const QByteArray& role, view->visibleRoles()) { - const QString text = roleText(role, values); - if (role != "text" && role != "rating" && text.isEmpty()) { - emptyRolesCount++; - } - } - // Calculate the number of lines required for wrapping the name QTextOption textOption(Qt::AlignHCenter); textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); @@ -92,7 +84,7 @@ QSizeF KStandardItemListWidgetInformant::itemSizeHint(int index, const KItemList layout.endLayout(); // Add one line for each additional information - textHeight += (additionalRolesCount - emptyRolesCount) * option.fontMetrics.lineSpacing(); + textHeight += additionalRolesCount * option.fontMetrics.lineSpacing(); const qreal maxTextHeight = option.maxTextSize.height(); if (maxTextHeight > 0 && textHeight > maxTextHeight) { @@ -988,17 +980,8 @@ void KStandardItemListWidget::updateIconsLayoutTextCache() qreal nameHeight = 0; QTextLine line; - int emptyRolesCount = 0; - foreach (const QByteArray& role, visibleRoles()) { - const QString text = roleText(role, values); - if (role != "text" && role != "rating" && text.isEmpty()) { - emptyRolesCount++; - } - } - const int additionalRolesCount = qMax(visibleRoles().count() - 1, 0); - const int maxNameLines = (option.maxTextSize.height() / int(lineSpacing)) - - (additionalRolesCount - emptyRolesCount); + const int maxNameLines = (option.maxTextSize.height() / int(lineSpacing)) - additionalRolesCount; QTextLayout layout(nameTextInfo->staticText.text(), m_customizedFont); layout.setTextOption(nameTextInfo->staticText.textOption()); @@ -1032,7 +1015,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache() nameTextInfo->staticText.setTextWidth(maxWidth); nameTextInfo->pos = QPointF(padding, widgetHeight - nameHeight - - (additionalRolesCount - emptyRolesCount)* lineSpacing - + additionalRolesCount * lineSpacing - padding); m_textRect = QRectF(padding + (maxWidth - nameWidth) / 2, nameTextInfo->pos.y(), @@ -1047,11 +1030,6 @@ void KStandardItemListWidget::updateIconsLayoutTextCache() } const QString text = roleText(role, values); - - if (role != "text" && role != "rating" && text.isEmpty()) { - continue; - } - TextInfo* textInfo = m_textInfo.value(role); textInfo->staticText.setText(text); -- 2.47.3