diff options
Diffstat (limited to 'src/sql')
-rw-r--r-- | src/sql/models/qsqltablemodel.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index c6efbad..4df1d63 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -1103,9 +1103,12 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent) int idx = row + i; if (idx >= rowCount()) return false; - if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) + if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) { revertRow(idx); - else { + // Reverting a row means all the other cache entries have been adjusted downwards + // so fake this by adjusting row + --row; + } else { d->cache[idx].op = QSqlTableModelPrivate::Delete; d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row()); emit headerDataChanged(Qt::Vertical, idx, idx); |