Skip to content

Commit

Permalink
Merge pull request #2903 from sebastic/qt5-qspatialite
Browse files Browse the repository at this point in the history
Add support for Qt5 to qspatialite provider.
  • Loading branch information
m-kuhn committed Mar 14, 2016
2 parents bd6508a + e2c83ae commit 627815d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions ci/travis/linux/qt4/install.sh
Expand Up @@ -15,6 +15,7 @@ cmake -DWITH_SERVER=ON \
-DSUPPRESS_QT_WARNINGS=ON \
-DENABLE_MODELTEST=ON \
-DENABLE_PGTEST=ON \
-DWITH_QSPATIALITE=ON \
-DWITH_QWTPOLAR=OFF \
-DWITH_APIDOC=ON \
-DWITH_ASTYLE=ON \
Expand Down
1 change: 1 addition & 0 deletions ci/travis/linux/qt5/install.sh
Expand Up @@ -29,6 +29,7 @@ cmake \
-DSUPPRESS_QT_WARNINGS=ON \
-DENABLE_MODELTEST=ON \
-DENABLE_PGTEST=ON \
-DWITH_QSPATIALITE=ON \
-DWITH_QWTPOLAR=OFF \
-DWITH_QTWEBKIT=OFF \
-DWITH_APIDOC=ON \
Expand Down
17 changes: 17 additions & 0 deletions src/providers/spatialite/qspatialite/qsql_spatialite.cpp
Expand Up @@ -60,6 +60,10 @@
#include <sqlite3.h>
#include <qgsslconnect.h>

#if QT_VERSION >= 0x050000
Q_DECLARE_OPAQUE_POINTER(sqlite3*)
Q_DECLARE_OPAQUE_POINTER(sqlite3_stmt*)
#endif
Q_DECLARE_METATYPE(sqlite3*)
Q_DECLARE_METATYPE(sqlite3_stmt*)

Expand Down Expand Up @@ -325,10 +329,12 @@ QSpatiaLiteResult::~QSpatiaLiteResult()
void QSpatiaLiteResult::virtual_hook(int id, void *data)
{
switch (id) {
#if QT_VERSION < 0x050000
case QSqlResult::DetachFromResultSet:
if (d->stmt)
sqlite3_reset(d->stmt);
break;
#endif
default:
QSqlCachedResult::virtual_hook(id, data);
}
Expand Down Expand Up @@ -485,6 +491,14 @@ QSqlRecord QSpatiaLiteResult::record() const
return d->rInf;
}

#if QT_VERSION >= 0x050000
void QSpatiaLiteResult::detachFromResultSet()
{
if (d->stmt)
sqlite3_reset(d->stmt);
}
#endif

QVariant QSpatiaLiteResult::handle() const
{
return QVariant::fromValue(d->stmt);
Expand Down Expand Up @@ -531,6 +545,9 @@ bool QSpatiaLiteDriver::hasFeature(DriverFeature f) const
case BatchOperations:
case EventNotifications:
case MultipleResultSets:
#if QT_VERSION >= 0x050000
case CancelQuery:
#endif
return false;
}
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/providers/spatialite/qspatialite/qsql_spatialite.h
Expand Up @@ -80,6 +80,9 @@ class QSpatiaLiteResult : public QSqlCachedResult
int numRowsAffected();
QVariant lastInsertId() const;
QSqlRecord record() const;
#if QT_VERSION >= 0x050000
void detachFromResultSet();
#endif
void virtual_hook(int id, void *data);

private:
Expand Down
5 changes: 5 additions & 0 deletions src/providers/spatialite/qspatialite/smain.cpp
Expand Up @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE

class QSpatiaLiteDriverPlugin : public QSqlDriverPlugin
{
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.qgis.QSpatiaLiteDriverPlugin")
#endif
public:
QSpatiaLiteDriverPlugin();

Expand Down Expand Up @@ -75,7 +78,9 @@ QStringList QSpatiaLiteDriverPlugin::keys() const
return l;
}

#if QT_VERSION < 0x050000
Q_EXPORT_STATIC_PLUGIN(QSpatiaLiteDriverPlugin)
Q_EXPORT_PLUGIN2(qspatialite, QSpatiaLiteDriverPlugin)
#endif

QT_END_NAMESPACE

0 comments on commit 627815d

Please sign in to comment.