mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 09:50:12 +00:00
[FileItemRolesUpdater] Fix calculation of requested indexes
In case the last and/or first page (a page being n=m_maximumVisibleItems items) overlapped the already inserted items, one item for each range would be inserted a second time, e.g. for the first page and last page: `beginExtendedVisibleRange == 0` => `endFirstPage := 0` => `0 <= 0` is inserted again. `count == 100; endExtendedVisibleRange == 99; m_maximumVisibleItems == 20` => `beginLastPage := 99` => `99 < 100` is inserted again.
This commit is contained in:
parent
b351afb9e1
commit
b4676b71c6
|
@ -1185,14 +1185,14 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
|
|||
}
|
||||
|
||||
// Add items on the last page.
|
||||
const int beginLastPage = qMax(qMin(endExtendedVisibleRange + 1, count - 1), count - m_maximumVisibleItems);
|
||||
const int beginLastPage = qMax(endExtendedVisibleRange + 1, count - m_maximumVisibleItems);
|
||||
for (int i = beginLastPage; i < count; ++i) {
|
||||
result.append(i);
|
||||
}
|
||||
|
||||
// Add items on the first page.
|
||||
const int endFirstPage = qMin(qMax(beginExtendedVisibleRange - 1, 0), m_maximumVisibleItems);
|
||||
for (int i = 0; i <= endFirstPage; ++i) {
|
||||
const int endFirstPage = qMin(beginExtendedVisibleRange, m_maximumVisibleItems);
|
||||
for (int i = 0; i < endFirstPage; ++i) {
|
||||
result.append(i);
|
||||
}
|
||||
|
||||
|
@ -1204,7 +1204,7 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
|
|||
--remainingItems;
|
||||
}
|
||||
|
||||
for (int i = beginExtendedVisibleRange - 1; i > endFirstPage && remainingItems > 0; --i) {
|
||||
for (int i = beginExtendedVisibleRange - 1; i >= endFirstPage && remainingItems > 0; --i) {
|
||||
result.append(i);
|
||||
--remainingItems;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue