summaryrefslogtreecommitdiffstats
path: root/src/sql/models/qsqltablemodel.cpp
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-02-29 01:51:23 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-15 15:35:22 +0100
commit3d7cec6577fa32fb6036b346db57c53e38ea2ffd (patch)
treeef364191256bdbc778629403cf3307a31e125301 /src/sql/models/qsqltablemodel.cpp
parentf6ca63f896b5f9a330ff497aebff6943653dc35d (diff)
QSqlTableModel: disallow insert if changes are pending
For OnFieldChange and OnRowChange, inserting rows should not be allowed if there are pending changes in cache. Change-Id: Ia794332959a35a1de87e798ba1a74ace3dfae68f Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
Diffstat (limited to 'src/sql/models/qsqltablemodel.cpp')
-rw-r--r--src/sql/models/qsqltablemodel.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index a001b262de..0eb5447600 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -1088,17 +1088,18 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent)
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()
*/
@@ -1108,8 +1109,9 @@ bool QSqlTableModel::insertRows(int row, int count, const QModelIndex &parent)
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);