QGIS API Documentation 3.29.0-Master (006c3c0232)
qgsmaplayerstylemanager.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaplayerstylemanager.h
3 --------------------------------------
4 Date : January 2015
5 Copyright : (C) 2015 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMAPLAYERSTYLEMANAGER_H
17#define QGSMAPLAYERSTYLEMANAGER_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsmaplayerstyle.h"
22
23#include <QByteArray>
24#include <QMap>
25#include <QStringList>
26#include <QObject>
27
28
29class QDomElement;
30
31class QgsMapLayer;
32
57class CORE_EXPORT QgsMapLayerStyleManager : public QObject
58{
59 Q_OBJECT
60 public:
61
67
69 QgsMapLayer *layer() const { return mLayer; }
70
72 void reset();
73
75 void readXml( const QDomElement &mgrElement );
77 void writeXml( QDomElement &mgrElement ) const;
78
80 QStringList styles() const;
81
87 QMap<QString, QgsMapLayerStyle> mapLayerStyles() const;
88
90 QgsMapLayerStyle style( const QString &name ) const;
91
96 bool addStyle( const QString &name, const QgsMapLayerStyle &style );
97
102 bool addStyleFromLayer( const QString &name );
103
108 bool removeStyle( const QString &name );
109
114 bool renameStyle( const QString &name, const QString &newName );
115
117 QString currentStyle() const;
118
123 bool setCurrentStyle( const QString &name );
124
130 bool setOverrideStyle( const QString &styleDef );
132 bool restoreOverrideStyle();
133
139 static bool isDefault( const QString &styleName );
140
147 void copyStylesFrom( QgsMapLayerStyleManager *other );
148
149 signals:
151 void styleAdded( const QString &name );
153 void styleRemoved( const QString &name );
155 void styleRenamed( const QString &oldName, const QString &newName );
157 void currentStyleChanged( const QString &currentName );
158
159 private:
160 QgsMapLayer *mLayer = nullptr;
161 QMap<QString, QgsMapLayerStyle> mStyles;
162 QString mCurrentStyle;
163 QgsMapLayerStyle *mOverriddenOriginalStyle = nullptr;
164 static QString defaultStyleName();
165};
166
167#endif // QGSMAPLAYERSTYLEMANAGER_H
Management of styles for use with one map layer.
void styleAdded(const QString &name)
Emitted when a new style has been added.
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.
void currentStyleChanged(const QString &currentName)
Emitted when the current style has been changed.
void styleRemoved(const QString &name)
Emitted when a style has been removed.
Stores style information (renderer, opacity, labeling, diagrams etc.) applicable to a map layer.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53