Skip to content
Permalink
Browse files

merged DB2 updates

[FEATURE] New vector data provider for DB2 sources
  • Loading branch information
dwadler authored and nyalldawson committed Apr 3, 2016
1 parent 883016f commit 5fe19c5f15c7ffd9a5b83f9db9060ef0aac3afa1
Showing with 6,660 additions and 4 deletions.
  1. +4 −0 CMakeLists.txt
  2. +2 −0 cmake_templates/qgsconfig.h.in
  3. +2 −0 images/images.qrc
  4. +138 −0 images/themes/default/mActionAddDb2Layer.svg
  5. +112 −0 images/themes/default/mIconDb2.svg
  6. +6 −0 python/core/qgsdatasourceuri.sip
  7. +27 −0 src/app/qgisapp.cpp
  8. +4 −0 src/app/qgisapp.h
  9. +1 −0 src/auth/basic/qgsauthbasicmethod.cpp
  10. +21 −0 src/core/qgsdatasourceuri.cpp
  11. +8 −0 src/core/qgsdatasourceuri.h
  12. +147 −0 src/gui/qgsmanageconnectionsdialog.cpp
  13. +3 −0 src/gui/qgsmanageconnectionsdialog.h
  14. +1 −0 src/providers/CMakeLists.txt
  15. +58 −0 src/providers/db2/CMakeLists.txt
  16. +606 −0 src/providers/db2/qgsdb2dataitems.cpp
  17. +177 −0 src/providers/db2/qgsdb2dataitems.h
  18. +246 −0 src/providers/db2/qgsdb2expressioncompiler.cpp
  19. +37 −0 src/providers/db2/qgsdb2expressioncompiler.h
  20. +458 −0 src/providers/db2/qgsdb2featureiterator.cpp
  21. +110 −0 src/providers/db2/qgsdb2featureiterator.h
  22. +163 −0 src/providers/db2/qgsdb2geometrycolumns.cpp
  23. +53 −0 src/providers/db2/qgsdb2geometrycolumns.h
  24. +199 −0 src/providers/db2/qgsdb2newconnection.cpp
  25. +56 −0 src/providers/db2/qgsdb2newconnection.h
  26. +1,757 −0 src/providers/db2/qgsdb2provider.cpp
  27. +201 −0 src/providers/db2/qgsdb2provider.h
  28. +768 −0 src/providers/db2/qgsdb2sourceselect.cpp
  29. +191 −0 src/providers/db2/qgsdb2sourceselect.h
  30. +484 −0 src/providers/db2/qgsdb2tablemodel.cpp
  31. +93 −0 src/providers/db2/qgsdb2tablemodel.h
  32. +14 −0 src/ui/qgisapp.ui
  33. +358 −0 src/ui/qgsdb2newconnectionbase.ui
  34. +28 −1 tests/src/core/testqgsdatasourceuri.cpp
  35. +3 −3 tests/src/python/providertestbase.py
  36. +81 −0 tests/src/python/test_provider_db2.py
  37. +43 −0 tests/testdata/provider/testdata_db2.sql
@@ -239,6 +239,10 @@ SET (HAVE_SPATIALITE TRUE)
# following variable is used in qgsconfig.h
SET (HAVE_MSSQL TRUE)


# following variable is used in qgsconfig.h
SET (HAVE_DB2 TRUE)

SET (WITH_QTWEBKIT TRUE CACHE INTERNAL "Enable QtWebkit support")
IF (WITH_QTWEBKIT)
ADD_DEFINITIONS(-DWITH_QTWEBKIT)
@@ -46,6 +46,8 @@

#cmakedefine HAVE_MSSQL

#cmakedefine HAVE_DB2

#cmakedefine HAVE_ORACLE

#cmakedefine HAVE_PYTHON
@@ -132,6 +132,7 @@
<file>themes/default/mActionAddMap.png</file>
<file>themes/default/mActionAddMap.svg</file>
<file>themes/default/mActionAddMssqlLayer.svg</file>
<file>themes/default/mActionAddDb2Layer.svg</file>
<file>themes/default/mActionAddNonDbLayer.png</file>
<file>themes/default/mActionAddOgrLayer.svg</file>
<file>themes/default/mActionAddOracleLayer.svg</file>
@@ -361,6 +362,7 @@
<file>themes/default/mIconDataDefineExpression.svg</file>
<file>themes/default/mIconDataDefineExpressionError.svg</file>
<file>themes/default/mIconDataDefineExpressionOn.svg</file>
<file>themes/default/mIconDb2.svg</file>
<file>themes/default/mIconDbSchema.png</file>
<file>themes/default/mIconDelete.png</file>
<file>themes/default/mIconDeselected.svg</file>
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Creator: CorelDRAW X6 -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xml:space="preserve"
width="24"
height="24"
version="1.1"
viewBox="0 0 266.66667 266.66773"
id="svg3336"
inkscape:version="0.91 r13725"
sodipodi:docname="mActionAddDb2Layer.svg"
style="clip-rule:evenodd;fill-rule:evenodd;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision"><metadata
id="metadata3365"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1323"
inkscape:window-height="1083"
id="namedview3363"
showgrid="false"
inkscape:zoom="10.455597"
inkscape:cx="38.601362"
inkscape:cy="33.548361"
inkscape:window-x="112"
inkscape:window-y="75"
inkscape:window-maximized="0"
inkscape:current-layer="_144357312"
units="px" /><defs
id="defs3338"><linearGradient
id="id0"
gradientUnits="userSpaceOnUse"
x1="500"
y1="999.992"
x2="500"
y2="0"><stop
offset="0"
stop-color="#039935"
id="stop3341" /><stop
offset="1"
stop-color="#75E69B"
id="stop3343" /></linearGradient><mask
id="id1"><linearGradient
id="id2"
gradientUnits="userSpaceOnUse"
x1="500"
y1="58.480301"
x2="500"
y2="307.01599"><stop
offset="0"
stop-opacity="1"
stop-color="white"
id="stop3347" /><stop
offset="0.141176"
stop-opacity="77.8"
stop-color="white"
id="stop3349" /><stop
offset="1"
stop-opacity="0"
stop-color="white"
id="stop3351" /></linearGradient><rect
width="1000"
height="365"
id="rect3353"
x="0"
y="0"
style="fill:url(#id2)" /></mask></defs><g
style="fill:#6d97c4;fill-opacity:1"
id="_144357312"
transform="matrix(0.22222311,0,0,0.22222311,2.1253949,0.87387553)"><path
inkscape:connector-curvature="0"
style="fill:#6d97c4;fill-opacity:1"
d="M 0,676 0,324 C 0,41 41,0 324,0 l 352,0 c 284,0 324,41 324,324 l 0,352 c 0,283 -40,324 -324,324 l -352,0 C 41,1000 0,959 0,676 Z"
id="Background" /><path
style="fill:#6d97c4;fill-opacity:1"
inkscape:connector-curvature="0"
id="path3359"
d="M 0,365 0,324 C 0,41 41,0 324,0 l 352,0 c 284,0 324,41 324,324 l 0,41 C 1000,82 960,41 676,41 L 324,41 C 41,41 0,82 0,365 Z"
mask="url(#id1)" /><path
style="fill:#6d97c4;fill-opacity:1;fill-rule:nonzero"
inkscape:connector-curvature="0"
id="path3361"
d="m 373,489 c 0,55 -7,96 -21,121 -16,28 -43,42 -81,42 l -106,0 0,-313 104,0 c 35,0 60,9 75,27 19,22 29,64 29,123 z m -66,4 c 0,-43 -4,-72 -12,-87 -7,-13 -21,-20 -42,-20 l -25,0 0,219 25,0 c 20,0 34,-8 42,-22 8,-16 12,-46 12,-90 z m 308,70 c 0,29 -8,51 -24,66 -16,15 -38,23 -66,23 l -114,0 0,-313 112,0 c 24,0 44,6 58,17 17,14 25,34 25,61 0,21 -6,38 -17,50 -10,11 -20,17 -31,19 l 0,1 c 12,0 24,5 35,15 15,14 22,35 22,61 z M 542,427 c 0,-27 -12,-41 -37,-41 l -31,0 0,82 31,0 c 10,0 19,-3 25,-10 8,-7 12,-17 12,-31 z m 7,131 c 0,-32 -15,-48 -44,-48 l -31,0 0,95 31,0 c 30,0 44,-16 44,-47 z m 286,94 -191,0 c 1,-47 20,-88 57,-124 l 38,-36 c 12,-11 20,-20 24,-28 5,-10 8,-23 8,-38 0,-27 -10,-41 -31,-41 -11,0 -19,3 -24,10 -6,10 -10,26 -10,49 l -61,0 c 0,-37 8,-63 25,-79 15,-16 39,-23 72,-23 62,0 93,28 93,86 0,35 -12,63 -35,84 l -41,38 c -20,18 -34,36 -42,52 l 118,0 0,50 z" /><text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:503.94992065px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="92.957787"
y="607.73456"
id="text4168"
sodipodi:linespacing="125%"
transform="scale(0.84099571,1.1890667)"><tspan
sodipodi:role="line"
id="tspan4170"
x="92.957787"
y="607.73456">DB2</tspan></text>
</g><g
style="display:inline"
id="g3772"
transform="matrix(7.6923386,0,0,7.6923386,21.69673,22.69158)"><rect
ry="2.6149368"
inkscape:export-ydpi="120"
inkscape:export-xdpi="120"
y="19"
x="19"
height="13"
width="13"
id="rect3563"
style="display:inline;fill:#5a8c5a;fill-opacity:1;stroke:#555753;stroke-width:0;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:export-filename="C:\Program Files\QGIS-Dev\themes\gis-0.1\mActionAddOgrLayer.png"
rx="2.6149371" /><path
inkscape:connector-curvature="0"
style="display:inline;overflow:visible;visibility:visible;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.5999999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
d="m 21.6,25.499999 7.8,0"
id="path3807"
sodipodi:nodetypes="cc" /><path
inkscape:connector-curvature="0"
id="path3809"
d="M 25.5,29.399999 25.5,21.6"
style="display:inline;overflow:visible;visibility:visible;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.5999999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
sodipodi:nodetypes="cc" /><path
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccsssc"
id="path6992"
d="m 20.3,25.499999 10.4,0 c 0,0 0,0 0,-2.6 C 30.7,20.3 30.05,20.3 25.5,20.3 c -4.55,0 -5.2,0 -5.2,2.599999 0,2.6 0,2.6 0,2.6 z"
style="display:inline;opacity:0.3;fill:#fcffff;fill-rule:evenodd;stroke:none;enable-background:new" /></g></svg>
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Creator: CorelDRAW X6 -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xml:space="preserve"
width="24"
height="24"
version="1.1"
viewBox="0 0 266.66667 266.66773"
id="svg2"
inkscape:version="0.91 r13725"
sodipodi:docname="mIconDb2.svg"
style="clip-rule:evenodd;fill-rule:evenodd;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision"><metadata
id="metadata31"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1332"
inkscape:window-height="926"
id="namedview29"
showgrid="false"
units="px"
inkscape:zoom="21.5"
inkscape:cx="14.818675"
inkscape:cy="13.03175"
inkscape:window-x="557"
inkscape:window-y="102"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" /><defs
id="defs4"><linearGradient
id="id0"
gradientUnits="userSpaceOnUse"
x1="500"
y1="999.992"
x2="500"
y2="0"><stop
offset="0"
stop-color="#039935"
id="stop7" /><stop
offset="1"
stop-color="#75E69B"
id="stop9" /></linearGradient><mask
id="id1"><linearGradient
id="id2"
gradientUnits="userSpaceOnUse"
x1="500"
y1="58.480301"
x2="500"
y2="307.01599"><stop
offset="0"
stop-opacity="1"
stop-color="white"
id="stop13" /><stop
offset="0.141176"
stop-opacity="77.8"
stop-color="white"
id="stop15" /><stop
offset="1"
stop-opacity="0"
stop-color="white"
id="stop17" /></linearGradient><rect
width="1000"
height="365"
id="rect19"
x="0"
y="0"
style="fill:url(#id2)" /></mask></defs><g
id="Layer_x0020_1"
transform="matrix(0.26666772,0,0,0.26666772,0,-1.5712542e-5)"
style="fill:#6d97c4;fill-opacity:1"><metadata
id="CorelCorpID_0Corel-Layer" /><g
id="_144357312"
style="fill:#6d97c4;fill-opacity:1"><path
id="Background"
d="M 0,676 0,324 C 0,41 41,0 324,0 l 352,0 c 284,0 324,41 324,324 l 0,352 c 0,283 -40,324 -324,324 l -352,0 C 41,1000 0,959 0,676 Z"
inkscape:connector-curvature="0"
style="fill:#6d97c4;fill-opacity:1" /><path
mask="url(#id1)"
d="M 0,365 0,324 C 0,41 41,0 324,0 l 352,0 c 284,0 324,41 324,324 l 0,41 C 1000,82 960,41 676,41 L 324,41 C 41,41 0,82 0,365 Z"
id="path25"
inkscape:connector-curvature="0"
style="fill:#6d97c4;fill-opacity:1" /><path
d="m 373,489 c 0,55 -7,96 -21,121 -16,28 -43,42 -81,42 l -106,0 0,-313 104,0 c 35,0 60,9 75,27 19,22 29,64 29,123 z m -66,4 c 0,-43 -4,-72 -12,-87 -7,-13 -21,-20 -42,-20 l -25,0 0,219 25,0 c 20,0 34,-8 42,-22 8,-16 12,-46 12,-90 z m 308,70 c 0,29 -8,51 -24,66 -16,15 -38,23 -66,23 l -114,0 0,-313 112,0 c 24,0 44,6 58,17 17,14 25,34 25,61 0,21 -6,38 -17,50 -10,11 -20,17 -31,19 l 0,1 c 12,0 24,5 35,15 15,14 22,35 22,61 z M 542,427 c 0,-27 -12,-41 -37,-41 l -31,0 0,82 31,0 c 10,0 19,-3 25,-10 8,-7 12,-17 12,-31 z m 7,131 c 0,-32 -15,-48 -44,-48 l -31,0 0,95 31,0 c 30,0 44,-16 44,-47 z m 286,94 -191,0 c 1,-47 20,-88 57,-124 l 38,-36 c 12,-11 20,-20 24,-28 5,-10 8,-23 8,-38 0,-27 -10,-41 -31,-41 -11,0 -19,3 -24,10 -6,10 -10,26 -10,49 l -61,0 c 0,-37 8,-63 25,-79 15,-16 39,-23 72,-23 62,0 93,28 93,86 0,35 -12,63 -35,84 l -41,38 c -20,18 -34,36 -42,52 l 118,0 0,50 z"
id="path27"
inkscape:connector-curvature="0"
style="fill:#6d97c4;fill-rule:nonzero;fill-opacity:1" /></g></g><text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:108.85260773px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
x="11.770355"
y="177.04869"
id="text4159"
sodipodi:linespacing="125%"
transform="scale(1.0910442,0.91655315)"><tspan
sodipodi:role="line"
id="tspan4161"
x="11.770355"
y="177.04869">DB2</tspan></text>
</svg>
@@ -144,6 +144,12 @@ class QgsDataSourceURI
QString database() const;
//! Returns the port
QString port() const;
//! Returns the driver
// @note added in QGIS 2.16
QString driver() const;
//! Sets the driver name
// @note added in QGIS 2.16
void setDriver( const QString& driver );
//! Returns the password
QString password() const;
//! Returns the SSL mode
@@ -1425,6 +1425,7 @@ void QgisApp::createActions()
connect( mActionAddPgLayer, SIGNAL( triggered() ), this, SLOT( addDatabaseLayer() ) );
connect( mActionAddSpatiaLiteLayer, SIGNAL( triggered() ), this, SLOT( addSpatiaLiteLayer() ) );
connect( mActionAddMssqlLayer, SIGNAL( triggered() ), this, SLOT( addMssqlLayer() ) );
connect( mActionAddDb2Layer, SIGNAL( triggered() ), this, SLOT( addDb2Layer() ) );
connect( mActionAddOracleLayer, SIGNAL( triggered() ), this, SLOT( addOracleLayer() ) );
connect( mActionAddWmsLayer, SIGNAL( triggered() ), this, SLOT( addWmsLayer() ) );
connect( mActionAddWcsLayer, SIGNAL( triggered() ), this, SLOT( addWcsLayer() ) );
@@ -1555,6 +1556,11 @@ void QgisApp::createActions()
mActionAddMssqlLayer = 0;
#endif

#ifndef HAVE_DB2
delete mActionAddDb2Layer;
mActionAddDb2Layer = 0;
#endif

#ifndef HAVE_ORACLE
delete mActionAddOracleLayer;
mActionAddOracleLayer = nullptr;
@@ -2221,6 +2227,9 @@ void QgisApp::setTheme( const QString& theThemeName )
#ifdef HAVE_MSSQL
mActionAddMssqlLayer->setIcon( QgsApplication::getThemeIcon( "/mActionAddMssqlLayer.svg" ) );
#endif
#ifdef HAVE_DB2
mActionAddDb2Layer->setIcon( QgsApplication::getThemeIcon( "/mActionAddDb2Layer.svg" ) );
#endif
#ifdef HAVE_ORACLE
mActionAddOracleLayer->setIcon( QgsApplication::getThemeIcon( "/mActionAddOracleLayer.svg" ) );
#endif
@@ -3872,6 +3881,24 @@ void QgisApp::addMssqlLayer()
#endif
} // QgisApp::addMssqlLayer()

void QgisApp::addDb2Layer()
{
#ifdef HAVE_DB2
// show the DB2 dialog
QgsDebugMsg( "Show dialog for DB2 " );
QDialog *dbs = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "DB2", this ) );
if ( !dbs )
{
QMessageBox::warning( this, tr( "DB2" ), tr( "Cannot get DB2 select dialog from provider." ) );
return;
}
connect( dbs, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
this, SLOT( addDatabaseLayers( QStringList const &, QString const & ) ) );
dbs->exec();
delete dbs;
#endif
} // QgisApp::addDb2Layer()

void QgisApp::addOracleLayer()
{
#ifdef HAVE_ORACLE
@@ -721,6 +721,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Add a MSSQL layer to the map
void addMssqlLayer();
//#endif
//#ifdef HAVE_DB2
//! Add a DB2 layer to the map
void addDb2Layer();
//#endif
//#ifdef HAVE_ORACLE
//! Add a Oracle layer to the map
void addOracleLayer();
@@ -33,6 +33,7 @@ QgsAuthBasicMethod::QgsAuthBasicMethod()
setExpansions( QgsAuthMethod::NetworkRequest | QgsAuthMethod::DataSourceURI );
setDataProviders( QStringList()
<< "postgres"
<< "db2"
<< "ows"
<< "wfs" // convert to lowercase
<< "wcs"

0 comments on commit 5fe19c5

Please sign in to comment.
You can’t perform that action at this time.