diff options
Diffstat (limited to 'src/sql/models/qsqltablemodel.cpp')
-rw-r--r-- | src/sql/models/qsqltablemodel.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index b759c11..df94080 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. @@ -20,10 +21,9 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this -** package. +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. @@ -559,7 +559,7 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in if (row.op == QSqlTableModelPrivate::None) { row.op = QSqlTableModelPrivate::Update; row.rec = d->rec; - row.primaryValues = d->primaryValues(indexInQuery(index).row()); + row.primaryValues = d->primaryValues(indexInQuery(index).row()); } row.rec.setValue(index.column(), value); emit dataChanged(index, index); @@ -669,7 +669,7 @@ bool QSqlTableModel::deleteRowFromTable(int row) Q_D(QSqlTableModel); emit beforeDelete(row); - QSqlRecord rec = d->primaryValues(row); + const QSqlRecord whereValues = d->strategy == OnManualSubmit ? d->cache[row].primaryValues : d->primaryValues(row); bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries); QString stmt = d->db.driver()->sqlStatement(QSqlDriver::DeleteStatement, d->tableName, @@ -677,7 +677,7 @@ bool QSqlTableModel::deleteRowFromTable(int row) prepStatement); QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement, d->tableName, - rec, + whereValues, prepStatement); if (stmt.isEmpty() || where.isEmpty()) { @@ -687,7 +687,7 @@ bool QSqlTableModel::deleteRowFromTable(int row) } stmt.append(QLatin1Char(' ')).append(where); - return d->exec(stmt, prepStatement, rec); + return d->exec(stmt, prepStatement, whereValues); } /*! @@ -1099,6 +1099,7 @@ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent) revertRow(idx); else { d->cache[idx].op = QSqlTableModelPrivate::Delete; + d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row()); emit headerDataChanged(Qt::Vertical, idx, idx); } } |