QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
16 #ifndef QGSMAPTHEMECOLLECTION_H
17 #define QGSMAPTHEMECOLLECTION_H
19 #include "qgis_core.h"
25 #include <QStringList>
48 Q_PROPERTY( QStringList mapThemes READ mapThemes NOTIFY mapThemesChanged )
49 Q_PROPERTY(
QgsProject *project READ project WRITE setProject NOTIFY projectChanged )
66 return mLayer == other.mLayer && isVisible == other.
isVisible &&
73 return !( *
this == other );
86 bool isVisible =
true;
89 bool usingCurrentStyle =
false;
93 bool usingLegendItems =
false;
108 bool expandedLayerNode =
false;
127 mHasExpandedStateInfo == other.mHasExpandedStateInfo &&
128 mExpandedGroupNodes == other.mExpandedGroupNodes && mCheckedGroupNodes == other.mCheckedGroupNodes;
132 return !( *
this == other );
136 QList<QgsMapThemeCollection::MapThemeLayerRecord>
layerRecords()
const {
return mLayerRecords; }
139 void setLayerRecords(
const QList<QgsMapThemeCollection::MapThemeLayerRecord> &records ) { mLayerRecords = records; }
150 QHash<QgsMapLayer *, QgsMapThemeCollection::MapThemeLayerRecord> validLayerRecords() const
SIP_SKIP;
157 bool hasExpandedStateInfo()
const {
return mHasExpandedStateInfo; }
208 void setCheckedGroupNodes(
const QSet<QString> &checkedGroupNodes ) { mCheckedGroupNodes = checkedGroupNodes; }
212 QList<MapThemeLayerRecord> mLayerRecords;
215 bool mHasExpandedStateInfo =
false;
217 bool mHasCheckedStateInfo =
false;
223 QSet<QString> mExpandedGroupNodes;
229 QSet<QString> mCheckedGroupNodes;
270 bool renameMapTheme(
const QString &name,
const QString &newName );
316 void readXml(
const QDomDocument &doc );
402 void registryLayersRemoved(
const QStringList &layerIDs );
405 void layerStyleRenamed(
const QString &oldName,
const QString &newName );
412 void applyMapThemeCheckedLegendNodesToLayer(
const MapThemeLayerRecord &layerRec,
QgsMapLayer *layer );
417 void reconnectToLayersStyleManager();
419 static bool findRecordForLayer(
QgsMapLayer *layer,
const MapThemeRecord &rec, MapThemeLayerRecord &layerRec );
425 typedef QMap<QString, MapThemeRecord> MapThemeRecordMap;
426 MapThemeRecordMap mMapThemes;
432 #endif // QGSMAPTHEMECOLLECTION_H
bool operator==(const QgsMapThemeCollection::MapThemeRecord &other) const
void mapThemeRenamed(const QString &name, const QString &newName)
Emitted when a map theme within the collection is renamed.
QStringList mapThemeVisibleLayerIds(const QString &name) const
Returns the list of layer IDs that are visible for the specified map theme.
void readXml(const QDomDocument &doc)
Reads the map theme collection state from XML.
QList< QgsMapLayer * > masterVisibleLayers() const
Returns the master list of visible layers.
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.
bool operator!=(const QgsMapThemeCollection::MapThemeRecord &other) const
QHash< QgsMapLayer *, QgsMapThemeCollection::MapThemeLayerRecord > validLayerRecords() const
Returns set with only records for valid layers.
QList< QgsMapThemeCollection::MapThemeLayerRecord > layerRecords() const
Returns a list of records for all visible layer belonging to the theme.
bool usingLegendItems
Whether checkedLegendItems should be applied.
bool operator==(const QgsMapThemeCollection::MapThemeLayerRecord &other) const
void removeMapTheme(const QString &name)
Removes an existing map theme from collection.
void setLayerRecords(const QList< QgsMapThemeCollection::MapThemeLayerRecord > &records)
Sets layer records for the theme.
QSet< QString > expandedLegendItems
Rule keys of expanded legend items in layer tree view.
QList< QgsMapLayer * > mapThemeVisibleLayers(const QString &name) const
Returns the list of layers that are visible for the specified map theme.
void setCheckedGroupNodes(const QSet< QString > &checkedGroupNodes)
Sets a set of group identifiers for group nodes that should have checked state.
QMap< QString, QString > mapThemeStyleOverrides(const QString &name)
Gets layer style overrides (for QgsMapSettings) of the visible layers for given map theme.
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...
QSet< QString > checkedGroupNodes() const
Returns a set of group identifiers for group nodes that should have checked state (other group nodes ...
void insert(const QString &name, const QgsMapThemeCollection::MapThemeRecord &state)
Inserts a new map theme to the collection.
void clear()
Removes all map themes from the collection.
void mapThemesChanged()
Emitted when map themes within the collection are changed.
void setHasExpandedStateInfo(bool hasInfo)
Sets whether the map theme contains valid expanded/collapsed state of nodes.
QSet< QString > expandedGroupNodes() const
Returns a set of group identifiers for group nodes that should have expanded state (other group nodes...
QString currentStyle
Name of the current style of the layer.
void projectChanged()
Emitted when the project changes.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
bool operator!=(const QgsMapThemeCollection::MapThemeLayerRecord &other) const
bool usingCurrentStyle
Whether current style is valid and should be applied.
QList< QgsMapLayer * > masterLayerOrder() const
Returns the master layer order (this will always match the project's QgsProject::layerOrder() ).
static QgsMapThemeCollection::MapThemeRecord createThemeFromCurrentState(QgsLayerTreeGroup *root, QgsLayerTreeModel *model)
Static method to create theme from the current state of layer visibilities in layer tree,...
void writeXml(QDomDocument &doc)
Writes the map theme collection state to XML.
void setExpandedGroupNodes(const QSet< QString > &expandedGroupNodes)
Sets a set of group identifiers for group nodes that should have expanded state.
void setHasCheckedStateInfo(bool hasInfo)
Sets whether the map theme contains valid checked/unchecked state of group nodes.
MapThemeLayerRecord(QgsMapLayer *l=nullptr)
Initialize layer record with a map layer - it will be stored as a weak pointer.
void setProject(QgsProject *project)
bool hasMapTheme(const QString &name) const
Returns whether a map theme with a matching name exists.
Container class that allows storage of map themes consisting of visible map layers and layer styles.
bool renameMapTheme(const QString &name, const QString &newName)
Renames the existing map theme called name to newName.
QgsMapLayer * layer() const
Returns map layer or nullptr if the layer does not exist anymore.
bool hasCheckedStateInfo() const
Returns whether information about checked/unchecked state of groups has been recorded and thus whethe...
bool isVisible
true if the layer is visible in the associated theme.
QgsMapThemeCollection::MapThemeRecord mapThemeState(const QString &name) const
Returns the recorded state of a map theme.
QSet< QString > checkedLegendItems
Rule keys of check legend items in layer tree model.
void update(const QString &name, const QgsMapThemeCollection::MapThemeRecord &state)
Updates a map theme within the collection.
bool expandedLayerNode
Whether the layer's tree node is expanded (only to be applied if the parent MapThemeRecord has the in...