QGIS/python/core/qgsmaplayerstylemanager.sip

225 lines
6.4 KiB
Plaintext
Raw Normal View History

2017-05-14 09:48:41 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsmaplayerstylemanager.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsMapLayerStyle
{
2017-05-14 09:48:41 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Stores style information (renderer, opacity, labeling, diagrams etc.) applicable to a map layer.
2017-05-14 09:48:41 +02:00
2017-12-15 10:36:55 -04:00
Stored data are considered as opaque - it is not possible to access them directly or modify them - it is
only possible to read or write layer's current style.
2017-05-14 09:48:41 +02:00
.. versionadded:: 2.8
%End
%TypeHeaderCode
2017-05-14 09:48:41 +02:00
#include "qgsmaplayerstylemanager.h"
%End
public:
QgsMapLayerStyle();
2017-05-14 09:48:41 +02:00
%Docstring
construct invalid style
%End
explicit QgsMapLayerStyle( const QString &xmlData );
2017-05-14 09:48:41 +02:00
%Docstring
construct style from QML definition (XML)
%End
bool isValid() const;
2017-05-14 09:48:41 +02:00
%Docstring
Tell whether the style is valid (i.e. there is something stored in it)
%End
void clear();
2017-05-14 09:48:41 +02:00
%Docstring
Remove any stored style data (will get invalid)
%End
QString xmlData() const;
2017-05-14 09:48:41 +02:00
%Docstring
Return XML content of the style
%End
void readFromLayer( QgsMapLayer *layer );
2017-05-14 09:48:41 +02:00
%Docstring
Store layer's active style information in the instance
%End
void writeToLayer( QgsMapLayer *layer ) const;
2017-05-14 09:48:41 +02:00
%Docstring
Apply stored layer's style information to the layer
%End
void readXml( const QDomElement &styleElement );
2017-05-14 09:48:41 +02:00
%Docstring
Read style configuration (for project file reading)
%End
void writeXml( QDomElement &styleElement ) const;
2017-05-14 09:48:41 +02:00
%Docstring
Write style configuration (for project file writing)
%End
};
class QgsMapLayerStyleManager : QObject
{
2017-05-14 09:48:41 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Management of styles for use with one map layer. Stored styles are identified by their names. The manager
always keep track of which style of the stored ones is currently active. When the current style is changed,
the new style is applied to the associated layer.
2017-05-14 09:48:41 +02:00
2017-12-15 10:36:55 -04:00
The class takes care of updating itself when the layer's current style configuration changes.
When some of layer style's properties change (e.g. opacity / colors), the style manager will
record them in the currently active style without any extra effort required.
2017-05-14 09:48:41 +02:00
2017-12-15 10:36:55 -04:00
When an instance is created, it creates "default" style (with empty name) recorded from the associated map layer
and it is set as the current style. The instance must always contain at least one style (which is the current).
2017-05-14 09:48:41 +02:00
2017-12-15 10:36:55 -04:00
The style which is marked as current has no style data stored in its entry. This is to avoid duplication
of data as all data is stored in map layer and can be retrieved easily. Also when saving, the entry for
the current style will be saved with no data because everything is already saved by the map layer itself.
2017-05-14 09:48:41 +02:00
2017-12-15 10:36:55 -04:00
The class also features support for temporary change of the layer's style, ideal for short-term use of a custom
style followed by restoration of the original style (for example, when rendering a map with a different than current style).
2017-05-14 09:48:41 +02:00
.. versionadded:: 2.8
%End
%TypeHeaderCode
2017-05-14 09:48:41 +02:00
#include "qgsmaplayerstylemanager.h"
%End
public:
QgsMapLayerStyleManager( QgsMapLayer *layer );
2017-05-14 09:48:41 +02:00
%Docstring
Construct a style manager associated with a map layer (must not be null)
%End
QgsMapLayer *layer() const;
2017-05-14 09:48:41 +02:00
%Docstring
Get pointer to the associated map layer
%End
void reset();
2017-05-14 09:48:41 +02:00
%Docstring
Reset the style manager to a basic state - with one default style which is set as current
%End
void readXml( const QDomElement &mgrElement );
2017-05-14 09:48:41 +02:00
%Docstring
Read configuration (for project loading)
%End
void writeXml( QDomElement &mgrElement ) const;
2017-05-14 09:48:41 +02:00
%Docstring
Write configuration (for project saving)
%End
QStringList styles() const;
2017-05-14 09:48:41 +02:00
%Docstring
Return list of all defined style names
%End
2017-05-16 13:34:18 +02:00
QMap<QString, QgsMapLayerStyle> mapLayerStyles() const;
%Docstring
2017-12-15 10:36:55 -04:00
Gets available styles for the associated map layer.
:return: A map of map layer style by style name
2017-05-16 13:34:18 +02:00
.. versionadded:: 3.0
%End
QgsMapLayerStyle style( const QString &name ) const;
2017-05-14 09:48:41 +02:00
%Docstring
Return data of a stored style - accessed by its unique name
%End
bool addStyle( const QString &name, const QgsMapLayerStyle &style );
2017-05-14 09:48:41 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Add a style with given name and data
:return: true on success (name is unique and style is valid)
2017-05-14 09:48:41 +02:00
%End
bool addStyleFromLayer( const QString &name );
2017-05-14 09:48:41 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Add style by cloning the current one
:return: true on success
2017-05-14 09:48:41 +02:00
%End
bool removeStyle( const QString &name );
2017-05-14 09:48:41 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Remove a stored style
:return: true on success (style exists and it is not the last one)
2017-05-14 09:48:41 +02:00
%End
bool renameStyle( const QString &name, const QString &newName );
2017-05-14 09:48:41 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Rename a stored style to a different name
:return: true on success (style exists and new name is unique)
2017-05-14 09:48:41 +02:00
%End
QString currentStyle() const;
2017-05-14 09:48:41 +02:00
%Docstring
Return name of the current style
%End
bool setCurrentStyle( const QString &name );
2017-05-14 09:48:41 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Set a different style as the current style - will apply it to the layer
:return: true on success
2017-05-14 09:48:41 +02:00
%End
bool setOverrideStyle( const QString &styleDef );
2017-05-14 09:48:41 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
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()
2017-05-14 09:48:41 +02:00
%End
bool restoreOverrideStyle();
2017-05-14 09:48:41 +02:00
%Docstring
Restore the original store after a call to setOverrideStyle()
%End
signals:
void styleAdded( const QString &name );
2017-05-14 09:48:41 +02:00
%Docstring
Emitted when a new style has been added
%End
void styleRemoved( const QString &name );
2017-05-14 09:48:41 +02:00
%Docstring
Emitted when a style has been removed
%End
void styleRenamed( const QString &oldName, const QString &newName );
2017-05-14 09:48:41 +02:00
%Docstring
Emitted when a style has been renamed
%End
void currentStyleChanged( const QString &currentName );
2017-05-14 09:48:41 +02:00
%Docstring
Emitted when the current style has been changed
%End
};
2017-05-14 09:48:41 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsmaplayerstylemanager.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/