39 void QgsMaskingWidget::onSelectionChanged()
42 bool printMessage = mMaskTargetsWidget->selection().empty() != mMaskSourcesWidget->selection().empty();
44 if ( mMessageBarItem && !printMessage )
46 mMessageBar->popWidget( mMessageBarItem );
47 delete mMessageBarItem;
49 else if ( !mMessageBarItem && printMessage )
51 mMessageBarItem =
new QgsMessageBarItem( tr(
"Select both sources and symbol layers or your configuration will be lost" ),
Qgis::Warning, 0,
this );
52 mMessageBar->pushItem( mMessageBarItem );
68 mMustPopulate =
false;
110 QVector<int> indexPath = rootPath;
111 indexPath.push_back( idx );
115 mCallback( sl,
QgsSymbolLayerId( mSymbolKey + leafIdentifier, indexPath ) );
120 visitSymbol( subSymbol, leafIdentifier, indexPath );
129 if ( symbolEntity->symbol() )
137 QList<QPair<QgsSymbolLayerId, QList<QgsSymbolLayerReference>>> mMasks;
155 QList<QPair<QgsSymbolLayerId, QList<QgsSymbolLayerReference>>> mMasks;
158 if ( ! sl->
masks().isEmpty() )
159 mMasks.push_back( qMakePair( lid, sl->
masks() ) );
167 if ( mLayer != layer )
170 mMustPopulate =
true;
174 void QgsMaskingWidget::populate()
176 mMaskSourcesWidget->update();
177 mMaskTargetsWidget->setLayer( mLayer );
180 QSet<QgsSymbolLayerId> maskedSymbolLayers;
181 QList<QgsMaskSourceSelectionWidget::MaskSource> maskSources;
185 for (
auto layerIt = layers.begin(); layerIt != layers.end(); layerIt++ )
187 QString layerId = layerIt.key();
188 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layerIt.value() );
193 QList<QPair<QgsSymbolLayerId, QList<QgsSymbolLayerReference>>> slMasks =
symbolLayerMasks( vl );
194 for (
auto p : slMasks )
207 maskSources.append( source );
214 for (
auto it = labelMasks.begin(); it != labelMasks.end(); it++ )
216 const QString &ruleKey = it.key();
217 for (
auto it2 = it.value().begin(); it2 != it.value().end(); it2++ )
219 if ( it2.key() == mLayer->
id() )
222 maskedSymbolLayers.unite( it2.value() );
227 maskSources.append( source );
233 mMaskSourcesWidget->setSelection( maskSources );
234 mMaskTargetsWidget->setSelection( maskedSymbolLayers );
239 QList<QgsMaskSourceSelectionWidget::MaskSource> maskSources = mMaskSourcesWidget->selection();
240 QSet<QgsSymbolLayerId> maskedSymbolLayers = mMaskTargetsWidget->selection();
242 QSet<QString> layersToRefresh;
245 for (
auto layerIt = layers.begin(); layerIt != layers.end(); layerIt++ )
247 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layerIt.value() );
257 QgsMaskMarkerSymbolLayer *maskSl = const_cast<QgsMaskMarkerSymbolLayer *>( static_cast<const QgsMaskMarkerSymbolLayer *>( sl ) );
259 QgsSymbolLayerReferenceList masks = maskSl->masks();
260 QgsSymbolLayerReferenceList newMasks;
261 for ( const QgsSymbolLayerReference &ref : masks )
264 if ( ref.layerId() != mLayer->id() )
265 newMasks.append( ref );
272 for ( const QgsSymbolLayerId &maskedId : maskedSymbolLayers )
274 newMasks.append( QgsSymbolLayerReference( mLayer->id(), maskedId ) );
277 layersToRefresh.insert( source.
layerId );
280 maskSl->setMasks( newMasks );
302 if ( ref.
layerId() != mLayer->id() )
303 newMasks.append( ref );
316 layersToRefresh.insert( source.
layerId );
327 mLayer->triggerRepaint();
329 for ( QString layerId : layersToRefresh )