QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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
6  Email : denis@opengis.ch
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 <QStringList>
25 #include <QObject>
26 
27 
28 class QDomElement;
29 class QgsMapLayer;
30 
40 class 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 
79 class 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
Base class for all map layer types.
Definition: qgsmaplayer.h:78
Restore overridden layer style on destruction.
Stores style information (renderer, opacity, labeling, diagrams etc.) applicable to a map layer...
QgsMapLayerStyleOverride(QgsMapLayer *layer)
Construct a style override object associated with a map layer.