Skip to content
Permalink
Browse files

Update another method

  • Loading branch information
pblottiere committed May 11, 2020
1 parent 6550dad commit 2cbf4a12ea68dad9321e9380cebcc9cf983d1296
Showing with 6 additions and 5 deletions.
  1. +5 −4 src/core/qgslegendrenderer.cpp
  2. +1 −1 src/core/qgslegendrenderer.h
@@ -76,13 +76,14 @@ QJsonObject QgsLegendRenderer::exportLegendToJson( const QgsRenderContext &conte
if ( !rootGroup )
return json;

json = exportLegendToJson( context, rootGroup );
json[QStringLiteral( "title" )] = mSettings.title();
exportLegendToJson( context, rootGroup, json );
return json;
}

void QgsLegendRenderer::exportLegendToJson( const QgsRenderContext &context, QgsLayerTreeGroup *nodeGroup, QJsonObject &json )
QJsonObject QgsLegendRenderer::exportLegendToJson( const QgsRenderContext &context, QgsLayerTreeGroup *nodeGroup )
{
QJsonObject json;
QJsonArray nodes;
const QList<QgsLayerTreeNode *> childNodes = nodeGroup->children();
for ( QgsLayerTreeNode *node : childNodes )
@@ -93,10 +94,9 @@ void QgsLegendRenderer::exportLegendToJson( const QgsRenderContext &context, Qgs
const QModelIndex idx = mLegendModel->node2index( nodeGroup );
const QString text = mLegendModel->data( idx, Qt::DisplayRole ).toString();

QJsonObject group;
QJsonObject group = exportLegendToJson( context, nodeGroup );
group[ QStringLiteral( "type" ) ] = QStringLiteral( "group" );
group[ QStringLiteral( "title" ) ] = text;
exportLegendToJson( context, nodeGroup, group );
nodes.append( group );
}
else if ( QgsLayerTree::isLayer( node ) )
@@ -141,6 +141,7 @@ void QgsLegendRenderer::exportLegendToJson( const QgsRenderContext &context, Qgs
}

json[QStringLiteral( "nodes" )] = nodes;
return json;
}

QSizeF QgsLegendRenderer::paintAndDetermineSize( QgsRenderContext &context )
@@ -234,7 +234,7 @@ class CORE_EXPORT QgsLegendRenderer
*
* \since QGIS 3.8
*/
void exportLegendToJson( const QgsRenderContext &context, QgsLayerTreeGroup *nodeGroup, QJsonObject &json );
QJsonObject exportLegendToJson( const QgsRenderContext &context, QgsLayerTreeGroup *nodeGroup );

/**
* Draws the legend using the specified render \a context, and returns the actual size of the legend.

0 comments on commit 2cbf4a1

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