void TreeToTableProxyModel::sourceRowsAboutToBeInserted(const QModelIndex& aParent, int aStart, int aEnd)
{
if (sourceModel())
{
QModelIndex modelStartIndex
= sourceModel
()->index
(aStart,
0, aParent
);
QModelIndex modelEndIndex
= sourceModel
()->index
(aEnd,
0, aParent
);
QModelIndex proxyStartIndex
= mapFromSource
(modelStartIndex
);
QModelIndex proxyEndIndex
= mapFromSource
(modelEndIndex
);
beginInsertRows(proxyStartIndex.parent(), proxyStartIndex.row(), proxyEndIndex.row());
//beginResetModel();
}
}
void TreeToTableProxyModel::sourceRowsAboutToBeRemoved(const QModelIndex& aParent, int aStart, int aEnd)
{
if (sourceModel())
{
QModelIndex modelStartIndex
= sourceModel
()->index
(aStart,
0, aParent
);
QModelIndex modelEndIndex
= sourceModel
()->index
(aEnd,
0, aParent
);
QModelIndex proxyStartIndex
= mapFromSource
(modelStartIndex
);
QModelIndex proxyEndIndex
= mapFromSource
(modelEndIndex
);
beginRemoveRows(proxyStartIndex.parent(), proxyStartIndex.row(), proxyEndIndex.row());
//beginResetModel();
}
}
void TreeToTableProxyModel::sourceRowsInserted(const QModelIndex& aParent, int aStart, int aEnd)
{
if (sourceModel())
{
//emit layoutAboutToBeChanged();
mMapFromSource.clear();
mMapToSource.clear();
createMap(...);
//emit layoutChanged();
endInsertRows();
//endResetModel();
}
}
void TreeToTableProxyModel::sourceRowsRemoved(const QModelIndex& aParent, int aStart, int aEnd)
{
if (sourceModel())
{
//emit layoutAboutToBeChanged();
mMapFromSource.clear();
mMapToSource.clear();
createMap(...);
//emit layoutChanged();
endRemoveRows();
//endResetModel();
}
}
void TreeToTableProxyModel::sourceRowsAboutToBeInserted(const QModelIndex& aParent, int aStart, int aEnd)
{
if (sourceModel())
{
QModelIndex modelStartIndex = sourceModel()->index(aStart, 0, aParent);
QModelIndex modelEndIndex = sourceModel()->index(aEnd, 0, aParent);
QModelIndex proxyStartIndex = mapFromSource(modelStartIndex);
QModelIndex proxyEndIndex = mapFromSource(modelEndIndex);
beginInsertRows(proxyStartIndex.parent(), proxyStartIndex.row(), proxyEndIndex.row());
//beginResetModel();
}
}
void TreeToTableProxyModel::sourceRowsAboutToBeRemoved(const QModelIndex& aParent, int aStart, int aEnd)
{
if (sourceModel())
{
QModelIndex modelStartIndex = sourceModel()->index(aStart, 0, aParent);
QModelIndex modelEndIndex = sourceModel()->index(aEnd, 0, aParent);
QModelIndex proxyStartIndex = mapFromSource(modelStartIndex);
QModelIndex proxyEndIndex = mapFromSource(modelEndIndex);
beginRemoveRows(proxyStartIndex.parent(), proxyStartIndex.row(), proxyEndIndex.row());
//beginResetModel();
}
}
void TreeToTableProxyModel::sourceRowsInserted(const QModelIndex& aParent, int aStart, int aEnd)
{
if (sourceModel())
{
//emit layoutAboutToBeChanged();
mMapFromSource.clear();
mMapToSource.clear();
createMap(...);
//emit layoutChanged();
endInsertRows();
//endResetModel();
}
}
void TreeToTableProxyModel::sourceRowsRemoved(const QModelIndex& aParent, int aStart, int aEnd)
{
if (sourceModel())
{
//emit layoutAboutToBeChanged();
mMapFromSource.clear();
mMapToSource.clear();
createMap(...);
//emit layoutChanged();
endRemoveRows();
//endResetModel();
}
}
To copy to clipboard, switch view to plain text mode
connect(sourceModel(), SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int)), this, SLOT(sourceRowsAboutToBeInserted(const QModelIndex&, int, int)));
connect(sourceModel(), SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int)), this, SLOT(sourceRowsAboutToBeInserted(const QModelIndex&, int, int)));
To copy to clipboard, switch view to plain text mode
Bookmarks