Skip to content
Permalink
Browse files

[browser] Unify layer name in properties for raster/vector layers

(cherry picked from commit 620643e)
  • Loading branch information
nyalldawson committed Oct 31, 2018
1 parent 5cfd9aa commit b9f36f1b27f973a7deb6847db9df6971a3d737b3
Showing with 13 additions and 33 deletions.
  1. +13 −33 src/gui/qgsbrowserdockwidget_p.cpp
@@ -159,6 +159,8 @@ void QgsBrowserLayerProperties::setItem( QgsDataItem *item )
ProjectionSettingRestorer restorer;
( void )restorer; // no warnings

std::unique_ptr<QgsMapLayer> layer;

// find root item
// we need to create a temporary layer to get metadata
// we could use a provider but the metadata is not as complete and "pretty" and this is easier
@@ -167,54 +169,32 @@ void QgsBrowserLayerProperties::setItem( QgsDataItem *item )
{
QgsDebugMsg( QStringLiteral( "creating raster layer" ) );
// should copy code from addLayer() to split uri ?
std::unique_ptr<QgsRasterLayer> layer( new QgsRasterLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() ) );
if ( layer )
{
if ( layer->isValid() )
{
bool ok = false;
layer->loadDefaultMetadata( ok );
layerCrs = layer->crs();
layerMetadata = layer->htmlMetadata();
}
}
layer = qgis::make_unique< QgsRasterLayer >( layerItem->uri(), layerItem->name(), layerItem->providerKey() );
}
else if ( type == QgsMapLayer::MeshLayer )
{
QgsDebugMsg( QStringLiteral( "creating mesh layer" ) );
std::unique_ptr<QgsMeshLayer> layer( new QgsMeshLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() ) );
if ( layer )
{
if ( layer->isValid() )
{
bool ok = false;
layer->loadDefaultMetadata( ok );
layerCrs = layer->crs();
layerMetadata = layer->htmlMetadata();
}
}
layer = qgis::make_unique < QgsMeshLayer >( layerItem->uri(), layerItem->name(), layerItem->providerKey() );
}
else if ( type == QgsMapLayer::VectorLayer )
{
QgsDebugMsg( QStringLiteral( "creating vector layer" ) );
std::unique_ptr<QgsVectorLayer> layer( new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() ) );
if ( layer )
{
if ( layer->isValid() )
{
bool ok = false;
layer->loadDefaultMetadata( ok );
layerCrs = layer->crs();
layerMetadata = layer->htmlMetadata();
}
}
layer = qgis::make_unique < QgsVectorLayer>( layerItem->uri(), layerItem->name(), layerItem->providerKey() );
}
else if ( type == QgsMapLayer::PluginLayer )
{
// TODO: support display of properties for plugin layers
return;
}

if ( layer && layer->isValid() )
{
bool ok = false;
layer->loadDefaultMetadata( ok );
layerCrs = mLayer->crs();
layerMetadata = mLayer->htmlMetadata();
}

QString myStyle = QgsApplication::reportStyleSheet();
mMetadataTextBrowser->document()->setDefaultStyleSheet( myStyle );
mMetadataTextBrowser->setHtml( layerMetadata );

0 comments on commit b9f36f1

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