mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			373 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			373 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/core/qgsmapthemecollection.h                                     *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
class QgsMapThemeCollection : QObject
 | 
						|
{
 | 
						|
%Docstring(signature="appended")
 | 
						|
Container class that allows storage of map themes consisting of visible
 | 
						|
map layers and layer styles.
 | 
						|
%End
 | 
						|
 | 
						|
%TypeHeaderCode
 | 
						|
#include "qgsmapthemecollection.h"
 | 
						|
%End
 | 
						|
  public:
 | 
						|
 | 
						|
    class MapThemeLayerRecord
 | 
						|
{
 | 
						|
%Docstring(signature="appended")
 | 
						|
Individual record of a visible layer in a map theme record.
 | 
						|
%End
 | 
						|
 | 
						|
%TypeHeaderCode
 | 
						|
#include "qgsmapthemecollection.h"
 | 
						|
%End
 | 
						|
      public:
 | 
						|
        MapThemeLayerRecord( QgsMapLayer *l = 0 );
 | 
						|
%Docstring
 | 
						|
Initialize layer record with a map layer - it will be stored as a weak pointer
 | 
						|
%End
 | 
						|
 | 
						|
        bool operator==( const QgsMapThemeCollection::MapThemeLayerRecord &other ) const;
 | 
						|
        bool operator!=( const QgsMapThemeCollection::MapThemeLayerRecord &other ) const;
 | 
						|
 | 
						|
        QgsMapLayer *layer() const;
 | 
						|
%Docstring
 | 
						|
Returns map layer or ``None`` if the layer does not exist anymore
 | 
						|
%End
 | 
						|
 | 
						|
        void setLayer( QgsMapLayer *layer );
 | 
						|
%Docstring
 | 
						|
Sets the map layer for this record
 | 
						|
%End
 | 
						|
 | 
						|
        bool isVisible;
 | 
						|
 | 
						|
        bool usingCurrentStyle;
 | 
						|
        QString currentStyle;
 | 
						|
        bool usingLegendItems;
 | 
						|
        QSet<QString> checkedLegendItems;
 | 
						|
 | 
						|
        QSet<QString> expandedLegendItems;
 | 
						|
 | 
						|
        bool expandedLayerNode;
 | 
						|
 | 
						|
    };
 | 
						|
 | 
						|
    class MapThemeRecord
 | 
						|
{
 | 
						|
%Docstring(signature="appended")
 | 
						|
Individual map theme record of visible layers and styles.
 | 
						|
%End
 | 
						|
 | 
						|
%TypeHeaderCode
 | 
						|
#include "qgsmapthemecollection.h"
 | 
						|
%End
 | 
						|
      public:
 | 
						|
 | 
						|
        bool operator==( const QgsMapThemeCollection::MapThemeRecord &other ) const;
 | 
						|
        bool operator!=( const QgsMapThemeCollection::MapThemeRecord &other ) const;
 | 
						|
 | 
						|
        QList<QgsMapThemeCollection::MapThemeLayerRecord> layerRecords() const;
 | 
						|
%Docstring
 | 
						|
Returns a list of records for all visible layer belonging to the theme.
 | 
						|
%End
 | 
						|
 | 
						|
        void setLayerRecords( const QList<QgsMapThemeCollection::MapThemeLayerRecord> &records );
 | 
						|
%Docstring
 | 
						|
Sets layer records for the theme.
 | 
						|
%End
 | 
						|
 | 
						|
        void removeLayerRecord( QgsMapLayer *layer );
 | 
						|
%Docstring
 | 
						|
Removes a record for ``layer`` if present.
 | 
						|
%End
 | 
						|
 | 
						|
        void addLayerRecord( const QgsMapThemeCollection::MapThemeLayerRecord &record );
 | 
						|
%Docstring
 | 
						|
Add a new record for a layer.
 | 
						|
%End
 | 
						|
 | 
						|
 | 
						|
        bool hasExpandedStateInfo() const;
 | 
						|
%Docstring
 | 
						|
Returns whether information about expanded/collapsed state of nodes has been recorded
 | 
						|
and thus whether :py:func:`~MapThemeRecord.expandedGroupNodes` and expandedLegendItems + expandedLayerNode from layer records are valid.
 | 
						|
 | 
						|
.. versionadded:: 3.2
 | 
						|
%End
 | 
						|
 | 
						|
        bool hasCheckedStateInfo() const;
 | 
						|
%Docstring
 | 
						|
Returns whether information about checked/unchecked state of groups has been recorded
 | 
						|
and thus whether :py:func:`~MapThemeRecord.checkedGroupNodes` is valid.
 | 
						|
 | 
						|
.. versionadded:: 3.10.1
 | 
						|
%End
 | 
						|
        void setHasExpandedStateInfo( bool hasInfo );
 | 
						|
%Docstring
 | 
						|
Sets whether the map theme contains valid expanded/collapsed state of nodes
 | 
						|
 | 
						|
.. versionadded:: 3.2
 | 
						|
%End
 | 
						|
 | 
						|
        void setHasCheckedStateInfo( bool hasInfo );
 | 
						|
%Docstring
 | 
						|
Sets whether the map theme contains valid checked/unchecked state of group nodes
 | 
						|
 | 
						|
.. versionadded:: 3.10.1
 | 
						|
%End
 | 
						|
        QSet<QString> expandedGroupNodes() const;
 | 
						|
%Docstring
 | 
						|
Returns a set of group identifiers for group nodes that should have expanded state (other group nodes should be collapsed).
 | 
						|
The returned value is valid only when :py:func:`~MapThemeRecord.hasExpandedStateInfo` returns ``True``.
 | 
						|
Group identifiers are built using group names, a sub-group name is prepended by parent group's identifier
 | 
						|
and a forward slash, e.g. "level1/level2"
 | 
						|
 | 
						|
.. versionadded:: 3.2
 | 
						|
%End
 | 
						|
 | 
						|
        QSet<QString> checkedGroupNodes() const;
 | 
						|
%Docstring
 | 
						|
Returns a set of group identifiers for group nodes that should have checked state (other group nodes should be unchecked).
 | 
						|
The returned value is valid only when :py:func:`~MapThemeRecord.hasCheckedStateInfo` returns ``True``.
 | 
						|
Group identifiers are built using group names, a sub-group name is prepended by parent group's identifier
 | 
						|
and a forward slash, e.g. "level1/level2"
 | 
						|
 | 
						|
.. versionadded:: 3.10.1
 | 
						|
%End
 | 
						|
 | 
						|
        void setExpandedGroupNodes( const QSet<QString> &expandedGroupNodes );
 | 
						|
%Docstring
 | 
						|
Sets a set of group identifiers for group nodes that should have expanded state. See :py:func:`~MapThemeRecord.expandedGroupNodes`.
 | 
						|
 | 
						|
.. versionadded:: 3.2
 | 
						|
%End
 | 
						|
 | 
						|
        void setCheckedGroupNodes( const QSet<QString> &checkedGroupNodes );
 | 
						|
%Docstring
 | 
						|
Sets a set of group identifiers for group nodes that should have checked state. See :py:func:`~MapThemeRecord.checkedGroupNodes`.
 | 
						|
 | 
						|
.. versionadded:: 3.10.1
 | 
						|
%End
 | 
						|
 | 
						|
        static MapThemeRecord readXml( const QDomElement &element, const QgsProject *project );
 | 
						|
%Docstring
 | 
						|
Reads the map theme record from XML
 | 
						|
 | 
						|
:param element: DOM element
 | 
						|
:param project: the QGIS project
 | 
						|
 | 
						|
.. seealso:: :py:func:`writeXml`
 | 
						|
 | 
						|
.. versionadded:: 3.42
 | 
						|
%End
 | 
						|
 | 
						|
        void writeXml( QDomElement element, QDomDocument &document ) const;
 | 
						|
%Docstring
 | 
						|
Writes the map theme record to XML.
 | 
						|
 | 
						|
:param element: DOM element
 | 
						|
:param document: DOM document
 | 
						|
 | 
						|
.. seealso:: :py:func:`readXml`
 | 
						|
 | 
						|
.. versionadded:: 3.42
 | 
						|
%End
 | 
						|
 | 
						|
    };
 | 
						|
 | 
						|
    QgsMapThemeCollection( QgsProject *project = 0 );
 | 
						|
%Docstring
 | 
						|
Create map theme collection that handles themes of the given project.
 | 
						|
%End
 | 
						|
 | 
						|
    bool hasMapTheme( const QString &name ) const;
 | 
						|
%Docstring
 | 
						|
Returns whether a map theme with a matching name exists.
 | 
						|
%End
 | 
						|
 | 
						|
    void insert( const QString &name, const QgsMapThemeCollection::MapThemeRecord &state );
 | 
						|
%Docstring
 | 
						|
Inserts a new map theme to the collection.
 | 
						|
 | 
						|
.. seealso:: :py:func:`update`
 | 
						|
%End
 | 
						|
 | 
						|
    void update( const QString &name, const QgsMapThemeCollection::MapThemeRecord &state );
 | 
						|
%Docstring
 | 
						|
Updates a map theme within the collection.
 | 
						|
 | 
						|
:param name: name of map theme to update
 | 
						|
:param state: map theme record to replace existing map theme
 | 
						|
 | 
						|
.. seealso:: :py:func:`insert`
 | 
						|
%End
 | 
						|
 | 
						|
    void removeMapTheme( const QString &name );
 | 
						|
%Docstring
 | 
						|
Removes an existing map theme from collection.
 | 
						|
%End
 | 
						|
 | 
						|
    bool renameMapTheme( const QString &name, const QString &newName );
 | 
						|
%Docstring
 | 
						|
Renames the existing map theme called ``name`` to ``newName``.
 | 
						|
Returns ``True`` if the rename was successful, or ``False`` if it failed (e.g. due to a duplicate name for ``newName``).
 | 
						|
 | 
						|
.. versionadded:: 3.14
 | 
						|
%End
 | 
						|
 | 
						|
    void clear();
 | 
						|
%Docstring
 | 
						|
Removes all map themes from the collection.
 | 
						|
%End
 | 
						|
 | 
						|
    QStringList mapThemes() const;
 | 
						|
%Docstring
 | 
						|
Returns a list of existing map theme names.
 | 
						|
%End
 | 
						|
 | 
						|
    QgsMapThemeCollection::MapThemeRecord mapThemeState( const QString &name ) const;
 | 
						|
%Docstring
 | 
						|
Returns the recorded state of a map theme.
 | 
						|
%End
 | 
						|
 | 
						|
    QStringList mapThemeVisibleLayerIds( const QString &name ) const;
 | 
						|
%Docstring
 | 
						|
Returns the list of layer IDs that are visible for the specified map theme.
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   The order of the returned list is not guaranteed to reflect the order of layers
 | 
						|
   in the canvas.
 | 
						|
%End
 | 
						|
 | 
						|
    QList<QgsMapLayer *> mapThemeVisibleLayers( const QString &name ) const;
 | 
						|
%Docstring
 | 
						|
Returns the list of layers that are visible for the specified map theme.
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   The order of the returned list is not guaranteed to reflect the order of layers
 | 
						|
   in the canvas.
 | 
						|
%End
 | 
						|
 | 
						|
    QMap<QString, QString> mapThemeStyleOverrides( const QString &name );
 | 
						|
%Docstring
 | 
						|
Gets layer style overrides (for :py:class:`QgsMapSettings`) of the visible layers for given map theme.
 | 
						|
%End
 | 
						|
 | 
						|
    void readXml( const QDomDocument &doc );
 | 
						|
%Docstring
 | 
						|
Reads the map theme collection state from XML
 | 
						|
 | 
						|
:param doc: DOM document
 | 
						|
 | 
						|
.. seealso:: :py:func:`writeXml`
 | 
						|
%End
 | 
						|
 | 
						|
    void writeXml( QDomDocument &doc ) const;
 | 
						|
%Docstring
 | 
						|
Writes the map theme collection state to XML.
 | 
						|
 | 
						|
:param doc: DOM document
 | 
						|
 | 
						|
.. seealso:: :py:func:`readXml`
 | 
						|
%End
 | 
						|
 | 
						|
    static QgsMapThemeCollection::MapThemeRecord createThemeFromCurrentState( QgsLayerTreeGroup *root, QgsLayerTreeModel *model );
 | 
						|
%Docstring
 | 
						|
Static method to create theme from the current state of layer visibilities in layer tree,
 | 
						|
current style of layers and check state of legend items (from a layer tree model).
 | 
						|
%End
 | 
						|
 | 
						|
    void applyTheme( const QString &name, QgsLayerTreeGroup *root, QgsLayerTreeModel *model );
 | 
						|
%Docstring
 | 
						|
Apply theme given by its name and modify layer tree, current style of layers and checked
 | 
						|
legend items of passed layer tree model.
 | 
						|
%End
 | 
						|
 | 
						|
    QgsProject *project();
 | 
						|
%Docstring
 | 
						|
Returns the :py:class:`QgsProject` on which this map theme collection works.
 | 
						|
 | 
						|
.. seealso:: :py:func:`setProject`
 | 
						|
 | 
						|
.. seealso:: :py:func:`projectChanged`
 | 
						|
%End
 | 
						|
 | 
						|
    void setProject( QgsProject *project );
 | 
						|
%Docstring
 | 
						|
Sets the ``project`` on which this map theme collection works.
 | 
						|
 | 
						|
.. seealso:: :py:func:`project`
 | 
						|
 | 
						|
.. seealso:: :py:func:`projectChanged`
 | 
						|
%End
 | 
						|
 | 
						|
    QList< QgsMapLayer * > masterLayerOrder() const;
 | 
						|
%Docstring
 | 
						|
Returns the master layer order (this will always match the project's :py:func:`QgsProject.layerOrder()` ).
 | 
						|
All map themes will maintain the same layer order as the master layer order.
 | 
						|
 | 
						|
.. seealso:: :py:func:`masterVisibleLayers`
 | 
						|
%End
 | 
						|
 | 
						|
    QList< QgsMapLayer * > masterVisibleLayers() const;
 | 
						|
%Docstring
 | 
						|
Returns the master list of visible layers. The order of returned layers will always match those
 | 
						|
of :py:func:`~QgsMapThemeCollection.masterLayerOrder`, but the returned layers are filtered to only include those visible
 | 
						|
in the project's layer tree.
 | 
						|
 | 
						|
.. seealso:: :py:func:`masterLayerOrder`
 | 
						|
%End
 | 
						|
 | 
						|
  signals:
 | 
						|
 | 
						|
    void mapThemesChanged();
 | 
						|
%Docstring
 | 
						|
Emitted when map themes within the collection are changed.
 | 
						|
%End
 | 
						|
 | 
						|
    void mapThemeChanged( const QString &theme );
 | 
						|
%Docstring
 | 
						|
Emitted when a map theme changes definition.
 | 
						|
%End
 | 
						|
 | 
						|
    void mapThemeRenamed( const QString &name, const QString &newName );
 | 
						|
%Docstring
 | 
						|
Emitted when a map theme within the collection is renamed.
 | 
						|
 | 
						|
.. versionadded:: 3.14
 | 
						|
%End
 | 
						|
 | 
						|
    void projectChanged();
 | 
						|
%Docstring
 | 
						|
Emitted when the project changes
 | 
						|
 | 
						|
.. seealso:: :py:func:`project`
 | 
						|
 | 
						|
.. seealso:: :py:func:`setProject`
 | 
						|
%End
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/core/qgsmapthemecollection.h                                     *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | 
						|
 ************************************************************************/
 |