For OnRowChange, an index may receive a change only if no other
row has a cached change. Changes are not submitted automatically.
+ Returns true if \a value is equal to the current value. However,
+ the value will not be submitted to the database.
+
Returns true if the value could be set or false on error, for
example if \a index is out of bounds.
if (!(flags(index) & Qt::ItemIsEditable))
return false;
+ if (QSqlTableModel::data(index, role) == value)
+ return true;
+
QSqlTableModelPrivate::ModifiedRow &row = d->cache[index.row()];
if (row.op() == QSqlTableModelPrivate::None)
QVERIFY_SQL(model, select());
QFAIL_SQL(model, isDirty());
+ // check that setting the current value does not add to the cache
+ {
+ QModelIndex i = model.index(0, 1);
+ QVariant v = model.data(i, Qt::EditRole);
+ QVERIFY_SQL(model, setData(i, v));
+ QFAIL_SQL(model, isDirty());
+ }
+
if (submitpolicy != QSqlTableModel::OnFieldChange) {
// setData() followed by revertAll()
QCOMPARE(model.data(model.index(0, 1)).toString(), QString("harry"));