The code below always adds the visible range, up to 5 pages before and
after the visible range (each capped to ResolveAllItemsLimit/2) and
the very first and last page (each up to m_maximumVisibleItems).
Use this number to avoid growing the list later.
const int count = m_model->count();
QList<int> result;
- result.reserve(ResolveAllItemsLimit);
+ result.reserve(qMin(count, (m_lastVisibleIndex - m_firstVisibleIndex + 1) +
+ ResolveAllItemsLimit +
+ (2 * m_maximumVisibleItems)));
// Add visible items.
for (int i = m_firstVisibleIndex; i <= m_lastVisibleIndex; ++i) {