Nothing special, just a little bit of code cleanup in KItemListViewLayouter::doLayout().

Make use of QSizeF::transpose() and simplify the m_itemInfos usage.

REVIEW: 112535
This commit is contained in:
Emmanuel Pescosta 2013-09-05 17:03:04 +02:00
parent 7b862465d4
commit 1848854c6d

View 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& itemInfo = m_itemInfos[index];
itemInfo.rect = QRectF(x, y, itemSize.width(), requiredItemHeight);
itemInfo.column = column;
itemInfo.row = row;
m_itemInfos.append(itemInfo);
}
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