- m_firstVisibleIndex = int(m_scrollOffset / minimumHeight) * m_columnCount;
-
- // 2. Decrease the index by checking the real row heights
- int prevRowIndex = m_firstVisibleIndex - m_columnCount;
- while (prevRowIndex > maxIndex) {
- prevRowIndex -= m_columnCount;
- }
-
- const qreal top = m_scrollOffset + m_headerHeight;
- while (prevRowIndex >= 0 && m_itemBoundingRects[prevRowIndex].bottom() >= top) {
- m_firstVisibleIndex = prevRowIndex;
- prevRowIndex -= m_columnCount;
- }
- m_firstVisibleIndex = qBound(0, m_firstVisibleIndex, maxIndex);
-
- // Calculate the last visible index
- const int visibleHeight = horizontalScrolling ? m_size.width() : m_size.height();
- const qreal bottom = m_scrollOffset + visibleHeight;
- m_lastVisibleIndex = m_firstVisibleIndex; // first visible row, first column
- int nextRowIndex = m_lastVisibleIndex + m_columnCount;
- while (nextRowIndex <= maxIndex && m_itemBoundingRects[nextRowIndex].y() <= bottom) {
- m_lastVisibleIndex = nextRowIndex;
- nextRowIndex += m_columnCount;
- }
- m_lastVisibleIndex += m_columnCount - 1; // move it to the last column
- m_lastVisibleIndex = qBound(0, m_lastVisibleIndex, maxIndex);
-
- m_visibleIndexesDirty = false;
-}
-
-void KItemListViewLayouter::updateGroupedVisibleIndexes()
-{
- if (!m_visibleIndexesDirty) {
- return;
- }
-
- Q_ASSERT(m_grouped);
- Q_ASSERT(!m_dirty);
-
- if (m_model->count() <= 0) {
- m_firstVisibleIndex = -1;
- m_lastVisibleIndex = -1;
- m_visibleIndexesDirty = false;
- return;
- }