From 83c9ebbd6692cde99ee692e6549c591100f12545 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Mon, 23 Apr 2012 01:06:17 +0200 Subject: 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 Reviewed-by: Olivier Goffart Reviewed-by: Honglei Zhang --- dist/changes-5.0.0 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'dist') diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index d3ea3fbcb3..617cf3e0dc 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -451,7 +451,7 @@ QTestLib QtSql ----- -QSqlTableModel/QSqlRelationalTableModel +QSqlQueryModel/QSqlTableModel/QSqlRelationalTableModel * The dataChanged() signal is now emitted for changes made to an inserted record that has not yet been committed. Previously, dataChanged() was @@ -486,6 +486,10 @@ removed and only if there are no other changed rows. QSqlTableModel::indexInQuery() as example of how to implement in a subclass. +* QSqlQueryMode::setQuery() emits fewer signals. The modelAboutToBeReset() +and modelReset() signals suffice to inform views that they must reinterrogate +the model. + * QSqlTableModel::selectRow(): This is a new method that refreshes a single row in the model from the database. -- cgit v1.2.3