Skip to content

Commit 2cc83ff

Browse files
committed
port sqldrivers ocispatial and qspatialite to qt5
1 parent 5902f0e commit 2cc83ff

File tree

7 files changed

+88
-38
lines changed

7 files changed

+88
-38
lines changed

src/providers/oracle/ocispatial/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ADD_DEFINITIONS(-DQT_SHARED)
1212
INCLUDE_DIRECTORIES(SYSTEM ${OCI_INCLUDE_DIR})
1313

1414
SET(QSQLOCISPATIAL_SRC qsql_ocispatial.cpp main.cpp)
15-
QT4_WRAP_CPP(QSQLOCISPATIAL_SRC qsql_ocispatial.h)
15+
QT4_WRAP_CPP(QSQLOCISPATIAL_SRC qsql_ocispatial.h main.h)
1616

1717
ADD_LIBRARY(qsqlocispatial SHARED ${QSQLOCISPATIAL_SRC})
1818

src/providers/oracle/ocispatial/main.cpp

+5-14
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,11 @@
4141
**
4242
****************************************************************************/
4343

44-
#include <qsqldriverplugin.h>
45-
#include <qstringlist.h>
44+
#include "main.h"
4645
#include "qsql_ocispatial.h"
4746

4847
QT_BEGIN_NAMESPACE
4948

50-
class QOCISpatialDriverPlugin : public QSqlDriverPlugin
51-
{
52-
public:
53-
QOCISpatialDriverPlugin();
54-
55-
QSqlDriver* create( const QString & );
56-
QStringList keys() const;
57-
};
58-
5949
QOCISpatialDriverPlugin::QOCISpatialDriverPlugin()
6050
: QSqlDriverPlugin()
6151
{
@@ -74,12 +64,13 @@ QSqlDriver* QOCISpatialDriverPlugin::create( const QString &name )
7464
QStringList QOCISpatialDriverPlugin::keys() const
7565
{
7666
QStringList l;
77-
l.append( QLatin1String( "QOCISPATIAL8" ) );
78-
l.append( QLatin1String( "QOCISPATIAL" ) );
67+
l << QLatin1String( "QOCISPATIAL8" ) << QLatin1String( "QOCISPATIAL" );
7968
return l;
8069
}
8170

71+
#if QT_VERSION < 0x050000
8272
Q_EXPORT_STATIC_PLUGIN( QOCISpatialDriverPlugin )
83-
Q_EXPORT_PLUGIN2( qsqloci, QOCISpatialDriverPlugin )
73+
Q_EXPORT_PLUGIN2( qsqlocispatial, QOCISpatialDriverPlugin )
74+
#endif
8475

8576
QT_END_NAMESPACE
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4+
** Contact: http://www.qt-project.org/legal
5+
**
6+
** This file is part of the plugins of the Qt Toolkit.
7+
**
8+
** $QT_BEGIN_LICENSE:LGPL$
9+
** Commercial License Usage
10+
** Licensees holding valid commercial Qt licenses may use this file in
11+
** accordance with the commercial license agreement provided with the
12+
** Software or, alternatively, in accordance with the terms contained in
13+
** a written agreement between you and Digia. For licensing terms and
14+
** conditions see http://qt.digia.com/licensing. For further information
15+
** use the contact form at http://qt.digia.com/contact-us.
16+
**
17+
** GNU Lesser General Public License Usage
18+
** Alternatively, this file may be used under the terms of the GNU Lesser
19+
** General Public License version 2.1 as published by the Free Software
20+
** Foundation and appearing in the file LICENSE.LGPL included in the
21+
** packaging of this file. Please review the following information to
22+
** ensure the GNU Lesser General Public License version 2.1 requirements
23+
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24+
**
25+
** In addition, as a special exception, Digia gives you certain additional
26+
** rights. These rights are described in the Digia Qt LGPL Exception
27+
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28+
**
29+
** GNU General Public License Usage
30+
** Alternatively, this file may be used under the terms of the GNU
31+
** General Public License version 3.0 as published by the Free Software
32+
** Foundation and appearing in the file LICENSE.GPL included in the
33+
** packaging of this file. Please review the following information to
34+
** ensure the GNU General Public License version 3.0 requirements will be
35+
** met: http://www.gnu.org/copyleft/gpl.html.
36+
**
37+
**
38+
** $QT_END_LICENSE$
39+
**
40+
** Oracle Spatial Support: (C) 2012-2013 Juergen E. Fischer < jef at norbit dot de >, norBIT GmbH
41+
**
42+
****************************************************************************/
43+
44+
#ifndef QOCISPATIAL_MAIN_H
45+
#define QOCISPATIAL_MAIN_H
46+
47+
#include <QSqlDriverPlugin>
48+
#include <QStringList>
49+
50+
#if QT_VERSION < 0x050000
51+
#define Q_PLUGIN_METADATA(x)
52+
#endif
53+
54+
class QOCISpatialDriverPlugin : public QSqlDriverPlugin
55+
{
56+
Q_OBJECT
57+
Q_PLUGIN_METADATA( IID "org.qt-project.Qt.QSqlDriverFactoryInterface" FILE "qocispatial.json" )
58+
public:
59+
QOCISpatialDriverPlugin();
60+
61+
QSqlDriver* create( const QString & );
62+
QStringList keys() const;
63+
};
64+
65+
#endif

src/providers/oracle/ocispatial/qsql_ocispatial.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
#define QOCISPATIAL_THREADED
9595

9696

97+
#if QT_VERSION >= 0x050000
98+
Q_DECLARE_OPAQUE_POINTER( OCIEnv* )
99+
Q_DECLARE_OPAQUE_POINTER( OCIStmt* )
100+
#endif
97101
Q_DECLARE_METATYPE( OCIEnv* )
98102
Q_DECLARE_METATYPE( OCIStmt* )
99103

@@ -2525,7 +2529,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index )
25252529
}
25262530

25272531
Q_ASSERT( nPoints % nDims == 0 );
2528-
Q_ASSERT( iType == gtMultipoint || nPoints == nDims );
2532+
Q_ASSERT( iType == gtMultiPoint || nPoints == nDims );
25292533

25302534
int wkbSize = 0;
25312535

@@ -2696,7 +2700,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v, int index )
26962700
}
26972701

26982702
Q_ASSERT( nPolygons > 0 );
2699-
Q_ASSERT( nRings.size() >= nPolygons );
2703+
Q_ASSERT( nRings >= nPolygons );
27002704
Q_ASSERT( nPoints % nDims == 0 );
27012705

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

32653269
switch ( id )
32663270
{
3271+
#if QT_VERSION < 0x050000
32673272
case QSqlResult::BatchOperation:
32683273
QOCISpatialCols::execBatch( d, boundValues(), *reinterpret_cast<bool *>( data ) );
32693274
break;
3275+
#endif
32703276
default:
32713277
QSqlCachedResult::virtual_hook( id, data );
32723278
}
@@ -3356,6 +3362,9 @@ bool QOCISpatialDriver::hasFeature( DriverFeature f ) const
33563362
case EventNotifications:
33573363
case FinishQuery:
33583364
case MultipleResultSets:
3365+
#if QT_VERSION >= 0x050000
3366+
case CancelQuery:
3367+
#endif
33593368
return false;
33603369
case Unicode:
33613370
return d->serverVersion >= 9;

src/providers/oracle/qgsoracleprovider.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ QString QgsOracleProvider::storageType() const
237237
return "Oracle database with locator/spatial extension";
238238
}
239239

240+
#if QT_VERSION < 0x050000
240241
static bool operator<( const QVariant &a, const QVariant &b )
241242
{
242243
if ( a.isNull() || b.isNull() )
@@ -313,6 +314,7 @@ static bool operator<( const QVariant &a, const QVariant &b )
313314

314315
return a.canConvert( QVariant::String ) && b.canConvert( QVariant::String ) && a.toString() < b.toString();
315316
}
317+
#endif
316318

317319

318320
QString QgsOracleProvider::pkParamWhereClause() const

src/providers/spatialite/qspatialite/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ADD_DEFINITIONS(-DQT_SHARED)
99
INCLUDE_DIRECTORIES(SYSTEM ${SQLITE3_INCLUDE_DIR})
1010

1111
SET(QSQLSPATIALITE_SRC qsql_spatialite.cpp smain.cpp)
12-
QT4_WRAP_CPP(QSQLSPATIALITE_SRC qsql_spatialite.h)
12+
QT4_WRAP_CPP(QSQLSPATIALITE_SRC qsql_spatialite.h smain.h)
1313

1414
ADD_LIBRARY(qsqlspatialite SHARED ${QSQLSPATIALITE_SRC})
1515
TARGET_LINK_LIBRARIES(qsqlspatialite

src/providers/spatialite/qspatialite/smain.cpp

+3-20
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,9 @@
3939
**
4040
****************************************************************************/
4141

42-
#include <qsqldriverplugin.h>
43-
#include <qstringlist.h>
42+
#include "smain.h"
4443
#include "qsql_spatialite.h"
4544

46-
QT_BEGIN_NAMESPACE
47-
48-
class QSpatiaLiteDriverPlugin : public QSqlDriverPlugin
49-
{
50-
#if QT_VERSION >= 0x050000
51-
Q_PLUGIN_METADATA(IID "org.qgis.QSpatiaLiteDriverPlugin")
52-
#endif
53-
public:
54-
QSpatiaLiteDriverPlugin();
55-
56-
QSqlDriver* create(const QString &);
57-
QStringList keys() const;
58-
};
59-
6045
QSpatiaLiteDriverPlugin::QSpatiaLiteDriverPlugin()
6146
: QSqlDriverPlugin()
6247
{
@@ -79,8 +64,6 @@ QStringList QSpatiaLiteDriverPlugin::keys() const
7964
}
8065

8166
#if QT_VERSION < 0x050000
82-
Q_EXPORT_STATIC_PLUGIN(QSpatiaLiteDriverPlugin)
83-
Q_EXPORT_PLUGIN2(qspatialite, QSpatiaLiteDriverPlugin)
67+
Q_EXPORT_STATIC_PLUGIN( QSpatiaLiteDriverPlugin )
68+
Q_EXPORT_PLUGIN2( qspatialite, QSpatiaLiteDriverPlugin )
8469
#endif
85-
86-
QT_END_NAMESPACE

0 commit comments

Comments
 (0)