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);
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
}
}
{
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();
}
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()));
}