Skip to content

Commit

Permalink
Merge pull request #5156 from boundlessgeo/gpkg_tab
Browse files Browse the repository at this point in the history
[feature][needs-docs] Gpkg tab in source select dialog
  • Loading branch information
elpaso authored Sep 11, 2017
2 parents a650681 + c733b36 commit 32dee44
Show file tree
Hide file tree
Showing 19 changed files with 1,137 additions and 263 deletions.
3 changes: 2 additions & 1 deletion images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,9 @@
<file>themes/default/mActionNewMap.svg</file>
<file>themes/default/mActionMapSettings.svg</file>
<file>themes/default/mActionLockExtent.svg</file>
<file>icons/qgis_icon.svg</file>
<file>themes/default/mGeoPackage.svg</file>
<file>themes/default/mActionAddGeoPackageLayer.svg</file>
<file>icons/qgis_icon.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
39 changes: 39 additions & 0 deletions images/themes/default/mActionAddGeoPackageLayer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion python/core/qgsdataitem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,14 @@ Returns provider key

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

static QString iconName( const LayerType &layerType );
%Docstring
Returns the icon name of the given ``layerType``
.. versionadded:: 3
:rtype: str
%End
Expand Down
50 changes: 28 additions & 22 deletions src/core/qgsdataitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,49 +545,55 @@ QgsLayerItem::QgsLayerItem( QgsDataItem *parent, const QString &name, const QStr
, mProviderKey( providerKey )
, mUri( uri )
, mLayerType( layerType )
{
mIconName = iconName( layerType );
}

QgsMapLayer::LayerType QgsLayerItem::mapLayerType() const
{
if ( mLayerType == QgsLayerItem::Raster )
return QgsMapLayer::RasterLayer;
if ( mLayerType == QgsLayerItem::Plugin )
return QgsMapLayer::PluginLayer;
return QgsMapLayer::VectorLayer;
}

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

QString QgsLayerItem::iconName( const QgsLayerItem::LayerType &layerType )
{
switch ( layerType )
{
case Point:
mIconName = QStringLiteral( "/mIconPointLayer.svg" );
return QStringLiteral( "/mIconPointLayer.svg" );
break;
case Line:
mIconName = QStringLiteral( "/mIconLineLayer.svg" );
return QStringLiteral( "/mIconLineLayer.svg" );
break;
case Polygon:
mIconName = QStringLiteral( "/mIconPolygonLayer.svg" );
return QStringLiteral( "/mIconPolygonLayer.svg" );
break;
// TODO add a new icon for generic Vector layers
case Vector :
mIconName = QStringLiteral( "/mIconPolygonLayer.svg" );
return QStringLiteral( "/mIconPolygonLayer.svg" );
break;
case TableLayer:
mIconName = QStringLiteral( "/mIconTableLayer.svg" );
case Table:
return QStringLiteral( "/mIconTableLayer.svg" );
break;
case Raster:
mIconName = QStringLiteral( "/mIconRaster.svg" );
return QStringLiteral( "/mIconRaster.svg" );
break;
default:
mIconName = QStringLiteral( "/mIconLayer.png" );
return QStringLiteral( "/mIconLayer.png" );
break;
}
}

QgsMapLayer::LayerType QgsLayerItem::mapLayerType() const
{
if ( mLayerType == QgsLayerItem::Raster )
return QgsMapLayer::RasterLayer;
if ( mLayerType == QgsLayerItem::Plugin )
return QgsMapLayer::PluginLayer;
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 );
Expand Down
7 changes: 6 additions & 1 deletion src/core/qgsdataitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,16 @@ class CORE_EXPORT QgsLayerItem : public QgsDataItem
*/
virtual QString comments() const { return QString(); }

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

/** Returns the icon name of the given \a layerType
* \since QGIS 3
*/
static QString iconName( const LayerType &layerType );

protected:

//! The provider key
Expand Down
8 changes: 6 additions & 2 deletions src/providers/ogr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ SET (OGR_SRCS
qgsogrexpressioncompiler.cpp
qgsogrsourceselect.cpp
qgsgeopackagedataitems.cpp
qgsgeopackageconnection.cpp
qgsgeopackagerasterwriter.cpp
qgsgeopackagerasterwritertask.cpp
qgsogrdbconnection.cpp
qgsogrdbsourceselect.cpp
qgsogrdbtablemodel.cpp
)

SET(OGR_MOC_HDRS
Expand All @@ -18,8 +20,10 @@ SET(OGR_MOC_HDRS
qgsogrconnpool.h
qgsogrsourceselect.h
qgsgeopackagedataitems.h
qgsgeopackageconnection.h
qgsgeopackagerasterwritertask.h
qgsogrdbconnection.h
qgsogrdbsourceselect.h
qgsogrdbtablemodel.h
)

########################################################
Expand Down
Loading

0 comments on commit 32dee44

Please sign in to comment.