QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsmaplayerstyle.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaplayersty.h
3 --------------------------------------
4 Date : September 2019
5 Copyright : (C) 2018 by Denis Rouzaud
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 QGSMAPLAYERSTYLE_H
17#define QGSMAPLAYERSTYLE_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21
22#include <QByteArray>
23#include <QMap>
24#include <QObject>
25#include <QStringList>
26
27class QDomElement;
28class QgsMapLayer;
29
40class CORE_EXPORT QgsMapLayerStyle
41{
42 public:
44 QgsMapLayerStyle() = default;
45
47 explicit QgsMapLayerStyle( const QString &xmlData );
48
50 bool isValid() const;
51
53 void clear();
54
56 QString xmlData() const;
57
59 void readFromLayer( QgsMapLayer *layer );
61 void writeToLayer( QgsMapLayer *layer ) const;
62
64 void readXml( const QDomElement &styleElement );
66 void writeXml( QDomElement &styleElement ) const;
67
68 private:
69 QString mXmlData;
70};
71
72
79class CORE_EXPORT QgsMapLayerStyleOverride
80{
81 public:
82
88 : mLayer( layer )
89 {
90 }
91
93
98 void setOverrideStyle( const QString &style );
99
100 private:
101
102 QgsMapLayer *mLayer = nullptr;
103 bool mStyleOverridden = false;
104};
105#endif // QGSMAPLAYERSTYLE_H
Restore overridden layer style on destruction.
QgsMapLayerStyleOverride(QgsMapLayer *layer)
Construct a style override object associated with a map layer.
void readXml(const QDomElement &styleElement)
Read style configuration (for project file reading).
void readFromLayer(QgsMapLayer *layer)
Store layer's active style information in the instance.
void clear()
Remove any stored style data (will get invalid).
void writeToLayer(QgsMapLayer *layer) const
Apply stored layer's style information to the layer.
bool isValid() const
Tell whether the style is valid (i.e. there is something stored in it).
void writeXml(QDomElement &styleElement) const
Write style configuration (for project file writing).
QString xmlData() const
Returns XML content of the style.
QgsMapLayerStyle()=default
construct invalid style
Base class for all map layer types.
Definition qgsmaplayer.h:80