69 SymbolLayerFillVisitor( QTreeWidgetItem *layerItem,
const QgsVectorLayer *layer, QHash<QgsSymbolLayerReference, QTreeWidgetItem *> &items, QScreen *screen )
70 : mLayerItem( layerItem )
89 : sl( _sl ), symbol( _symbol ) {};
93 QList<TreeNode> children;
97 bool visitSymbol( TreeNode &parent,
const QString &identifier,
const QgsSymbol *symbol, QVector<int> rootPath )
105 QVector<int> indexPath = rootPath;
106 indexPath.append( idx );
108 TreeNode node( symbol, sl );
109 if ( ( sl->
layerType() ==
"MaskMarker" ) ||
110 ( subSymbol && visitSymbol( node, identifier, subSymbol, indexPath ) ) )
113 parent.children << node;
125 const QgsSymbol *symbol = symbolEntity->symbol();
129 TreeNode node( symbol );
130 if ( visitSymbol( node, leaf.
identifier, symbol, {} ) )
136 void createItems(
const QString &leafDescription, QTreeWidgetItem *rootItem,
const TreeNode &node )
138 QTreeWidgetItem *item =
nullptr;
142 item =
new QTreeWidgetItem( rootItem, QStringList() << ( mCurrentDescription + leafDescription ) );
144 item->setIcon( 0, icon );
149 item =
new QTreeWidgetItem( rootItem );
151 item->setIcon( 0, slIcon );
152 if ( node.sl->layerType() ==
"MaskMarker" )
154 item->setText( 0, QObject::tr(
"Mask symbol layer" ) );
155 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
156 item->setCheckState( 0, Qt::Unchecked );
163 rootItem->addChild( item );
165 for ( TreeNode child : node.children )
166 createItems( leafDescription, item, child );
170 QString mCurrentDescription;
171 QTreeWidgetItem *mLayerItem;
173 QHash<QgsSymbolLayerReference, QTreeWidgetItem *> &mItems;
174 QPointer< QScreen > mScreen;
180 LabelMasksVisitor( QTreeWidgetItem *layerItem,
const QgsVectorLayer *layer, QHash<QgsSymbolLayerReference, QTreeWidgetItem *> &items ):
181 mLayerItem( layerItem ), mLayer( layer ), mItems( items )
198 if ( labelSettingsEntity->settings().format().mask().enabled() )
200 const QString maskTitle = currentRule.isEmpty()
201 ? QObject::tr(
"Label mask" )
202 : QObject::tr(
"Label mask for '%1' rule" ).arg( currentDescription );
203 QTreeWidgetItem *slItem =
new QTreeWidgetItem( mLayerItem, QStringList() << maskTitle );
204 slItem->setFlags( slItem->flags() | Qt::ItemIsUserCheckable );
205 slItem->setCheckState( 0, Qt::Unchecked );
206 mLayerItem->addChild( slItem );
213 QHash<QString, QHash<QString, QSet<QgsSymbolLayerId>>> masks;
216 QString currentDescription;
217 QTreeWidgetItem *mLayerItem;
219 QHash<QgsSymbolLayerReference, QTreeWidgetItem *> &mItems;
233 std::unique_ptr< QTreeWidgetItem > layerItem = std::make_unique< QTreeWidgetItem >( mTree, QStringList() << layer->
name() );
234 layerItem->setData( 0, Qt::UserRole, QVariant::fromValue( vl ) );
238 LabelMasksVisitor lblVisitor( layerItem.get(), vl, mItems );
242 SymbolLayerFillVisitor slVisitor( layerItem.get(), vl, mItems, screen() );
245 if ( layerItem->childCount() > 0 )
246 mTree->addTopLevelItem( layerItem.release() );
249 expandAll( mTree->invisibleRootItem() );