Skip to content

Commit

Permalink
add GRASS vector layers from browser with map + layer name
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Nov 6, 2014
1 parent 2202b42 commit d74b52e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -53,9 +53,10 @@ extern "C"
#if GRASS_VERSION_MAJOR >= 7
#define G_suppress_masking Rast_suppress_masking
#define BOUND_BOX bound_box
#if GRASS_VERSION_MINOR >= 1
#define G_available_mapsets G_get_available_mapsets
#endif

#if GRASS_VERSION_MAJOR > 7 || (GRASS_VERSION_MAJOR == 7 && GRASS_VERSION_MINOR >= 1)
#define G_available_mapsets G_get_available_mapsets
#endif

#if !defined(GRASS_VERSION_MAJOR) || \
Expand Down
14 changes: 13 additions & 1 deletion src/providers/grass/qgsgrassprovidermodule.cpp
Expand Up @@ -117,7 +117,7 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
}
else
{
QgsLayerItem *layer = new QgsLayerItem( map, baseLayerName, path, uri, layerType, "grass" );
QgsLayerItem *layer = new QgsGrassVectorLayerItem( map, name, baseLayerName, path, uri, layerType, "grass" );
map->addChild( layer );
}
}
Expand All @@ -140,6 +140,18 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
return items;
}

QgsGrassVectorLayerItem::QgsGrassVectorLayerItem( QgsDataItem* parent, QString mapName, QString layerName, QString path, QString uri, LayerType layerType, QString providerKey )
: QgsLayerItem( parent, layerName, path, uri, layerType, providerKey )
, mMapName( mapName )
{
}

QString QgsGrassVectorLayerItem::layerName() const
{
// to get map + layer when added from browser
return mMapName + " " + name();
}

QGISEXTERN int dataCapabilities()
{
return QgsDataProvider::Dir;
Expand Down
12 changes: 12 additions & 0 deletions src/providers/grass/qgsgrassprovidermodule.h
Expand Up @@ -41,4 +41,16 @@ class QgsGrassMapsetItem : public QgsDataCollectionItem
QString mGisdbase;
};

class QgsGrassVectorLayerItem : public QgsLayerItem
{
public:
QgsGrassVectorLayerItem( QgsDataItem* parent, QString mapName, QString layerName, QString path, QString uri, LayerType layerType, QString providerKey );
~QgsGrassVectorLayerItem() {};

QString layerName() const;

private:
QString mMapName;
};

#endif // QGSGRASSPROVIDERMODULE_H

0 comments on commit d74b52e

Please sign in to comment.