summaryrefslogtreecommitdiffstats
path: root/src/sql/models/qsqlquerymodel.cpp
diff options
context:
space:
mode:
authorDerick Hawcroft <derick.hawcroft@nokia.com>2009-11-09 03:56:46 (GMT)
committerBill King <bill.king@nokia.com>2009-11-09 23:39:34 (GMT)
commit9a6de1fa0db0da8c4fa5eb904ef6d78cc619e332 (patch)
tree63cc04b5546454fcf668125169c6793fcdbdf04c /src/sql/models/qsqlquerymodel.cpp
parentb770abdd564f28a8d9dde816f72f73e6b15984af (diff)
downloadQt-9a6de1fa0db0da8c4fa5eb904ef6d78cc619e332.zip
Qt-9a6de1fa0db0da8c4fa5eb904ef6d78cc619e332.tar.gz
Qt-9a6de1fa0db0da8c4fa5eb904ef6d78cc619e332.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/models/qsqlquerymodel.cpp')
-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()) {