summaryrefslogtreecommitdiffstats
path: root/src/sql/models/qsqlquerymodel.h
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-04-23 01:06:17 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-23 19:20:19 +0200
commit83c9ebbd6692cde99ee692e6549c591100f12545 (patch)
treebc367b1ea99f3a8b679ce338b59b5f95f006585b /src/sql/models/qsqlquerymodel.h
parent508a90302b5bd2a1b228c62d1a1b24a3e66d24a9 (diff)
QSqlQueryModel::setQuery() don't use deprecated reset()
Previously the method attempted to reset only as a last resort. Now reset() is deprecated and resetting must happen between emitting modelAboutToBeReset() and modelReset(). Since this suffices in all cases to notify views that they must reinterrogate the model, it is no longer necessary to signal explicitly row removals and insertions within the scope of the reset. Additionally, fetchMore() is now called within the scope of the reset so insert signals do not have to be emitted here either. This improved handling of resetting in QSqlQueryModel also allows the cache in QSqlTableModel to be cleared directly at select(). This change may actually allow views to operate more efficiently since they no longer have to react to separate row removal and insert signals. Views can avoid pointless deallocation and reallocation by considering row count only after the reset is finished. The cost is that the columns and horizontal headers must be considered in the view at each setQuery() call. In any case, it is not clear that trying to be smart about this in the model justifies additional complexity. Tests had to be adjusted where they expected explicit row removal and insert signals. Change-Id: I4f7eac1419824361d7d9bdcc6a87092b33e80d7a Task-Id: QTBUG-25419 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
Diffstat (limited to 'src/sql/models/qsqlquerymodel.h')
-rw-r--r--src/sql/models/qsqlquerymodel.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/sql/models/qsqlquerymodel.h b/src/sql/models/qsqlquerymodel.h
index b5e1a7a746..89b72c8222 100644
--- a/src/sql/models/qsqlquerymodel.h
+++ b/src/sql/models/qsqlquerymodel.h
@@ -90,6 +90,8 @@ public:
bool canFetchMore(const QModelIndex &parent = QModelIndex()) const;
protected:
+ void beginResetModel();
+ void endResetModel();
virtual void queryChange();
virtual QModelIndex indexInQuery(const QModelIndex &item) const;