mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
There is a new check box that allows the user to tell whether a map should keep the layer styles (it will store the state when the check box is checked). The stored layer styles keep a snapshot of each layer's configuration instead of just keeping name of the style. This solves issues with styles and visibility presets in composer which were not completely compatible. This code has been funded by Tuscany Region (Italy) - SITA (CIG: 6002233F59) and commissioned to Gis3W s.a.s.
83 lines
2.9 KiB
Plaintext
83 lines
2.9 KiB
Plaintext
|
|
class QgsMapLayerStyle
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgsmaplayerstylemanager.h>
|
|
%End
|
|
public:
|
|
//! construct invalid style
|
|
QgsMapLayerStyle();
|
|
|
|
//! construct style from QML definition (XML)
|
|
explicit QgsMapLayerStyle( const QString& xmlData );
|
|
|
|
//! Tell whether the style is valid (i.e. there is something stored in it)
|
|
bool isValid() const;
|
|
|
|
//! Remove any stored style data (will get invalid)
|
|
void clear();
|
|
|
|
//! Return XML content of the style
|
|
QString xmlData() const;
|
|
|
|
//! Store layer's active style information in the instance
|
|
void readFromLayer( QgsMapLayer* layer );
|
|
//! Apply stored layer's style information to the layer
|
|
void writeToLayer( QgsMapLayer* layer ) const;
|
|
|
|
//! Read style configuration (for project file reading)
|
|
void readXml( const QDomElement& styleElement );
|
|
//! Write style configuration (for project file writing)
|
|
void writeXml( QDomElement& styleElement ) const;
|
|
};
|
|
|
|
|
|
class QgsMapLayerStyleManager
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgsmaplayerstylemanager.h>
|
|
%End
|
|
public:
|
|
//! Construct a style manager associated with a map layer (must not be null)
|
|
QgsMapLayerStyleManager( QgsMapLayer* layer );
|
|
|
|
//! Reset the style manager to a basic state - with one default style which is set as current
|
|
void reset();
|
|
|
|
//! Read configuration (for project loading)
|
|
void readXml( const QDomElement& mgrElement );
|
|
//! Write configuration (for project saving)
|
|
void writeXml( QDomElement& mgrElement ) const;
|
|
|
|
//! Return list of all defined style names
|
|
QStringList styles() const;
|
|
//! Return data of a stored style - accessed by its unique name
|
|
QgsMapLayerStyle style( const QString& name ) const;
|
|
|
|
//! Add a style with given name and data
|
|
//! @return true on success (name is unique and style is valid)
|
|
bool addStyle( const QString& name, const QgsMapLayerStyle& style );
|
|
//! Add style by cloning the current one
|
|
//! @return true on success
|
|
bool addStyleFromLayer( const QString& name );
|
|
//! Remove a stored style
|
|
//! @return true on success (style exists and it is not the last one)
|
|
bool removeStyle( const QString& name );
|
|
//! Rename a stored style to a different name
|
|
//! @return true on success (style exists and new name is unique)
|
|
bool renameStyle( const QString& name, const QString& newName );
|
|
|
|
//! Return name of the current style
|
|
QString currentStyle() const;
|
|
//! Set a different style as the current style - will apply it to the layer
|
|
//! @return true on success
|
|
bool setCurrentStyle( const QString& name );
|
|
|
|
//! Temporarily apply a different style to the layer. The argument
|
|
//! can be either a style name or a full QML style definition.
|
|
//! Each call must be paired with restoreOverrideStyle()
|
|
bool setOverrideStyle( const QString& styleDef );
|
|
//! Restore the original store after a call to setOverrideStyle()
|
|
bool restoreOverrideStyle();
|
|
};
|