QSqlTableModel::setData(): call dataChanged() before select()
authorMark Brand <mabrand@mabrand.nl>
Wed, 8 Feb 2012 08:35:38 +0000 (09:35 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 8 Feb 2012 13:43:18 +0000 (14:43 +0100)
Emit dataChanged() before a possible new select instead of after.
The select reinserts all the rows, emitting signals for that, so
there isn't any point to dataChanged() afterwards.

Change-Id: I698a0d385f97104891343d94cc27e4ecf3a7233c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
src/sql/models/qsqltablemodel.cpp

index d943b5d..38705c7 100644 (file)
@@ -506,6 +506,7 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
     }
 
     row.setValue(index.column(), value);
+    emit dataChanged(index, index);
 
     bool isOk = true;
     if (d->strategy == OnFieldChange && row.op() != QSqlTableModelPrivate::Insert) {
@@ -517,8 +518,6 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
             select();
     }
 
-    emit dataChanged(index, index);
-
     return isOk;
 }