26#include "moc_qgsmapthemecollection.cpp"
36 MapThemeLayerRecord layerRec( nodeLayer->
layer() );
37 layerRec.isVisible = nodeLayer->
isVisible();
38 layerRec.usingCurrentStyle =
true;
40 layerRec.expandedLayerNode = nodeLayer->
isExpanded();
41 const QStringList expandedLegendNodes = nodeLayer->
customProperty( QStringLiteral(
"expandedLegendNodes" ) ).toStringList();
42 layerRec.expandedLegendItems = QSet<QString>( expandedLegendNodes.begin(), expandedLegendNodes.end() );
45 bool hasCheckableItems =
false;
46 bool someItemsUnchecked =
false;
47 QSet<QString> checkedItems;
48 const QList<QgsLayerTreeModelLegendNode *> layerLegendNodes = model->
layerLegendNodes( nodeLayer,
true );
51 if ( legendNode->
flags() & Qt::ItemIsUserCheckable )
53 hasCheckableItems =
true;
55 if ( legendNode->
data( Qt::CheckStateRole ).toInt() == Qt::Checked )
58 someItemsUnchecked =
true;
62 if ( hasCheckableItems && someItemsUnchecked )
64 layerRec.usingLegendItems =
true;
65 layerRec.checkedLegendItems = checkedItems;
75 lst.prepend( node->
name() );
78 return lst.join(
'/' );
83 const QList<QgsLayerTreeNode *> constChildren = parent->
children();
84 for ( QgsLayerTreeNode *node : constChildren )
90 rec.mExpandedGroupNodes.insert( _groupId( node ) );
92 rec.mCheckedGroupNodes.insert( _groupId( node ) );
98 rec.mLayerRecords << createThemeLayerRecord( nodeLayer, model );
116 if ( lr.layer() == layer )
128 const bool recordExists = findRecordForLayer( nodeLayer->
layer(), rec, layerRec );
144 if ( layerRec.usingCurrentStyle )
150 if ( layerRec.usingLegendItems )
153 const QList<QgsLayerTreeModelLegendNode *> constLayerLegendNodes = model->
layerLegendNodes( nodeLayer,
true );
154 for ( QgsLayerTreeModelLegendNode *legendNode : constLayerLegendNodes )
157 Qt::CheckState shouldHaveState = layerRec.checkedLegendItems.contains( ruleKey ) ? Qt::Checked : Qt::Unchecked;
159 legendNode->
data( Qt::CheckStateRole ).toInt() != shouldHaveState )
166 const QList<QgsLayerTreeModelLegendNode *> constLayerLegendNodes = model->
layerLegendNodes( nodeLayer,
true );
167 for ( QgsLayerTreeModelLegendNode *legendNode : constLayerLegendNodes )
178 nodeLayer->
setExpanded( layerRec.expandedLayerNode );
179 nodeLayer->
setCustomProperty( QStringLiteral(
"expandedLegendNodes" ), QStringList( layerRec.expandedLegendItems.constBegin(), layerRec.expandedLegendItems.constEnd() ) );
186 const QList<QgsLayerTreeNode *> constChildren = parent->
children();
187 for ( QgsLayerTreeNode *node : constChildren )
230 return QList< QgsMapLayer * >();
232 return mProject->layerTreeRoot()->layerOrder();
238 const QList< QgsMapLayer * > visibleLayers = mProject->layerTreeRoot()->checkedLayers();
240 if ( allLayers.isEmpty() )
243 return visibleLayers;
247 QList< QgsMapLayer * > orderedVisibleLayers;
250 if ( visibleLayers.contains( layer ) )
251 orderedVisibleLayers << layer;
253 return orderedVisibleLayers;
260 return mMapThemes.contains( name );
265 mMapThemes.insert( name, state );
267 reconnectToLayersStyleManager();
274 if ( !mMapThemes.contains( name ) )
277 mMapThemes[name] = state;
279 reconnectToLayersStyleManager();
286 if ( !mMapThemes.contains( name ) || mMapThemes.contains( newName ) )
291 insert( newName, newState );
299 if ( !mMapThemes.contains( name ) )
302 mMapThemes.remove( name );
304 reconnectToLayersStyleManager();
312 reconnectToLayersStyleManager();
318 return mMapThemes.keys();
323 QStringList layerIds;
325 for (
QgsMapLayer *layer : constMapThemeVisibleLayers )
327 layerIds << layer->
id();
334 QList<QgsMapLayer *> layers;
335 const QList<MapThemeLayerRecord> recs = mMapThemes.value( name ).mLayerRecords;
337 if ( layerOrder.isEmpty() )
340 const QList<MapThemeLayerRecord> records { mMapThemes.value( name ).mLayerRecords };
343 if ( layerRec.isVisible && layerRec.layer() )
344 layers << layerRec.layer();
353 if ( layerRec.isVisible && layerRec.layer() == layer )
354 layers << layerRec.layer();
363void QgsMapThemeCollection::applyMapThemeCheckedLegendNodesToLayer(
const MapThemeLayerRecord &layerRec,
QgsMapLayer *layer )
366 if ( !vlayer || !vlayer->
renderer() )
373 bool someNodesUnchecked = layerRec.usingLegendItems;
379 bool shouldBeChecked = someNodesUnchecked ? layerRec.checkedLegendItems.contains( item.ruleKey() ) :
true;
380 if ( checked != shouldBeChecked )
388 QMap<QString, QString> styleOverrides;
389 if ( !mMapThemes.contains( presetName ) )
390 return styleOverrides;
392 const QList<MapThemeLayerRecord> records {mMapThemes.value( presetName ).mLayerRecords};
395 if ( !layerRec.layer() )
398 if ( layerRec.usingCurrentStyle )
405 applyMapThemeCheckedLegendNodesToLayer( layerRec, layer );
410 styleOverrides[layer->
id()] = layerStyle.
xmlData();
413 return styleOverrides;
416void 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;
429 for ( QgsMapLayer *ml : constLayers )
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 QString presetName = visPresetElem.attribute( QStringLiteral(
"name" ) );
448 mMapThemes.insert( presetName, rec );
450 visPresetElem = visPresetElem.nextSiblingElement( QStringLiteral(
"visibility-preset" ) );
453 reconnectToLayersStyleManager();
459 QDomElement visPresetsElem = doc.createElement( QStringLiteral(
"visibility-presets" ) );
461 QList< QString > keys = mMapThemes.keys();
463 std::sort( keys.begin(), keys.end() );
465 for (
const QString &grpName : std::as_const( keys ) )
468 QDomElement visPresetElem = doc.createElement( QStringLiteral(
"visibility-preset" ) );
470 visPresetElem.setAttribute( QStringLiteral(
"name" ), grpName );
473 visPresetsElem.appendChild( visPresetElem );
476 doc.firstChildElement( QStringLiteral(
"qgis" ) ).appendChild( visPresetsElem );
479void QgsMapThemeCollection::registryLayersRemoved(
const QStringList &layerIDs )
483 QSet< QString > changedThemes;
484 MapThemeRecordMap::iterator it = mMapThemes.begin();
485 for ( ; it != mMapThemes.end(); ++it )
487 MapThemeRecord &rec = it.value();
488 for (
int i = 0; i < rec.mLayerRecords.count(); ++i )
490 MapThemeLayerRecord &layerRec = rec.mLayerRecords[i];
491 if ( layerRec.layer() && layerIDs.contains( layerRec.layer()->id() ) )
493 rec.mLayerRecords.removeAt( i-- );
494 changedThemes << it.key();
499 for (
const QString &theme : std::as_const( changedThemes ) )
506void QgsMapThemeCollection::layerStyleRenamed(
const QString &oldName,
const QString &newName )
508 QgsMapLayerStyleManager *styleMgr = qobject_cast<QgsMapLayerStyleManager *>( sender() );
512 QSet< QString > changedThemes;
514 MapThemeRecordMap::iterator it = mMapThemes.begin();
515 for ( ; it != mMapThemes.end(); ++it )
518 for (
int i = 0; i < rec.mLayerRecords.count(); ++i )
521 if ( layerRec.layer() == styleMgr->
layer() )
523 if ( layerRec.currentStyle == oldName )
525 layerRec.currentStyle = newName;
526 changedThemes << it.key();
532 for (
const QString &theme : std::as_const( changedThemes ) )
541 for (
int i = 0; i < mLayerRecords.length(); ++i )
543 if ( mLayerRecords.at( i ).layer() == layer )
544 mLayerRecords.removeAt( i );
550 mLayerRecords.append( record );
555 QHash<QgsMapLayer *, MapThemeLayerRecord> validSet;
558 if (
auto *lLayer = layerRec.layer() )
559 validSet.insert( lLayer, layerRec );
568 bool expandedStateInfo =
false;
569 if ( element.hasAttribute( QStringLiteral(
"has-expanded-info" ) ) )
570 expandedStateInfo = element.attribute( QStringLiteral(
"has-expanded-info" ) ).toInt();
572 bool checkedStateInfo =
false;
573 if ( element.hasAttribute( QStringLiteral(
"has-checked-group-info" ) ) )
574 checkedStateInfo = element.attribute( QStringLiteral(
"has-checked-group-info" ) ).toInt();
576 QDomElement visPresetLayerElem = element.firstChildElement( QStringLiteral(
"layer" ) );
577 while ( !visPresetLayerElem.isNull() )
579 QString layerID = visPresetLayerElem.attribute( QStringLiteral(
"id" ) );
583 layerRecords[layerID].isVisible = visPresetLayerElem.attribute( QStringLiteral(
"visible" ), QStringLiteral(
"1" ) ).toInt();
585 if ( visPresetLayerElem.hasAttribute( QStringLiteral(
"style" ) ) )
588 layerRecords[layerID].currentStyle = visPresetLayerElem.attribute( QStringLiteral(
"style" ) );
591 if ( visPresetLayerElem.hasAttribute( QStringLiteral(
"expanded" ) ) )
592 layerRecords[layerID].expandedLayerNode = visPresetLayerElem.attribute( QStringLiteral(
"expanded" ) ).toInt();
594 visPresetLayerElem = visPresetLayerElem.nextSiblingElement( QStringLiteral(
"layer" ) );
597 QDomElement checkedLegendNodesElem = element.firstChildElement( QStringLiteral(
"checked-legend-nodes" ) );
598 while ( !checkedLegendNodesElem.isNull() )
600 QSet<QString> checkedLegendNodes;
602 QDomElement checkedLegendNodeElem = checkedLegendNodesElem.firstChildElement( QStringLiteral(
"checked-legend-node" ) );
603 while ( !checkedLegendNodeElem.isNull() )
605 checkedLegendNodes << checkedLegendNodeElem.attribute( QStringLiteral(
"id" ) );
606 checkedLegendNodeElem = checkedLegendNodeElem.nextSiblingElement( QStringLiteral(
"checked-legend-node" ) );
609 QString layerID = checkedLegendNodesElem.attribute( QStringLiteral(
"id" ) );
610 if (
project->mapLayer( layerID ) )
613 layerRecords[layerID].checkedLegendItems = checkedLegendNodes;
615 checkedLegendNodesElem = checkedLegendNodesElem.nextSiblingElement( QStringLiteral(
"checked-legend-nodes" ) );
619 if ( expandedStateInfo )
622 QDomElement expandedLegendNodesElem = element.firstChildElement( QStringLiteral(
"expanded-legend-nodes" ) );
623 while ( !expandedLegendNodesElem.isNull() )
625 QSet<QString> expandedLegendNodes;
627 QDomElement expandedLegendNodeElem = expandedLegendNodesElem.firstChildElement( QStringLiteral(
"expanded-legend-node" ) );
628 while ( !expandedLegendNodeElem.isNull() )
630 expandedLegendNodes << expandedLegendNodeElem.attribute( QStringLiteral(
"id" ) );
631 expandedLegendNodeElem = expandedLegendNodeElem.nextSiblingElement( QStringLiteral(
"expanded-legend-node" ) );
634 QString layerID = expandedLegendNodesElem.attribute( QStringLiteral(
"id" ) );
635 if (
project->mapLayer( layerID ) )
637 layerRecords[layerID].expandedLegendItems = expandedLegendNodes;
639 expandedLegendNodesElem = expandedLegendNodesElem.nextSiblingElement( QStringLiteral(
"expanded-legend-nodes" ) );
643 QDomElement expandedGroupNodesElem = element.firstChildElement( QStringLiteral(
"expanded-group-nodes" ) );
644 if ( !expandedGroupNodesElem.isNull() )
646 QDomElement expandedGroupNodeElem = expandedGroupNodesElem.firstChildElement( QStringLiteral(
"expanded-group-node" ) );
647 while ( !expandedGroupNodeElem.isNull() )
650 expandedGroupNodeElem = expandedGroupNodeElem.nextSiblingElement( QStringLiteral(
"expanded-group-node" ) );
656 if ( checkedStateInfo )
659 QDomElement checkedGroupNodesElem = element.firstChildElement( QStringLiteral(
"checked-group-nodes" ) );
660 if ( !checkedGroupNodesElem.isNull() )
662 QDomElement checkedGroupNodeElem = checkedGroupNodesElem.firstChildElement( QStringLiteral(
"checked-group-node" ) );
663 while ( !checkedGroupNodeElem.isNull() )
666 checkedGroupNodeElem = checkedGroupNodeElem.nextSiblingElement( QStringLiteral(
"checked-group-node" ) );
684 element.setAttribute( QStringLiteral(
"has-expanded-info" ), QStringLiteral(
"1" ) );
686 element.setAttribute( QStringLiteral(
"has-checked-group-info" ), QStringLiteral(
"1" ) );
689 if ( !layerRec.layer() )
691 QString layerID = layerRec.layer()->id();
692 QDomElement layerElem = document.createElement( QStringLiteral(
"layer" ) );
693 layerElem.setAttribute( QStringLiteral(
"id" ), layerID );
694 layerElem.setAttribute( QStringLiteral(
"visible" ), layerRec.isVisible ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
695 if ( layerRec.usingCurrentStyle )
696 layerElem.setAttribute( QStringLiteral(
"style" ), layerRec.currentStyle );
697 element.appendChild( layerElem );
699 if ( layerRec.usingLegendItems )
701 QDomElement checkedLegendNodesElem = document.createElement( QStringLiteral(
"checked-legend-nodes" ) );
702 checkedLegendNodesElem.setAttribute( QStringLiteral(
"id" ), layerID );
703 for (
const QString &checkedLegendNode : std::as_const( layerRec.checkedLegendItems ) )
705 QDomElement checkedLegendNodeElem = document.createElement( QStringLiteral(
"checked-legend-node" ) );
706 checkedLegendNodeElem.setAttribute( QStringLiteral(
"id" ), checkedLegendNode );
707 checkedLegendNodesElem.appendChild( checkedLegendNodeElem );
709 element.appendChild( checkedLegendNodesElem );
714 layerElem.setAttribute( QStringLiteral(
"expanded" ), layerRec.expandedLayerNode ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
716 QDomElement expandedLegendNodesElem = document.createElement( QStringLiteral(
"expanded-legend-nodes" ) );
717 expandedLegendNodesElem.setAttribute( QStringLiteral(
"id" ), layerID );
718 for (
const QString &expandedLegendNode : std::as_const( layerRec.expandedLegendItems ) )
720 QDomElement expandedLegendNodeElem = document.createElement( QStringLiteral(
"expanded-legend-node" ) );
721 expandedLegendNodeElem.setAttribute( QStringLiteral(
"id" ), expandedLegendNode );
722 expandedLegendNodesElem.appendChild( expandedLegendNodeElem );
724 element.appendChild( expandedLegendNodesElem );
730 QDomElement checkedGroupElems = document.createElement( QStringLiteral(
"checked-group-nodes" ) );
732 for (
const QString &groupId : _checkedGroupNodes )
734 QDomElement checkedGroupElem = document.createElement( QStringLiteral(
"checked-group-node" ) );
735 checkedGroupElem.setAttribute( QStringLiteral(
"id" ), groupId );
736 checkedGroupElems.appendChild( checkedGroupElem );
738 element.appendChild( checkedGroupElems );
743 QDomElement expandedGroupElems = document.createElement( QStringLiteral(
"expanded-group-nodes" ) );
745 for (
const QString &groupId : _expandedGroupNodes )
747 QDomElement expandedGroupElem = document.createElement( QStringLiteral(
"expanded-group-node" ) );
748 expandedGroupElem.setAttribute( QStringLiteral(
"id" ), groupId );
749 expandedGroupElems.appendChild( expandedGroupElem );
751 element.appendChild( expandedGroupElems );
Abstract base class for all 2D vector feature renderers.
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.
An abstract interface for legend items returned from QgsMapLayerLegend implementation.
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.
A model representing the layer tree, including layers and groups of layers.
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...
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).
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.
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.
Stores information about one class/rule of a vector layer renderer in a unified way that can be used ...
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.
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.
QgsMapLayer * layer() const
Returns map layer or nullptr if the layer does not exist anymore.
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 writeXml(QDomElement element, QDomDocument &document) const
Writes the map theme record to XML.
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...
QList< QgsMapThemeCollection::MapThemeLayerRecord > layerRecords() const
Returns a list of records for all visible layer belonging to the theme.
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.
static MapThemeRecord readXml(const QDomElement &element, const QgsProject *project)
Reads the map theme record from XML.
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)
Sets the project on which this map theme collection works.
QList< QgsMapLayer * > masterLayerOrder() const
Returns the master layer order (this will always match the project's QgsProject::layerOrder() ).
void writeXml(QDomDocument &doc) const
Writes the map theme collection state to XML.
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 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,...
void layersWillBeRemoved(const QStringList &layerIds)
Emitted when one or more layers are about to be removed from the registry.
Represents a vector layer which manages a vector based dataset.
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)