|
| 1 | + |
| 2 | +class QgsMapLayerStyle |
| 3 | +{ |
| 4 | +%TypeHeaderCode |
| 5 | +#include <qgsmaplayerstylemanager.h> |
| 6 | +%End |
| 7 | + public: |
| 8 | + //! construct invalid style |
| 9 | + QgsMapLayerStyle(); |
| 10 | + |
| 11 | + //! Tell whether the style is valid (i.e. there is something stored in it) |
| 12 | + bool isValid() const; |
| 13 | + |
| 14 | + //! Return information about the style - for debugging purposes only |
| 15 | + QString dump() const; |
| 16 | + |
| 17 | + //! Store layer's active style information in the instance |
| 18 | + void readFromLayer( QgsMapLayer* layer ); |
| 19 | + //! Apply stored layer's style information to the layer |
| 20 | + void writeToLayer( QgsMapLayer* layer ) const; |
| 21 | + |
| 22 | + //! Read style configuration (for project file reading) |
| 23 | + void readXml( const QDomElement& styleElement ); |
| 24 | + //! Write style configuration (for project file writing) |
| 25 | + void writeXml( QDomElement& styleElement ) const; |
| 26 | +}; |
| 27 | + |
| 28 | + |
| 29 | +class QgsMapLayerStyleManager |
| 30 | +{ |
| 31 | +%TypeHeaderCode |
| 32 | +#include <qgsmaplayerstylemanager.h> |
| 33 | +%End |
| 34 | + public: |
| 35 | + //! Construct a style manager associated with a map layer (must not be null) |
| 36 | + QgsMapLayerStyleManager( QgsMapLayer* layer ); |
| 37 | + |
| 38 | + //! Read configuration (for project loading) |
| 39 | + void readXml( const QDomElement& mgrElement ); |
| 40 | + //! Write configuration (for project saving) |
| 41 | + void writeXml( QDomElement& mgrElement ) const; |
| 42 | + |
| 43 | + //! Return list of all defined style names |
| 44 | + QStringList styles() const; |
| 45 | + //! Return data of a stored style - accessed by its unique name |
| 46 | + QgsMapLayerStyle style( const QString& name ) const; |
| 47 | + |
| 48 | + //! Add a style with given name and data |
| 49 | + //! @return true on success (name is unique and style is valid) |
| 50 | + bool addStyle( const QString& name, const QgsMapLayerStyle& style ); |
| 51 | + //! Add style by cloning the current one |
| 52 | + //! @return true on success |
| 53 | + bool addStyleFromLayer( const QString& name ); |
| 54 | + //! Remove a stored style |
| 55 | + //! @return true on success (style exists and it is not the last one) |
| 56 | + bool removeStyle( const QString& name ); |
| 57 | + |
| 58 | + //! Return name of the current style |
| 59 | + QString currentStyle() const; |
| 60 | + //! Set a different style as the current style - will apply it to the layer |
| 61 | + //! @return true on success |
| 62 | + bool setCurrentStyle( const QString& name ); |
| 63 | +}; |
0 commit comments