| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| : GPL \(v[23] or later\)$ | ||
| : GPL \(v2 or later\) GENERATED FILE$ | ||
| : \*No copyright\* LGPL \(v2\.1 or later\)$ | ||
| : GPL LGPL$ | ||
| : LGPL$ | ||
| : Apache \(v2\.0\)$ | ||
| : GPL \(v2\)$ | ||
| : LGPL \(v2 or later\)$ | ||
| : Apache \(v2.0\) GPL \(v2 or later\)$ | ||
| : MIT\/X11 \(BSD like\)$ | ||
| : MPL \(v1\.1\) GPL \(unversioned\/unknown version\)$ | ||
| : LGPL \(v2\.1\)$ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ######################################################## | ||
| # Files | ||
|
|
||
| ADD_SUBDIRECTORY(ocispatial) | ||
|
|
||
| SET(ORACLE_SRCS | ||
| qgsoracleprovider.cpp | ||
| qgsoracleconn.cpp | ||
| qgsoracledataitems.cpp | ||
| qgsoraclesourceselect.cpp | ||
| qgsoraclenewconnection.cpp | ||
| qgsoracletablemodel.cpp | ||
| qgsoraclecolumntypethread.cpp | ||
| ) | ||
|
|
||
| SET(ORACLE_MOC_HDRS | ||
| qgsoracleprovider.h | ||
| qgsoracleconn.h | ||
| qgsoracledataitems.h | ||
| qgsoraclesourceselect.h | ||
| qgsoraclenewconnection.h | ||
| qgsoracletablemodel.h | ||
| qgsoraclecolumntypethread.h | ||
| ) | ||
|
|
||
|
|
||
| ######################################################## | ||
| # Build | ||
|
|
||
| QT4_WRAP_CPP(ORACLE_MOC_SRCS ${ORACLE_MOC_HDRS}) | ||
|
|
||
| INCLUDE_DIRECTORIES( | ||
| ../../core | ||
| ../../gui | ||
| ${GEOS_INCLUDE_DIR} | ||
| ${CMAKE_CURRENT_BINARY_DIR}/../../ui | ||
| ${QT_QTSQL_INCLUDEDIR} | ||
| ) | ||
|
|
||
| ADD_LIBRARY (oracleprovider MODULE ${ORACLE_SRCS} ${ORACLE_MOC_SRCS}) | ||
|
|
||
| TARGET_LINK_LIBRARIES (oracleprovider | ||
| qgis_core | ||
| qgis_gui | ||
| ${QT_QTSQL_LIBRARY} | ||
| ) | ||
|
|
||
|
|
||
| ######################################################## | ||
| # Install | ||
|
|
||
| INSTALL(TARGETS oracleprovider | ||
| RUNTIME DESTINATION ${QGIS_PLUGIN_DIR} | ||
| LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) | ||
| SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR}/sqldrivers) | ||
| SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR}/sqldrivers) | ||
|
|
||
| FIND_PACKAGE(OCI) | ||
|
|
||
| ADD_DEFINITIONS(${QT_DEFINITIONS}) | ||
| ADD_DEFINITIONS(-DQT_PLUGIN) | ||
| ADD_DEFINITIONS(-DQT_NO_DEBUG) | ||
| ADD_DEFINITIONS(-DQT_SHARED) | ||
|
|
||
| INCLUDE_DIRECTORIES(${OCI_INCLUDE_DIR}) | ||
|
|
||
| SET(QSQLOCISPATIAL_SRC qsql_ocispatial.cpp main.cpp) | ||
| QT4_WRAP_CPP(QSQLOCISPATIAL_SRC qsql_ocispatial.h) | ||
|
|
||
| ADD_LIBRARY(qsqlocispatial SHARED ${QSQLOCISPATIAL_SRC}) | ||
|
|
||
| TARGET_LINK_LIBRARIES(qsqlocispatial | ||
| ${QT_QTCORE_LIBRARY} | ||
| ${QT_QTSQL_LIBRARY} | ||
| ${OCI_LIBRARY} | ||
| ) | ||
|
|
||
| IF(MSVC) | ||
| TARGET_LINK_LIBRARIES(qsqlocispatial wsock32) | ||
| ENDIF(MSVC) | ||
|
|
||
| INSTALL(TARGETS qsqlocispatial | ||
| RUNTIME DESTINATION ${QT_PLUGINS_DIR}/sqldrivers | ||
| LIBRARY DESTINATION ${QT_PLUGINS_DIR}/sqldrivers | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| QOCISPATIAL driver derived from QOCI driver. | ||
|
|
||
| You will need the Oracle development headers and libraries installed | ||
| before compiling this plugin. | ||
|
|
||
| See the Qt SQL documentation for more information on compiling Qt SQL | ||
| driver plugins (sql-driver.html). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # ~~~~~~~~~~ | ||
| # Copyright (c) 2012, Juergen E. Fischer <jef at norbit dot de> | ||
| # Redistribution and use is allowed according to the terms of the BSD license. | ||
| # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
| # | ||
| # CMake module to search for OCI library | ||
| # | ||
| # If it's found it sets OCI_FOUND to TRUE | ||
| # and following variables are set: | ||
| # OCI_INCLUDE_DIR | ||
| # OCI_LIBRARY | ||
|
|
||
| FIND_PATH(OCI_INCLUDE_DIR oci.h | ||
| PATHS | ||
| /usr/include/oracle/11.2/client64 | ||
| $ENV{OSGEO4W_ROOT}/include | ||
| $ENV{ORACLE_HOME}/rdbms/public | ||
| ) | ||
|
|
||
| FIND_LIBRARY(OCI_LIBRARY clntsh oci | ||
| PATHS | ||
| /usr/lib/oracle/11.2/client64/lib/ | ||
| $ENV{OSGEO4W_ROOT}/lib | ||
| $ENV{ORACLE_HOME}/lib | ||
| ) | ||
|
|
||
| IF (OCI_INCLUDE_DIR) | ||
| SET(OCI_FOUND TRUE) | ||
| ELSE (OCI_INCLUDE_DIR) | ||
| SET(OCI_FOUND FALSE) | ||
| ENDIF(OCI_INCLUDE_DIR) | ||
|
|
||
| IF (OCI_FOUND) | ||
| IF (NOT OCI_FIND_QUIETLY) | ||
| MESSAGE(STATUS "Found OCI: ${OCI_LIBRARY}") | ||
| ENDIF (NOT OCI_FIND_QUIETLY) | ||
| ELSE (OCI_FOUND) | ||
| IF (OCI_FIND_REQUIRED) | ||
| MESSAGE(FATAL_ERROR "Could not find OCI") | ||
| ELSE (OCI_FIND_REQUIRED) | ||
| IF (NOT OCI_FIND_QUIETLY) | ||
| MESSAGE(STATUS "Could not find OCI") | ||
| ENDIF (NOT OCI_FIND_QUIETLY) | ||
| ENDIF (OCI_FIND_REQUIRED) | ||
| ENDIF (OCI_FOUND) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /**************************************************************************** | ||
| ** | ||
| ** 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 | ||
| ** | ||
| ****************************************************************************/ | ||
|
|
||
| #include <qsqldriverplugin.h> | ||
| #include <qstringlist.h> | ||
| #include "qsql_ocispatial.h" | ||
|
|
||
| QT_BEGIN_NAMESPACE | ||
|
|
||
| class QOCISpatialDriverPlugin : public QSqlDriverPlugin | ||
| { | ||
| public: | ||
| QOCISpatialDriverPlugin(); | ||
|
|
||
| QSqlDriver* create( const QString & ); | ||
| QStringList keys() const; | ||
| }; | ||
|
|
||
| QOCISpatialDriverPlugin::QOCISpatialDriverPlugin() | ||
| : QSqlDriverPlugin() | ||
| { | ||
| } | ||
|
|
||
| QSqlDriver* QOCISpatialDriverPlugin::create( const QString &name ) | ||
| { | ||
| if ( name == QLatin1String( "QOCISPATIAL" ) || name == QLatin1String( "QOCISPATIAL8" ) ) | ||
| { | ||
| QOCISpatialDriver* driver = new QOCISpatialDriver(); | ||
| return driver; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| QStringList QOCISpatialDriverPlugin::keys() const | ||
| { | ||
| QStringList l; | ||
| l.append( QLatin1String( "QOCISPATIAL8" ) ); | ||
| l.append( QLatin1String( "QOCISPATIAL" ) ); | ||
| return l; | ||
| } | ||
|
|
||
| Q_EXPORT_STATIC_PLUGIN( QOCISpatialDriverPlugin ) | ||
| Q_EXPORT_PLUGIN2( qsqloci, QOCISpatialDriverPlugin ) | ||
|
|
||
| QT_END_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| /**************************************************************************** | ||
| ** | ||
| ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | ||
| ** Contact: http://www.qt-project.org/legal | ||
| ** | ||
| ** This file is part of the QtSql module 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$ | ||
| ** | ||
| ****************************************************************************/ | ||
|
|
||
| #ifndef QSQL_OCISPATIAL_H | ||
| #define QSQL_OCISPATIAL_H | ||
|
|
||
| #include <QtSql/qsqlresult.h> | ||
| #include <QtSql/qsqldriver.h> | ||
| #include "qsqlcachedresult_p.h" | ||
|
|
||
| #ifdef QT_PLUGIN | ||
| #define Q_EXPORT_SQLDRIVER_OCISPATIAL | ||
| #else | ||
| #define Q_EXPORT_SQLDRIVER_OCISPATIAL Q_SQL_EXPORT | ||
| #endif | ||
|
|
||
| QT_BEGIN_HEADER | ||
|
|
||
| typedef struct OCIEnv OCIEnv; | ||
| typedef struct OCISvcCtx OCISvcCtx; | ||
|
|
||
| QT_BEGIN_NAMESPACE | ||
|
|
||
| class QOCISpatialDriver; | ||
| class QOCISpatialCols; | ||
| struct QOCISpatialDriverPrivate; | ||
| struct QOCISpatialResultPrivate; | ||
|
|
||
| class Q_EXPORT_SQLDRIVER_OCISPATIAL QOCISpatialResult : public QSqlCachedResult | ||
| { | ||
| friend class QOCISpatialDriver; | ||
| friend struct QOCISpatialResultPrivate; | ||
| friend class QOCISpatialCols; | ||
| public: | ||
| QOCISpatialResult( const QOCISpatialDriver * db, const QOCISpatialDriverPrivate* p ); | ||
| ~QOCISpatialResult(); | ||
| bool prepare( const QString& query ); | ||
| bool exec(); | ||
| QVariant handle() const; | ||
|
|
||
| protected: | ||
| bool gotoNext( ValueCache &values, int index ); | ||
| bool reset( const QString& query ); | ||
| int size(); | ||
| int numRowsAffected(); | ||
| QSqlRecord record() const; | ||
| QVariant lastInsertId() const; | ||
| void virtual_hook( int id, void *data ); | ||
|
|
||
| private: | ||
| QOCISpatialResultPrivate *d; | ||
| }; | ||
|
|
||
| class Q_EXPORT_SQLDRIVER_OCISPATIAL QOCISpatialDriver : public QSqlDriver | ||
| { | ||
| Q_OBJECT | ||
| friend struct QOCISpatialResultPrivate; | ||
| friend class QOCISpatialPrivate; | ||
| public: | ||
| explicit QOCISpatialDriver( QObject* parent = 0 ); | ||
| QOCISpatialDriver( OCIEnv* env, OCISvcCtx* ctx, QObject* parent = 0 ); | ||
| ~QOCISpatialDriver(); | ||
| bool hasFeature( DriverFeature f ) const; | ||
| bool open( const QString & db, | ||
| const QString & user, | ||
| const QString & password, | ||
| const QString & host, | ||
| int port, | ||
| const QString& connOpts ); | ||
| void close(); | ||
| QSqlResult *createResult() const; | ||
| QStringList tables( QSql::TableType ) const; | ||
| QSqlRecord record( const QString& tablename ) const; | ||
| QSqlIndex primaryIndex( const QString& tablename ) const; | ||
| QString formatValue( const QSqlField &field, | ||
| bool trimStrings ) const; | ||
| QVariant handle() const; | ||
| QString escapeIdentifier( const QString &identifier, IdentifierType ) const; | ||
|
|
||
| protected: | ||
| bool beginTransaction(); | ||
| bool commitTransaction(); | ||
| bool rollbackTransaction(); | ||
| private: | ||
| QOCISpatialDriverPrivate *d; | ||
| }; | ||
|
|
||
| QT_END_NAMESPACE | ||
|
|
||
| QT_END_HEADER | ||
|
|
||
| #endif // QSQL_OCISPATIAL_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /**************************************************************************** | ||
| ** | ||
| ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | ||
| ** Contact: http://www.qt-project.org/legal | ||
| ** | ||
| ** This file is part of the QtSql module 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$ | ||
| ** | ||
| ****************************************************************************/ | ||
|
|
||
| #ifndef QSQLCACHEDRESULT_P_H | ||
| #define QSQLCACHEDRESULT_P_H | ||
|
|
||
| // | ||
| // W A R N I N G | ||
| // ------------- | ||
| // | ||
| // This file is not part of the Qt API. It exists for the convenience | ||
| // of other Qt classes. This header file may change from version to | ||
| // version without notice, or even be removed. | ||
| // | ||
| // We mean it. | ||
| // | ||
|
|
||
| #include "QtSql/qsqlresult.h" | ||
|
|
||
| QT_BEGIN_NAMESPACE | ||
|
|
||
| class QVariant; | ||
| template <typename T> class QVector; | ||
|
|
||
| class QSqlCachedResultPrivate; | ||
|
|
||
| class Q_SQL_EXPORT QSqlCachedResult: public QSqlResult | ||
| { | ||
| public: | ||
| virtual ~QSqlCachedResult(); | ||
|
|
||
| typedef QVector<QVariant> ValueCache; | ||
|
|
||
| protected: | ||
| QSqlCachedResult( const QSqlDriver * db ); | ||
|
|
||
| void init( int colCount ); | ||
| void cleanup(); | ||
| void clearValues(); | ||
|
|
||
| virtual bool gotoNext( ValueCache &values, int index ) = 0; | ||
|
|
||
| QVariant data( int i ); | ||
| bool isNull( int i ); | ||
| bool fetch( int i ); | ||
| bool fetchNext(); | ||
| bool fetchPrevious(); | ||
| bool fetchFirst(); | ||
| bool fetchLast(); | ||
|
|
||
| int colCount() const; | ||
| ValueCache &cache(); | ||
|
|
||
| void virtual_hook( int id, void *data ); | ||
| private: | ||
| bool cacheNext(); | ||
| QSqlCachedResultPrivate *d; | ||
| }; | ||
|
|
||
| QT_END_NAMESPACE | ||
|
|
||
| #endif // QSQLCACHEDRESULT_P_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /*************************************************************************** | ||
| wkbptr.h | ||
| --------------------- | ||
| begin : Dezember 2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| *************************************************************************** | ||
| * * | ||
| * 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. * | ||
| * * | ||
| ***************************************************************************/ | ||
| #ifndef WKBPTR_H | ||
| #define WKBPTR_H | ||
|
|
||
| #include <QSharedData> | ||
|
|
||
| union wkbPtr | ||
| { | ||
| void *vPtr; | ||
| double *dPtr; | ||
| int *iPtr; | ||
| unsigned char *ucPtr; | ||
| char *cPtr; | ||
|
|
||
| }; | ||
|
|
||
| const int SDO_ARRAY_SIZE = 1024; | ||
|
|
||
| #define SDO_GTYPE_D(g) (g/1000%10) | ||
| #define SDO_GTYPE_L(g) (g/100%10) | ||
| #define SDO_GTYPE_TT(g) (g%100) | ||
| #define SDO_GTYPE(g,tt) (g*1000+tt) | ||
|
|
||
| enum SDO_GTYPE_TT | ||
| { | ||
| gtUnknown = 0, | ||
| gtPoint = 1, | ||
| gtLine = 2, | ||
| gtPolygon = 3, | ||
| gtCollection = 4, | ||
| gtMultiPoint = 5, | ||
| gtMultiLine = 6, | ||
| gtMultiPolygon = 7, | ||
| }; | ||
|
|
||
|
|
||
| class QOCISpatialGeometry : public QSharedData | ||
| { | ||
| public: | ||
| bool isNull; | ||
| int gtype; | ||
| int srid; | ||
| double x, y, z; | ||
|
|
||
| QVector<int> eleminfo; | ||
| QVector<double> ordinates; | ||
| }; | ||
|
|
||
| Q_DECLARE_METATYPE( QOCISpatialGeometry ); | ||
|
|
||
| #endif // WKBPTR_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /*************************************************************************** | ||
| qgscolumntypethread.cpp - lookup oracle geometry type and srid in a thread | ||
| ------------------- | ||
| begin : 3.1.2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "qgsoraclecolumntypethread.h" | ||
|
|
||
| #include <QMetaType> | ||
|
|
||
| QgsOracleColumnTypeThread::QgsOracleColumnTypeThread( QgsOracleConn *conn, bool useEstimatedMetaData ) | ||
| : QThread() | ||
| , mConn( conn ) | ||
| , mUseEstimatedMetadata( useEstimatedMetaData ) | ||
| { | ||
| qRegisterMetaType<QgsOracleLayerProperty>( "QgsOracleLayerProperty" ); | ||
| } | ||
|
|
||
| void QgsOracleColumnTypeThread::addGeometryColumn( QgsOracleLayerProperty layerProperty ) | ||
| { | ||
| layerProperties << layerProperty; | ||
| } | ||
|
|
||
| void QgsOracleColumnTypeThread::stop() | ||
| { | ||
| mStopped = true; | ||
| } | ||
|
|
||
| void QgsOracleColumnTypeThread::run() | ||
| { | ||
| if ( !mConn ) | ||
| return; | ||
|
|
||
| mStopped = false; | ||
|
|
||
| foreach ( QgsOracleLayerProperty layerProperty, layerProperties ) | ||
| { | ||
| if ( !mStopped ) | ||
| { | ||
| mConn->retrieveLayerTypes( layerProperty, mUseEstimatedMetadata ); | ||
| } | ||
|
|
||
| if ( mStopped ) | ||
| { | ||
| layerProperty.types.clear(); | ||
| layerProperty.srids.clear(); | ||
| } | ||
|
|
||
| // Now tell the layer list dialog box... | ||
| emit setLayerType( layerProperty ); | ||
| } | ||
|
|
||
| mConn->disconnect(); | ||
| mConn = 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /*************************************************************************** | ||
| qgsoraclecolumntypethread.cpp - lookup oracle geometry type and srid in a thread | ||
| ------------------- | ||
| begin : 12.12.2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
| #ifndef QGSORACLECOLUMNTYPETHREAD_H | ||
| #define QGSORACLECOLUMNTYPETHREAD_H | ||
|
|
||
| #include <QThread> | ||
| #include "qgsoracleconn.h" | ||
|
|
||
| // A class that determines the geometry type of a given database | ||
| // schema.table.column, with the option of doing so in a separate | ||
| // thread. | ||
|
|
||
| class QgsOracleColumnTypeThread : public QThread | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| QgsOracleColumnTypeThread( QgsOracleConn *conn, bool useEstimatedMetaData ); | ||
|
|
||
| // These functions get the layer types and pass that information out | ||
| // by emitting the setLayerType() signal. | ||
| virtual void run(); | ||
|
|
||
| signals: | ||
| void setLayerType( QgsOracleLayerProperty layerProperty ); | ||
|
|
||
| public slots: | ||
| void addGeometryColumn( QgsOracleLayerProperty layerProperty ); | ||
| void stop(); | ||
|
|
||
| private: | ||
| QgsOracleColumnTypeThread() {} | ||
|
|
||
| QgsOracleConn *mConn; | ||
| bool mUseEstimatedMetadata; | ||
| bool mStopped; | ||
| QList<QgsOracleLayerProperty> layerProperties; | ||
| }; | ||
|
|
||
| #endif // QGSORACLECOLUMNTYPETHREAD_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| /*************************************************************************** | ||
| qgsoracleconn.h - connection class to Oracle | ||
| ------------------- | ||
| begin : August 2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef QGSORACLECONN_H | ||
| #define QGSORACLECONN_H | ||
|
|
||
| #include <QString> | ||
| #include <QStringList> | ||
| #include <QVector> | ||
| #include <QMap> | ||
| #include <QSet> | ||
| #include <QThread> | ||
|
|
||
| #include "qgis.h" | ||
| #include "qgsdatasourceuri.h" | ||
|
|
||
| #include <QSqlDatabase> | ||
| #include <QSqlQuery> | ||
|
|
||
| class QgsField; | ||
|
|
||
| // Oracle layer properties | ||
| struct QgsOracleLayerProperty | ||
| { | ||
| QList<QGis::WkbType> types; | ||
| QList<int> srids; | ||
| QString ownerName; | ||
| QString tableName; | ||
| QString geometryColName; | ||
| bool isView; | ||
| QStringList pkCols; | ||
| QString sql; | ||
|
|
||
| int size() { Q_ASSERT( types.size() == srids.size() ); return types.size(); } | ||
|
|
||
| QgsOracleLayerProperty at( int i ) | ||
| { | ||
| QgsOracleLayerProperty property; | ||
|
|
||
| Q_ASSERT( i >= 0 && i < size() ); | ||
|
|
||
| property.types << types.at( i ); | ||
| property.srids << srids.at( i ); | ||
| property.ownerName = ownerName; | ||
| property.tableName = tableName; | ||
| property.geometryColName = geometryColName; | ||
| property.isView = isView; | ||
| property.pkCols = pkCols; | ||
| property.sql = sql; | ||
|
|
||
| return property; | ||
| } | ||
|
|
||
| #if QGISDEBUG | ||
| QString toString() | ||
| { | ||
| QString typeString; | ||
| foreach ( QGis::WkbType type, types ) | ||
| { | ||
| if ( !typeString.isEmpty() ) | ||
| typeString += "|"; | ||
| typeString += QString::number( type ); | ||
| } | ||
| QString sridString; | ||
| foreach ( int srid, srids ) | ||
| { | ||
| if ( !sridString.isEmpty() ) | ||
| sridString += "|"; | ||
| sridString += QString::number( srid ); | ||
| } | ||
|
|
||
| return QString( "%1.%2.%3 type=%4 srid=%5 view=%6 sql=%7" ) | ||
| .arg( ownerName ) | ||
| .arg( tableName ) | ||
| .arg( geometryColName ) | ||
| .arg( typeString ) | ||
| .arg( sridString ) | ||
| .arg( isView ? "yes" : "no" ) | ||
| .arg( sql ); | ||
| } | ||
| #endif | ||
| }; | ||
|
|
||
| class QgsOracleConn : public QThread | ||
| { | ||
| Q_OBJECT; | ||
|
|
||
| public: | ||
| static QgsOracleConn *connectDb( QgsDataSourceURI uri ); | ||
| void disconnect(); | ||
|
|
||
| /** Double quote a Oracle identifier for placement in a SQL string. | ||
| */ | ||
| static QString quotedIdentifier( QString ident ); | ||
|
|
||
| /** Quote a value for placement in a SQL string. | ||
| */ | ||
| static QString quotedValue( QVariant value ); | ||
|
|
||
| //! Get the list of usable to check | ||
| bool supportedLayers( QVector<QgsOracleLayerProperty> &layers, | ||
| bool geometryTablesOnly, | ||
| bool userTablesOnly = true, | ||
| bool allowGeometrylessTables = false ); | ||
|
|
||
| void retrieveLayerTypes( QgsOracleLayerProperty &layerProperty, bool useEstimatedMetadata ); | ||
|
|
||
| /** Gets information about the spatial tables */ | ||
| bool tableInfo( bool geometryTablesOnly, bool userTablesOnly, bool allowGeometrylessTables ); | ||
|
|
||
| /** get primary key candidates (all int4 columns) */ | ||
| QStringList pkCandidates( QString ownerName, QString viewName ); | ||
|
|
||
| QString fieldExpression( const QgsField &fld ); | ||
|
|
||
| QString connInfo(); | ||
|
|
||
| QString currentUser(); | ||
|
|
||
| bool hasSpatial(); | ||
|
|
||
| static const int sGeomTypeSelectLimit; | ||
|
|
||
| static QString displayStringForWkbType( QGis::WkbType wkbType ); | ||
| static QGis::WkbType wkbTypeFromDatabase( int gtype ); | ||
|
|
||
| static QString databaseTypeFilter( QString alias, QString geomCol, QGis::WkbType wkbType ); | ||
|
|
||
| static QGis::WkbType wkbTypeFromGeomType( QGis::GeometryType geomType ); | ||
|
|
||
| static QStringList connectionList(); | ||
| static QString selectedConnection(); | ||
| static void setSelectedConnection( QString theConnName ); | ||
| static QgsDataSourceURI connUri( QString theConnName ); | ||
| static bool userTablesOnly( QString theConnName ); | ||
| static bool allowGeometrylessTables( QString theConnName ); | ||
| static void deleteConnection( QString theConnName ); | ||
| static QString databaseName( QString serviceName, QString host, QString port ); | ||
|
|
||
| operator QSqlDatabase() { return mDatabase; } | ||
|
|
||
| private: | ||
| QgsOracleConn( QgsDataSourceURI uri ); | ||
| ~QgsOracleConn(); | ||
|
|
||
| bool exec( QSqlQuery &qry, QString sql ); | ||
|
|
||
| //! reference count | ||
| int mRef; | ||
|
|
||
| QString mCurrentUser; | ||
|
|
||
| //! has spatial | ||
| int mHasSpatial; | ||
|
|
||
| QSqlDatabase mDatabase; | ||
| QSqlQuery mQuery; | ||
|
|
||
| //! List of the supported layers | ||
| QVector<QgsOracleLayerProperty> mLayersSupported; | ||
|
|
||
| static QMap<QString, QgsOracleConn *> sConnections; | ||
| static int snConnections; | ||
| }; | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /*************************************************************************** | ||
| qgsoracledataitems.h | ||
| --------------------- | ||
| begin : August 2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
| #ifndef QGSORACLEDATAITEMS_H | ||
| #define QGSORACLEDATAITEMS_H | ||
|
|
||
| #include <QSqlDatabase> | ||
|
|
||
| #include "qgsdataitem.h" | ||
|
|
||
| #include "qgsoracletablemodel.h" | ||
| #include "qgsoraclesourceselect.h" | ||
| #include "qgsmimedatautils.h" | ||
| #include "qgsvectorlayerimport.h" | ||
|
|
||
| class QSqlDatabase; | ||
|
|
||
| class QgsOracleRootItem; | ||
| class QgsOracleConnectionItem; | ||
| class QgsOracleOwnerItem; | ||
| class QgsOracleLayerItem; | ||
|
|
||
| class QgsOracleRootItem : public QgsDataCollectionItem | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| QgsOracleRootItem( QgsDataItem* parent, QString name, QString path ); | ||
| ~QgsOracleRootItem(); | ||
|
|
||
| QVector<QgsDataItem*> createChildren(); | ||
|
|
||
| virtual QWidget * paramWidget(); | ||
|
|
||
| virtual QList<QAction*> actions(); | ||
|
|
||
| public slots: | ||
| void connectionsChanged(); | ||
| void newConnection(); | ||
| }; | ||
|
|
||
| class QgsOracleConnectionItem : public QgsDataCollectionItem | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| QgsOracleConnectionItem( QgsDataItem* parent, QString name, QString path ); | ||
| ~QgsOracleConnectionItem(); | ||
|
|
||
| QVector<QgsDataItem*> createChildren(); | ||
| virtual bool equal( const QgsDataItem *other ); | ||
| virtual QList<QAction*> actions(); | ||
|
|
||
| virtual bool acceptDrop() { return true; } | ||
| virtual bool handleDrop( const QMimeData * data, Qt::DropAction action ); | ||
|
|
||
| QgsOracleConn *connection() const { return mConn; } | ||
|
|
||
| void refresh(); | ||
|
|
||
| signals: | ||
| void addGeometryColumn( QgsOracleLayerProperty ); | ||
|
|
||
| public slots: | ||
| void editConnection(); | ||
| void deleteConnection(); | ||
|
|
||
| void setLayerType( QgsOracleLayerProperty layerProperty ); | ||
|
|
||
| private: | ||
| void stop(); | ||
| QgsOracleConn *mConn; | ||
| QMap<QString, QgsOracleOwnerItem * > mOwnerMap; | ||
| QgsOracleColumnTypeThread *mColumnTypeThread; | ||
| }; | ||
|
|
||
| class QgsOracleOwnerItem : public QgsDataCollectionItem | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| QgsOracleOwnerItem( QgsDataItem* parent, QString name, QString path ); | ||
| ~QgsOracleOwnerItem(); | ||
|
|
||
| QVector<QgsDataItem*> createChildren(); | ||
|
|
||
| void addLayer( QgsOracleLayerProperty layerProperty ); | ||
| }; | ||
|
|
||
| class QgsOracleLayerItem : public QgsLayerItem | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| QgsOracleLayerItem( QgsDataItem* parent, QString name, QString path, QgsLayerItem::LayerType layerType, QgsOracleLayerProperty layerProperties ); | ||
| ~QgsOracleLayerItem(); | ||
|
|
||
| QString createUri(); | ||
|
|
||
| virtual QList<QAction*> actions(); | ||
|
|
||
| public slots: | ||
| void deleteLayer(); | ||
|
|
||
| private: | ||
| QgsOracleLayerProperty mLayerProperty; | ||
| }; | ||
|
|
||
| #endif // QGSORACLEDATAITEMS_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| /*************************************************************************** | ||
| qgsoraclenewconnection.cpp - description | ||
| ------------------- | ||
| begin : August 2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include <QSettings> | ||
| #include <QMessageBox> | ||
| #include <QInputDialog> | ||
|
|
||
| #include "qgsoraclenewconnection.h" | ||
| #include "qgscontexthelp.h" | ||
| #include "qgsdatasourceuri.h" | ||
| #include "qgsoracletablemodel.h" | ||
|
|
||
| QgsOracleNewConnection::QgsOracleNewConnection( QWidget *parent, const QString& connName, Qt::WFlags fl ) | ||
| : QDialog( parent, fl ), mOriginalConnName( connName ) | ||
| { | ||
| setupUi( this ); | ||
|
|
||
| if ( !connName.isEmpty() ) | ||
| { | ||
| // populate the dialog with the information stored for the connection | ||
| // populate the fields with the stored setting parameters | ||
| QSettings settings; | ||
|
|
||
| QString key = "/Oracle/connections/" + connName; | ||
| txtDatabase->setText( settings.value( key + "/database" ).toString() ); | ||
| txtHost->setText( settings.value( key + "/host" ).toString() ); | ||
| QString port = settings.value( key + "/port" ).toString(); | ||
| if ( port.length() == 0 ) | ||
| { | ||
| port = "1521"; | ||
| } | ||
| txtPort->setText( port ); | ||
| cb_userTablesOnly->setChecked( settings.value( key + "/userTablesOnly", false ).toBool() ); | ||
| cb_allowGeometrylessTables->setChecked( settings.value( key + "/allowGeometrylessTables", false ).toBool() ); | ||
| cb_useEstimatedMetadata->setChecked( settings.value( key + "/estimatedMetadata", false ).toBool() ); | ||
|
|
||
| if ( settings.value( key + "/saveUsername" ).toString() == "true" ) | ||
| { | ||
| txtUsername->setText( settings.value( key + "/username" ).toString() ); | ||
| chkStoreUsername->setChecked( true ); | ||
| } | ||
|
|
||
| if ( settings.value( key + "/savePassword" ).toString() == "true" ) | ||
| { | ||
| txtPassword->setText( settings.value( key + "/password" ).toString() ); | ||
| chkStorePassword->setChecked( true ); | ||
| } | ||
|
|
||
| // Old save setting | ||
| if ( settings.contains( key + "/save" ) ) | ||
| { | ||
| txtUsername->setText( settings.value( key + "/username" ).toString() ); | ||
| chkStoreUsername->setChecked( !txtUsername->text().isEmpty() ); | ||
|
|
||
| if ( settings.value( key + "/save" ).toString() == "true" ) | ||
| txtPassword->setText( settings.value( key + "/password" ).toString() ); | ||
|
|
||
| chkStorePassword->setChecked( true ); | ||
| } | ||
|
|
||
| txtName->setText( connName ); | ||
| } | ||
| } | ||
| /** Autoconnected SLOTS **/ | ||
| void QgsOracleNewConnection::accept() | ||
| { | ||
| QSettings settings; | ||
| QString baseKey = "/Oracle/connections/"; | ||
| settings.setValue( baseKey + "selected", txtName->text() ); | ||
|
|
||
| if ( chkStorePassword->isChecked() && | ||
| QMessageBox::question( this, | ||
| tr( "Saving passwords" ), | ||
| tr( "WARNING: You have opted to save your password. It will be stored in plain text in your project files and in your home directory on Unix-like systems, or in your user profile on Windows. If you do not want this to happen, please press the Cancel button.\n" ), | ||
| QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // warn if entry was renamed to an existing connection | ||
| if (( mOriginalConnName.isNull() || mOriginalConnName != txtName->text() ) && | ||
| ( settings.contains( baseKey + txtName->text() + "/service" ) || | ||
| settings.contains( baseKey + txtName->text() + "/host" ) ) && | ||
| QMessageBox::question( this, | ||
| tr( "Save connection" ), | ||
| tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ), | ||
| QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // on rename delete the original entry first | ||
| if ( !mOriginalConnName.isNull() && mOriginalConnName != txtName->text() ) | ||
| { | ||
|
|
||
| settings.remove( baseKey + mOriginalConnName ); | ||
| } | ||
|
|
||
| baseKey += txtName->text(); | ||
| settings.setValue( baseKey + "/database", txtDatabase->text() ); | ||
| settings.setValue( baseKey + "/host", txtHost->text() ); | ||
| settings.setValue( baseKey + "/port", txtPort->text() ); | ||
| settings.setValue( baseKey + "/username", chkStoreUsername->isChecked() ? txtUsername->text() : "" ); | ||
| settings.setValue( baseKey + "/password", chkStorePassword->isChecked() ? txtPassword->text() : "" ); | ||
| settings.setValue( baseKey + "/userTablesOnly", cb_userTablesOnly->isChecked() ); | ||
| settings.setValue( baseKey + "/allowGeometrylessTables", cb_allowGeometrylessTables->isChecked() ); | ||
| settings.setValue( baseKey + "/saveUsername", chkStoreUsername->isChecked() ? "true" : "false" ); | ||
| settings.setValue( baseKey + "/savePassword", chkStorePassword->isChecked() ? "true" : "false" ); | ||
| settings.setValue( baseKey + "/estimatedMetadata", cb_useEstimatedMetadata->isChecked() ? "true" : "false" ); | ||
|
|
||
| // remove old save setting | ||
| settings.remove( baseKey + "/save" ); | ||
|
|
||
| QDialog::accept(); | ||
| } | ||
|
|
||
| void QgsOracleNewConnection::on_btnConnect_clicked() | ||
| { | ||
| QgsDataSourceURI uri; | ||
| uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), txtUsername->text(), txtPassword->text() ); | ||
|
|
||
| QgsOracleConn *conn = QgsOracleConn::connectDb( uri ); | ||
|
|
||
| if ( conn ) | ||
| { | ||
| // Database successfully opened; we can now issue SQL commands. | ||
| QMessageBox::information( this, | ||
| tr( "Test connection" ), | ||
| tr( "Connection to %1 was successful" ).arg( txtDatabase->text() ) ); | ||
|
|
||
| // free connection resources | ||
| conn->disconnect(); | ||
| } | ||
| else | ||
| { | ||
| QMessageBox::information( this, | ||
| tr( "Test connection" ), | ||
| tr( "Connection failed - Check settings and try again.\n\n" ) ); | ||
| } | ||
| } | ||
|
|
||
| /** end Autoconnected SLOTS **/ | ||
|
|
||
| QgsOracleNewConnection::~QgsOracleNewConnection() | ||
| { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /*************************************************************************** | ||
| qgsoraclenewconnection.h - description | ||
| ------------------- | ||
| begin : August 2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
| #ifndef QGSORACLENEWCONNECTION_H | ||
| #define QGSORACLENEWCONNECTION_H | ||
| #include "ui_qgsoraclenewconnectionbase.h" | ||
| #include "qgisgui.h" | ||
| #include "qgscontexthelp.h" | ||
|
|
||
| /*! \class QgsOracleNewConnection | ||
| * \brief Dialog to allow the user to configure and save connection | ||
| * information for a Oracle database | ||
| */ | ||
| class QgsOracleNewConnection : public QDialog, private Ui::QgsOracleNewConnectionBase | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| //! Constructor | ||
| QgsOracleNewConnection( QWidget *parent = 0, const QString& connName = QString::null, Qt::WFlags fl = QgisGui::ModalDialogFlags ); | ||
| //! Destructor | ||
| ~QgsOracleNewConnection(); | ||
| public slots: | ||
| void accept(); | ||
| void on_btnConnect_clicked(); | ||
| void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); } | ||
| private: | ||
| QString mOriginalConnName; //store initial name to delete entry in case of rename | ||
| }; | ||
|
|
||
| #endif // QGSORACLENEWCONNECTIONBASE_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| /*************************************************************************** | ||
| qgoraclesourceselect.h - description | ||
| ------------------- | ||
| begin : August 2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
| #ifndef QGSORACLESOURCESELECT_H | ||
| #define QGSORACLESOURCESELECT_H | ||
|
|
||
| #include "ui_qgsdbsourceselectbase.h" | ||
| #include "qgisgui.h" | ||
| #include "qgsdbfilterproxymodel.h" | ||
| #include "qgscontexthelp.h" | ||
|
|
||
| #include "qgsoracletablemodel.h" | ||
|
|
||
| #include <QMap> | ||
| #include <QPair> | ||
| #include <QIcon> | ||
| #include <QItemDelegate> | ||
|
|
||
| class QPushButton; | ||
| class QStringList; | ||
| class QgisApp; | ||
| class QgsOracleColumnTypeThread; | ||
| class QgsOracleSourceSelect; | ||
|
|
||
| class QgsOracleSourceSelectDelegate : public QItemDelegate | ||
| { | ||
| Q_OBJECT; | ||
|
|
||
| public: | ||
| QgsOracleSourceSelectDelegate( QObject *parent = NULL ) | ||
| : QItemDelegate( parent ) | ||
| , mConn( 0 ) | ||
| {} | ||
|
|
||
| ~QgsOracleSourceSelectDelegate() | ||
| { | ||
| setConn( 0 ); | ||
| } | ||
|
|
||
| QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const; | ||
| void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const; | ||
|
|
||
| void setConn( QgsOracleConn *conn ) { if ( mConn ) mConn->disconnect(); mConn = conn; } | ||
| private: | ||
| QgsOracleConn *mConn; | ||
| }; | ||
|
|
||
|
|
||
| /*! \class QgsOracleSourceSelect | ||
| * \brief Dialog to create connections and add tables from Oracle. | ||
| * | ||
| * This dialog allows the user to define and save connection information | ||
| * for Oracle databases. The user can then connect and add | ||
| * tables from the database to the map canvas. | ||
| */ | ||
| class QgsOracleSourceSelect : public QDialog, private Ui::QgsDbSourceSelectBase | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| //! Constructor | ||
| QgsOracleSourceSelect( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags, bool managerMode = false, bool embeddedMode = false ); | ||
| //! Destructor | ||
| ~QgsOracleSourceSelect(); | ||
| //! Populate the connection list combo box | ||
| void populateConnectionList(); | ||
| //! String list containing the selected tables | ||
| QStringList selectedTables(); | ||
| //! Connection info (database, host, user, password) | ||
| QString connectionInfo(); | ||
|
|
||
| signals: | ||
| void addDatabaseLayers( QStringList const & layerPathList, QString const & providerKey ); | ||
| void connectionsChanged(); | ||
| void addGeometryColumn( QgsOracleLayerProperty ); | ||
|
|
||
| public slots: | ||
| //! Determines the tables the user selected and closes the dialog | ||
| void addTables(); | ||
| void buildQuery(); | ||
|
|
||
| /*! Connects to the database using the stored connection parameters. | ||
| * Once connected, available layers are displayed. | ||
| */ | ||
| void on_btnConnect_clicked(); | ||
| void on_cbxAllowGeometrylessTables_stateChanged( int ); | ||
| //! Opens the create connection dialog to build a new connection | ||
| void on_btnNew_clicked(); | ||
| //! Opens a dialog to edit an existing connection | ||
| void on_btnEdit_clicked(); | ||
| //! Deletes the selected connection | ||
| void on_btnDelete_clicked(); | ||
| //! Saves the selected connections to file | ||
| void on_btnSave_clicked(); | ||
| //! Loads the selected connections from file | ||
| void on_btnLoad_clicked(); | ||
| void on_mSearchTableEdit_textChanged( const QString & text ); | ||
| void on_mSearchColumnComboBox_currentIndexChanged( const QString & text ); | ||
| void on_mSearchModeComboBox_currentIndexChanged( const QString & text ); | ||
| void on_cmbConnections_currentIndexChanged( const QString &text ); | ||
| void setSql( const QModelIndex& index ); | ||
| //! Store the selected database | ||
| void setLayerType( QgsOracleLayerProperty layerProperty ); | ||
| void on_mTablesTreeView_clicked( const QModelIndex &index ); | ||
| void on_mTablesTreeView_doubleClicked( const QModelIndex &index ); | ||
| //!Sets a new regular expression to the model | ||
| void setSearchExpression( const QString& regexp ); | ||
|
|
||
| void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); } | ||
|
|
||
| void columnThreadFinished(); | ||
|
|
||
| private: | ||
| typedef QPair<QString, QString> geomPair; | ||
| typedef QList<geomPair> geomCol; | ||
|
|
||
| //! Connections manager mode | ||
| bool mManagerMode; | ||
|
|
||
| //! Embedded mode, without 'Close' | ||
| bool mEmbeddedMode; | ||
|
|
||
| // queue another query for the thread | ||
| void addSearchGeometryColumn( QgsOracleLayerProperty layerProperty ); | ||
|
|
||
| // Set the position of the database connection list to the last | ||
| // used one. | ||
| void setConnectionListPosition(); | ||
| // Combine the schema, table and column data into a single string | ||
| // useful for display to the user | ||
| QString fullDescription( QString schema, QString table, QString column, QString type ); | ||
| // The column labels | ||
| QStringList mColumnLabels; | ||
| // Our thread for doing long running queries | ||
| QgsOracleColumnTypeThread *mColumnTypeThread; | ||
| QString mConnInfo; | ||
| QStringList mSelectedTables; | ||
| bool mUseEstimatedMetadata; | ||
| // Storage for the range of layer type icons | ||
| QMap<QString, QPair<QString, QIcon> > mLayerIcons; | ||
|
|
||
| //! Model that acts as datasource for mTableTreeWidget | ||
| QgsOracleTableModel mTableModel; | ||
| QgsDbFilterProxyModel mProxyModel; | ||
| QgsOracleSourceSelectDelegate *mTablesTreeDelegate; | ||
|
|
||
| QPushButton *mBuildQueryButton; | ||
| QPushButton *mAddButton; | ||
|
|
||
| void finishList(); | ||
| bool mIsConnected; | ||
| }; | ||
|
|
||
| #endif // QGSORACLESOURCESELECT_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,339 @@ | ||
| /*************************************************************************** | ||
| qgsoracletablemodel.cpp - description | ||
| ------------------- | ||
| begin : August 2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "qgsoracletablemodel.h" | ||
| #include "qgsdataitem.h" | ||
| #include "qgslogger.h" | ||
|
|
||
| QgsOracleTableModel::QgsOracleTableModel() | ||
| : QStandardItemModel() | ||
| , mTableCount( 0 ) | ||
| { | ||
| QStringList headerLabels; | ||
| headerLabels << tr( "Owner" ); | ||
| headerLabels << tr( "Table" ); | ||
| headerLabels << tr( "Type" ); | ||
| headerLabels << tr( "Geometry column" ); | ||
| headerLabels << tr( "SRID" ); | ||
| headerLabels << tr( "Primary key column" ); | ||
| headerLabels << tr( "Select at id" ); | ||
| headerLabels << tr( "Sql" ); | ||
| setHorizontalHeaderLabels( headerLabels ); | ||
| } | ||
|
|
||
| QgsOracleTableModel::~QgsOracleTableModel() | ||
| { | ||
| } | ||
|
|
||
| void QgsOracleTableModel::addTableEntry( QgsOracleLayerProperty layerProperty ) | ||
| { | ||
| #ifdef QGISDEBUG | ||
| QString typeString; | ||
| foreach ( QGis::WkbType type, layerProperty.types ) | ||
| { | ||
| if ( !typeString.isEmpty() ) | ||
| typeString += "|"; | ||
| typeString += QString::number( type ); | ||
| } | ||
| QString sridString; | ||
| foreach ( int srid, layerProperty.srids ) | ||
| { | ||
| if ( !sridString.isEmpty() ) | ||
| sridString += "|"; | ||
| sridString += QString::number( srid ); | ||
| } | ||
| QgsDebugMsg( layerProperty.toString() ); | ||
| #endif | ||
|
|
||
| if ( !layerProperty.types.contains( QGis::WKBUnknown ) ) | ||
| { | ||
| layerProperty.types << ( layerProperty.geometryColName.isEmpty() ? QGis::WKBNoGeometry : QGis::WKBUnknown ); | ||
| layerProperty.srids << 0; | ||
| } | ||
|
|
||
| // is there already a root item with the given scheme Name? | ||
| QStandardItem *ownerItem = 0; | ||
|
|
||
| for ( int i = 0; i < layerProperty.size(); i++ ) | ||
| { | ||
| QGis::WkbType wkbType = layerProperty.at( i ).types[0]; | ||
| int srid = layerProperty.at( i ).srids[0]; | ||
|
|
||
| QStandardItem *ownerNameItem = new QStandardItem( layerProperty.ownerName ); | ||
|
|
||
| bool selectable = wkbType != QGis::WKBUnknown && srid != 0; | ||
|
|
||
| QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), wkbType == QGis::WKBUnknown ? tr( "Select..." ) : QgsOracleConn::displayStringForWkbType( wkbType ) ); | ||
| typeItem->setData( wkbType == QGis::WKBUnknown, Qt::UserRole + 1 ); | ||
| typeItem->setData( wkbType, Qt::UserRole + 2 ); | ||
| if ( wkbType == QGis::WKBUnknown ) | ||
| typeItem->setFlags( typeItem->flags() | Qt::ItemIsEditable ); | ||
|
|
||
| QStandardItem *tableItem = new QStandardItem( layerProperty.tableName ); | ||
| QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName ); | ||
| QStandardItem *sridItem = new QStandardItem( QString::number( srid ) ); | ||
| sridItem->setEditable( srid == 0 ); | ||
| if ( srid == 0 ) | ||
| { | ||
| sridItem->setText( tr( "Enter..." ) ); | ||
| sridItem->setFlags( sridItem->flags() | Qt::ItemIsEditable ); | ||
| } | ||
|
|
||
| QStandardItem *pkItem = new QStandardItem( layerProperty.isView ? tr( "Select..." ) : "" ); | ||
| if ( layerProperty.isView ) | ||
| pkItem->setFlags( pkItem->flags() | Qt::ItemIsEditable ); | ||
| else | ||
| pkItem->setFlags( pkItem->flags() & ~Qt::ItemIsEditable ); | ||
|
|
||
| pkItem->setData( layerProperty.isView, Qt::UserRole + 1 ); | ||
| pkItem->setData( false, Qt::UserRole + 2 ); // not selected | ||
|
|
||
| QStandardItem *selItem = new QStandardItem( "" ); | ||
| selItem->setFlags( selItem->flags() | Qt::ItemIsUserCheckable ); | ||
| selItem->setCheckState( Qt::Checked ); | ||
| selItem->setToolTip( tr( "Disable 'Fast Access to Features at ID' capability to force keeping the attribute table in memory (e.g. in case of expensive views)." ) ); | ||
|
|
||
| QStandardItem* sqlItem = new QStandardItem( layerProperty.sql ); | ||
|
|
||
| QList<QStandardItem*> childItemList; | ||
| childItemList << ownerNameItem; | ||
| childItemList << tableItem; | ||
| childItemList << typeItem; | ||
| childItemList << geomItem; | ||
| childItemList << sridItem; | ||
| childItemList << pkItem; | ||
| childItemList << selItem; | ||
| childItemList << sqlItem; | ||
|
|
||
| foreach ( QStandardItem *item, childItemList ) | ||
| { | ||
| if ( selectable ) | ||
| { | ||
| item->setFlags( item->flags() | Qt::ItemIsSelectable ); | ||
| } | ||
| else | ||
| { | ||
| item->setFlags( item->flags() & ~Qt::ItemIsSelectable ); | ||
| } | ||
| } | ||
|
|
||
| if ( !ownerItem ) | ||
| { | ||
| QList<QStandardItem*> ownerItems = findItems( layerProperty.ownerName, Qt::MatchExactly, dbtmOwner ); | ||
|
|
||
| // there is already an item for this schema | ||
| if ( ownerItems.size() > 0 ) | ||
| { | ||
| ownerItem = ownerItems.at( dbtmOwner ); | ||
| } | ||
| else | ||
| { | ||
| // create a new toplevel item for this schema | ||
| ownerItem = new QStandardItem( layerProperty.ownerName ); | ||
| ownerItem->setFlags( Qt::ItemIsEnabled ); | ||
| invisibleRootItem()->setChild( invisibleRootItem()->rowCount(), ownerItem ); | ||
| } | ||
| } | ||
|
|
||
| ownerItem->appendRow( childItemList ); | ||
|
|
||
| ++mTableCount; | ||
| } | ||
| } | ||
|
|
||
| void QgsOracleTableModel::setSql( const QModelIndex &index, const QString &sql ) | ||
| { | ||
| if ( !index.isValid() || !index.parent().isValid() ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| //find out schema name and table name | ||
| QModelIndex ownerSibling = index.sibling( index.row(), dbtmOwner ); | ||
| QModelIndex tableSibling = index.sibling( index.row(), dbtmTable ); | ||
| QModelIndex geomSibling = index.sibling( index.row(), dbtmGeomCol ); | ||
|
|
||
| if ( !ownerSibling.isValid() || !tableSibling.isValid() || !geomSibling.isValid() ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| QString ownerName = itemFromIndex( ownerSibling )->text(); | ||
| QString tableName = itemFromIndex( tableSibling )->text(); | ||
| QString geomName = itemFromIndex( geomSibling )->text(); | ||
|
|
||
| QList<QStandardItem*> ownerItems = findItems( ownerName, Qt::MatchExactly, dbtmOwner ); | ||
| if ( ownerItems.size() < 1 ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| QStandardItem* ownerItem = ownerItems.at( dbtmOwner ); | ||
|
|
||
| int n = ownerItem->rowCount(); | ||
| for ( int i = 0; i < n; i++ ) | ||
| { | ||
| QModelIndex currentChildIndex = indexFromItem( ownerItem->child( i, dbtmOwner ) ); | ||
| if ( !currentChildIndex.isValid() ) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| QModelIndex currentTableIndex = currentChildIndex.sibling( i, dbtmTable ); | ||
| if ( !currentTableIndex.isValid() ) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| QModelIndex currentGeomIndex = currentChildIndex.sibling( i, dbtmGeomCol ); | ||
| if ( !currentGeomIndex.isValid() ) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| if ( itemFromIndex( currentTableIndex )->text() == tableName && itemFromIndex( currentGeomIndex )->text() == geomName ) | ||
| { | ||
| QModelIndex sqlIndex = currentChildIndex.sibling( i, dbtmSql ); | ||
| if ( sqlIndex.isValid() ) | ||
| { | ||
| itemFromIndex( sqlIndex )->setText( sql ); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| QIcon QgsOracleTableModel::iconForWkbType( QGis::WkbType type ) | ||
| { | ||
| switch ( type ) | ||
| { | ||
| case QGis::WKBPoint: | ||
| case QGis::WKBPoint25D: | ||
| case QGis::WKBMultiPoint: | ||
| case QGis::WKBMultiPoint25D: | ||
| return QgsApplication::getThemeIcon( "/mIconPointLayer.png" ); | ||
| case QGis::WKBLineString: | ||
| case QGis::WKBLineString25D: | ||
| case QGis::WKBMultiLineString: | ||
| case QGis::WKBMultiLineString25D: | ||
| return QgsApplication::getThemeIcon( "/mIconLineLayer.png" ); | ||
| case QGis::WKBPolygon: | ||
| case QGis::WKBPolygon25D: | ||
| case QGis::WKBMultiPolygon: | ||
| case QGis::WKBMultiPolygon25D: | ||
| return QgsApplication::getThemeIcon( "/mIconPolygonLayer.png" ); | ||
| case QGis::WKBNoGeometry: | ||
| return QgsApplication::getThemeIcon( "/mIconTableLayer.png" ); | ||
| case QGis::WKBUnknown: | ||
| break; | ||
| } | ||
| return QgsApplication::getThemeIcon( "/mIconLayer.png" ); | ||
| } | ||
|
|
||
| bool QgsOracleTableModel::setData( const QModelIndex &idx, const QVariant &value, int role ) | ||
| { | ||
| if ( !QStandardItemModel::setData( idx, value, role ) ) | ||
| return false; | ||
|
|
||
| if ( idx.column() == dbtmType || idx.column() == dbtmSrid || idx.column() == dbtmPkCol ) | ||
| { | ||
| QGis::WkbType geomType = ( QGis::WkbType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt(); | ||
|
|
||
| bool ok = geomType != QGis::WKBUnknown; | ||
|
|
||
| if ( ok && geomType != QGis::WKBNoGeometry ) | ||
| idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok ); | ||
|
|
||
| int srid = idx.sibling( idx.row(), dbtmSrid ).data().toInt(); | ||
| ok &= srid != 0; | ||
|
|
||
| ok &= !idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 1 ).toBool() || | ||
| idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 2 ).toBool(); | ||
|
|
||
| for ( int i = 0; i < dbtmColumns; i++ ) | ||
| { | ||
| QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) ); | ||
| if ( ok ) | ||
| item->setFlags( item->flags() | Qt::ItemIsSelectable ); | ||
| else | ||
| item->setFlags( item->flags() & ~Qt::ItemIsSelectable ); | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| QString QgsOracleTableModel::layerURI( const QModelIndex &index, QString connInfo, bool useEstimatedMetadata ) | ||
| { | ||
| if ( !index.isValid() ) | ||
| { | ||
| QgsDebugMsg( "invalid index" ); | ||
| return QString::null; | ||
| } | ||
|
|
||
| QGis::WkbType wkbType = ( QGis::WkbType ) itemFromIndex( index.sibling( index.row(), dbtmType ) )->data( Qt::UserRole + 2 ).toInt(); | ||
| if ( wkbType == QGis::WKBUnknown ) | ||
| { | ||
| QgsDebugMsg( "unknown geometry type" ); | ||
| // no geometry type selected | ||
| return QString::null; | ||
| } | ||
|
|
||
| QStandardItem *pkItem = itemFromIndex( index.sibling( index.row(), dbtmPkCol ) ); | ||
| QString pkColumnName = pkItem->data( Qt::DisplayRole ).toString(); | ||
| bool isView = pkItem->data( Qt::UserRole + 1 ).toBool(); | ||
| bool isSet = pkItem->data( Qt::UserRole + 2 ).toBool(); | ||
|
|
||
| if ( isView && !isSet ) | ||
| { | ||
| // no valid primary candidate selected | ||
| QgsDebugMsg( "no pk candidate selected" ); | ||
| return QString::null; | ||
| } | ||
|
|
||
| QString ownerName = index.sibling( index.row(), dbtmOwner ).data( Qt::DisplayRole ).toString(); | ||
| QString tableName = index.sibling( index.row(), dbtmTable ).data( Qt::DisplayRole ).toString(); | ||
|
|
||
| QString geomColumnName; | ||
| QString srid; | ||
| if ( wkbType != QGis::WKBNoGeometry ) | ||
| { | ||
| geomColumnName = index.sibling( index.row(), dbtmGeomCol ).data( Qt::DisplayRole ).toString(); | ||
|
|
||
| srid = index.sibling( index.row(), dbtmSrid ).data( Qt::DisplayRole ).toString(); | ||
| bool ok; | ||
| srid.toInt( &ok ); | ||
| if ( !ok ) | ||
| { | ||
| QgsDebugMsg( "srid not numeric" ); | ||
| return QString::null; | ||
| } | ||
| } | ||
|
|
||
| bool selectAtId = itemFromIndex( index.sibling( index.row(), dbtmSelectAtId ) )->checkState() == Qt::Checked; | ||
| QString sql = index.sibling( index.row(), dbtmSql ).data( Qt::DisplayRole ).toString(); | ||
|
|
||
| QgsDataSourceURI uri( connInfo ); | ||
| uri.setDataSource( ownerName, tableName, geomColumnName, sql, pkColumnName ); | ||
| uri.setUseEstimatedMetadata( useEstimatedMetadata ); | ||
| uri.setWkbType( wkbType ); | ||
| uri.setSrid( srid ); | ||
| uri.disableSelectAtId( !selectAtId ); | ||
|
|
||
| QgsDebugMsg( QString( "returning uri %1" ).arg( uri.uri() ) ); | ||
| return uri.uri(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /*************************************************************************** | ||
| qgsoracletablemodel.h - description | ||
| ------------------- | ||
| begin : August 2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
| #ifndef QGSORACLETABLEMODEL_H | ||
| #define QGSORACLETABLEMODEL_H | ||
| #include <QStandardItemModel> | ||
|
|
||
| #include "qgis.h" | ||
| #include "qgsoracleconn.h" | ||
|
|
||
| class QIcon; | ||
|
|
||
| /**A model that holds the tables of a database in a hierarchy where the | ||
| schemas are the root elements that contain the individual tables as children. | ||
| The tables have the following columns: Type, Owner, Tablename, Geometry Column, Sql*/ | ||
| class QgsOracleTableModel : public QStandardItemModel | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| QgsOracleTableModel(); | ||
| ~QgsOracleTableModel(); | ||
|
|
||
| /**Adds entry for one database table to the model*/ | ||
| void addTableEntry( QgsOracleLayerProperty property ); | ||
|
|
||
| /**Sets an sql statement that belongs to a cell specified by a model index*/ | ||
| void setSql( const QModelIndex& index, const QString& sql ); | ||
|
|
||
| /**Returns the number of tables in the model*/ | ||
| int tableCount() const { return mTableCount; } | ||
|
|
||
| enum columns | ||
| { | ||
| dbtmOwner = 0, | ||
| dbtmTable, | ||
| dbtmType, | ||
| dbtmGeomCol, | ||
| dbtmSrid, | ||
| dbtmPkCol, | ||
| dbtmSelectAtId, | ||
| dbtmSql, | ||
| dbtmColumns | ||
| }; | ||
|
|
||
| bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); | ||
|
|
||
| QString layerURI( const QModelIndex &index, QString connInfo, bool useEstimatedMetadata ); | ||
|
|
||
| static QIcon iconForWkbType( QGis::WkbType type ); | ||
|
|
||
| private: | ||
| /**Number of tables in the model*/ | ||
| int mTableCount; | ||
| }; | ||
|
|
||
| #endif // QGSORACLETABLEMODEL_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,265 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>QgsOracleNewConnectionBase</class> | ||
| <widget class="QDialog" name="QgsOracleNewConnectionBase"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>400</width> | ||
| <height>459</height> | ||
| </rect> | ||
| </property> | ||
| <property name="sizePolicy"> | ||
| <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> | ||
| <horstretch>0</horstretch> | ||
| <verstretch>0</verstretch> | ||
| </sizepolicy> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>Create a New Oracle connection</string> | ||
| </property> | ||
| <property name="sizeGripEnabled"> | ||
| <bool>true</bool> | ||
| </property> | ||
| <property name="modal"> | ||
| <bool>true</bool> | ||
| </property> | ||
| <layout class="QGridLayout"> | ||
| <property name="margin"> | ||
| <number>9</number> | ||
| </property> | ||
| <property name="spacing"> | ||
| <number>6</number> | ||
| </property> | ||
| <item row="1" column="0"> | ||
| <widget class="QDialogButtonBox" name="buttonBox"> | ||
| <property name="standardButtons"> | ||
| <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="0"> | ||
| <widget class="QGroupBox" name="GroupBox1"> | ||
| <property name="title"> | ||
| <string>Connection Information</string> | ||
| </property> | ||
| <layout class="QGridLayout" name="gridLayout"> | ||
| <item row="4" column="1" colspan="2"> | ||
| <widget class="QLineEdit" name="txtUsername"/> | ||
| </item> | ||
| <item row="5" column="0"> | ||
| <widget class="QLabel" name="TextLabel3_2"> | ||
| <property name="text"> | ||
| <string>Password</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>txtPassword</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="5" column="1" colspan="2"> | ||
| <widget class="QLineEdit" name="txtPassword"> | ||
| <property name="echoMode"> | ||
| <enum>QLineEdit::Password</enum> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="6" column="0" colspan="2"> | ||
| <widget class="QCheckBox" name="chkStoreUsername"> | ||
| <property name="text"> | ||
| <string>Save Username</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="4" column="0"> | ||
| <widget class="QLabel" name="TextLabel3"> | ||
| <property name="text"> | ||
| <string>Username</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>txtUsername</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="1" colspan="2"> | ||
| <widget class="QLineEdit" name="txtName"> | ||
| <property name="toolTip"> | ||
| <string>Name of the new connection</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="0"> | ||
| <widget class="QLabel" name="label"> | ||
| <property name="text"> | ||
| <string>Database</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>txtDatabase</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="0"> | ||
| <widget class="QLabel" name="TextLabel1_2"> | ||
| <property name="text"> | ||
| <string>Name</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>txtName</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="8" column="0" colspan="3"> | ||
| <widget class="QCheckBox" name="cb_geometryColumnsOnly"> | ||
| <property name="toolTip"> | ||
| <string>Restrict the displayed tables to those that are in the geometry_columns table</string> | ||
| </property> | ||
| <property name="whatsThis"> | ||
| <string><html><head/><body><p>Restricts the displayed tables to those that are in the all_sdo_geom_metadata view. This can speed up the initial display of spatial tables.</p></body></html></string> | ||
| </property> | ||
| <property name="text"> | ||
| <string>Only look in meta data table</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="9" column="0" colspan="3"> | ||
| <widget class="QCheckBox" name="cb_userTablesOnly"> | ||
| <property name="toolTip"> | ||
| <string>Restrict the search to the public schema for spatial tables not in the geometry_columns table</string> | ||
| </property> | ||
| <property name="whatsThis"> | ||
| <string><html><head/><body><p>When searching for spatial tables restrict the search to tables that are owner by the user.</p></body></html></string> | ||
| </property> | ||
| <property name="text"> | ||
| <string>Only look for user's tables</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="10" column="0" colspan="3"> | ||
| <widget class="QCheckBox" name="cb_allowGeometrylessTables"> | ||
| <property name="text"> | ||
| <string>Also list tables with no geometry</string> | ||
| </property> | ||
| <property name="checked"> | ||
| <bool>false</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="3" column="0"> | ||
| <widget class="QLabel" name="TextLabel2_2"> | ||
| <property name="text"> | ||
| <string>Port</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>txtPort</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="3" column="1" colspan="2"> | ||
| <widget class="QLineEdit" name="txtPort"> | ||
| <property name="text"> | ||
| <string>1521</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="6" column="2" rowspan="2"> | ||
| <widget class="QPushButton" name="btnConnect"> | ||
| <property name="text"> | ||
| <string>&Test Connect</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="7" column="0" colspan="2"> | ||
| <widget class="QCheckBox" name="chkStorePassword"> | ||
| <property name="text"> | ||
| <string>Save Password</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="1" colspan="2"> | ||
| <widget class="QLineEdit" name="txtDatabase"/> | ||
| </item> | ||
| <item row="2" column="0"> | ||
| <widget class="QLabel" name="TextLabel1"> | ||
| <property name="text"> | ||
| <string>Host</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>txtHost</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="1" colspan="2"> | ||
| <widget class="QLineEdit" name="txtHost"/> | ||
| </item> | ||
| <item row="11" column="0" colspan="3"> | ||
| <widget class="QCheckBox" name="cb_useEstimatedMetadata"> | ||
| <property name="toolTip"> | ||
| <string>Use estimated table statistics for the layer metadata.</string> | ||
| </property> | ||
| <property name="whatsThis"> | ||
| <string><html><head/><body><p>When the layer is setup various metadata is required for the Oracle table. This includes information such as the table row count, geometry type and spatial extents of the data in the geometry column. If the table contains a large number of rows determining this metadata is time consuming.</p><p>By activating this option the following fast table metadata operations are done:</p><p>1) Row count is determined from all_tables.num_rows.</p><p>2) Table extents are always determined with the SDO_TUNE.EXTENTS_OF function even if a layer filter is applied.</p><p>3) The table geometry is determined from the first 100 non-null geometry rows in the table.</p></body></html></string> | ||
| </property> | ||
| <property name="text"> | ||
| <string>Use estimated table metadata</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <layoutdefault spacing="6" margin="11"/> | ||
| <tabstops> | ||
| <tabstop>txtName</tabstop> | ||
| <tabstop>txtDatabase</tabstop> | ||
| <tabstop>txtHost</tabstop> | ||
| <tabstop>txtPort</tabstop> | ||
| <tabstop>txtUsername</tabstop> | ||
| <tabstop>txtPassword</tabstop> | ||
| <tabstop>chkStoreUsername</tabstop> | ||
| <tabstop>chkStorePassword</tabstop> | ||
| <tabstop>btnConnect</tabstop> | ||
| <tabstop>cb_geometryColumnsOnly</tabstop> | ||
| <tabstop>cb_userTablesOnly</tabstop> | ||
| <tabstop>cb_allowGeometrylessTables</tabstop> | ||
| <tabstop>cb_useEstimatedMetadata</tabstop> | ||
| <tabstop>buttonBox</tabstop> | ||
| </tabstops> | ||
| <resources/> | ||
| <connections> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>rejected()</signal> | ||
| <receiver>QgsOracleNewConnectionBase</receiver> | ||
| <slot>reject()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>313</x> | ||
| <y>501</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>451</x> | ||
| <y>312</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>accepted()</signal> | ||
| <receiver>QgsOracleNewConnectionBase</receiver> | ||
| <slot>accept()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>395</x> | ||
| <y>501</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>450</x> | ||
| <y>287</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| </connections> | ||
| </ui> |