34 MapThemeLayerRecord layerRec( nodeLayer->
layer() );
35 layerRec.isVisible = nodeLayer->
isVisible();
36 layerRec.usingCurrentStyle =
true;
38 layerRec.expandedLayerNode = nodeLayer->
isExpanded();
39 const QStringList expandedLegendNodes = nodeLayer->
customProperty( QStringLiteral(
"expandedLegendNodes" ) ).toStringList();
40 layerRec.expandedLegendItems = QSet<QString>( expandedLegendNodes.begin(), expandedLegendNodes.end() );
43 bool hasCheckableItems =
false;
44 bool someItemsUnchecked =
false;
45 QSet<QString> checkedItems;
46 const QList<QgsLayerTreeModelLegendNode *> layerLegendNodes = model->
layerLegendNodes( nodeLayer,
true );
49 if ( legendNode->
flags() & Qt::ItemIsUserCheckable )
51 hasCheckableItems =
true;
53 if ( legendNode->
data( Qt::CheckStateRole ).toInt() == Qt::Checked )
56 someItemsUnchecked =
true;
60 if ( hasCheckableItems && someItemsUnchecked )
62 layerRec.usingLegendItems =
true;
63 layerRec.checkedLegendItems = checkedItems;
73 lst.prepend( node->
name() );
76 return lst.join(
'/' );
81 const QList<QgsLayerTreeNode *> constChildren = parent->
children();
88 rec.mExpandedGroupNodes.insert( _groupId( node ) );
90 rec.mCheckedGroupNodes.insert( _groupId( node ) );
96 rec.mLayerRecords << createThemeLayerRecord( nodeLayer, model );
114 if ( lr.layer() == layer )
125 MapThemeLayerRecord layerRec;
126 const bool recordExists = findRecordForLayer( nodeLayer->
layer(), rec, layerRec );
142 if ( layerRec.usingCurrentStyle )
148 if ( layerRec.usingLegendItems )
151 const QList<QgsLayerTreeModelLegendNode *> constLayerLegendNodes = model->
layerLegendNodes( nodeLayer,
true );
155 Qt::CheckState shouldHaveState = layerRec.checkedLegendItems.contains( ruleKey ) ? Qt::Checked : Qt::Unchecked;
157 legendNode->
data( Qt::CheckStateRole ).toInt() != shouldHaveState )
164 const QList<QgsLayerTreeModelLegendNode *> constLayerLegendNodes = model->
layerLegendNodes( nodeLayer,
true );
176 nodeLayer->
setExpanded( layerRec.expandedLayerNode );
177 nodeLayer->
setCustomProperty( QStringLiteral(
"expandedLegendNodes" ), QStringList( layerRec.expandedLegendItems.constBegin(), layerRec.expandedLegendItems.constEnd() ) );
184 const QList<QgsLayerTreeNode *> constChildren = parent->
children();
228 return QList< QgsMapLayer * >();
238 if ( allLayers.isEmpty() )
241 return visibleLayers;
245 QList< QgsMapLayer * > orderedVisibleLayers;
248 if ( visibleLayers.contains( layer ) )
249 orderedVisibleLayers << layer;
251 return orderedVisibleLayers;
258 return mMapThemes.contains( name );
263 mMapThemes.insert( name, state );
265 reconnectToLayersStyleManager();
272 if ( !mMapThemes.contains( name ) )
275 mMapThemes[name] = state;
277 reconnectToLayersStyleManager();
284 if ( !mMapThemes.contains( name ) || mMapThemes.contains( newName ) )
289 insert( newName, newState );
297 if ( !mMapThemes.contains( name ) )
300 mMapThemes.remove( name );
302 reconnectToLayersStyleManager();
310 reconnectToLayersStyleManager();
316 return mMapThemes.keys();
321 QStringList layerIds;
323 for (
QgsMapLayer *layer : constMapThemeVisibleLayers )
325 layerIds << layer->
id();
332 QList<QgsMapLayer *> layers;
333 const QList<MapThemeLayerRecord> recs = mMapThemes.value( name ).mLayerRecords;
335 if ( layerOrder.isEmpty() )
338 const QList<MapThemeLayerRecord> records { mMapThemes.value( name ).mLayerRecords };
341 if ( layerRec.isVisible && layerRec.layer() )
342 layers << layerRec.layer();
351 if ( layerRec.isVisible && layerRec.layer() == layer )
352 layers << layerRec.layer();
361void QgsMapThemeCollection::applyMapThemeCheckedLegendNodesToLayer(
const MapThemeLayerRecord &layerRec,
QgsMapLayer *layer )
364 if ( !vlayer || !vlayer->
renderer() )
371 bool someNodesUnchecked = layerRec.usingLegendItems;
377 bool shouldBeChecked = someNodesUnchecked ? layerRec.checkedLegendItems.contains( item.ruleKey() ) :
true;
378 if ( checked != shouldBeChecked )
386 QMap<QString, QString> styleOverrides;
387 if ( !mMapThemes.contains( presetName ) )
388 return styleOverrides;
390 const QList<MapThemeLayerRecord> records {mMapThemes.value( presetName ).mLayerRecords};
393 if ( !layerRec.layer() )
396 if ( layerRec.usingCurrentStyle )
403 applyMapThemeCheckedLegendNodesToLayer( layerRec, layer );
408 styleOverrides[layer->
id()] = layerStyle.
xmlData();
411 return styleOverrides;
414void QgsMapThemeCollection::reconnectToLayersStyleManager()
418 QSet<QgsMapLayer *> layers;
419 for (
const MapThemeRecord &rec : std::as_const( mMapThemes ) )
421 for (
const MapThemeLayerRecord &layerRec : std::as_const( rec.mLayerRecords ) )
423 if (
auto *lLayer = layerRec.layer() )
428 const QSet<QgsMapLayer *> constLayers = layers;
439 QDomElement visPresetsElem = doc.firstChildElement( QStringLiteral(
"qgis" ) ).firstChildElement( QStringLiteral(
"visibility-presets" ) );
440 if ( visPresetsElem.isNull() )
443 QDomElement visPresetElem = visPresetsElem.firstChildElement( QStringLiteral(
"visibility-preset" ) );
444 while ( !visPresetElem.isNull() )
446 QHash<QString, MapThemeLayerRecord> layerRecords;
448 bool expandedStateInfo =
false;
449 if ( visPresetElem.hasAttribute( QStringLiteral(
"has-expanded-info" ) ) )
450 expandedStateInfo = visPresetElem.attribute( QStringLiteral(
"has-expanded-info" ) ).toInt();
452 bool checkedStateInfo =
false;
453 if ( visPresetElem.hasAttribute( QStringLiteral(
"has-checked-group-info" ) ) )
454 checkedStateInfo = visPresetElem.attribute( QStringLiteral(
"has-checked-group-info" ) ).toInt();
456 QString presetName = visPresetElem.attribute( QStringLiteral(
"name" ) );
457 QDomElement visPresetLayerElem = visPresetElem.firstChildElement( QStringLiteral(
"layer" ) );
458 while ( !visPresetLayerElem.isNull() )
460 QString layerID = visPresetLayerElem.attribute( QStringLiteral(
"id" ) );
464 layerRecords[layerID].isVisible = visPresetLayerElem.attribute( QStringLiteral(
"visible" ), QStringLiteral(
"1" ) ).toInt();
466 if ( visPresetLayerElem.hasAttribute( QStringLiteral(
"style" ) ) )
468 layerRecords[layerID].usingCurrentStyle =
true;
469 layerRecords[layerID].currentStyle = visPresetLayerElem.attribute( QStringLiteral(
"style" ) );
472 if ( visPresetLayerElem.hasAttribute( QStringLiteral(
"expanded" ) ) )
473 layerRecords[layerID].expandedLayerNode = visPresetLayerElem.attribute( QStringLiteral(
"expanded" ) ).toInt();
475 visPresetLayerElem = visPresetLayerElem.nextSiblingElement( QStringLiteral(
"layer" ) );
478 QDomElement checkedLegendNodesElem = visPresetElem.firstChildElement( QStringLiteral(
"checked-legend-nodes" ) );
479 while ( !checkedLegendNodesElem.isNull() )
481 QSet<QString> checkedLegendNodes;
483 QDomElement checkedLegendNodeElem = checkedLegendNodesElem.firstChildElement( QStringLiteral(
"checked-legend-node" ) );
484 while ( !checkedLegendNodeElem.isNull() )
486 checkedLegendNodes << checkedLegendNodeElem.attribute( QStringLiteral(
"id" ) );
487 checkedLegendNodeElem = checkedLegendNodeElem.nextSiblingElement( QStringLiteral(
"checked-legend-node" ) );
490 QString layerID = checkedLegendNodesElem.attribute( QStringLiteral(
"id" ) );
491 if ( mProject->
mapLayer( layerID ) )
493 layerRecords[layerID].usingLegendItems =
true;
494 layerRecords[layerID].checkedLegendItems = checkedLegendNodes;
496 checkedLegendNodesElem = checkedLegendNodesElem.nextSiblingElement( QStringLiteral(
"checked-legend-nodes" ) );
499 QSet<QString> expandedGroupNodes;
500 if ( expandedStateInfo )
503 QDomElement expandedLegendNodesElem = visPresetElem.firstChildElement( QStringLiteral(
"expanded-legend-nodes" ) );
504 while ( !expandedLegendNodesElem.isNull() )
506 QSet<QString> expandedLegendNodes;
508 QDomElement expandedLegendNodeElem = expandedLegendNodesElem.firstChildElement( QStringLiteral(
"expanded-legend-node" ) );
509 while ( !expandedLegendNodeElem.isNull() )
511 expandedLegendNodes << expandedLegendNodeElem.attribute( QStringLiteral(
"id" ) );
512 expandedLegendNodeElem = expandedLegendNodeElem.nextSiblingElement( QStringLiteral(
"expanded-legend-node" ) );
515 QString layerID = expandedLegendNodesElem.attribute( QStringLiteral(
"id" ) );
516 if ( mProject->
mapLayer( layerID ) )
518 layerRecords[layerID].expandedLegendItems = expandedLegendNodes;
520 expandedLegendNodesElem = expandedLegendNodesElem.nextSiblingElement( QStringLiteral(
"expanded-legend-nodes" ) );
524 QDomElement expandedGroupNodesElem = visPresetElem.firstChildElement( QStringLiteral(
"expanded-group-nodes" ) );
525 if ( !expandedGroupNodesElem.isNull() )
527 QDomElement expandedGroupNodeElem = expandedGroupNodesElem.firstChildElement( QStringLiteral(
"expanded-group-node" ) );
528 while ( !expandedGroupNodeElem.isNull() )
530 expandedGroupNodes << expandedGroupNodeElem.attribute( QStringLiteral(
"id" ) );
531 expandedGroupNodeElem = expandedGroupNodeElem.nextSiblingElement( QStringLiteral(
"expanded-group-node" ) );
536 QSet<QString> checkedGroupNodes;
537 if ( checkedStateInfo )
540 QDomElement checkedGroupNodesElem = visPresetElem.firstChildElement( QStringLiteral(
"checked-group-nodes" ) );
541 if ( !checkedGroupNodesElem.isNull() )
543 QDomElement checkedGroupNodeElem = checkedGroupNodesElem.firstChildElement( QStringLiteral(
"checked-group-node" ) );
544 while ( !checkedGroupNodeElem.isNull() )
546 checkedGroupNodes << checkedGroupNodeElem.attribute( QStringLiteral(
"id" ) );
547 checkedGroupNodeElem = checkedGroupNodeElem.nextSiblingElement( QStringLiteral(
"checked-group-node" ) );
558 mMapThemes.insert( presetName, rec );
561 visPresetElem = visPresetElem.nextSiblingElement( QStringLiteral(
"visibility-preset" ) );
564 reconnectToLayersStyleManager();
570 QDomElement visPresetsElem = doc.createElement( QStringLiteral(
"visibility-presets" ) );
572 QList< QString > keys = mMapThemes.keys();
574 std::sort( keys.begin(), keys.end() );
576 for (
const QString &grpName : std::as_const( keys ) )
579 QDomElement visPresetElem = doc.createElement( QStringLiteral(
"visibility-preset" ) );
580 visPresetElem.setAttribute( QStringLiteral(
"name" ), grpName );
582 visPresetElem.setAttribute( QStringLiteral(
"has-expanded-info" ), QStringLiteral(
"1" ) );
584 visPresetElem.setAttribute( QStringLiteral(
"has-checked-group-info" ), QStringLiteral(
"1" ) );
587 if ( !layerRec.layer() )
589 QString layerID = layerRec.layer()->id();
590 QDomElement layerElem = doc.createElement( QStringLiteral(
"layer" ) );
591 layerElem.setAttribute( QStringLiteral(
"id" ), layerID );
592 layerElem.setAttribute( QStringLiteral(
"visible" ), layerRec.isVisible ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
593 if ( layerRec.usingCurrentStyle )
594 layerElem.setAttribute( QStringLiteral(
"style" ), layerRec.currentStyle );
595 visPresetElem.appendChild( layerElem );
597 if ( layerRec.usingLegendItems )
599 QDomElement checkedLegendNodesElem = doc.createElement( QStringLiteral(
"checked-legend-nodes" ) );
600 checkedLegendNodesElem.setAttribute( QStringLiteral(
"id" ), layerID );
601 for (
const QString &checkedLegendNode : std::as_const( layerRec.checkedLegendItems ) )
603 QDomElement checkedLegendNodeElem = doc.createElement( QStringLiteral(
"checked-legend-node" ) );
604 checkedLegendNodeElem.setAttribute( QStringLiteral(
"id" ), checkedLegendNode );
605 checkedLegendNodesElem.appendChild( checkedLegendNodeElem );
607 visPresetElem.appendChild( checkedLegendNodesElem );
612 layerElem.setAttribute( QStringLiteral(
"expanded" ), layerRec.expandedLayerNode ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
614 QDomElement expandedLegendNodesElem = doc.createElement( QStringLiteral(
"expanded-legend-nodes" ) );
615 expandedLegendNodesElem.setAttribute( QStringLiteral(
"id" ), layerID );
616 for (
const QString &expandedLegendNode : std::as_const( layerRec.expandedLegendItems ) )
618 QDomElement expandedLegendNodeElem = doc.createElement( QStringLiteral(
"expanded-legend-node" ) );
619 expandedLegendNodeElem.setAttribute( QStringLiteral(
"id" ), expandedLegendNode );
620 expandedLegendNodesElem.appendChild( expandedLegendNodeElem );
622 visPresetElem.appendChild( expandedLegendNodesElem );
628 QDomElement checkedGroupElems = doc.createElement( QStringLiteral(
"checked-group-nodes" ) );
630 for (
const QString &groupId : checkedGroupNodes )
632 QDomElement checkedGroupElem = doc.createElement( QStringLiteral(
"checked-group-node" ) );
633 checkedGroupElem.setAttribute( QStringLiteral(
"id" ), groupId );
634 checkedGroupElems.appendChild( checkedGroupElem );
636 visPresetElem.appendChild( checkedGroupElems );
641 QDomElement expandedGroupElems = doc.createElement( QStringLiteral(
"expanded-group-nodes" ) );
643 for (
const QString &groupId : expandedGroupNodes )
645 QDomElement expandedGroupElem = doc.createElement( QStringLiteral(
"expanded-group-node" ) );
646 expandedGroupElem.setAttribute( QStringLiteral(
"id" ), groupId );
647 expandedGroupElems.appendChild( expandedGroupElem );
649 visPresetElem.appendChild( expandedGroupElems );
652 visPresetsElem.appendChild( visPresetElem );
655 doc.firstChildElement( QStringLiteral(
"qgis" ) ).appendChild( visPresetsElem );
658void QgsMapThemeCollection::registryLayersRemoved(
const QStringList &layerIDs )
662 QSet< QString > changedThemes;
663 MapThemeRecordMap::iterator it = mMapThemes.begin();
664 for ( ; it != mMapThemes.end(); ++it )
666 MapThemeRecord &rec = it.value();
667 for (
int i = 0; i < rec.mLayerRecords.count(); ++i )
669 MapThemeLayerRecord &layerRec = rec.mLayerRecords[i];
670 if ( layerRec.layer() && layerIDs.contains( layerRec.layer()->id() ) )
672 rec.mLayerRecords.removeAt( i-- );
673 changedThemes << it.key();
678 for (
const QString &theme : std::as_const( changedThemes ) )
685void QgsMapThemeCollection::layerStyleRenamed(
const QString &oldName,
const QString &newName )
691 QSet< QString > changedThemes;
693 MapThemeRecordMap::iterator it = mMapThemes.begin();
694 for ( ; it != mMapThemes.end(); ++it )
696 MapThemeRecord &rec = it.value();
697 for (
int i = 0; i < rec.mLayerRecords.count(); ++i )
699 MapThemeLayerRecord &layerRec = rec.mLayerRecords[i];
700 if ( layerRec.layer() == styleMgr->
layer() )
702 if ( layerRec.currentStyle == oldName )
704 layerRec.currentStyle = newName;
705 changedThemes << it.key();
711 for (
const QString &theme : std::as_const( changedThemes ) )
720 for (
int i = 0; i < mLayerRecords.length(); ++i )
722 if ( mLayerRecords.at( i ).layer() == layer )
723 mLayerRecords.removeAt( i );
729 mLayerRecords.append( record );
734 QHash<QgsMapLayer *, MapThemeLayerRecord> validSet;
737 if (
auto *lLayer = layerRec.layer() )
738 validSet.insert( lLayer, layerRec );
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
virtual bool legendSymbolItemsCheckable() const
Returns true if symbology items in legend are checkable.
virtual bool legendSymbolItemChecked(const QString &key)
Returns true if the legend symbology item with the specified key is checked.
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
Sets whether the legend symbology item with the specified ley should be checked.
Layer tree group node serves as a container for layers and further groups.
Layer tree node points to a map layer.
QgsMapLayer * layer() const
Returns the map layer associated with this node.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
virtual QVariant data(int role) const =0
Returns data associated with the item. Must be implemented in derived class.
@ RuleKey
Rule key of the node (QString)
virtual Qt::ItemFlags flags() const
Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled.
virtual bool setData(const QVariant &value, int role)
Sets some data associated with the item. Default implementation does nothing and returns false.
The QgsLayerTreeModel class is model implementation for Qt item views framework.
QList< QgsLayerTreeModelLegendNode * > layerLegendNodes(QgsLayerTreeLayer *nodeLayer, bool skipNodeEmbeddedInParent=false)
Returns filtered list of active legend nodes attached to a particular layer node (by default it retur...
This class is a base class for nodes in a layer tree.
bool isVisible() const
Returns whether a node is really visible (ie checked and all its ancestors checked as well)
void setCustomProperty(const QString &key, const QVariant &value)
Sets a custom property for the node. Properties are stored in a map and saved in project file.
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer. Properties are stored in a map and saved in project file.
void setExpanded(bool expanded)
Sets whether the node should be shown as expanded or collapsed in GUI.
virtual QString name() const =0
Returns name of the node.
QgsLayerTreeNode * parent()
Gets pointer to the parent. If parent is nullptr, the node is a root node.
bool isExpanded() const
Returns whether the node should be shown as expanded or collapsed in GUI.
void setItemVisibilityChecked(bool checked)
Check or uncheck a node (independently of its ancestors or children)
QList< QgsMapLayer * > checkedLayers() const
Returns a list of any checked layers which belong to this node or its children.
bool itemVisibilityChecked() const
Returns whether a node is checked (independently of its ancestors or children)
void setItemVisibilityCheckedParentRecursive(bool checked)
Check or uncheck a node and all its parents.
static QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer.
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas.
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
static bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
static QgsLayerTreeGroup * toGroup(QgsLayerTreeNode *node)
Cast node to a group.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
Management of styles for use with one map layer.
QString currentStyle() const
Returns name of the current style.
bool setCurrentStyle(const QString &name)
Set a different style as the current style - will apply it to the layer.
void styleRenamed(const QString &oldName, const QString &newName)
Emitted when a style has been renamed.
QgsMapLayer * layer() const
Gets pointer to the associated map layer.
Restore overridden layer style on destruction.
void setOverrideStyle(const QString &style)
Temporarily apply a different style to the layer.
Stores style information (renderer, opacity, labeling, diagrams etc.) applicable to a map layer.
void readFromLayer(QgsMapLayer *layer)
Store layer's active style information in the instance.
QString xmlData() const
Returns XML content of the style.
Base class for all map layer types.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
Individual record of a visible layer in a map theme record.
void setLayer(QgsMapLayer *layer)
Sets the map layer for this record.
Individual map theme record of visible layers and styles.
void setExpandedGroupNodes(const QSet< QString > &expandedGroupNodes)
Sets a set of group identifiers for group nodes that should have expanded state.
void removeLayerRecord(QgsMapLayer *layer)
Removes a record for layer if present.
QSet< QString > expandedGroupNodes() const
Returns a set of group identifiers for group nodes that should have expanded state (other group nodes...
void setCheckedGroupNodes(const QSet< QString > &checkedGroupNodes)
Sets a set of group identifiers for group nodes that should have checked state.
void setHasExpandedStateInfo(bool hasInfo)
Sets whether the map theme contains valid expanded/collapsed state of nodes.
bool hasExpandedStateInfo() const
Returns whether information about expanded/collapsed state of nodes has been recorded and thus whethe...
QSet< QString > checkedGroupNodes() const
Returns a set of group identifiers for group nodes that should have checked state (other group nodes ...
void setLayerRecords(const QList< QgsMapThemeCollection::MapThemeLayerRecord > &records)
Sets layer records for the theme.
void setHasCheckedStateInfo(bool hasInfo)
Sets whether the map theme contains valid checked/unchecked state of group nodes.
QHash< QgsMapLayer *, QgsMapThemeCollection::MapThemeLayerRecord > validLayerRecords() const
Returns set with only records for valid layers.
void addLayerRecord(const QgsMapThemeCollection::MapThemeLayerRecord &record)
Add a new record for a layer.
bool hasCheckedStateInfo() const
Returns whether information about checked/unchecked state of groups has been recorded and thus whethe...
void mapThemesChanged()
Emitted when map themes within the collection are changed.
static QgsMapThemeCollection::MapThemeRecord createThemeFromCurrentState(QgsLayerTreeGroup *root, QgsLayerTreeModel *model)
Static method to create theme from the current state of layer visibilities in layer tree,...
void insert(const QString &name, const QgsMapThemeCollection::MapThemeRecord &state)
Inserts a new map theme to the collection.
bool renameMapTheme(const QString &name, const QString &newName)
Renames the existing map theme called name to newName.
void mapThemeRenamed(const QString &name, const QString &newName)
Emitted when a map theme within the collection is renamed.
void clear()
Removes all map themes from the collection.
bool hasMapTheme(const QString &name) const
Returns whether a map theme with a matching name exists.
QList< QgsMapLayer * > mapThemeVisibleLayers(const QString &name) const
Returns the list of layers that are visible for the specified map theme.
void removeMapTheme(const QString &name)
Removes an existing map theme from collection.
QgsMapThemeCollection::MapThemeRecord mapThemeState(const QString &name) const
Returns the recorded state of a map theme.
void setProject(QgsProject *project)
QList< QgsMapLayer * > masterLayerOrder() const
Returns the master layer order (this will always match the project's QgsProject::layerOrder() ).
void applyTheme(const QString &name, QgsLayerTreeGroup *root, QgsLayerTreeModel *model)
Apply theme given by its name and modify layer tree, current style of layers and checked legend items...
QMap< QString, QString > mapThemeStyleOverrides(const QString &name)
Gets layer style overrides (for QgsMapSettings) of the visible layers for given map theme.
QList< QgsMapLayer * > masterVisibleLayers() const
Returns the master list of visible layers.
QStringList mapThemeVisibleLayerIds(const QString &name) const
Returns the list of layer IDs that are visible for the specified map theme.
void update(const QString &name, const QgsMapThemeCollection::MapThemeRecord &state)
Updates a map theme within the collection.
void mapThemeChanged(const QString &theme)
Emitted when a map theme changes definition.
QgsMapThemeCollection(QgsProject *project=nullptr)
Create map theme collection that handles themes of the given project.
void writeXml(QDomDocument &doc)
Writes the map theme collection state to XML.
void projectChanged()
Emitted when the project changes.
void readXml(const QDomDocument &doc)
Reads the map theme collection state from XML.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
void layersWillBeRemoved(const QStringList &layerIds)
Emitted when one or more layers are about to be removed from the registry.
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
Represents a vector layer which manages a vector based data sets.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
QgsLayerTreeModelLegendNode * legendNode(const QString &rule, QgsLayerTreeModel &model)