mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			177 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			177 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/core/qgsmaplayerstylemanager.h                                   *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
class QgsMapLayerStyleManager : QObject
 | 
						|
{
 | 
						|
%Docstring(signature="appended")
 | 
						|
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.
 | 
						|
 | 
						|
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.
 | 
						|
 | 
						|
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).
 | 
						|
 | 
						|
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.
 | 
						|
 | 
						|
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).
 | 
						|
%End
 | 
						|
 | 
						|
%TypeHeaderCode
 | 
						|
#include "qgsmaplayerstylemanager.h"
 | 
						|
%End
 | 
						|
  public:
 | 
						|
 | 
						|
    QgsMapLayerStyleManager( QgsMapLayer *layer /TransferThis/ );
 | 
						|
%Docstring
 | 
						|
Construct a style manager associated with a map layer (must not be ``None``).
 | 
						|
The style manager will be parented to ``layer``.
 | 
						|
%End
 | 
						|
 | 
						|
    QgsMapLayer *layer() const;
 | 
						|
%Docstring
 | 
						|
Gets pointer to the associated map layer
 | 
						|
%End
 | 
						|
 | 
						|
    void reset();
 | 
						|
%Docstring
 | 
						|
Reset the style manager to a basic state - with one default style which is set as current
 | 
						|
%End
 | 
						|
 | 
						|
    void readXml( const QDomElement &mgrElement );
 | 
						|
%Docstring
 | 
						|
Read configuration (for project loading)
 | 
						|
%End
 | 
						|
    void writeXml( QDomElement &mgrElement ) const;
 | 
						|
%Docstring
 | 
						|
Write configuration (for project saving)
 | 
						|
%End
 | 
						|
 | 
						|
    QStringList styles() const;
 | 
						|
%Docstring
 | 
						|
Returns list of all defined style names
 | 
						|
%End
 | 
						|
 | 
						|
    QMap<QString, QgsMapLayerStyle> mapLayerStyles() const;
 | 
						|
%Docstring
 | 
						|
Gets available styles for the associated map layer.
 | 
						|
 | 
						|
:return: A map of map layer style by style name
 | 
						|
%End
 | 
						|
 | 
						|
    QgsMapLayerStyle style( const QString &name ) const;
 | 
						|
%Docstring
 | 
						|
Returns data of a stored style - accessed by its unique name
 | 
						|
%End
 | 
						|
 | 
						|
    bool addStyle( const QString &name, const QgsMapLayerStyle &style );
 | 
						|
%Docstring
 | 
						|
Add a style with given name and data
 | 
						|
 | 
						|
:return: ``True`` on success (name is unique and style is valid)
 | 
						|
%End
 | 
						|
 | 
						|
    bool addStyleFromLayer( const QString &name );
 | 
						|
%Docstring
 | 
						|
Add style by cloning the current one
 | 
						|
 | 
						|
:return: ``True`` on success
 | 
						|
%End
 | 
						|
 | 
						|
    bool removeStyle( const QString &name );
 | 
						|
%Docstring
 | 
						|
Remove a stored style
 | 
						|
 | 
						|
:return: ``True`` on success (style exists and it is not the last one)
 | 
						|
%End
 | 
						|
 | 
						|
    bool renameStyle( const QString &name, const QString &newName );
 | 
						|
%Docstring
 | 
						|
Rename a stored style to a different name
 | 
						|
 | 
						|
:return: ``True`` on success (style exists and new name is unique)
 | 
						|
%End
 | 
						|
 | 
						|
    QString currentStyle() const;
 | 
						|
%Docstring
 | 
						|
Returns name of the current style
 | 
						|
%End
 | 
						|
 | 
						|
    bool setCurrentStyle( const QString &name );
 | 
						|
%Docstring
 | 
						|
Set a different style as the current style - will apply it to the layer
 | 
						|
 | 
						|
:return: ``True`` on success
 | 
						|
%End
 | 
						|
 | 
						|
    bool setOverrideStyle( const QString &styleDef );
 | 
						|
%Docstring
 | 
						|
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 :py:func:`~QgsMapLayerStyleManager.restoreOverrideStyle`
 | 
						|
%End
 | 
						|
    bool restoreOverrideStyle();
 | 
						|
%Docstring
 | 
						|
Restore the original store after a call to :py:func:`~QgsMapLayerStyleManager.setOverrideStyle`
 | 
						|
%End
 | 
						|
 | 
						|
    static bool isDefault( const QString &styleName );
 | 
						|
%Docstring
 | 
						|
Returns ``True`` if this is the default style
 | 
						|
%End
 | 
						|
 | 
						|
    void copyStylesFrom( QgsMapLayerStyleManager *other );
 | 
						|
%Docstring
 | 
						|
Copies all styles from ``other``.
 | 
						|
In case there is already a style with the same name it will be overwritten.
 | 
						|
 | 
						|
.. versionadded:: 3.14
 | 
						|
%End
 | 
						|
 | 
						|
  signals:
 | 
						|
    void styleAdded( const QString &name );
 | 
						|
%Docstring
 | 
						|
Emitted when a new style has been added
 | 
						|
%End
 | 
						|
    void styleRemoved( const QString &name );
 | 
						|
%Docstring
 | 
						|
Emitted when a style has been removed
 | 
						|
%End
 | 
						|
    void styleRenamed( const QString &oldName, const QString &newName );
 | 
						|
%Docstring
 | 
						|
Emitted when a style has been renamed
 | 
						|
%End
 | 
						|
    void currentStyleChanged( const QString ¤tName );
 | 
						|
%Docstring
 | 
						|
Emitted when the current style has been changed
 | 
						|
%End
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/core/qgsmaplayerstylemanager.h                                   *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 |