11/**
22 \class QgsMapThemeCollection
33 \ingroup core
4- \brief Container class that allows storage of visibility presets consisting of visible
4+ \brief Container class that allows storage of map themes consisting of visible
55 map layers and layer styles.
6- \note added in QGIS 2.12
6+ \note Added in QGIS 2.12, renamed for QGIS 3.0
77*/
88
99class QgsMapThemeCollection : QObject
@@ -13,119 +13,134 @@ class QgsMapThemeCollection : QObject
1313%End
1414 public:
1515
16- /** Individual preset record of visible layers and styles.
16+ /** \ingroup core
17+ * Individual map theme record of visible layers and styles.
1718 */
18- class PresetRecord
19+ class MapThemeRecord
1920 {
2021 public:
2122
22- bool operator==( const QgsMapThemeCollection::PresetRecord & other ) const;
23- bool operator!=( const QgsMapThemeCollection::PresetRecord & other ) const;
23+ bool operator==( const QgsMapThemeCollection::MapThemeRecord & other ) const;
24+ bool operator!=( const QgsMapThemeCollection::MapThemeRecord & other ) const;
2425
25- //! Ordered list of layers that are visible
26- QStringList mVisibleLayerIDs;
27- /** For layers that have checkable legend symbols and not all symbols are checked - list which ones are
26+ /**
27+ * Ordered list of visible layers
28+ */
29+ QStringList visibleLayerIds() const;
30+
31+ /**
32+ * Ordered list of visible layers
33+ */
34+ void setVisibleLayerIds( const QStringList& visibleLayerIds );
35+
36+ /**
37+ * Lists which legend symbols are checked for layers which support this and where
38+ * not all symbols are checked.
39+ * @note not available in Python bindings
40+ */
41+ // QMap<QString, QSet<QString> > perLayerCheckedLegendSymbols() const;
42+
43+ /**
44+ * Lists which legend symbols are checked for layers which support this and where
45+ * not all symbols are checked.
2846 * @note not available in Python bindings
2947 */
30- //QMap<QString, QSet<QString> > mPerLayerCheckedLegendSymbols;
31- //! For layers that use multiple styles - which one is currently selected
32- QMap<QString, QString> mPerLayerCurrentStyle;
48+ // void setPerLayerCheckedLegendSymbols(const QMap<QString, QSet<QString> >& perLayerCheckedLegendSymbols);
49+
50+ /**
51+ * The currently used style name for layers with multiple styles.
52+ * The map has layer ids as keys and style names as values.
53+ */
54+ QMap<QString, QString> perLayerCurrentStyle() const;
55+
56+ /**
57+ * The currently used style name for layers with multiple styles.
58+ * The map has layer ids as keys and style names as values.
59+ */
60+ void setPerLayerCurrentStyle(const QMap<QString, QString>& perLayerCurrentStyle);
61+
3362 };
3463
3564 QgsMapThemeCollection();
3665
37- /** Returns whether a preset with a matching name exists.
38- * @param name name of preset to check
39- * @returns true if preset exists
66+ /**
67+ * Returns whether a map theme with a matching name exists.
4068 */
41- bool hasPreset ( const QString& name ) const;
69+ bool hasMapTheme ( const QString& name ) const;
4270
43- /** Inserts a new preset to the collection.
44- * @param name name of preset
45- * @param state preset record
71+ /**
72+ * Inserts a new map theme to the collection.
4673 * @see update()
4774 */
48- void insert( const QString& name, const PresetRecord & state );
75+ void insert( const QString& name, const MapThemeRecord & state );
4976
50- /** Updates a preset within the collection.
51- * @param name name of preset to update
52- * @param state preset record to replace existing preset
77+ /**
78+ * Updates a map theme within the collection.
79+ * @param name name of map theme to update
80+ * @param state map theme record to replace existing map theme
5381 * @see insert()
5482 */
55- void update( const QString& name, const PresetRecord & state );
83+ void update( const QString& name, const MapThemeRecord & state );
5684
57- /** Remove existing preset from collection.
58- * @param name preset name
85+ /**
86+ * Remove an existing map theme from collection.
5987 */
60- void removePreset ( const QString& name );
88+ void removeMapTheme ( const QString& name );
6189
62- //! Remove all presets from the collection.
90+ //! Remove all map themes from the collection.
6391 void clear();
6492
65- //! Returns a list of existing preset names.
66- QStringList presets () const;
93+ //! Returns a list of existing map theme names.
94+ QStringList mapThemes () const;
6795
68- /** Returns the recorded state of a preset.
69- * @param name name of preset
96+ /**
97+ * Returns the recorded state of a map theme.
7098 */
71- PresetRecord presetState ( const QString& name ) const;
99+ MapThemeRecord mapThemeState ( const QString& name ) const;
72100
73- /** Returns the list of layer IDs that should be visible for the specified preset.
101+ /**
102+ * Returns the list of layer IDs that are visible for the specified map theme.
103+ *
74104 * @note The order of the returned list is not guaranteed to reflect the order of layers
75105 * in the canvas.
76- * @param name preset name
77106 */
78- QStringList presetVisibleLayers ( const QString& name ) const;
107+ QStringList mapThemeVisibleLayers ( const QString& name ) const;
79108
80- /** Apply check states of legend nodes of a given layer as defined in the preset.
81- * @param name preset name
82- * @param layerID layer ID
109+ /**
110+ * Apply check states of legend nodes of a given layer as defined in the map theme.
83111 */
84- void applyPresetCheckedLegendNodesToLayer ( const QString& name, const QString& layerID );
112+ void applyMapThemeCheckedLegendNodesToLayer ( const QString& name, const QString& layerID );
85113
86- /** Get layer style overrides (for QgsMapSettings) of the visible layers for given preset.
87- * @param name preset name
114+ /**
115+ * Get layer style overrides (for QgsMapSettings) of the visible layers for given map theme.
88116 */
89- QMap<QString, QString> presetStyleOverrides ( const QString& name );
117+ QMap<QString, QString> mapThemeStyleOverride ( const QString& name );
90118
91- /** Reads the preset collection state from XML
119+ /**
120+ * Reads the map theme collection state from XML
92121 * @param doc DOM document
93- * @see writeXML
122+ * @see writeXml
94123 */
95124 void readXml( const QDomDocument& doc );
96125
97- /** Writes the preset collection state to XML.
126+ /** Writes the map theme collection state to XML.
98127 * @param doc DOM document
99- * @see readXML
128+ * @see readXml
100129 */
101130 void writeXml( QDomDocument& doc );
102131
103- /** Static method for adding visible layers from a layer tree group to a preset
132+ /**
133+ * Static method for adding visible layers from a layer tree group to a map theme
104134 * record.
105135 * @param parent layer tree group parent
106- * @param rec preset record to amend
136+ * @param rec map theme record to amend
107137 */
108- static void addVisibleLayersToPreset ( QgsLayerTreeGroup* parent, PresetRecord & rec );
138+ static void addVisibleLayersToMapTheme ( QgsLayerTreeGroup* parent, MapThemeRecord & rec );
109139
110140 signals:
111141
112- /** Emitted when presets within the collection are changed.
113- */
114- void presetsChanged();
115-
116- protected slots:
117-
118- /** Handles updates of the preset collection when layers are removed from the registry
119- */
120- void registryLayersRemoved( const QStringList& layerIDs );
121-
122- //! Update style name if a stored style gets renamed
123- void layerStyleRenamed( const QString& oldName, const QString& newName );
124-
125- protected:
126-
127- /** Reconnects all preset layers to handle style renames
142+ /** Emitted when map themes within the collection are changed.
128143 */
129- void reconnectToLayersStyleManager ();
144+ void mapThemesChanged ();
130145};
131146
0 commit comments