summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-08-09 12:42:59 +0200
committerIvan Solovev <ivan.solovev@qt.io>2022-08-10 22:38:24 +0200
commit2ca30440835ef99d8b5f720866fc163a9629bed7 (patch)
tree3d44c994a1f7dec26e5b732cfc4abfc7a244c0c1 /src
parent62859ccaa666909c2db8ac4d0a46fa0f5163153f (diff)
Make QSqlQueryModel::query() return a reference to the const QSqlQuery
Returning QSqlQuery instance by value does not make much sense, because it cannot be copied correctly. Also, its copy constructor and copy-assignment operators are deprecated from Qt 6.2. [ChangeLog][Potentially Source-Incompatible Changes][QSqlQueryModel] QSqlQueryModel::query() now returns a reference to the const QSqlQuery object associated with the model. Task-number: QTBUG-105048 Change-Id: I04a2aa377b17d770d2a9855040f8c730190484d8 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/sql/compat/removed_api.cpp12
-rw-r--r--src/sql/models/qsqlquerymodel.cpp7
-rw-r--r--src/sql/models/qsqlquerymodel.h3
3 files changed, 17 insertions, 5 deletions
diff --git a/src/sql/compat/removed_api.cpp b/src/sql/compat/removed_api.cpp
index 1ada26407a..cab5d5b528 100644
--- a/src/sql/compat/removed_api.cpp
+++ b/src/sql/compat/removed_api.cpp
@@ -17,6 +17,18 @@ QT_USE_NAMESPACE
#if QT_SQL_REMOVED_SINCE(6, 5)
+#if QT_CONFIG(sqlmodel)
+
+#include "qsqlquerymodel.h"
+#include "qsqlquery.h"
+
+QSqlQuery QSqlQueryModel::query() const
+{
+ QT_IGNORE_DEPRECATIONS(return query(QT6_CALL_NEW_OVERLOAD);)
+}
+
+#endif // QT_CONFIG(sqlmodel)
+
// #include <qotherheader.h>
// // implement removed functions from qotherheader.h
// order sections alphabetically to reduce chances of merge conflicts
diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp
index 61620f81d4..fee99bd8ea 100644
--- a/src/sql/models/qsqlquerymodel.cpp
+++ b/src/sql/models/qsqlquerymodel.cpp
@@ -522,18 +522,15 @@ bool QSqlQueryModel::setHeaderData(int section, Qt::Orientation orientation,
}
/*!
- Returns the QSqlQuery associated with this model.
+ Returns a reference to the const QSqlQuery object associated with this model.
\sa setQuery()
*/
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-QSqlQuery QSqlQueryModel::query() const
+const QSqlQuery &QSqlQueryModel::query(QT6_IMPL_NEW_OVERLOAD) const
{
Q_D(const QSqlQueryModel);
return d->query;
}
-QT_WARNING_POP
/*!
Returns information about the last error that occurred on the
diff --git a/src/sql/models/qsqlquerymodel.h b/src/sql/models/qsqlquerymodel.h
index ede97b04fb..73308b79e8 100644
--- a/src/sql/models/qsqlquerymodel.h
+++ b/src/sql/models/qsqlquerymodel.h
@@ -46,7 +46,10 @@ public:
#endif
void setQuery(QSqlQuery &&query);
void setQuery(const QString &query, const QSqlDatabase &db = QSqlDatabase());
+#if QT_SQL_REMOVED_SINCE(6, 5)
QSqlQuery query() const;
+#endif
+ const QSqlQuery &query(QT6_DECL_NEW_OVERLOAD) const;
virtual void clear();