┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kitemviews/kstandarditemmodel.cpp16
-rw-r--r--src/panels/places/placesitemmodel.cpp6
2 files changed, 17 insertions, 5 deletions
diff --git a/src/kitemviews/kstandarditemmodel.cpp b/src/kitemviews/kstandarditemmodel.cpp
index e3d40038d..11d72a4ac 100644
--- a/src/kitemviews/kstandarditemmodel.cpp
+++ b/src/kitemviews/kstandarditemmodel.cpp
@@ -42,6 +42,13 @@ void KStandardItemModel::insertItem(int index, KStandardItem* item)
item->m_model = this;
m_items.insert(index, item);
m_indexesForItems.insert(item, index);
+
+ // Inserting an item requires to update the indexes
+ // afterwards from m_indexesForItems.
+ for (int i = index + 1; i < m_items.count(); ++i) {
+ m_indexesForItems.insert(m_items[i], i);
+ }
+
// TODO: no hierarchical items are handled yet
onItemInserted(index);
@@ -94,12 +101,19 @@ void KStandardItemModel::removeItem(int index)
m_indexesForItems.remove(item);
m_items.removeAt(index);
+ // Removing an item requires to update the indexes
+ // afterwards from m_indexesForItems.
+ for (int i = index; i < m_items.count(); ++i) {
+ m_indexesForItems.insert(m_items[i], i);
+ }
+
onItemRemoved(index, item);
- emit itemsRemoved(KItemRangeList() << KItemRange(index, 1));
delete item;
item = 0;
+ emit itemsRemoved(KItemRangeList() << KItemRange(index, 1));
+
// TODO: no hierarchical items are handled yet
}
}
diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp
index 21cbf9ed3..14ec54be8 100644
--- a/src/panels/places/placesitemmodel.cpp
+++ b/src/panels/places/placesitemmodel.cpp
@@ -395,7 +395,7 @@ void PlacesItemModel::onItemChanged(int index, const QSet<QByteArray>& changedRo
{
const PlacesItem* changedItem = placesItem(index);
if (changedItem) {
- // Take care to apply the PlacesItemModel-order of the inserted item
+ // Take care to apply the PlacesItemModel-order of the changed item
// also to the bookmark-manager.
const KBookmark insertedBookmark = changedItem->bookmark();
@@ -409,9 +409,7 @@ void PlacesItemModel::onItemChanged(int index, const QSet<QByteArray>& changedRo
}
if (changedRoles.contains("isHidden")) {
- const PlacesItem* shownItem = placesItem(index);
- Q_ASSERT(shownItem);
- if (!m_hiddenItemsShown && shownItem->isHidden()) {
+ if (!m_hiddenItemsShown && changedItem->isHidden()) {
m_hiddenItemToRemove = index;
QTimer::singleShot(0, this, SLOT(hideItem()));
}