Ok.
Now instead of insertAfter(...), I'm trying this:
model->insertRows(itemRef->row(), 1, currentTreeIdx.parent());
model->insertRows(itemRef->row(), 1, currentTreeIdx.parent());
To copy to clipboard, switch view to plain text mode
and the function being called is:
bool DomModel
::insertRows(int position,
int rows,
const QModelIndex &parent
){
//DomItem *parentItem = getItem(parent);
DomItem *parentItem = static_cast<DomItem*>(parent.internalPointer()); // reference item
bool success;
//emit dataChanged(parent, parent);
beginInsertRows(parent, position, position + rows - 1);
success = parentItem->insertChildren(position, rows, 4);
endInsertRows();
return success;
}
bool DomModel::insertRows(int position, int rows, const QModelIndex &parent){
//DomItem *parentItem = getItem(parent);
DomItem *parentItem = static_cast<DomItem*>(parent.internalPointer()); // reference item
bool success;
//emit dataChanged(parent, parent);
beginInsertRows(parent, position, position + rows - 1);
success = parentItem->insertChildren(position, rows, 4);
endInsertRows();
return success;
}
To copy to clipboard, switch view to plain text mode
This one should create a row. It does create an invisible parent that I can click on to expand. But this parent now contains a copy of the entire model...
Added after 13 minutes:
Basically, to add to this, what I'm trying to achieve is combine "Editable Tree Model" and "Simple Dom Model" examples. So I'm having the latter as a base and I've copied the edit functions over there, changed the flags, setData, etc.
Bookmarks