Skip to content
Permalink
Browse files

Add a 'Layer / Create Layer / Create GeoPackage layer' menu item

  • Loading branch information
rouault committed Apr 23, 2016
1 parent e765bb6 commit 3ba86d48a92b7e86acb5e7090249860f9057b658
@@ -259,6 +259,7 @@
<file>themes/default/mActionNewComposer.svg</file>
<file>themes/default/mActionNewFolder.png</file>
<file>themes/default/mActionNewSpatiaLiteLayer.svg</file>
<file>themes/default/mActionNewGeoPackageLayer.svg</file>
<file>themes/default/mActionNewVectorLayer.svg</file>
<file>themes/default/mActionNodeTool.png</file>
<file>themes/default/mActionOffsetCurve.png</file>

Large diffs are not rendered by default.

@@ -121,6 +121,7 @@
%Include qgsnewmemorylayerdialog.sip
%Include qgsnewnamedialog.sip
%Include qgsnewvectorlayerdialog.sip
%Include qgsnewgeopackagelayerdialog.sip
%Include qgsnumericsortlistviewitem.sip
%Include qgsoptionsdialogbase.sip
%Include qgsorderbydialog.sip
@@ -0,0 +1,14 @@
/** Dialog to set up parameters to create a new GeoPackage layer, and on accept() to create it and add it to the layers */
class QgsNewGeoPackageLayerDialog : QDialog
{
%TypeHeaderCode
#include <qgsnewgeopackagelayerdialog.h>
%End

public:
/** Constructor */
QgsNewGeoPackageLayerDialog( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags& fl = QgisGui::ModalDialogFlags );

~QgsNewGeoPackageLayerDialog();

};
@@ -254,8 +254,13 @@
// GDAL/OGR includes
//
#include <ogr_api.h>
#include <gdal_version.h>
#include <proj_api.h>

#if defined(GDAL_COMPUTE_VERSION) && GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(1,11,0)
#define SUPPORT_GEOPACKAGE
#endif

//
// Other includes
//
@@ -334,6 +339,7 @@ extern "C"
#include <spatialite.h>
}
#include "qgsnewspatialitelayerdialog.h"
#include "qgsnewgeopackagelayerdialog.h"

#include "qgspythonutils.h"

@@ -1427,6 +1433,7 @@ void QgisApp::createActions()

connect( mActionNewVectorLayer, SIGNAL( triggered() ), this, SLOT( newVectorLayer() ) );
connect( mActionNewSpatiaLiteLayer, SIGNAL( triggered() ), this, SLOT( newSpatialiteLayer() ) );
connect( mActionNewGeoPackageLayer, SIGNAL( triggered() ), this, SLOT( newGeoPackageLayer() ) );
connect( mActionNewMemoryLayer, SIGNAL( triggered() ), this, SLOT( newMemoryLayer() ) );
connect( mActionShowRasterCalculator, SIGNAL( triggered() ), this, SLOT( showRasterCalculator() ) );
connect( mActionShowAlignRasterTool, SIGNAL( triggered() ), this, SLOT( showAlignRasterTool() ) );
@@ -1721,6 +1728,11 @@ void QgisApp::createMenus()
* For Mac, About and Exit are also automatically moved by Qt to the Application menu.
*/

// Layer menu
#ifndef SUPPORT_GEOPACKAGE
mNewLayerMenu->removeAction( mActionNewGeoPackageLayer );
#endif

// Panel and Toolbar Submenus
mPanelMenu = new QMenu( tr( "Panels" ), this );
mPanelMenu->setObjectName( "mPanelMenu" );
@@ -1976,6 +1988,9 @@ void QgisApp::createToolBars()
bt->setPopupMode( QToolButton::MenuButtonPopup );
bt->addAction( mActionNewVectorLayer );
bt->addAction( mActionNewSpatiaLiteLayer );
#ifdef SUPPORT_GEOPACKAGE
bt->addAction( mActionNewGeoPackageLayer );
#endif
bt->addAction( mActionNewMemoryLayer );

QAction* defNewLayerAction = mActionNewVectorLayer;
@@ -1990,6 +2005,11 @@ void QgisApp::createToolBars()
case 2:
defNewLayerAction = mActionNewMemoryLayer;
break;
#ifdef SUPPORT_GEOPACKAGE
case 3:
defNewLayerAction = mActionNewGeoPackageLayer;
break;
#endif
}
bt->setDefaultAction( defNewLayerAction );
QAction* newLayerAction = mLayerToolBar->addWidget( bt );
@@ -3663,10 +3683,10 @@ void QgisApp::loadOGRSublayers( const QString& layertype, const QString& uri, co
}

QString layerName = elements.value( 0 );
QString layerType = elements.value( 1 );
if ( layerType == "any" )
QString layerGeometryType = elements.value( 1 );
if ( layerGeometryType == "any" )
{
layerType = "";
layerGeometryType = "";
elements.removeAt( 1 );
}

@@ -3679,16 +3699,17 @@ void QgisApp::loadOGRSublayers( const QString& layertype, const QString& uri, co
composedURI = uri + "|layerindex=" + layerName;
}

if ( !layerType.isEmpty() )
if ( !layerGeometryType.isEmpty() )
{
composedURI += "|geometrytype=" + layerType;
composedURI += "|geometrytype=" + layerGeometryType;
}

// addVectorLayer( composedURI, list.at( i ), "ogr" );

QgsDebugMsg( "Creating new vector layer using " + composedURI );
QString name = list.at( i );
name.replace( ':', ' ' );
QString name = layerName;
if ( !layerGeometryType.isEmpty() )
name += " " + layerGeometryType;
QgsVectorLayer *layer = new QgsVectorLayer( composedURI, fileName + " " + name, "ogr", false );
if ( layer && layer->isValid() )
{
@@ -4361,6 +4382,12 @@ void QgisApp::newSpatialiteLayer()
spatialiteDialog.exec();
}

void QgisApp::newGeoPackageLayer()
{
QgsNewGeoPackageLayerDialog dialog( this );
dialog.exec();
}

void QgisApp::showRasterCalculator()
{
QgsRasterCalcDialog d( this );
@@ -11222,6 +11249,8 @@ void QgisApp::toolButtonActionTriggered( QAction *action )
settings.setValue( "/UI/defaultNewLayer", 1 );
else if ( action == mActionNewMemoryLayer )
settings.setValue( "/UI/defaultNewLayer", 2 );
else if ( action == mActionNewGeoPackageLayer )
settings.setValue( "/UI/defaultNewLayer", 3 );
bt->setDefaultAction( action );
}

@@ -947,6 +947,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void newMemoryLayer();
//! Create a new empty spatialite layer
void newSpatialiteLayer();
//! Create a new empty GeoPackage layer
void newGeoPackageLayer();
//! Print the current map view frame
void newPrintComposer();
void showComposerManager();
@@ -248,6 +248,7 @@ SET(QGIS_GUI_SRCS
qgsnewmemorylayerdialog.cpp
qgsnewnamedialog.cpp
qgsnewvectorlayerdialog.cpp
qgsnewgeopackagelayerdialog.cpp
qgsnumericsortlistviewitem.cpp
qgsoptionsdialogbase.cpp
qgsorderbydialog.cpp
@@ -387,6 +388,7 @@ SET(QGIS_GUI_MOC_HDRS
qgsnewmemorylayerdialog.h
qgsnewnamedialog.h
qgsnewvectorlayerdialog.h
qgsnewgeopackagelayerdialog.h
qgsoptionsdialogbase.h
qgsorderbydialog.h
qgsowssourceselect.h

0 comments on commit 3ba86d4

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