Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
port sqldrivers ocispatial and qspatialite to qt5
  • Loading branch information
jef-n committed Mar 19, 2016
1 parent 5902f0e commit 2cc83ff
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/providers/oracle/ocispatial/CMakeLists.txt
Expand Up @@ -12,7 +12,7 @@ ADD_DEFINITIONS(-DQT_SHARED)
INCLUDE_DIRECTORIES(SYSTEM ${OCI_INCLUDE_DIR})

SET(QSQLOCISPATIAL_SRC qsql_ocispatial.cpp main.cpp)
QT4_WRAP_CPP(QSQLOCISPATIAL_SRC qsql_ocispatial.h)
QT4_WRAP_CPP(QSQLOCISPATIAL_SRC qsql_ocispatial.h main.h)

ADD_LIBRARY(qsqlocispatial SHARED ${QSQLOCISPATIAL_SRC})

Expand Down
19 changes: 5 additions & 14 deletions src/providers/oracle/ocispatial/main.cpp
Expand Up @@ -41,21 +41,11 @@
**
****************************************************************************/

#include <qsqldriverplugin.h>
#include <qstringlist.h>
#include "main.h"
#include "qsql_ocispatial.h"

QT_BEGIN_NAMESPACE

class QOCISpatialDriverPlugin : public QSqlDriverPlugin
{
public:
QOCISpatialDriverPlugin();

QSqlDriver* create( const QString & );
QStringList keys() const;
};

QOCISpatialDriverPlugin::QOCISpatialDriverPlugin()
: QSqlDriverPlugin()
{
Expand All @@ -74,12 +64,13 @@ QSqlDriver* QOCISpatialDriverPlugin::create( const QString &name )
QStringList QOCISpatialDriverPlugin::keys() const
{
QStringList l;
l.append( QLatin1String( "QOCISPATIAL8" ) );
l.append( QLatin1String( "QOCISPATIAL" ) );
l << QLatin1String( "QOCISPATIAL8" ) << QLatin1String( "QOCISPATIAL" );
return l;
}

#if QT_VERSION < 0x050000
Q_EXPORT_STATIC_PLUGIN( QOCISpatialDriverPlugin )
Q_EXPORT_PLUGIN2( qsqloci, QOCISpatialDriverPlugin )
Q_EXPORT_PLUGIN2( qsqlocispatial, QOCISpatialDriverPlugin )
#endif

QT_END_NAMESPACE
65 changes: 65 additions & 0 deletions src/providers/oracle/ocispatial/main.h
@@ -0,0 +1,65 @@
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
** Oracle Spatial Support: (C) 2012-2013 Juergen E. Fischer < jef at norbit dot de >, norBIT GmbH
**
****************************************************************************/

#ifndef QOCISPATIAL_MAIN_H
#define QOCISPATIAL_MAIN_H

#include <QSqlDriverPlugin>
#include <QStringList>

#if QT_VERSION < 0x050000
#define Q_PLUGIN_METADATA(x)
#endif

class QOCISpatialDriverPlugin : public QSqlDriverPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA( IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "qocispatial.json" )
public:
QOCISpatialDriverPlugin();

QSqlDriver* create( const QString & );
QStringList keys() const;
};

#endif
13 changes: 11 additions & 2 deletions src/providers/oracle/ocispatial/qsql_ocispatial.cpp
Expand Up @@ -94,6 +94,10 @@
#define QOCISPATIAL_THREADED


#if QT_VERSION >= 0x050000
Q_DECLARE_OPAQUE_POINTER( OCIEnv* )
Q_DECLARE_OPAQUE_POINTER( OCIStmt* )
#endif
Q_DECLARE_METATYPE( OCIEnv* )
Q_DECLARE_METATYPE( OCIStmt* )

Expand Down Expand Up @@ -2525,7 +2529,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index )
}

Q_ASSERT( nPoints % nDims == 0 );
Q_ASSERT( iType == gtMultipoint || nPoints == nDims );
Q_ASSERT( iType == gtMultiPoint || nPoints == nDims );

int wkbSize = 0;

Expand Down Expand Up @@ -2696,7 +2700,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index )
}

Q_ASSERT( nPolygons > 0 );
Q_ASSERT( nRings.size() >= nPolygons );
Q_ASSERT( nRings >= nPolygons );
Q_ASSERT( nPoints % nDims == 0 );

qDebug() << "polygon" << nPolygons << "rings" << nRings << "points" << nPoints;
Expand Down Expand Up @@ -3264,9 +3268,11 @@ void QOCISpatialResult::virtual_hook( int id, void *data )

switch ( id )
{
#if QT_VERSION < 0x050000
case QSqlResult::BatchOperation:
QOCISpatialCols::execBatch( d, boundValues(), *reinterpret_cast<bool *>( data ) );
break;
#endif
default:
QSqlCachedResult::virtual_hook( id, data );
}
Expand Down Expand Up @@ -3356,6 +3362,9 @@ bool QOCISpatialDriver::hasFeature( DriverFeature f ) const
case EventNotifications:
case FinishQuery:
case MultipleResultSets:
#if QT_VERSION >= 0x050000
case CancelQuery:
#endif
return false;
case Unicode:
return d->serverVersion >= 9;
Expand Down
2 changes: 2 additions & 0 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -237,6 +237,7 @@ QString QgsOracleProvider::storageType() const
return "Oracle database with locator/spatial extension";
}

#if QT_VERSION < 0x050000
static bool operator<( const QVariant &a, const QVariant &b )
{
if ( a.isNull() || b.isNull() )
Expand Down Expand Up @@ -313,6 +314,7 @@ static bool operator<( const QVariant &a, const QVariant &b )

return a.canConvert( QVariant::String ) && b.canConvert( QVariant::String ) && a.toString() < b.toString();
}
#endif


QString QgsOracleProvider::pkParamWhereClause() const
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qspatialite/CMakeLists.txt
Expand Up @@ -9,7 +9,7 @@ ADD_DEFINITIONS(-DQT_SHARED)
INCLUDE_DIRECTORIES(SYSTEM ${SQLITE3_INCLUDE_DIR})

SET(QSQLSPATIALITE_SRC qsql_spatialite.cpp smain.cpp)
QT4_WRAP_CPP(QSQLSPATIALITE_SRC qsql_spatialite.h)
QT4_WRAP_CPP(QSQLSPATIALITE_SRC qsql_spatialite.h smain.h)

ADD_LIBRARY(qsqlspatialite SHARED ${QSQLSPATIALITE_SRC})
TARGET_LINK_LIBRARIES(qsqlspatialite
Expand Down
23 changes: 3 additions & 20 deletions src/providers/spatialite/qspatialite/smain.cpp
Expand Up @@ -39,24 +39,9 @@
**
****************************************************************************/

#include <qsqldriverplugin.h>
#include <qstringlist.h>
#include "smain.h"
#include "qsql_spatialite.h"

QT_BEGIN_NAMESPACE

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

QSqlDriver* create(const QString &);
QStringList keys() const;
};

QSpatiaLiteDriverPlugin::QSpatiaLiteDriverPlugin()
: QSqlDriverPlugin()
{
Expand All @@ -79,8 +64,6 @@ QStringList QSpatiaLiteDriverPlugin::keys() const
}

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

QT_END_NAMESPACE

0 comments on commit 2cc83ff

Please sign in to comment.