1
1
/**
2
2
\class QgsMapThemeCollection
3
3
\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
5
5
map layers and layer styles.
6
- \note added in QGIS 2.12
6
+ \note Added in QGIS 2.12, renamed for QGIS 3.0
7
7
*/
8
8
9
9
class QgsMapThemeCollection : QObject
@@ -13,119 +13,134 @@ class QgsMapThemeCollection : QObject
13
13
%End
14
14
public:
15
15
16
- /** Individual preset record of visible layers and styles.
16
+ /** \ingroup core
17
+ * Individual map theme record of visible layers and styles.
17
18
*/
18
- class PresetRecord
19
+ class MapThemeRecord
19
20
{
20
21
public:
21
22
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;
24
25
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.
28
46
* @note not available in Python bindings
29
47
*/
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
+
33
62
};
34
63
35
64
QgsMapThemeCollection();
36
65
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.
40
68
*/
41
- bool hasPreset ( const QString& name ) const;
69
+ bool hasMapTheme ( const QString& name ) const;
42
70
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.
46
73
* @see update()
47
74
*/
48
- void insert( const QString& name, const PresetRecord & state );
75
+ void insert( const QString& name, const MapThemeRecord & state );
49
76
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
53
81
* @see insert()
54
82
*/
55
- void update( const QString& name, const PresetRecord & state );
83
+ void update( const QString& name, const MapThemeRecord & state );
56
84
57
- /** Remove existing preset from collection.
58
- * @param name preset name
85
+ /**
86
+ * Remove an existing map theme from collection.
59
87
*/
60
- void removePreset ( const QString& name );
88
+ void removeMapTheme ( const QString& name );
61
89
62
- //! Remove all presets from the collection.
90
+ //! Remove all map themes from the collection.
63
91
void clear();
64
92
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;
67
95
68
- /** Returns the recorded state of a preset.
69
- * @param name name of preset
96
+ /**
97
+ * Returns the recorded state of a map theme.
70
98
*/
71
- PresetRecord presetState ( const QString& name ) const;
99
+ MapThemeRecord mapThemeState ( const QString& name ) const;
72
100
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
+ *
74
104
* @note The order of the returned list is not guaranteed to reflect the order of layers
75
105
* in the canvas.
76
- * @param name preset name
77
106
*/
78
- QStringList presetVisibleLayers ( const QString& name ) const;
107
+ QStringList mapThemeVisibleLayers ( const QString& name ) const;
79
108
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.
83
111
*/
84
- void applyPresetCheckedLegendNodesToLayer ( const QString& name, const QString& layerID );
112
+ void applyMapThemeCheckedLegendNodesToLayer ( const QString& name, const QString& layerID );
85
113
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.
88
116
*/
89
- QMap<QString, QString> presetStyleOverrides ( const QString& name );
117
+ QMap<QString, QString> mapThemeStyleOverride ( const QString& name );
90
118
91
- /** Reads the preset collection state from XML
119
+ /**
120
+ * Reads the map theme collection state from XML
92
121
* @param doc DOM document
93
- * @see writeXML
122
+ * @see writeXml
94
123
*/
95
124
void readXml( const QDomDocument& doc );
96
125
97
- /** Writes the preset collection state to XML.
126
+ /** Writes the map theme collection state to XML.
98
127
* @param doc DOM document
99
- * @see readXML
128
+ * @see readXml
100
129
*/
101
130
void writeXml( QDomDocument& doc );
102
131
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
104
134
* record.
105
135
* @param parent layer tree group parent
106
- * @param rec preset record to amend
136
+ * @param rec map theme record to amend
107
137
*/
108
- static void addVisibleLayersToPreset ( QgsLayerTreeGroup* parent, PresetRecord & rec );
138
+ static void addVisibleLayersToMapTheme ( QgsLayerTreeGroup* parent, MapThemeRecord & rec );
109
139
110
140
signals:
111
141
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.
128
143
*/
129
- void reconnectToLayersStyleManager ();
144
+ void mapThemesChanged ();
130
145
};
131
146
0 commit comments