beginRemoveRows / endRemoveRows with TreeView

Added by adam s over 4 years ago

Hi,

I just started working with Wt, and I thing it's really cool lib (kudos guys). I created my first WTreeView with model, and I'm trying to implement inserts and deletes operations. I would expect that i should do something like:

class MyTreeModel : public Wt::WAbstractItemModel {
MyDataToInternalIdMap map_;

index/parent/rowCount use map_ to create WModelIndex
void OnAdd(newNode, row
{
beginInsertRows().emit(row);
map_.insert(newNode);
endInsertRows().emit();
}
void OnRemove(node) {
row = map_.find(node);
beginRemoveRows().emit(row);
map_.remove(node);
endRemoveRows().emit();
}
}

But OnRemove is not working as I would expect - it looks like we are deleting and shifting model indexes in WTreeView::modelRowsAboutToBeRemoved, but since my map structure is not yet updated and return 'old' indexes. Did I misunderstood something?