]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Nothing special, just a little bit of code cleanup in KItemListViewLayouter::doLayout().
authorEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Thu, 5 Sep 2013 15:03:04 +0000 (17:03 +0200)
committerEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Thu, 5 Sep 2013 15:03:04 +0000 (17:03 +0200)
Make use of QSizeF::transpose() and simplify the m_itemInfos usage.

REVIEW: 112535

src/kitemviews/private/kitemlistviewlayouter.cpp

index da569b3dc6cf0ee97b8b119efd9aaba31ea4eb03..d6e78ae1a6beeb08298fe510e836d0fb3c4880b4 100644 (file)
@@ -375,12 +375,9 @@ void KItemListViewLayouter::doLayout()
         if (horizontalScrolling) {
             // Flip everything so that the layout logically can work like having
             // a vertical scrolling
-            itemSize.setWidth(m_itemSize.height());
-            itemSize.setHeight(m_itemSize.width());
-            itemMargin.setWidth(m_itemMargin.height());
-            itemMargin.setHeight(m_itemMargin.width());
-            size.setWidth(m_size.height());
-            size.setHeight(m_size.width());
+            itemSize.transpose();
+            itemMargin.transpose();
+            size.transpose();
 
             if (grouped) {
                 // In the horizontal scrolling case all groups are aligned
@@ -411,7 +408,7 @@ void KItemListViewLayouter::doLayout()
             ++rowCount;
         }
 
-        m_itemInfos.reserve(itemCount);
+        m_itemInfos.resize(itemCount);
 
         qreal y = m_headerHeight + itemMargin.height();
         int row = 0;
@@ -458,18 +455,10 @@ void KItemListViewLayouter::doLayout()
                     }
                 }
 
-                const QRectF bounds(x, y, itemSize.width(), requiredItemHeight);
-                if (index < m_itemInfos.count()) {
-                    m_itemInfos[index].rect = bounds;
-                    m_itemInfos[index].column = column;
-                    m_itemInfos[index].row = row;
-                } else {
-                    ItemInfo itemInfo;
-                    itemInfo.rect = bounds;
-                    itemInfo.column = column;
-                    itemInfo.row = row;
-                    m_itemInfos.append(itemInfo);
-                }
+                ItemInfo& itemInfo = m_itemInfos[index];
+                itemInfo.rect = QRectF(x, y, itemSize.width(), requiredItemHeight);
+                itemInfo.column = column;
+                itemInfo.row = row;
 
                 if (grouped && horizontalScrolling) {
                     // When grouping is enabled in the horizontal mode, the header alignment
@@ -505,10 +494,6 @@ void KItemListViewLayouter::doLayout()
             y += maxItemHeight + itemMargin.height();
             ++row;
         }
-        if (m_itemInfos.count() > itemCount) {
-            m_itemInfos.erase(m_itemInfos.begin() + itemCount,
-                              m_itemInfos.end());
-        }
 
         if (itemCount > 0) {
             // Calculate the maximum y-range of the last row for m_maximumScrollOffset