┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemmodel.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2011-10-03 16:12:18 +0200
committerFrank Reininghaus <[email protected]>2011-10-03 16:15:31 +0200
commitc94e1e1cd6753b2d8f4ebb942b744be1a62c887d (patch)
tree8b58164be6401a95a2d48b9ff88eaacc5ed04d39 /src/kitemviews/kfileitemmodel.cpp
parentaf3c3a43281db7d7b6a3045c94836a746b031f51 (diff)
Keep current item and selection when resorting, part 2
This commit adds the missing pieces to KItemListView and makes KFileItemModel::resortAllItems() only emit the itemsMoved() signal.
Diffstat (limited to 'src/kitemviews/kfileitemmodel.cpp')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index 0d6f60336..ddb89533c 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -733,26 +733,26 @@ void KFileItemModel::resortAllItems()
}
const KFileItemList oldSortedItems = m_sortedItems;
+ const QHash<KUrl, int> oldItems = m_items;
+ const QList<QHash<QByteArray, QVariant> > oldData = m_data;
- KFileItemList sortedItems = m_sortedItems;
- m_sortedItems.clear();
m_items.clear();
m_data.clear();
- emit itemsRemoved(KItemRangeList() << KItemRange(0, itemCount));
- sort(sortedItems.begin(), sortedItems.end());
+ sort(m_sortedItems.begin(), m_sortedItems.end());
int index = 0;
- foreach (const KFileItem& item, sortedItems) {
- m_sortedItems.append(item);
+ foreach (const KFileItem& item, m_sortedItems) {
m_items.insert(item.url(), index);
- m_data.append(retrieveData(item));
+
+ const int oldItemIndex = oldItems.value(item.url());
+ m_data.append(oldData.at(oldItemIndex));
++index;
}
bool emitItemsMoved = false;
QList<int> movedToIndexes;
- movedToIndexes.reserve(sortedItems.count());
+ movedToIndexes.reserve(m_sortedItems.count());
for (int i = 0; i < itemCount; i++) {
const int newIndex = m_items.value(oldSortedItems.at(i).url());
movedToIndexes.append(newIndex);
@@ -762,12 +762,8 @@ void KFileItemModel::resortAllItems()
}
if (emitItemsMoved) {
- // TODO:
- // * Implement KItemListView::slotItemsMoved() (which should call KItemListSelectionManager::itemsMoved())
- // * Do not emit itemsRemoved()/itemsInserted() here.
emit itemsMoved(KItemRange(0, itemCount), movedToIndexes);
}
- emit itemsInserted(KItemRangeList() << KItemRange(0, itemCount));
}
void KFileItemModel::removeExpandedItems()