diff options
author | Derick Hawcroft <derick.hawcroft@nokia.com> | 2009-11-09 03:56:46 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-11-11 16:06:44 (GMT) |
commit | 14b93b10b00aef37986e82b2568ad916ef21f2ed (patch) | |
tree | 431031f8503a13aa8efd611177468283a108d14e | |
parent | a9729ff8edc98e0f20f031ff7761b58b1ad3c598 (diff) | |
download | Qt-14b93b10b00aef37986e82b2568ad916ef21f2ed.zip Qt-14b93b10b00aef37986e82b2568ad916ef21f2ed.tar.gz Qt-14b93b10b00aef37986e82b2568ad916ef21f2ed.tar.bz2 |
Don't reset view if a query fails.
The view of a table gets reset if for example a query fails.
However this also resets and removes the Header views of the
table. A better solution visually is to keep them displayed.
Task-number: QTBUG-3162
-rw-r--r-- | src/sql/models/qsqlquerymodel.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp index 1719239..319055e 100644 --- a/src/sql/models/qsqlquerymodel.cpp +++ b/src/sql/models/qsqlquerymodel.cpp @@ -314,6 +314,7 @@ void QSqlQueryModel::setQuery(const QSqlQuery &query) QSqlRecord newRec = query.record(); bool columnsChanged = (newRec != d->rec); bool hasQuerySize = query.driver()->hasFeature(QSqlDriver::QuerySize); + bool hasNewData = (newRec != QSqlRecord()) || !query.lastError().isValid(); if (d->colOffsets.size() != newRec.count() || columnsChanged) d->initColOffsets(newRec.count()); @@ -328,13 +329,13 @@ void QSqlQueryModel::setQuery(const QSqlQuery &query) d->error = QSqlError(); d->query = query; d->rec = newRec; - + if (mustClearModel) endRemoveRows(); - - d->atEnd = false; - if (columnsChanged) + d->atEnd = false; + + if (columnsChanged && hasNewData) reset(); if (!query.isActive() || query.isForwardOnly()) { |