]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix group-header clipping in compact mode
authorPeter Penz <peter.penz19@gmail.com>
Tue, 27 Dec 2011 08:09:57 +0000 (09:09 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 27 Dec 2011 08:10:27 +0000 (09:10 +0100)
src/kitemviews/kitemlistviewlayouter.cpp
src/kitemviews/kitemlistviewlayouter_p.h

index b486a390babc89c588d92a71e8450bc3218707a9..60822adc7f1ad96301fe89206ece8ee6ced1997c 100644 (file)
@@ -234,7 +234,7 @@ QRectF KItemListViewLayouter::groupHeaderRect(int index) const
         pos.rx() = 0;
         size = QSizeF(m_size.width(), m_groupHeaderHeight);
     } else {
-        size = QSizeF(firstItemRect.width(), m_groupHeaderHeight);
+        size = QSizeF(minimumGroupHeaderWidth(), m_groupHeaderHeight);
     }
     return QRectF(pos, size);
 }
@@ -293,10 +293,7 @@ void KItemListViewLayouter::doLayout()
             // Apply the unused width equally to each column
             const qreal unusedWidth = size.width() - m_columnCount * m_columnWidth;
             if (unusedWidth > 0) {
-                // [Comment #1] A cast to int is done on purpose to prevent rounding issues when
-                // drawing pixmaps and drawing text or other graphic primitives: Qt uses a different
-                // rastering algorithm for the upper/left of pixmaps
-                const qreal columnInc = int(unusedWidth / (m_columnCount + 1));
+                const qreal columnInc = unusedWidth / (m_columnCount + 1);
                 m_columnWidth += columnInc;
                 m_xPosInc += columnInc;
             }
@@ -367,9 +364,9 @@ void KItemListViewLayouter::doLayout()
                     // (in average a character requires the halve width of the font height).
                     //
                     // TODO: Let the group headers provide a minimum width and respect this width here
-                    const qreal minimumGroupHeaderWidth = int(m_groupHeaderHeight * 15 / 2); // See [Comment #1]
-                    if (requiredItemHeight < minimumGroupHeaderWidth) {
-                        requiredItemHeight = minimumGroupHeaderWidth;
+                    const qreal headerWidth = minimumGroupHeaderWidth();
+                    if (requiredItemHeight < headerWidth) {
+                        requiredItemHeight = headerWidth;
                     }
                 }
 
@@ -511,4 +508,9 @@ bool KItemListViewLayouter::createGroupHeaders()
     return true;
 }
 
+qreal KItemListViewLayouter::minimumGroupHeaderWidth() const
+{
+    return m_groupHeaderHeight * 15 / 2;
+}
+
 #include "kitemlistviewlayouter_p.moc"
index 3d2f1090639a03b979bb1e0353ea34f56f55ece4..dec99d0542a1a4ea82c926dd09dc845aab169070 100644 (file)
@@ -120,6 +120,16 @@ private:
     void updateVisibleIndexes();
     bool createGroupHeaders();
 
+    /**
+     * @return Minimum width of group headers when grouping is enabled in the horizontal
+     *         alignment mode. The header alignment is done like this:
+     *         Header-1 Header-2 Header-3
+     *         Item 1   Item 4   Item 7
+     *         Item 2   Item 5   Item 8
+     *         Item 3   Item 6   Item 9
+     */
+    qreal minimumGroupHeaderWidth() const;
+
 private:
     bool m_dirty;
     bool m_visibleIndexesDirty;