Skip to content

Commit f3482d2

Browse files
authoredOct 20, 2016
Rename visibility presets to map themes part 2 (#3641)
1 parent bb225f5 commit f3482d2

13 files changed

+330
-217
lines changed
 

‎doc/api_break.dox

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,8 @@ in code which previously passed a null pointer to QgsVectorLayerImport.</li>
14671467

14681468
<ul>
14691469
<li>Has been renamed to QgsMapThemeCollection</li>
1470+
<li>The nested class PresetRecord has been renamed to MapThemeRecord</li>
1471+
<li>Various member functions have been renamed from *preset* to *mapTheme*</li>
14701472
</ul>
14711473

14721474
\subsection qgis_api_break_3_0_QgsVectorFileWriter QgsVectorFileWriter

‎python/core/qgsmapthemecollection.sip

Lines changed: 82 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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

99
class 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

‎src/app/composer/qgscomposermapwidget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void QgsComposerMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu()
158158
return;
159159

160160
menu->clear();
161-
Q_FOREACH ( const QString& presetName, QgsProject::instance()->mapThemeCollection()->presets() )
161+
Q_FOREACH ( const QString& presetName, QgsProject::instance()->mapThemeCollection()->mapThemes() )
162162
{
163163
menu->addAction( presetName, this, SLOT( keepLayersVisibilityPresetSelected() ) );
164164
}
@@ -206,7 +206,7 @@ void QgsComposerMapWidget::keepLayersVisibilityPresetSelected()
206206

207207
mKeepLayerStylesCheckBox->setChecked( true );
208208

209-
mComposerMap->setLayerStyleOverrides( QgsProject::instance()->mapThemeCollection()->presetStyleOverrides( presetName ) );
209+
mComposerMap->setLayerStyleOverrides( QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverride( presetName ) );
210210

211211
mComposerMap->cache();
212212
mComposerMap->update();
@@ -219,7 +219,7 @@ void QgsComposerMapWidget::onPresetsChanged()
219219
{
220220
QStringList lst;
221221
lst.append( tr( "(none)" ) );
222-
lst += QgsProject::instance()->mapThemeCollection()->presets();
222+
lst += QgsProject::instance()->mapThemeCollection()->mapThemes();
223223
model->setStringList( lst );
224224

225225
// select the previously selected item again

‎src/app/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ int main( int argc, char *argv[] )
12001200
QList< QPair<QgsVectorLayer *, int > > layers;
12011201
if ( !dxfPreset.isEmpty() )
12021202
{
1203-
Q_FOREACH ( const QString& layer, QgsProject::instance()->mapThemeCollection()->presetVisibleLayers( dxfPreset ) )
1203+
Q_FOREACH ( const QString& layer, QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( dxfPreset ) )
12041204
{
12051205
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( layer ) );
12061206
if ( !vl )

‎src/app/qgsdxfexportdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ void QgsVectorLayerAndAttributeModel::applyVisibilityPreset( const QString &name
346346
}
347347
else
348348
{
349-
visibleLayers = QgsProject::instance()->mapThemeCollection()->presetVisibleLayers( name ).toSet();
349+
visibleLayers = QgsProject::instance()->mapThemeCollection()->mapThemeVisibleLayers( name ).toSet();
350350
}
351351

352352
if ( visibleLayers.isEmpty() )
@@ -452,7 +452,7 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
452452
mLayerTitleAsName->setChecked( QgsProject::instance()->readEntry( "dxf", "/lastDxfLayerTitleAsName", s.value( "qgis/lastDxfLayerTitleAsName", "false" ).toString() ) != "false" );
453453
mMapExtentCheckBox->setChecked( QgsProject::instance()->readEntry( "dxf", "/lastDxfMapRectangle", s.value( "qgis/lastDxfMapRectangle", "false" ).toString() ) != "false" );
454454

455-
QStringList ids = QgsProject::instance()->mapThemeCollection()->presets();
455+
QStringList ids = QgsProject::instance()->mapThemeCollection()->mapThemes();
456456
ids.prepend( "" );
457457
mVisibilityPresets->addItems( ids );
458458
mVisibilityPresets->setCurrentIndex( mVisibilityPresets->findText( QgsProject::instance()->readEntry( "dxf", "/lastVisibliltyPreset", "" ) ) );

0 commit comments

Comments
 (0)
Please sign in to comment.