that fail upon resubmitting for edit strategies OnFieldChange and OnRowChange.
Instead, pending (failed) changes cause new changes inappropriate to the
edit strategy to be refused. The application should resolve or revert pending
-changes.
+changes. insertRows() and insertRecord() also respect the edit strategy.
****************************************************************************
* Database Drivers *
parent must be invalid, since this model does not support
parent-child relations.
- Only one row at a time can be inserted when using the
- OnFieldChange or OnRowChange update strategies.
+ For edit strategies OnFieldChange and OnRowChange, only one row
+ may be inserted at a time and the model may not contain other
+ cached changes.
The primeInsert() signal will be emitted for each new row.
Connect to it if you want to initialize the new row with default
values.
- Returns false if the parameters are out of bounds; otherwise
- returns true.
+ Does not submit rows, regardless of edit strategy.
- Does not submit rows, regardless of edit strategy, not even OnFieldChange.
+ Returns false if the parameters are out of bounds or the row cannot be
+ inserted; otherwise returns true.
\sa primeInsert(), insertRecord()
*/
if (row < 0 || count <= 0 || row > rowCount() || parent.isValid())
return false;
- if (d->strategy != OnManualSubmit && count != 1)
- return false;
+ if (d->strategy != OnManualSubmit)
+ if (count != 1 || isDirty())
+ return false;
d->busyInsertingRows = true;
beginInsertRows(parent, row, row + count - 1);
QCOMPARE(model.data(model.index(1, 1)).toString(), QString("blah"));
QFAIL_SQL(model, setRecord(1, values));
QCOMPARE(model.data(model.index(1, 1)).toString(), QString("blah"));
+ QFAIL_SQL(model, insertRow(2));
+ QCOMPARE(model.rowCount(), 2);
} else {
QVERIFY_SQL(model, setData(model.index(1, 1), QString("eggs")));
QCOMPARE(model.data(model.index(1, 1)).toString(), QString("eggs"));
QVERIFY_SQL(model, setRecord(1, values));
QCOMPARE(model.data(model.index(1, 1)).toString(), QString("spam"));
+ QVERIFY_SQL(model, insertRow(2));
+ QCOMPARE(model.rowCount(), 3);
}
// restore empty table