summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Ehrlicher <[email protected]>2024-01-19 20:53:26 +0100
committerChristian Ehrlicher <[email protected]>2024-01-24 21:35:09 +0100
commit212e88889ad02ee7ea0ebbd989c57412cccb59bf (patch)
tree3e4789d4bce39d895eeaf90e18032a54ce0035c3
parente752c77b35185fa51cdc3684329a9733abe2be3b (diff)
QSqlQuery: add Q_PROPERTY
Add Q_PROPERTY to follow the current Qt style and simplify the documentation. Task-number: QTBUG-120566 Change-Id: I3803f5246c1814d627a16fa2569d1342b54f6adf Reviewed-by: Kai Köhne <[email protected]>
-rw-r--r--src/sql/kernel/qsqlquery.cpp46
-rw-r--r--src/sql/kernel/qsqlquery.h6
2 files changed, 36 insertions, 16 deletions
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp
index 1b44d286763..381690e53f2 100644
--- a/src/sql/kernel/qsqlquery.cpp
+++ b/src/sql/kernel/qsqlquery.cpp
@@ -864,10 +864,9 @@ bool QSqlQuery::isSelect() const
}
/*!
- Returns \c true if you can only scroll forward through a result set;
- otherwise returns \c false.
+ Returns \l forwardOnly.
- \sa setForwardOnly(), next()
+ \sa forwardOnly, next(), seek()
*/
bool QSqlQuery::isForwardOnly() const
{
@@ -875,7 +874,10 @@ bool QSqlQuery::isForwardOnly() const
}
/*!
- Sets forward only mode to \a forward. If \a forward is true, only
+ \property QSqlQuery::forwardOnly
+ \since 6.8
+
+ This property holds the forward only mode. If \a forward is true, only
next() and seek() with positive values, are allowed for navigating
the results.
@@ -904,7 +906,11 @@ bool QSqlQuery::isForwardOnly() const
mode, do not execute any other SQL command on the same database
connection. This will cause the query results to be lost.
- \sa isForwardOnly(), next(), seek(), QSqlResult::setForwardOnly()
+ \sa next(), seek()
+*/
+/*!
+ Sets \l forwardOnly to \a forward.
+ \sa forwardOnly, next(), seek()
*/
void QSqlQuery::setForwardOnly(bool forward)
{
@@ -1246,6 +1252,8 @@ QVariant QSqlQuery::lastInsertId() const
}
/*!
+ \property QSqlQuery::numericalPrecisionPolicy
+ \since 6.8
Instruct the database driver to return numerical values with a
precision specified by \a precisionPolicy.
@@ -1264,17 +1272,19 @@ QVariant QSqlQuery::lastInsertId() const
active query. Call \l{exec()}{exec(QString)} or prepare() in order
to activate the policy.
- \sa QSql::NumericalPrecisionPolicy, numericalPrecisionPolicy()
+ \sa QSql::NumericalPrecisionPolicy, QSqlDriver::numericalPrecisionPolicy,
+ QSqlDatabase::numericalPrecisionPolicy
*/
+/*!
+ Sets \l numericalPrecisionPolicy to \a precisionPolicy.
+ */
void QSqlQuery::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)
{
d->sqlResult->setNumericalPrecisionPolicy(precisionPolicy);
}
/*!
- Returns the current precision policy.
-
- \sa QSql::NumericalPrecisionPolicy, setNumericalPrecisionPolicy()
+ Returns the \l numericalPrecisionPolicy.
*/
QSql::NumericalPrecisionPolicy QSqlQuery::numericalPrecisionPolicy() const
{
@@ -1282,18 +1292,23 @@ QSql::NumericalPrecisionPolicy QSqlQuery::numericalPrecisionPolicy() const
}
/*!
- Enables or disables the positional \l {Approaches to Binding Values}{binding}
+ \property QSqlQuery::positionalBindingEnabled
+ \since 6.8
+ This property enables or disables the positional \l {Approaches to Binding Values}{binding}
for this query, depending on \a enable (default is \c true).
Disabling positional bindings is useful if the query itself contains a '?'
which must not be handled as a positional binding parameter but, for example,
as a JSON operator for a PostgreSQL database.
- This function will have no effect when the database has native
+ This property will have no effect when the database has native
support for positional bindings with question marks (see also
\l{QSqlDriver::PositionalPlaceholders}).
+*/
+/*!
+ Sets \l positionalBindingEnabled to \a enable.
\since 6.7
- \sa isPositionalBindingEnabled()
+ \sa positionalBindingEnabled
*/
void QSqlQuery::setPositionalBindingEnabled(bool enable)
{
@@ -1301,10 +1316,9 @@ void QSqlQuery::setPositionalBindingEnabled(bool enable)
}
/*!
- Returns \c true if the positional binding is currently enabled.
-
+ Returns \l positionalBindingEnabled.
\since 6.7
- \sa setPositionalBindingEnabled()
+ \sa positionalBindingEnabled
*/
bool QSqlQuery::isPositionalBindingEnabled() const
{
@@ -1359,7 +1373,7 @@ void QSqlQuery::finish()
databases may have restrictions on which statements are allowed to
be used in a SQL batch.
- \sa QSqlDriver::hasFeature(), setForwardOnly(), next(), isSelect(),
+ \sa QSqlDriver::hasFeature(), forwardOnly, next(), isSelect(),
numRowsAffected(), isActive(), lastError()
*/
bool QSqlQuery::nextResult()
diff --git a/src/sql/kernel/qsqlquery.h b/src/sql/kernel/qsqlquery.h
index 86e401f5b5f..244b0262050 100644
--- a/src/sql/kernel/qsqlquery.h
+++ b/src/sql/kernel/qsqlquery.h
@@ -9,6 +9,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qvariant.h>
+// clazy:excludeall=qproperty-without-notify
QT_BEGIN_NAMESPACE
@@ -21,7 +22,12 @@ class QSqlQueryPrivate;
class Q_SQL_EXPORT QSqlQuery
{
+ Q_GADGET
public:
+ Q_PROPERTY(bool forwardOnly READ isForwardOnly WRITE setForwardOnly)
+ Q_PROPERTY(bool positionalBindingEnabled READ isPositionalBindingEnabled WRITE setPositionalBindingEnabled)
+ Q_PROPERTY(QSql::NumericalPrecisionPolicy numericalPrecisionPolicy READ numericalPrecisionPolicy WRITE setNumericalPrecisionPolicy)
+
explicit QSqlQuery(QSqlResult *r);
explicit QSqlQuery(const QString& query = QString(), const QSqlDatabase &db = QSqlDatabase());
explicit QSqlQuery(const QSqlDatabase &db);