This is my NonMerge method:
void TxTableModel
::parseXml(const QByteArray &xml
) {
TxSaxTableHandler handler(&m_Data, false);
inputSource.setData(xml);
reader.setContentHandler(&handler);
reader.setErrorHandler(&handler);
QModelIndexList selectedList = parent->selectionModel()->selectedRows();
beginResetModel();
m_Data.clearData();
reader.parse(inputSource);
endResetModel();
if (scrollBottomIndex.row() == -1) {
parent->scrollToBottom();
} else {
parent->scrollTo(scrollTopIndex);
}
if (selectedList.count() > 0 && (selectedList.at(0).row() >= scrollTopIndex.row()) && (scrollBottomIndex.row() == -1 || scrollBottomIndex.row() > selectedList.at(0).row() )) {
parent->selectRow(selectedList.at(0).row());
}
}
void TxTableModel::parseXml(const QByteArray &xml)
{
QXmlInputSource inputSource;
QXmlSimpleReader reader;
TxSaxTableHandler handler(&m_Data, false);
inputSource.setData(xml);
reader.setContentHandler(&handler);
reader.setErrorHandler(&handler);
QModelIndexList selectedList = parent->selectionModel()->selectedRows();
QModelIndex scrollTopIndex = parent->indexAt(QPoint(1, 1));
QModelIndex scrollBottomIndex = parent->indexAt(QPoint(1, parent->height() - 1));
beginResetModel();
m_Data.clearData();
reader.parse(inputSource);
endResetModel();
if (scrollBottomIndex.row() == -1) {
parent->scrollToBottom();
} else {
parent->scrollTo(scrollTopIndex);
}
if (selectedList.count() > 0 && (selectedList.at(0).row() >= scrollTopIndex.row()) && (scrollBottomIndex.row() == -1 || scrollBottomIndex.row() > selectedList.at(0).row() )) {
parent->selectRow(selectedList.at(0).row());
}
}
To copy to clipboard, switch view to plain text mode
But I really hope that you would not use this. It makes me a lot of pain to support (edit cell is something terrible) and I`m working on merge too.
Bookmarks