diff options
| author | Emmanuel Pescosta <[email protected]> | 2013-06-20 19:16:22 +0200 |
|---|---|---|
| committer | Emmanuel Pescosta <[email protected]> | 2013-06-20 19:19:47 +0200 |
| commit | 0c0c86f22027c53a52d783eb2da7e6fe7ebfcd78 (patch) | |
| tree | 1bb8572fd3cb954c3a6911885577e453be68a553 | |
| parent | 015957c5a2fb0fed52e1101fb1f67f1f691e799f (diff) | |
Avoid a unnecessary resorting when items are changed, only resort the items when the sorting role value is changed.
BUG: 299565
FIXED-IN: 4.11
REVIEW: 111146
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 4b7e5eb19..7ea5e8018 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -846,12 +846,12 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& kDebug() << "Refreshing" << items.count() << "items"; #endif - m_groups.clear(); - // Get the indexes of all items that have been refreshed QList<int> indexes; indexes.reserve(items.count()); + QSet<QByteArray> changedRoles; + QListIterator<QPair<KFileItem, KFileItem> > it(items); while (it.hasNext()) { const QPair<KFileItem, KFileItem>& itemPair = it.next(); @@ -864,9 +864,14 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& // Keep old values as long as possible if they could not retrieved synchronously yet. // The update of the values will be done asynchronously by KFileItemModelRolesUpdater. QHashIterator<QByteArray, QVariant> it(retrieveData(newItem, m_itemData.at(index)->parent)); + QHash<QByteArray, QVariant>& values = m_itemData[index]->values; while (it.hasNext()) { it.next(); - m_itemData[index]->values.insert(it.key(), it.value()); + const QByteArray& role = it.key(); + if (values.value(role) != it.value()) { + values.insert(role, it.value()); + changedRoles.insert(role); + } } m_items.remove(oldItem.url()); @@ -907,9 +912,11 @@ void KFileItemModel::slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& itemRangeList.append(KItemRange(rangeIndex, rangeCount)); } - emit itemsChanged(itemRangeList, m_roles); + emit itemsChanged(itemRangeList, changedRoles); - resortAllItems(); + if (changedRoles.contains(sortRole())) { + resortAllItems(); + } } void KFileItemModel::slotClear() |
