QGIS API Documentation 4.1.0-Master (60fea48833c)
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:
64
66 QgsMapLayer *layer() const { return mLayer; }
67
69 void reset();
70
72 void readXml( const QDomElement &mgrElement );
74 void writeXml( QDomElement &mgrElement ) const;
75
77 QStringList styles() const;
78
83 QMap<QString, QgsMapLayerStyle> mapLayerStyles() const;
84
86 QgsMapLayerStyle style( const QString &name ) const;
87
92 bool addStyle( const QString &name, const QgsMapLayerStyle &style );
93
98 bool addStyleFromLayer( const QString &name );
99
104 bool removeStyle( const QString &name );
105
110 bool renameStyle( const QString &name, const QString &newName );
111
113 QString currentStyle() const;
114
119 bool setCurrentStyle( const QString &name );
120
126 bool setOverrideStyle( const QString &styleDef );
128 bool restoreOverrideStyle();
129
134 static bool isDefault( const QString &styleName );
135
142 void copyStylesFrom( QgsMapLayerStyleManager *other );
143
144 signals:
146 void styleAdded( const QString &name );
148 void styleRemoved( const QString &name );
150 void styleRenamed( const QString &oldName, const QString &newName );
152 void currentStyleChanged( const QString &currentName );
153
154 private:
155 QgsMapLayer *mLayer = nullptr;
156 QMap<QString, QgsMapLayerStyle> mStyles;
157 QString mCurrentStyle;
158 QgsMapLayerStyle *mOverriddenOriginalStyle = nullptr;
159 static QString defaultStyleName();
160};
161
162#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:83
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52