]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Revert part of 20b0cb68bf5cc1099fd6e61982817d9e2ae0130c
authorFrank Reininghaus <frank78ac@googlemail.com>
Mon, 24 Sep 2012 21:32:51 +0000 (23:32 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Mon, 24 Sep 2012 21:32:51 +0000 (23:32 +0200)
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

index 97c8a038b5324f683c0929d8f2a2324b0c6f32e5..72d10cf40e29059731e2338d2c8c699f54c21eaf 100644 (file)
@@ -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);