summaryrefslogtreecommitdiffstats
path: root/src/sql/models
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2011-07-07 12:42:07 +0200
committerQt by Nokia <qt-info@nokia.com>2012-02-05 17:50:39 +0100
commite5c8927fe87d0b0d91ac905ec2e57a4ea6f278ec (patch)
tree7594b8fbae1e9fe099b32296155467e13eba4479 /src/sql/models
parentf6e3f2468357ceece00ef05a1a17b63524eae1d9 (diff)
QSqlTableModel::setData(): comment historical idiosyncracies
Change-Id: I5c4782e18dc7a471dc294a4146db04f1efd3ed2e Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
Diffstat (limited to 'src/sql/models')
-rw-r--r--src/sql/models/qsqltablemodel.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 298cd03e20..3e5beb33b7 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -494,11 +494,25 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
bool isOk = true;
if (d->strategy == OnFieldChange && row.op != QSqlTableModelPrivate::Insert) {
+ // historical bug: bad style to call updateRowInTable.
+ // Should call submit(), but maybe the author wanted to avoid
+ // clearing the cache on failure.
isOk = updateRowInTable(index.row(), row.rec);
if (isOk)
select();
}
+ // historical bug: dataChanged() is suppressed for OnFieldChange and OnRowChange
+ // when operating on an "insert" record. This is to accomodate
+ // applications that call setData() while handling primeInsert().
+ // Otherwise dataChanged() would be emitted between beginInsert()
+ // and endInsert().
+ // The price of this workaround is that, although the view making
+ // the change will already display the new value, other views connected
+ // to the model probably will not.
+ // It's not clear why OnManualSubmit is excluded from this workaround.
+ // Calling setData() while handling primeInsert() is arguably very wrong anyway.
+ // primeInsert() provides a ref to the record for settings values.
if (d->strategy == OnManualSubmit || row.op != QSqlTableModelPrivate::Insert)
emit dataChanged(index, index);