create interface QSqlDriver::cancelQuery()

This is useful for canceling a long running sql query.
Note that it needs support from the individual drivers.

Change-Id: Ia170a70487ff4ee13c85f12bc13e62fb198617fe
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This commit is contained in:
Sune Vuorela 2012-11-16 13:19:05 +01:00 committed by The Qt Project
parent e671110a10
commit 93069a298a
2 changed files with 27 additions and 1 deletions

View File

@ -789,4 +789,27 @@ QSql::NumericalPrecisionPolicy QSqlDriver::numericalPrecisionPolicy() const
return d_func()->precisionPolicy;
}
/*!
\since 5.0
\internal
Tries to cancel the running query, if the underlying driver has the
capability to cancel queries. Returns true on success, otherwise false.
This function can be called from a different thread.
If you use this function as a slot, you need to use a Qt::DirectConnection
from a different thread.
Reimplement this function to support canceling running queries in
your own QSqlDriver subclass. It must be implemented in a thread-safe
manner.
\sa QSqlDriver::hasFeature()
*/
bool QSqlDriver::cancelQuery()
{
return false;
}
QT_END_NAMESPACE

View File

@ -71,7 +71,7 @@ public:
enum DriverFeature { Transactions, QuerySize, BLOB, Unicode, PreparedQueries,
NamedPlaceholders, PositionalPlaceholders, LastInsertId,
BatchOperations, SimpleLocking, LowPrecisionNumbers,
EventNotifications, FinishQuery, MultipleResultSets };
EventNotifications, FinishQuery, MultipleResultSets, CancelQuery };
enum StatementType { WhereStatement, SelectStatement, UpdateStatement,
InsertStatement, DeleteStatement };
@ -120,6 +120,9 @@ public:
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy);
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
public Q_SLOTS:
virtual bool cancelQuery();
Q_SIGNALS:
void notification(const QString &name);
void notification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload);