254
254
// GDAL/OGR includes
255
255
//
256
256
#include < ogr_api.h>
257
+ #include < gdal_version.h>
257
258
#include < proj_api.h>
258
259
260
+ #if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(1,11,0)
261
+ #define SUPPORT_GEOPACKAGE
262
+ #endif
263
+
259
264
//
260
265
// Other includes
261
266
//
@@ -334,6 +339,7 @@ extern "C"
334
339
#include < spatialite.h>
335
340
}
336
341
#include " qgsnewspatialitelayerdialog.h"
342
+ #include " qgsnewgeopackagelayerdialog.h"
337
343
338
344
#include " qgspythonutils.h"
339
345
@@ -1431,6 +1437,7 @@ void QgisApp::createActions()
1431
1437
1432
1438
connect ( mActionNewVectorLayer , SIGNAL ( triggered () ), this , SLOT ( newVectorLayer () ) );
1433
1439
connect ( mActionNewSpatiaLiteLayer , SIGNAL ( triggered () ), this , SLOT ( newSpatialiteLayer () ) );
1440
+ connect ( mActionNewGeoPackageLayer , SIGNAL ( triggered () ), this , SLOT ( newGeoPackageLayer () ) );
1434
1441
connect ( mActionNewMemoryLayer , SIGNAL ( triggered () ), this , SLOT ( newMemoryLayer () ) );
1435
1442
connect ( mActionShowRasterCalculator , SIGNAL ( triggered () ), this , SLOT ( showRasterCalculator () ) );
1436
1443
connect ( mActionShowAlignRasterTool , SIGNAL ( triggered () ), this , SLOT ( showAlignRasterTool () ) );
@@ -1725,6 +1732,11 @@ void QgisApp::createMenus()
1725
1732
* For Mac, About and Exit are also automatically moved by Qt to the Application menu.
1726
1733
*/
1727
1734
1735
+ // Layer menu
1736
+ #ifndef SUPPORT_GEOPACKAGE
1737
+ mNewLayerMenu ->removeAction ( mActionNewGeoPackageLayer );
1738
+ #endif
1739
+
1728
1740
// Panel and Toolbar Submenus
1729
1741
mPanelMenu = new QMenu ( tr ( " Panels" ), this );
1730
1742
mPanelMenu ->setObjectName ( " mPanelMenu" );
@@ -1980,6 +1992,9 @@ void QgisApp::createToolBars()
1980
1992
bt->setPopupMode ( QToolButton::MenuButtonPopup );
1981
1993
bt->addAction ( mActionNewVectorLayer );
1982
1994
bt->addAction ( mActionNewSpatiaLiteLayer );
1995
+ #ifdef SUPPORT_GEOPACKAGE
1996
+ bt->addAction ( mActionNewGeoPackageLayer );
1997
+ #endif
1983
1998
bt->addAction ( mActionNewMemoryLayer );
1984
1999
1985
2000
QAction* defNewLayerAction = mActionNewVectorLayer ;
@@ -1994,6 +2009,11 @@ void QgisApp::createToolBars()
1994
2009
case 2 :
1995
2010
defNewLayerAction = mActionNewMemoryLayer ;
1996
2011
break ;
2012
+ #ifdef SUPPORT_GEOPACKAGE
2013
+ case 3 :
2014
+ defNewLayerAction = mActionNewGeoPackageLayer ;
2015
+ break ;
2016
+ #endif
1997
2017
}
1998
2018
bt->setDefaultAction ( defNewLayerAction );
1999
2019
QAction* newLayerAction = mLayerToolBar ->addWidget ( bt );
@@ -3668,10 +3688,10 @@ void QgisApp::loadOGRSublayers( const QString& layertype, const QString& uri, co
3668
3688
}
3669
3689
3670
3690
QString layerName = elements.value ( 0 );
3671
- QString layerType = elements.value ( 1 );
3672
- if ( layerType == " any" )
3691
+ QString layerGeometryType = elements.value ( 1 );
3692
+ if ( layerGeometryType == " any" )
3673
3693
{
3674
- layerType = " " ;
3694
+ layerGeometryType = " " ;
3675
3695
elements.removeAt ( 1 );
3676
3696
}
3677
3697
@@ -3684,16 +3704,17 @@ void QgisApp::loadOGRSublayers( const QString& layertype, const QString& uri, co
3684
3704
composedURI = uri + " |layerindex=" + layerName;
3685
3705
}
3686
3706
3687
- if ( !layerType .isEmpty () )
3707
+ if ( !layerGeometryType .isEmpty () )
3688
3708
{
3689
- composedURI += " |geometrytype=" + layerType ;
3709
+ composedURI += " |geometrytype=" + layerGeometryType ;
3690
3710
}
3691
3711
3692
3712
// addVectorLayer( composedURI, list.at( i ), "ogr" );
3693
3713
3694
3714
QgsDebugMsg ( " Creating new vector layer using " + composedURI );
3695
- QString name = list.at ( i );
3696
- name.replace ( ' :' , ' ' );
3715
+ QString name = layerName;
3716
+ if ( !layerGeometryType.isEmpty () )
3717
+ name += " " + layerGeometryType;
3697
3718
QgsVectorLayer *layer = new QgsVectorLayer ( composedURI, fileName + " " + name, " ogr" , false );
3698
3719
if ( layer && layer->isValid () )
3699
3720
{
@@ -4366,6 +4387,12 @@ void QgisApp::newSpatialiteLayer()
4366
4387
spatialiteDialog.exec ();
4367
4388
}
4368
4389
4390
+ void QgisApp::newGeoPackageLayer ()
4391
+ {
4392
+ QgsNewGeoPackageLayerDialog dialog ( this );
4393
+ dialog.exec ();
4394
+ }
4395
+
4369
4396
void QgisApp::showRasterCalculator ()
4370
4397
{
4371
4398
QgsRasterCalcDialog d ( this );
@@ -11227,6 +11254,8 @@ void QgisApp::toolButtonActionTriggered( QAction *action )
11227
11254
settings.setValue ( " /UI/defaultNewLayer" , 1 );
11228
11255
else if ( action == mActionNewMemoryLayer )
11229
11256
settings.setValue ( " /UI/defaultNewLayer" , 2 );
11257
+ else if ( action == mActionNewGeoPackageLayer )
11258
+ settings.setValue ( " /UI/defaultNewLayer" , 3 );
11230
11259
bt->setDefaultAction ( action );
11231
11260
}
11232
11261
0 commit comments