summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-02-06 16:05:53 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-08 14:43:18 +0100
commit7b726900ecdd1d4d5e9b8f7c34f00dd27524b1c6 (patch)
tree325d5730eb0cf39520174b357e2b997ceaffcdc6 /src/sql
parent5953304bc5f50eca77f78fd0623479de6bebacbe (diff)
QSqlTableModel::setRecord(): emit dataChanged() consistently
Previously, if any fields in the supplied record could not be matched with a column in the target table, dataChanged() was supressed for all columns for OnManualSubmit. This is not good because it prevents other views from noticing the fields that *do* change. It's simplest and probably more efficient just to emit dataChanged() once for the whole row. Fewer signals need to be processed and in typical cases much or all of the row is likely to be changed anyway. Change-Id: Ib56bf9a18e51b9cb85771acefcb2bf26e295a54e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/models/qsqltablemodel.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 7210ddce5b..437712d83e 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -1212,21 +1212,16 @@ bool QSqlTableModel::setRecord(int row, const QSqlRecord &record)
bool isOk = true;
for (int i = 0; i < record.count(); ++i) {
int idx = d->nameToIndex(record.fieldName(i));
- if (idx == -1) {
+ if (idx == -1)
isOk = false;
- } else if (d->strategy != OnManualSubmit) {
- // historical bug: this could all be simple like OnManualSubmit, but isn't
- const QModelIndex cIndex = createIndex(row, idx);
+ else
mrow.setValue(idx, record.value(i));
- emit dataChanged(cIndex, cIndex);
- } else {
- mrow.setValue(idx, record.value(i));
- }
}
- if (d->strategy == OnManualSubmit && isOk)
+ if (columnCount())
emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
- else if (d->strategy == OnFieldChange)
+
+ if (d->strategy == OnFieldChange)
return submit();
else if (d->strategy == OnManualSubmit)
return isOk;