QSqlTableModel::indexInQuery(): fix for inserted rows

Should return invalid QModelIndex since inserted row does not map to
query.

Change-Id: Ib1d15cf4198a7063717fb3f3b594b2b1d8a54dfe
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
bb10
Mark Brand 2012-02-13 08:46:23 +01:00 committed by Qt by Nokia
parent 76fa96b99e
commit 22e0060e59
1 changed files with 3 additions and 0 deletions

View File

@ -1143,6 +1143,9 @@ int QSqlTableModel::rowCount(const QModelIndex &parent) const
QModelIndex QSqlTableModel::indexInQuery(const QModelIndex &item) const
{
Q_D(const QSqlTableModel);
if (d->cache.value(item.row()).op() == QSqlTableModelPrivate::Insert)
return QModelIndex();
const int rowOffset = d->insertCount(item.row());
return QSqlQueryModel::indexInQuery(createIndex(item.row() - rowOffset, item.column(), item.internalPointer()));
}