From 3957884bf2e44619a4ed35ba0ffead519988885b Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Mon, 8 Aug 2011 23:41:18 +0200 Subject: Improvements for selections, smooth scrolling, tooltips and info-panel --- src/kitemviews/kfileitemmodel.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/kitemviews/kfileitemmodel.cpp') diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index b191abab6..ddc56209b 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -403,8 +403,9 @@ void KFileItemModel::insertItems(const KFileItemList& items) KItemRangeList itemRanges; int targetIndex = 0; int sourceIndex = 0; - int insertedAtIndex = -1; - int insertedCount = 0; + int insertedAtIndex = -1; // Index for the current item-range + int insertedCount = 0; // Count for the current item-range + int previouslyInsertedCount = 0; // Sum of previously inserted items for all ranges while (sourceIndex < sortedItems.count()) { // Find target index from m_items to insert the current item // in a sorted order @@ -418,7 +419,8 @@ void KFileItemModel::insertItems(const KFileItemList& items) if (targetIndex - previousTargetIndex > 0 && insertedAtIndex >= 0) { itemRanges << KItemRange(insertedAtIndex, insertedCount); - insertedAtIndex = targetIndex; + previouslyInsertedCount += insertedCount; + insertedAtIndex = targetIndex - previouslyInsertedCount; insertedCount = 0; } @@ -431,6 +433,7 @@ void KFileItemModel::insertItems(const KFileItemList& items) if (insertedAtIndex < 0) { insertedAtIndex = targetIndex; + Q_ASSERT(previouslyInsertedCount == 0); } ++targetIndex; ++sourceIndex; -- cgit v1.3