QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 <QStringList>
26#include <QObject>
27
28
29class QDomElement;
30
31class QgsMapLayer;
32
56class CORE_EXPORT QgsMapLayerStyleManager : public QObject
57{
58 Q_OBJECT
59 public:
60
66
68 QgsMapLayer *layer() const { return mLayer; }
69
71 void reset();
72
74 void readXml( const QDomElement &mgrElement );
76 void writeXml( QDomElement &mgrElement ) const;
77
79 QStringList styles() const;
80
85 QMap<QString, QgsMapLayerStyle> mapLayerStyles() const;
86
88 QgsMapLayerStyle style( const QString &name ) const;
89
94 bool addStyle( const QString &name, const QgsMapLayerStyle &style );
95
100 bool addStyleFromLayer( const QString &name );
101
106 bool removeStyle( const QString &name );
107
112 bool renameStyle( const QString &name, const QString &newName );
113
115 QString currentStyle() const;
116
121 bool setCurrentStyle( const QString &name );
122
128 bool setOverrideStyle( const QString &styleDef );
130 bool restoreOverrideStyle();
131
136 static bool isDefault( const QString &styleName );
137
144 void copyStylesFrom( QgsMapLayerStyleManager *other );
145
146 signals:
148 void styleAdded( const QString &name );
150 void styleRemoved( const QString &name );
152 void styleRenamed( const QString &oldName, const QString &newName );
154 void currentStyleChanged( const QString &currentName );
155
156 private:
157 QgsMapLayer *mLayer = nullptr;
158 QMap<QString, QgsMapLayerStyle> mStyles;
159 QString mCurrentStyle;
160 QgsMapLayerStyle *mOverriddenOriginalStyle = nullptr;
161 static QString defaultStyleName();
162};
163
164#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:76
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53