Skip to content
Permalink
Browse files

Merge pull request #4953 from boundlessgeo/gpkg-enhancements

Expose GeoPackage to the browser tree
  • Loading branch information
elpaso committed Aug 9, 2017
2 parents 267286e + 92da308 commit d9a2492fc2b9e5f2f4a55887355db8c3412bef30
@@ -563,6 +563,7 @@
<file>themes/default/mActionMapSettings.svg</file>
<file>themes/default/mActionLockExtent.svg</file>
<file>icons/qgis_icon.svg</file>
<file>themes/default/mGeoPackage.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
@@ -0,0 +1,29 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="22" height="22" viewBox="0 0 22 22">
<defs>
<polygon id="icon-geopackage-a" points="0 .128 10.142 6.18 10.142 13.944 0 7.892"/>
<polygon id="icon-geopackage-b" points="10.142 .128 20.283 6.18 20.283 13.944 10.142 7.892"/>
</defs>
<g fill="none" fill-rule="evenodd">
<g transform="rotate(-180 10.57 7.375)">
<use fill="#806600" xlink:href="#icon-geopackage-a"/>
<path stroke="#000" stroke-width=".5" d="M0.25,0.568583189 L0.25,7.7496822 L9.89166407,13.5034603 L9.89166407,6.32236127 L0.25,0.568583189 Z"/>
<g transform="matrix(-1 0 0 1 30.425 0)">
<use fill="#806600" xlink:href="#icon-geopackage-b"/>
<path stroke="#000" stroke-width=".5" d="M10.3916641,0.568583189 L10.3916641,7.7496822 L20.0333281,13.5034603 L20.0333281,6.32236127 L10.3916641,0.568583189 Z"/>
</g>
</g>
<g transform="translate(3.459)">
<circle cx="7.627" cy="7.876" r="7.599" fill="#6E96C4"/>
<g transform="translate(.95 1.199)">
<circle cx="6.73" cy="6.598" r="6.536" fill="#2E4E72"/>
<path fill="#AEC7E2" fill-rule="nonzero" d="M12.4632607,4.24578962 L12.2923695,4.05823298 L12.259886,3.75684303 L12.0850403,3.85231613 L11.990697,4.22149765 L11.737891,3.95230868 L11.7274398,3.69809035 L11.4836727,3.48793653 L11.3935664,3.39867764 L11.1102542,3.39867764 L11.200078,3.65120119 L11.5404481,3.84101754 L11.5994833,3.9040072 L11.5260424,3.94101009 L11.5288671,4.14071271 L11.3627778,4.20991659 L11.2215454,4.17884546 L11.1328514,4.05314862 L11.3627778,4.06585953 L11.4252025,3.98196748 L10.9147886,3.63764288 L10.8758084,3.49047871 L10.6681968,3.67803534 L10.458043,3.63481823 L10.1380103,4.05117136 L10.0747382,4.21415356 L9.86966876,4.23279624 L9.56686648,4.23449103 L9.38580654,4.15003405 L9.33270315,3.79017388 L9.39738759,3.6190002 L9.70583917,3.55149111 L10.0416898,3.6190002 L10.0829297,3.43285589 L9.93972004,3.39924257 L9.98915138,3.10971614 L10.3269793,3.05661275 L10.5636848,2.72245688 L10.8074519,2.68121702 L11.028057,2.71398294 L11.1091244,2.71398294 L11.0647774,2.40016453 L10.7972832,2.50834855 L10.70294,2.27390276 L10.5473019,2.25158803 L10.5179255,2.09058309 L10.6447522,1.9524578 L10.9461422,1.8343875 L11.0235375,1.69569728 C10.1671042,0.940668834 9.11125074,0.406810335 7.94721324,0.181685879 C7.92066155,0.176883977 7.89467478,0.172082075 7.86840556,0.167562638 C7.74807554,0.145812847 7.62605075,0.131124677 7.50317855,0.116154042 C7.24161613,0.0842355178 6.9769466,0.0619207975 6.70634531,0.0619207975 C5.27142406,0.0619207975 3.94383943,0.527705276 2.86397645,1.31436978 L2.91962202,1.31408732 L3.19361289,1.3118276 L3.34077705,1.39317747 L3.61759257,1.45277754 L3.6390599,1.56180896 L4.07970501,1.57790945 L4.01982247,1.43695951 L3.6286087,1.42594338 L3.72069223,1.33894422 L3.68849124,1.23584456 L3.33512776,1.23584456 L3.72069223,0.947447989 L4.09043867,0.947447989 L4.26415453,1.18697815 L4.55255111,1.20307865 L4.72626697,1.03444715 L4.85676571,1.09969652 L4.61751801,1.33329492 C4.61751801,1.33329492 4.28618679,1.33894422 4.30228728,1.33894422 C4.3189527,1.33894422 4.32996883,1.56717579 4.32996883,1.56717579 L4.7316338,1.55615966 L4.77513338,1.44769317 L5.05223136,1.43102775 L5.08471481,1.26861048 L4.92201508,1.24092893 L4.97624833,1.09404723 L5.10081531,1.05591448 L5.53552866,1.0773818 L5.2959985,1.29516217 L5.33469618,1.4635112 L5.58467754,1.50164395 L5.56829458,1.19771181 L5.80754227,1.0725799 L6.23152196,1.02343102 L6.84588293,1.29544464 L6.84588293,1.52932551 L7.04106612,1.57790945 L6.94305083,1.76264144 L6.66651777,1.76264144 L6.58403805,1.97449005 L5.950187,1.82534863 L6.44845494,1.56011417 L6.25863858,1.39882676 L5.82929206,1.45306001 L5.79115931,1.49204015 L5.78974699,1.49147522 L5.78409769,1.4996667 L5.66037811,1.62790573 L5.45615605,1.64541854 L5.472539,1.74738834 L5.5440026,1.77676468 L5.54117795,1.810378 L5.37480618,1.83410504 L5.36266019,1.93070801 L5.2036325,1.93889949 L5.17482109,1.74738834 L4.88924916,1.83410504 L4.30652425,2.175605 L4.37149116,2.41570009 L4.53419089,2.52190686 L4.86043775,2.56681877 L4.86043775,2.93769507 L5.01070903,2.91312063 L5.14968172,2.62387666 L5.49654851,2.51399785 L5.49654851,2.06939823 L5.68947198,1.92392885 L6.15553892,2.03409013 L6.12249054,2.32757107 L6.24762245,2.32757107 L6.58996981,2.15922204 L6.60663523,2.54478651 L6.85633413,2.69703505 L6.84588293,2.92554908 L6.60663523,3.00689895 L6.62301819,3.08259952 L6.91084984,3.21394566 L6.90548301,3.37127856 L6.82159096,3.37834018 C6.82159096,3.37579799 6.82102603,3.37382074 6.82102603,3.37382074 L6.45721135,3.26196467 L6.44167578,3.14502424 L6.44167578,3.14502424 L6.54788255,3.07214832 L6.54788255,2.96594155 L6.43376677,2.9374126 L6.40552028,3.03542789 L6.2046878,3.06621656 L6.18491526,3.0594374 L6.18491526,3.06960614 L6.11571139,3.08005733 L6.05921842,2.96594155 L5.99368659,2.9374126 L5.85104185,2.9374126 L5.78635741,2.99051599 L5.78635741,3.10858628 L5.90838221,3.14954368 L6.02927715,3.1662091 L6.00216053,3.17835509 L5.89171679,3.30009742 L5.84369777,3.23908502 L5.73720853,3.21112101 L5.4476821,3.48369955 L5.48581485,3.51477068 L5.05788066,3.75119373 L4.6553683,4.16980659 L4.62796921,4.3559509 L4.22489192,4.62090289 L4.02547176,4.82201784 L4.04750402,5.22424774 L3.77040604,5.09487885 L3.77238329,4.85986813 L3.00125435,4.86015059 L2.60156664,5.0623954 L2.42841571,5.38214557 L2.35949429,5.63551651 L2.47191529,5.88154336 L2.78629862,5.91995857 L3.28654381,5.58523777 L3.33004339,5.75104461 L3.17751239,6.03944119 L3.55855743,6.10412563 L3.59669018,6.69193491 L3.64470919,6.70012639 L3.64922863,6.70069132 L4.11868515,6.78062886 L4.44973391,6.39760657 L4.85224627,6.4792389 L4.99319622,6.67583441 L5.37932562,6.65295476 L5.38977681,6.53912144 L5.60219035,6.64193864 L5.84115559,7.01648698 L6.25411914,7.02241874 L6.40665014,7.28878306 L6.42811747,7.61418253 L6.88486307,7.78846332 L7.46080883,7.79411261 L7.62944032,8.07064567 L7.88450605,8.15284293 L7.8359221,8.38135696 L7.55571701,8.73698016 L7.47408468,9.52392713 L7.2209962,9.72391222 L6.84673032,9.71233116 L6.72131595,9.93011154 L6.81424687,10.3377083 L6.40665014,10.8597032 L6.27586894,11.0992334 L5.88719735,11.2856602 L5.63213162,11.3249228 L5.6211155,11.4333893 L5.80076312,11.4850803 L5.7784484,11.6014558 L5.61800838,11.7559641 L5.71574121,11.8791188 L5.90894714,11.884768 L5.89793101,12.0339095 L5.84652242,12.1810736 L5.83042192,12.3002738 L6.11627632,12.5414987 L6.0778611,12.6660657 L5.68862459,12.6592866 L5.30136533,12.3208937 L4.99997537,11.7907073 L5.04206263,11.278881 L4.81354859,10.9746664 L4.90591459,10.4586032 L4.77061394,10.420188 L4.77061394,9.30077993 C4.77061394,9.30077993 4.38985137,9.01238335 4.36838405,9.01238335 C4.34635179,9.01238335 4.16698663,8.96379941 4.16698663,8.96379941 L4.12913635,8.75166833 L3.634258,8.13250546 L3.68312441,7.90964072 L3.69978983,7.54554358 L4.04185472,7.30601341 L3.99327077,6.89841669 L3.49330805,6.86084887 L3.10152936,6.41483693 L2.82471384,6.33885389 L2.64534868,6.30608797 L2.66681601,6.14338824 L2.43830197,6.11062232 L2.43830197,6.20298832 L1.86772305,6.06175591 L1.63779669,5.71036968 L1.71745177,5.56603016 L1.62310852,5.5649003 L1.59542697,5.4733817 L1.66237113,5.43948592 L1.37002005,5.01268159 L1.30759532,4.62655219 L1.16071362,4.62655219 L1.2098625,5.001383 L1.45984386,5.38722993 L1.43244477,5.53976093 L1.2203137,5.50727748 L0.959881138,5.06267786 L0.959881138,4.54520232 L0.687867522,4.41442111 L0.687867522,4.09919038 L0.687867522,4.04213249 C0.534771593,4.40114527 0.414159117,4.77767087 0.327159955,5.16605998 L0.342413055,5.16295287 L0.432236865,5.14487512 L0.48534025,5.39994085 L0.597196317,5.5810008 L0.671767028,5.66630517 L0.807067674,5.71940855 L0.679676042,5.87080969 L0.43308426,5.8948192 L0.246657483,5.8948192 L0.267559879,5.67449665 L0.422068132,5.64257813 L0.409074751,5.53891354 L0.28111819,5.4581286 L0.270666992,5.45078452 C0.204005296,5.82476793 0.167002405,6.20892008 0.167002405,6.6012637 C0.167002405,6.61284476 0.1678498,6.62442582 0.1678498,6.63600688 C0.186774942,10.2261347 3.11254548,13.141454 6.70691024,13.141454 C8.7511081,13.141454 10.5789379,12.1977391 11.7791309,10.7238377 L11.5636103,10.7238377 L11.5636103,10.2891243 L11.3136289,9.95327365 L11.3136289,9.42986635 L11.1229651,9.24033246 L11.1065822,9.02255209 L11.3478071,8.56043965 L10.8893667,7.7508955 L10.9433175,7.20150143 L10.5306364,7.15913171 L10.3783879,7.00688318 L10.1010074,7.00688318 L9.95977504,7.13738192 L9.47139337,7.13738192 L9.45444549,7.18059904 L9.18243187,7.18059904 L8.55790217,6.46850524 L8.56298653,5.91402681 L8.66608619,5.87589406 L8.70478387,5.66376299 L8.55790217,5.66376299 L8.49773716,5.44089825 L9.22056462,4.91918574 L9.22056462,4.54972176 L9.5747755,4.35312625 L9.71770269,4.36781442 L10.0089239,4.36781442 L10.2371555,4.24522469 L10.9709991,4.18788433 L10.9709991,4.56299761 L11.5500519,4.71016177 L11.6638853,4.79151164 L11.7703745,4.79151164 L11.7703745,4.58757205 L12.1045304,4.55508859 L12.4223033,4.79151164 L12.9440158,4.79151164 L12.9804538,4.75818079 C12.9287627,4.58220521 12.8697276,4.40961921 12.8036308,4.23957539 L12.4632607,4.24578962 Z"/>
</g>
</g>
<g transform="translate(1 7)">
<polygon fill="#D4AA00" points="0 .137 10 6.348 10 14.844 0 8.401"/>
<polygon fill="#FFFF7A" points="10 .137 20 6.342 20 14.844 10 8.401" transform="matrix(-1 0 0 1 30 0)"/>
<path stroke="#000" stroke-linecap="square" stroke-width=".5" d="M10,6.75 L10,14.5200005"/>
<polygon stroke="#000" stroke-width=".5" points=".015 8.403 10.037 14.669 20.078 8.403 20.078 .232 10.047 6.339 .015 .232"/>
</g>
</g>
</svg>
@@ -361,6 +361,7 @@ class QgsLayerItem : QgsDataItem
Plugin
};


QgsLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, LayerType layerType, const QString &providerKey );


@@ -410,6 +411,13 @@ Returns provider key
:rtype: str
%End

static QString layerTypeAsString( const LayerType &layerType );
%Docstring
Returns the string representatio of the given ``layerType``
.. versionadded:: 3
:rtype: str
%End

protected:


@@ -517,6 +525,7 @@ Check if the given path is hidden from the browser model
:rtype: bool
%End


public slots:
virtual void childrenCreated();
void directoryChanged();
@@ -778,6 +778,14 @@ Returns the number of registered layers.
.. seealso:: QgsMapLayer.reload()
%End

QgsCoordinateReferenceSystem defaultCrsForNewLayers() const;
%Docstring
Returns the default CRS for new layers based on the settings and
the current project CRS
:rtype: QgsCoordinateReferenceSystem
%End


signals:
void readProject( const QDomDocument & );
%Docstring
@@ -1010,6 +1018,8 @@ emitted whenever the configuration for snapping has changed
\param layers List of QgsMapLayer which were added to the legend.
%End



public slots:

void setSnappingConfig( const QgsSnappingConfig &snappingConfig );
@@ -1740,27 +1740,6 @@ void QgisApp::applyDefaultSettingsToCanvas( QgsMapCanvas *canvas )
canvas->setSegmentationToleranceType( QgsAbstractGeometry::SegmentationToleranceType( settings.value( QStringLiteral( "qgis/segmentationToleranceType" ), "0" ).toInt() ) );
}

QgsCoordinateReferenceSystem QgisApp::defaultCrsForNewLayers() const
{
QgsSettings settings;
QgsCoordinateReferenceSystem defaultCrs;
if ( settings.value( QStringLiteral( "/Projections/defaultBehavior" ), QStringLiteral( "prompt" ) ).toString() == QStringLiteral( "useProject" )
|| settings.value( QStringLiteral( "/Projections/defaultBehavior" ), QStringLiteral( "prompt" ) ).toString() == QStringLiteral( "prompt" ) )
{
// for new layers if the new layer crs method is set to either prompt or use project, then we use the project crs
// (since "prompt" has no meaning here - the prompt will always be shown, it's just deciding on the default choice in the prompt!)
defaultCrs = QgsProject::instance()->crs();
}
else
{
// global crs
QString layerDefaultCrs = settings.value( QStringLiteral( "/Projections/layerDefaultCrs" ), GEO_EPSG_CRS_AUTHID ).toString();
defaultCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( layerDefaultCrs );
}

return defaultCrs;
}

int QgisApp::chooseReasonableDefaultIconSize() const
{
QScreen *screen = QApplication::screens().at( 0 );
@@ -4488,6 +4467,7 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
}
}

// Check if the current layer uri contains the

// We initialize a selection dialog and display it.
QgsSublayersDialog chooseSublayersDialog( QgsSublayersDialog::Ogr, QStringLiteral( "ogr" ), this );
@@ -5098,7 +5078,7 @@ void QgisApp::fileNewFromTemplateAction( QAction *qAction )
void QgisApp::newVectorLayer()
{
QString enc;
QString fileName = QgsNewVectorLayerDialog::runAndCreateLayer( this, &enc, defaultCrsForNewLayers() );
QString fileName = QgsNewVectorLayerDialog::runAndCreateLayer( this, &enc, QgsProject::instance()->defaultCrsForNewLayers() );

if ( !fileName.isEmpty() )
{
@@ -5120,7 +5100,7 @@ void QgisApp::newVectorLayer()

void QgisApp::newMemoryLayer()
{
QgsVectorLayer *newLayer = QgsNewMemoryLayerDialog::runAndCreateLayer( this, defaultCrsForNewLayers() );
QgsVectorLayer *newLayer = QgsNewMemoryLayerDialog::runAndCreateLayer( this, QgsProject::instance()->defaultCrsForNewLayers() );

if ( newLayer )
{
@@ -5135,14 +5115,14 @@ void QgisApp::newMemoryLayer()

void QgisApp::newSpatialiteLayer()
{
QgsNewSpatialiteLayerDialog spatialiteDialog( this, QgsGuiUtils::ModalDialogFlags, defaultCrsForNewLayers() );
QgsNewSpatialiteLayerDialog spatialiteDialog( this, QgsGuiUtils::ModalDialogFlags, QgsProject::instance()->defaultCrsForNewLayers() );
spatialiteDialog.exec();
}

void QgisApp::newGeoPackageLayer()
{
QgsNewGeoPackageLayerDialog dialog( this );
dialog.setCrs( defaultCrsForNewLayers() );
dialog.setCrs( QgsProject::instance()->defaultCrsForNewLayers() );
dialog.exec();
}

@@ -9807,7 +9787,7 @@ QgsVectorLayer *QgisApp::addVectorLayer( const QString &vectorLayerPath, const Q

// If the newly created layer has more than 1 layer of data available, we show the
// sublayers selection dialog so the user can select the sublayers to actually load.
if ( sublayers.count() > 1 )
if ( sublayers.count() > 1 && ! vectorLayerPath.contains( QStringLiteral( "layerid=" ) ) )
{
askUserForOGRSublayers( layer );

@@ -238,6 +238,7 @@ void QgsDataItem::populate( bool foreground )
{
mFutureWatcher = new QFutureWatcher< QVector <QgsDataItem *> >( this );
}

connect( mFutureWatcher, &QFutureWatcherBase::finished, this, &QgsDataItem::childrenCreated );
mFutureWatcher->setFuture( QtConcurrent::run( runCreateChildren, this ) );
}
@@ -581,6 +582,12 @@ QgsMapLayer::LayerType QgsLayerItem::mapLayerType() const
return QgsMapLayer::VectorLayer;
}

QString QgsLayerItem::layerTypeAsString( const QgsLayerItem::LayerType &layerType )
{
static int enumIdx = staticMetaObject.indexOfEnumerator( "LayerType" );
return staticMetaObject.enumerator( enumIdx ).valueToKey( layerType );
}

bool QgsLayerItem::equal( const QgsDataItem *other )
{
//QgsDebugMsg ( mPath + " x " + other->mPath );
@@ -785,12 +792,22 @@ void QgsDirectoryItem::directoryChanged()
{
if ( state() == Populating )
{
// schedule to refresh later, because refres() simply returns if Populating
// schedule to refresh later, because refresh() simply returns if Populating
mRefreshLater = true;
}
else
{
refresh();
// We definintely don't want the temporary files created by sqlite
// to re-trigger a refresh in an infinite loop.
disconnect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
// QFileSystemWhatcher::directoryChanged is emitted when a
// file is created and not when it is closed/flushed.
//
// Delay to give to OS the time to complete writing the file
// this happens when a new file appears in the directory and
// the item's children thread will try to open the file with
// GDAL or OGR even if it is still being written.
QTimer::singleShot( 100, this, SLOT( refresh() ) );
}
}

@@ -803,6 +820,7 @@ bool QgsDirectoryItem::hiddenPath( const QString &path )
return ( idx > -1 );
}


void QgsDirectoryItem::childrenCreated()
{
QgsDebugMsgLevel( QString( "mRefreshLater = %1" ).arg( mRefreshLater ), 3 );
@@ -818,6 +836,8 @@ void QgsDirectoryItem::childrenCreated()
{
QgsDataCollectionItem::childrenCreated();
}
// Re-connect the file watcher after all children have been created
connect( mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &QgsDirectoryItem::directoryChanged );
}

bool QgsDirectoryItem::equal( const QgsDataItem *other )
@@ -328,6 +328,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDataItem::Capabilities )
class CORE_EXPORT QgsLayerItem : public QgsDataItem
{
Q_OBJECT
Q_ENUMS( LayerType )
public:
enum LayerType
{
@@ -343,6 +344,8 @@ class CORE_EXPORT QgsLayerItem : public QgsDataItem
Plugin //!< Added in 2.10
};

Q_ENUMS( LayerType )

QgsLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, LayerType layerType, const QString &providerKey );

// --- reimplemented from QgsDataItem ---
@@ -379,6 +382,11 @@ class CORE_EXPORT QgsLayerItem : public QgsDataItem
*/
virtual QString comments() const { return QString(); }

/** Returns the string representatio of the given \a layerType
* \since QGIS 3
*/
static QString layerTypeAsString( const LayerType &layerType );

protected:

//! The provider key
@@ -460,6 +468,7 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
//! Check if the given path is hidden from the browser model
static bool hiddenPath( const QString &path );


public slots:
virtual void childrenCreated() override;
void directoryChanged();
@@ -2241,3 +2241,23 @@ QMap<QString, QgsMapLayer *> QgsProject::mapLayers() const
}


QgsCoordinateReferenceSystem QgsProject::defaultCrsForNewLayers() const
{
QgsSettings settings;
QgsCoordinateReferenceSystem defaultCrs;
if ( settings.value( QStringLiteral( "/Projections/defaultBehavior" ), QStringLiteral( "prompt" ) ).toString() == QStringLiteral( "useProject" )
|| settings.value( QStringLiteral( "/Projections/defaultBehavior" ), QStringLiteral( "prompt" ) ).toString() == QStringLiteral( "prompt" ) )
{
// for new layers if the new layer crs method is set to either prompt or use project, then we use the project crs
// (since "prompt" has no meaning here - the prompt will always be shown, it's just deciding on the default choice in the prompt!)
defaultCrs = crs();
}
else
{
// global crs
QString layerDefaultCrs = settings.value( QStringLiteral( "/Projections/layerDefaultCrs" ), GEO_EPSG_CRS_AUTHID ).toString();
defaultCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( layerDefaultCrs );
}

return defaultCrs;
}
@@ -750,6 +750,12 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*/
void reloadAllLayers();

/** Returns the default CRS for new layers based on the settings and
* the current project CRS
*/
QgsCoordinateReferenceSystem defaultCrsForNewLayers() const;


signals:
//! emitted when project is being read
void readProject( const QDomDocument & );
@@ -967,6 +973,8 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*/
void legendLayersAdded( const QList<QgsMapLayer *> &layers );



public slots:

/**

0 comments on commit d9a2492

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