QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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 <QObject>
26#include <QStringList>
27
28class QDomElement;
29
30class QgsMapLayer;
31
55class CORE_EXPORT QgsMapLayerStyleManager : public QObject
56{
57 Q_OBJECT
58 public:
59
65
67 QgsMapLayer *layer() const { return mLayer; }
68
70 void reset();
71
73 void readXml( const QDomElement &mgrElement );
75 void writeXml( QDomElement &mgrElement ) const;
76
78 QStringList styles() const;
79
84 QMap<QString, QgsMapLayerStyle> mapLayerStyles() const;
85
87 QgsMapLayerStyle style( const QString &name ) const;
88
93 bool addStyle( const QString &name, const QgsMapLayerStyle &style );
94
99 bool addStyleFromLayer( const QString &name );
100
105 bool removeStyle( const QString &name );
106
111 bool renameStyle( const QString &name, const QString &newName );
112
114 QString currentStyle() const;
115
120 bool setCurrentStyle( const QString &name );
121
127 bool setOverrideStyle( const QString &styleDef );
129 bool restoreOverrideStyle();
130
135 static bool isDefault( const QString &styleName );
136
143 void copyStylesFrom( QgsMapLayerStyleManager *other );
144
145 signals:
147 void styleAdded( const QString &name );
149 void styleRemoved( const QString &name );
151 void styleRenamed( const QString &oldName, const QString &newName );
153 void currentStyleChanged( const QString &currentName );
154
155 private:
156 QgsMapLayer *mLayer = nullptr;
157 QMap<QString, QgsMapLayerStyle> mStyles;
158 QString mCurrentStyle;
159 QgsMapLayerStyle *mOverriddenOriginalStyle = nullptr;
160 static QString defaultStyleName();
161};
162
163#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.
QgsMapLayerStyleManager(QgsMapLayer *layer)
Construct a style manager associated with a map layer (must not be nullptr).
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:80
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53