summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorSune Vuorela <sune@vuorela.dk>2012-11-16 13:19:05 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-20 14:13:07 +0100
commit93069a298a81d508ac651a2c1e9ca7dc00842589 (patch)
tree95d0dd5c17f10d148615686e4bfd74a59b486939 /src/sql
parente671110a107358451bc84564cb80d27af8dfd8b2 (diff)
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>
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/kernel/qsqldriver.cpp23
-rw-r--r--src/sql/kernel/qsqldriver.h5
2 files changed, 27 insertions, 1 deletions
diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp
index ec1628291d..62ec4e7e1f 100644
--- a/src/sql/kernel/qsqldriver.cpp
+++ b/src/sql/kernel/qsqldriver.cpp
@@ -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
diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h
index 921e1a4993..f0176700a9 100644
--- a/src/sql/kernel/qsqldriver.h
+++ b/src/sql/kernel/qsqldriver.h
@@ -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);