summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-07-21 18:42:23 +0200
committerIvan Solovev <ivan.solovev@qt.io>2022-08-10 22:38:24 +0200
commitc4fabe37b9a97a189b02de4e72d040009892ad08 (patch)
treeb3466548b611b3f9b41be6b49d1b78bd424a62eb
parent2ca30440835ef99d8b5f720866fc163a9629bed7 (diff)
Remove QSqlTableModel::setQuery(const QSqlQuery &)
... and simply use the public methods of the base class instead. We can't completely remove it, so we just add it to removed_api.cpp By removing the setQuery() method in the QSqlTableModel class, we open up name lookup to the base class, where the const ref overload was already deprecated in 14f9f00fdb2dc428610c08e3d9d03e38e9602166, and the proper replacements were provided. [ChangeLog][QtSql][QSqlTableModel] The setQuery(const QSqlQuery &) method is removed, because QSqlQuery cannot be copied correctly. Use the public setQuery() overloads of the base QSqlQueryModel class instead. They allow passing of QSqlQuery by rvalue ref, or creation of the query by specifying query string and database object. Task-number: QTBUG-105048 Change-Id: I6f47067af6b4769578d4de9dbdbbbc7504ddf4ad Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r--src/sql/compat/removed_api.cpp7
-rw-r--r--src/sql/models/qsqltablemodel.cpp17
-rw-r--r--src/sql/models/qsqltablemodel.h2
3 files changed, 11 insertions, 15 deletions
diff --git a/src/sql/compat/removed_api.cpp b/src/sql/compat/removed_api.cpp
index cab5d5b528..ff223b9967 100644
--- a/src/sql/compat/removed_api.cpp
+++ b/src/sql/compat/removed_api.cpp
@@ -27,6 +27,13 @@ QSqlQuery QSqlQueryModel::query() const
QT_IGNORE_DEPRECATIONS(return query(QT6_CALL_NEW_OVERLOAD);)
}
+#include "qsqltablemodel.h"
+
+void QSqlTableModel::setQuery(const QSqlQuery &query)
+{
+ QT_IGNORE_DEPRECATIONS(QSqlQueryModel::setQuery(query);)
+}
+
#endif // QT_CONFIG(sqlmodel)
// #include <qotherheader.h>
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 1fed690170..a6a8f68d20 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -342,10 +342,9 @@ bool QSqlTableModel::select()
d->clearCache();
- QSqlQuery qu(query, d->db);
- setQuery(qu);
+ setQuery(query, d->db);
- if (!qu.isActive() || lastError().isValid()) {
+ if (!d->query.isActive() || lastError().isValid()) {
// something went wrong - revert to non-select state
d->initRecordAndPrimaryIndex();
endResetModel();
@@ -582,18 +581,6 @@ bool QSqlTableModel::clearItemData(const QModelIndex &index)
}
/*!
- This function simply calls QSqlQueryModel::setQuery(\a query).
- You should normally not call it on a QSqlTableModel. Instead, use
- setTable(), setSort(), setFilter(), etc., to set up the query.
-
- \sa selectStatement()
-*/
-void QSqlTableModel::setQuery(const QSqlQuery &query)
-{
- QT_IGNORE_DEPRECATIONS(QSqlQueryModel::setQuery(query);)
-}
-
-/*!
Updates the given \a row in the currently active database table
with the specified \a values. Returns \c true if successful; otherwise
returns \c false.
diff --git a/src/sql/models/qsqltablemodel.h b/src/sql/models/qsqltablemodel.h
index fc04d72a0d..8af3f84c59 100644
--- a/src/sql/models/qsqltablemodel.h
+++ b/src/sql/models/qsqltablemodel.h
@@ -99,7 +99,9 @@ protected:
virtual QString selectStatement() const;
void setPrimaryKey(const QSqlIndex &key);
+#if QT_SQL_REMOVED_SINCE(6, 5)
void setQuery(const QSqlQuery &query);
+#endif
QModelIndex indexInQuery(const QModelIndex &item) const override;
QSqlRecord primaryValues(int row) const;
};