QSqlTableModel::indexInQuery: fix inserted row accounting
authorMark Brand <mabrand@mabrand.nl>
Wed, 7 Mar 2012 23:19:03 +0000 (00:19 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 12 Mar 2012 12:14:05 +0000 (13:14 +0100)
Commit b979956ec46093e5668c2b264f9b68da3cbb0326 introduced a
distinction between rows that have a pending INSERT operation and
rows that have already been inserted in the database but still are
in the change cache. Both cases are rows that are not in the underlying
query. Unfortunately, we overlooked a case where the point of the test
is whether the row is in the query.

Change-Id: I0f58bed232d9336fed6e67c3d140fd580ec35868
Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
src/sql/models/qsqltablemodel.cpp

index d39df1d..5fed167 100644 (file)
@@ -1163,7 +1163,7 @@ 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)
+    if (d->cache.value(item.row()).insert())
         return QModelIndex();
 
     const int rowOffset = d->insertCount(item.row());