summaryrefslogtreecommitdiff
path: root/src/sql/models
diff options
context:
space:
mode:
authorDerick Hawcroft <derick.hawcroft@nokia.com>2009-11-09 13:56:46 +1000
committerBill King <bill.king@nokia.com>2009-11-10 09:39:34 +1000
commit9a6de1fa0db0da8c4fa5eb904ef6d78cc619e332 (patch)
tree63cc04b5546454fcf668125169c6793fcdbdf04c /src/sql/models
parentb770abdd564f28a8d9dde816f72f73e6b15984af (diff)
downloadqt4-tools-9a6de1fa0db0da8c4fa5eb904ef6d78cc619e332.tar.gz
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/models')
-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 1719239dff..319055e96d 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()) {