mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Keep the "item size hints" of moved items
It's quite expensive to re-calculate them, so we should better just move them to the correct position, rather than throwing them away. REVIEW: 111399
This commit is contained in:
parent
786cea0076
commit
837be34333
|
@ -1165,7 +1165,7 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
|
|||
|
||||
void KItemListView::slotItemsMoved(const KItemRange& itemRange, const QList<int>& movedToIndexes)
|
||||
{
|
||||
m_sizeHintResolver->itemsMoved(itemRange.index, itemRange.count);
|
||||
m_sizeHintResolver->itemsMoved(itemRange, movedToIndexes);
|
||||
m_layouter->markAsDirty();
|
||||
|
||||
if (m_controller) {
|
||||
|
|
|
@ -114,13 +114,17 @@ void KItemListSizeHintResolver::itemsRemoved(const KItemRangeList& itemRanges)
|
|||
}
|
||||
}
|
||||
|
||||
void KItemListSizeHintResolver::itemsMoved(int index, int count)
|
||||
void KItemListSizeHintResolver::itemsMoved(const KItemRange& range, const QList<int>& movedToIndexes)
|
||||
{
|
||||
while (count) {
|
||||
m_sizeHintCache[index] = QSizeF();
|
||||
++index;
|
||||
--count;
|
||||
QVector<QSizeF> newSizeHintCache(m_sizeHintCache);
|
||||
|
||||
const int movedRangeEnd = range.index + range.count;
|
||||
for (int i = range.index; i < movedRangeEnd; ++i) {
|
||||
const int newIndex = movedToIndexes.at(i);
|
||||
newSizeHintCache[newIndex] = m_sizeHintCache.at(i);
|
||||
}
|
||||
|
||||
m_sizeHintCache = newSizeHintCache;
|
||||
}
|
||||
|
||||
void KItemListSizeHintResolver::itemsChanged(int index, int count, const QSet<QByteArray>& roles)
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
void itemsInserted(const KItemRangeList& itemRanges);
|
||||
void itemsRemoved(const KItemRangeList& itemRanges);
|
||||
void itemsMoved(int index, int count);
|
||||
void itemsMoved(const KItemRange& range, const QList<int>& movedToIndexes);
|
||||
void itemsChanged(int index, int count, const QSet<QByteArray>& roles);
|
||||
|
||||
void clearCache();
|
||||
|
|
Loading…
Reference in a new issue