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" ) || ( subSymbol && visitSymbol( node, identifier, subSymbol, indexPath ) ) )
112 parent.children << node;
124 const QgsSymbol *symbol = symbolEntity->symbol();
128 TreeNode node( symbol );
129 if ( visitSymbol( node, leaf.
identifier, symbol, {} ) )
135 void createItems(
const QString &leafDescription, QTreeWidgetItem *rootItem,
const TreeNode &node )
137 QTreeWidgetItem *item =
nullptr;
141 item =
new QTreeWidgetItem( rootItem, QStringList() << ( mCurrentDescription + leafDescription ) );
143 item->setIcon( 0, icon );
148 item =
new QTreeWidgetItem( rootItem );
150 item->setIcon( 0, slIcon );
151 if ( node.sl->layerType() ==
"MaskMarker" )
153 item->setText( 0, QObject::tr(
"Mask symbol layer" ) );
154 item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
155 item->setCheckState( 0, Qt::Unchecked );
162 rootItem->addChild( item );
164 for ( TreeNode child : node.children )
165 createItems( leafDescription, item, child );
169 QString mCurrentDescription;
170 QTreeWidgetItem *mLayerItem;
172 QHash<QgsSymbolLayerReference, QTreeWidgetItem *> &mItems;
173 QPointer<QScreen> mScreen;
179 LabelMasksVisitor( QTreeWidgetItem *layerItem,
const QgsVectorLayer *layer, QHash<QgsSymbolLayerReference, QTreeWidgetItem *> &items )
180 : mLayerItem( layerItem ), mLayer( layer ), mItems( items )
197 if ( labelSettingsEntity->settings().format().mask().enabled() )
199 const QString maskTitle = currentRule.isEmpty()
200 ? QObject::tr(
"Label mask" )
201 : QObject::tr(
"Label mask for '%1' rule" ).arg( currentDescription );
202 QTreeWidgetItem *slItem =
new QTreeWidgetItem( mLayerItem, QStringList() << maskTitle );
203 slItem->setFlags( slItem->flags() | Qt::ItemIsUserCheckable );
204 slItem->setCheckState( 0, Qt::Unchecked );
205 mLayerItem->addChild( slItem );
212 QHash<QString, QHash<QString, QSet<QgsSymbolLayerId>>> masks;
215 QString currentDescription;
216 QTreeWidgetItem *mLayerItem;
218 QHash<QgsSymbolLayerReference, QTreeWidgetItem *> &mItems;
232 std::unique_ptr<QTreeWidgetItem> layerItem = std::make_unique<QTreeWidgetItem>( mTree, QStringList() << layer->
name() );
233 layerItem->setData( 0, Qt::UserRole, QVariant::fromValue( vl ) );
237 LabelMasksVisitor lblVisitor( layerItem.get(), vl, mItems );
241 SymbolLayerFillVisitor slVisitor( layerItem.get(), vl, mItems, screen() );
244 if ( layerItem->childCount() > 0 )
245 mTree->addTopLevelItem( layerItem.release() );
248 expandAll( mTree->invisibleRootItem() );