diff options
author | Mark Brand <mabrand@mabrand.nl> | 2011-07-06 09:49:45 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-05 17:50:21 +0100 |
commit | 48c68b05465e488020e241dd66290777b0eeeb3d (patch) | |
tree | 3db00d1db516cc4a65a49449dd13c3a54106ee86 /src/sql/models/qsqlrelationaltablemodel.cpp | |
parent | 23457bd6d9d54df2cab505e581e72f9942b0fdbb (diff) |
ModifiedRow: use for all edit strategies
Previously ModifiedRow was used only for OnManualSubmit and
a seperate buffer and utility methods were used for OnFieldChange
and OnRowChange.
Also, initialization of the edit buffer is done by ModifiedRow
instead of a helper function.
Change-Id: I3316498e5bb10c416138ca14c3a7f8b143c8e544
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
Diffstat (limited to 'src/sql/models/qsqlrelationaltablemodel.cpp')
-rw-r--r-- | src/sql/models/qsqlrelationaltablemodel.cpp | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp index e9b9e719a5..e12976ef24 100644 --- a/src/sql/models/qsqlrelationaltablemodel.cpp +++ b/src/sql/models/qsqlrelationaltablemodel.cpp @@ -265,7 +265,6 @@ public: mutable QVector<QRelation> relations; QSqlRecord baseRec; // the record without relations void clearChanges(); - void clearEditBuffer(); void clearCache(); void revertCachedRow(int row); @@ -311,12 +310,6 @@ int QSqlRelationalTableModelPrivate::nameToIndex(const QString &name) const return idx; } -void QSqlRelationalTableModelPrivate::clearEditBuffer() -{ - editBuffer = baseRec; - clearGenerated(editBuffer); -} - /*! \reimp */ @@ -445,23 +438,16 @@ QVariant QSqlRelationalTableModel::data(const QModelIndex &index, int role) cons //when the value at index has been changed or added. //At an unmodified index, the underlying model will //already have the correct display value. - QVariant v; - switch (d->strategy) { - case OnFieldChange: - break; - case OnRowChange: - if ((index.row() == d->editIndex || index.row() == d->insertIndex) - && d->editBuffer.isGenerated(index.column())) - v = d->editBuffer.value(index.column()); - break; - case OnManualSubmit: - const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row()); - if (row.op != QSqlTableModelPrivate::None && row.rec.isGenerated(index.column())) - v = row.rec.value(index.column()); - break; + if (d->strategy != OnFieldChange) { + const QSqlTableModelPrivate::ModifiedRow row = d->cache.value(index.row()); + if (row.op != QSqlTableModelPrivate::None && row.rec.isGenerated(index.column())) { + if (d->strategy == OnManualSubmit || row.op != QSqlTableModelPrivate::Delete) { + QVariant v = row.rec.value(index.column()); + if (v.isValid()) + return relation.dictionary[v.toString()]; + } + } } - if (v.isValid()) - return relation.dictionary[v.toString()]; } return QSqlTableModel::data(index, role); } |