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 *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-01-07 20:15:11 +07:00
|
|
|
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
|
|
|
|
|
2015-01-07 20:15:11 +07:00
|
|
|
%TypeHeaderCode
|
2017-05-14 09:48:41 +02:00
|
|
|
#include "qgsmaplayerstylemanager.h"
|
2015-01-07 20:15:11 +07:00
|
|
|
%End
|
|
|
|
public:
|
|
|
|
QgsMapLayerStyle();
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
construct invalid style
|
|
|
|
%End
|
2015-01-07 20:15:11 +07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
explicit QgsMapLayerStyle( const QString &xmlData );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
construct style from QML definition (XML)
|
|
|
|
%End
|
2015-01-19 15:09:14 +07:00
|
|
|
|
2015-01-07 20:15:11 +07:00
|
|
|
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
|
2015-01-07 20:15:11 +07:00
|
|
|
|
2015-01-09 17:01:12 +07:00
|
|
|
void clear();
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Remove any stored style data (will get invalid)
|
|
|
|
%End
|
2015-01-09 17:01:12 +07:00
|
|
|
|
2015-01-19 15:09:14 +07:00
|
|
|
QString xmlData() const;
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2018-05-25 13:54:27 +10:00
|
|
|
Returns XML content of the style
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2015-01-07 20:15:11 +07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
void readFromLayer( QgsMapLayer *layer );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Store layer's active style information in the instance
|
|
|
|
%End
|
2017-05-01 16:42:33 +02:00
|
|
|
void writeToLayer( QgsMapLayer *layer ) const;
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Apply stored layer's style information to the layer
|
|
|
|
%End
|
2015-01-07 20:15:11 +07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
void readXml( const QDomElement &styleElement );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Read style configuration (for project file reading)
|
|
|
|
%End
|
2017-05-01 16:42:33 +02:00
|
|
|
void writeXml( QDomElement &styleElement ) const;
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Write style configuration (for project file writing)
|
|
|
|
%End
|
|
|
|
|
2015-01-07 20:15:11 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-01-19 18:39:03 +07:00
|
|
|
class QgsMapLayerStyleManager : QObject
|
2015-01-07 20:15:11 +07:00
|
|
|
{
|
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
|
|
|
|
|
2015-01-07 20:15:11 +07:00
|
|
|
%TypeHeaderCode
|
2017-05-14 09:48:41 +02:00
|
|
|
#include "qgsmaplayerstylemanager.h"
|
2015-01-07 20:15:11 +07:00
|
|
|
%End
|
|
|
|
public:
|
2018-02-06 16:30:20 +10:00
|
|
|
|
|
|
|
QgsMapLayerStyleManager( QgsMapLayer *layer /TransferThis/ );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2018-02-06 16:30:20 +10:00
|
|
|
Construct a style manager associated with a map layer (must not be null).
|
|
|
|
The style manager will be parented to ``layer``.
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2015-01-07 20:15:11 +07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsMapLayer *layer() const;
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2018-05-26 18:44:30 +10:00
|
|
|
Gets pointer to the associated map layer
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2015-01-19 18:39:03 +07:00
|
|
|
|
2015-01-09 17:01:12 +07:00
|
|
|
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
|
2015-01-09 17:01:12 +07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
void readXml( const QDomElement &mgrElement );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Read configuration (for project loading)
|
|
|
|
%End
|
2017-05-01 16:42:33 +02:00
|
|
|
void writeXml( QDomElement &mgrElement ) const;
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Write configuration (for project saving)
|
|
|
|
%End
|
2015-01-07 20:15:11 +07:00
|
|
|
|
|
|
|
QStringList styles() const;
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2018-05-25 13:54:27 +10:00
|
|
|
Returns list of all defined style names
|
2017-05-14 09:48:41 +02:00
|
|
|
%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
|
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
QgsMapLayerStyle style( const QString &name ) const;
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2018-05-25 13:54:27 +10:00
|
|
|
Returns data of a stored style - accessed by its unique name
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2015-01-07 20:15:11 +07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
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
|
2017-10-05 11:51:04 +10:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
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
|
2017-10-05 11:51:04 +10:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
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
|
2017-10-05 11:51:04 +10:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
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
|
2015-01-07 20:15:11 +07:00
|
|
|
|
|
|
|
QString currentStyle() const;
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2018-05-25 13:54:27 +10:00
|
|
|
Returns name of the current style
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2017-10-05 11:51:04 +10:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
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
|
2015-01-19 15:09:14 +07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
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
|
2015-01-19 15:09:14 +07:00
|
|
|
bool restoreOverrideStyle();
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Restore the original store after a call to setOverrideStyle()
|
|
|
|
%End
|
2015-01-19 18:39:03 +07:00
|
|
|
|
2017-11-24 13:43:26 +01:00
|
|
|
bool isDefault( const QString &styleName ) const;
|
|
|
|
%Docstring
|
2017-12-18 18:51:56 +01:00
|
|
|
Returns true if this is the default style
|
2017-11-24 13:43:26 +01:00
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2015-01-19 18:39:03 +07:00
|
|
|
signals:
|
2017-05-01 16:42:33 +02:00
|
|
|
void styleAdded( const QString &name );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Emitted when a new style has been added
|
|
|
|
%End
|
2017-05-01 16:42:33 +02:00
|
|
|
void styleRemoved( const QString &name );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Emitted when a style has been removed
|
|
|
|
%End
|
2017-05-01 16:42:33 +02:00
|
|
|
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
|
2017-05-01 16:42:33 +02:00
|
|
|
void currentStyleChanged( const QString ¤tName );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
|
|
|
Emitted when the current style has been changed
|
|
|
|
%End
|
|
|
|
|
2015-01-07 20:15:11 +07:00
|
|
|
};
|
2017-05-14 09:48:41 +02:00
|
|
|
|
2018-06-11 10:13:39 +07:00
|
|
|
|
2018-06-11 16:42:49 +07:00
|
|
|
class QgsMapLayerStyleOverride
|
2018-06-11 10:13:39 +07:00
|
|
|
{
|
|
|
|
%Docstring
|
|
|
|
Restore overridden layer style on destruction.
|
|
|
|
|
|
|
|
.. versionadded:: 3.2
|
|
|
|
%End
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsmaplayerstylemanager.h"
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
2018-06-11 16:42:49 +07:00
|
|
|
QgsMapLayerStyleOverride( QgsMapLayer *layer );
|
2018-06-11 10:13:39 +07:00
|
|
|
%Docstring
|
|
|
|
Construct a style override object associated with a map layer.
|
|
|
|
The overridden style will be restored upon object destruction.
|
|
|
|
%End
|
|
|
|
|
2018-06-11 16:42:49 +07:00
|
|
|
~QgsMapLayerStyleOverride();
|
2018-06-11 10:13:39 +07:00
|
|
|
|
|
|
|
void setOverrideStyle( const QString &style );
|
|
|
|
%Docstring
|
|
|
|
Temporarily apply a different style to the layer. The argument
|
|
|
|
can be either a style name or a full QML style definition.
|
|
|
|
%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 *
|
|
|
|
************************************************************************/
|