summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorDerick Hawcroft <derick.hawcroft@nokia.com>2009-11-09 03:56:46 (GMT)
committerDerick Hawcroft <derick.hawcroft@nokia.com>2009-11-09 03:56:46 (GMT)
commit87fb186c553d0875c92938a6fd5a9aaf8d69a057 (patch)
tree8d912bd672f53974af708ae8717b38ec7fabbabd /src/sql
parent80713aab0926e3d2ae9d0345e48c027deca1fbbb (diff)
downloadQt-87fb186c553d0875c92938a6fd5a9aaf8d69a057.zip
Qt-87fb186c553d0875c92938a6fd5a9aaf8d69a057.tar.gz
Qt-87fb186c553d0875c92938a6fd5a9aaf8d69a057.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
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/models/qsqlquerymodel.cpp9
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()) {