Skip to content
Permalink
Browse files

Fix editing composer legend titles while filtering enabled (fix #11459)

  • Loading branch information
nyalldawson committed Jan 27, 2016
1 parent 6893f49 commit c7204cc72285489461722fd5c1669310ac53edc7
@@ -93,10 +93,16 @@ class QgsLayerTreeModel : QAbstractItemModel
//! @note added in 2.6
QModelIndex legendNode2index( QgsLayerTreeModelLegendNode* legendNode );

//! Return list of legend nodes attached to a particular layer node
//! Return filtered list of active legend nodes attached to a particular layer node
//! @note added in 2.6
//! @see layerOriginalLegendNodes()
QList<QgsLayerTreeModelLegendNode*> layerLegendNodes( QgsLayerTreeLayer* nodeLayer );

//! Return original (unfiltered) list of legend nodes attached to a particular layer node
//! @note added in 2.14
//! @see layerLegendNodes()
QList<QgsLayerTreeModelLegendNode*> layerOriginalLegendNodes( QgsLayerTreeLayer* nodeLayer );

/** Searches through the layer tree to find a legend node with a matching layer ID
* and rule key.
* @param layerId map layer ID
@@ -773,7 +773,10 @@ void QgsComposerLegendWidget::on_mEditPushButton_clicked()
else if ( legendNode )
{
QList<int> order = QgsMapLayerLegendUtils::legendNodeOrder( legendNode->layerNode() );
int originalIndex = ( idx.row() >= 0 && idx.row() < order.count() ? order[idx.row()] : -1 );
//find unfiltered row number
QList<QgsLayerTreeModelLegendNode*> layerLegendNodes = model->layerOriginalLegendNodes( legendNode->layerNode() );
int unfilteredRowIndex = layerLegendNodes.indexOf( legendNode );
int originalIndex = ( unfilteredRowIndex >= 0 && unfilteredRowIndex < order.count() ? order[unfilteredRowIndex] : -1 );
QgsMapLayerLegendUtils::setLegendNodeUserLabel( legendNode->layerNode(), originalIndex, newText );
model->refreshLayerLegend( legendNode->layerNode() );
}
@@ -1338,6 +1338,11 @@ QList<QgsLayerTreeModelLegendNode*> QgsLayerTreeModel::layerLegendNodes( QgsLaye
return mLegend.value( nodeLayer ).activeNodes;
}

QList<QgsLayerTreeModelLegendNode*> QgsLayerTreeModel::layerOriginalLegendNodes( QgsLayerTreeLayer* nodeLayer )
{
return mLegend.value( nodeLayer ).originalNodes;
}

QgsLayerTreeModelLegendNode* QgsLayerTreeModel::findLegendNode( const QString& layerId, const QString& ruleKey ) const
{
Q_FOREACH ( QgsLayerTreeLayer* layer, mLegend.keys() )
@@ -117,10 +117,16 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
//! @note added in 2.6
QModelIndex legendNode2index( QgsLayerTreeModelLegendNode* legendNode );

//! Return list of legend nodes attached to a particular layer node
//! Return filtered list of active legend nodes attached to a particular layer node
//! @note added in 2.6
//! @see layerOriginalLegendNodes()
QList<QgsLayerTreeModelLegendNode*> layerLegendNodes( QgsLayerTreeLayer* nodeLayer );

//! Return original (unfiltered) list of legend nodes attached to a particular layer node
//! @note added in 2.14
//! @see layerLegendNodes()
QList<QgsLayerTreeModelLegendNode*> layerOriginalLegendNodes( QgsLayerTreeLayer* nodeLayer );

/** Searches through the layer tree to find a legend node with a matching layer ID
* and rule key.
* @param layerId map layer ID

0 comments on commit c7204cc

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