Skip to content
Permalink
Browse files
Merge pull request #4357 from nyalldawson/composer_layer_ref
Use weak layer references and loose matching for composer legend customisation
  • Loading branch information
nyalldawson committed Apr 18, 2017
2 parents 302e9dd + 3535ee2 commit 33b6c41dd2b516e5cc141b1550bcd6d6b9679955
Showing with 709 additions and 316 deletions.
  1. +0 −2 python/auto_sip.blacklist
  2. +3 −3 python/core/annotations/qgshtmlannotation.sip
  3. +1 −1 python/core/annotations/qgssvgannotation.sip
  4. +1 −1 python/core/annotations/qgstextannotation.sip
  5. +207 −79 python/core/layertree/qgslayertreegroup.sip
  6. +97 −41 python/core/layertree/qgslayertreelayer.sip
  7. +10 −4 python/core/layertree/qgslayertreenode.sip
  8. +10 −19 python/core/qgscolorramp.sip
  9. +7 −0 python/core/qgsmaplayer.sip
  10. +10 −15 python/core/qgsvectorlayer.sip
  11. +2 −2 python/core/raster/qgsrasterlayer.sip
  12. +11 −11 python/gui/qgscolorbutton.sip
  13. +5 −5 python/gui/qgscolorrampbutton.sip
  14. +2 −2 python/gui/qgsmessagelogviewer.sip
  15. +4 −4 python/gui/symbology-ng/characterwidget.sip
  16. +6 −0 scripts/sipify.pl
  17. +1 −1 src/core/composer/qgscomposerlegend.cpp
  18. +2 −2 src/core/layertree/qgslayertreegroup.cpp
  19. +149 −52 src/core/layertree/qgslayertreegroup.h
  20. +28 −4 src/core/layertree/qgslayertreelayer.cpp
  21. +68 −27 src/core/layertree/qgslayertreelayer.h
  22. +10 −4 src/core/layertree/qgslayertreenode.h
  23. +1 −4 src/core/qgscolorramp.h
  24. +12 −0 src/core/qgsmaplayer.h
  25. +2 −6 src/core/qgsmaplayerproxymodel.cpp
  26. +39 −1 src/core/qgsmaplayerref.h
  27. +7 −9 src/core/qgsmimedatautils.cpp
  28. +3 −3 src/core/qgsvectordataprovider.h
  29. +3 −8 src/core/qgsvectorlayer.h
  30. +3 −3 src/core/raster/qgsrasterlayer.h
  31. +3 −1 tests/scripts/sipifyheader.expected.sip
  32. +2 −0 tests/scripts/sipifyheader.h
  33. +0 −2 tests/src/core/testqgscomposition.cpp
@@ -217,8 +217,6 @@ core/fieldformatter/qgsrelationreferencefieldformatter.sip
core/fieldformatter/qgsvaluemapfieldformatter.sip
core/fieldformatter/qgsvaluerelationfieldformatter.sip
core/layertree/qgslayertree.sip
core/layertree/qgslayertreegroup.sip
core/layertree/qgslayertreelayer.sip
core/layertree/qgslayertreemodel.sip
core/layertree/qgslayertreemodellegendnode.sip
core/layertree/qgslayertreenode.sip
@@ -31,7 +31,7 @@ class QgsHtmlAnnotation: QgsAnnotation

~QgsHtmlAnnotation();

QSizeF minimumFrameSize() const;
virtual QSizeF minimumFrameSize() const;

void setSourceFile( const QString &htmlFile );
%Docstring
@@ -49,7 +49,7 @@ class QgsHtmlAnnotation: QgsAnnotation
virtual void writeXml( QDomElement &elem, QDomDocument &doc ) const;
virtual void readXml( const QDomElement &itemElem, const QDomDocument &doc );

void setAssociatedFeature( const QgsFeature &feature );
virtual void setAssociatedFeature( const QgsFeature &feature );

static QgsHtmlAnnotation *create() /Factory/;
%Docstring
@@ -59,7 +59,7 @@ class QgsHtmlAnnotation: QgsAnnotation

protected:

void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;

};

@@ -50,7 +50,7 @@ class QgsSvgAnnotation: QgsAnnotation

protected:

void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;

};

@@ -52,7 +52,7 @@ class QgsTextAnnotation: QgsAnnotation

protected:

void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;

};

@@ -1,104 +1,232 @@
/**
* Layer tree group node serves as a container for layers and further groups.
*
* Group names do not need to be unique within one tree nor within one parent.
*
* @note added in 2.4
*/
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layertree/qgslayertreegroup.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsLayerTreeGroup : QgsLayerTreeNode
{
%TypeHeaderCode
#include <qgslayertreegroup.h>
%Docstring
Layer tree group node serves as a container for layers and further groups.

Group names do not need to be unique within one tree nor within one parent.

.. versionadded:: 2.4
%End

%TypeHeaderCode
#include "qgslayertreegroup.h"
%End
public:
QgsLayerTreeGroup( const QString& name = QString(), Qt::CheckState checked = Qt::Checked );

//! Get group's name
QString name() const;
//! Set group's name
void setName( const QString& n );

//! Insert a new group node with given name at specified position. Newly created node is owned by this group.
QgsLayerTreeGroup* insertGroup( int index, const QString& name );
//! Append a new group node with given name. Newly created node is owned by this group.
QgsLayerTreeGroup* addGroup( const QString& name );
//! Insert a new layer node for given map layer at specified position. Newly created node is owned by this group.
QgsLayerTreeLayer* insertLayer( int index, QgsMapLayer* layer );
//! Append a new layer node for given map layer. Newly created node is owned by this group.
QgsLayerTreeLayer* addLayer( QgsMapLayer* layer );

//! Insert existing nodes at specified position. The nodes must not have a parent yet. The nodes will be owned by this group.
void insertChildNodes( int index, const QList<QgsLayerTreeNode*>& nodes /Transfer/ );
//! Insert existing node at specified position. The node must not have a parent yet. The node will be owned by this group.
void insertChildNode( int index, QgsLayerTreeNode* node /Transfer/ );
//! Append an existing node. The node must not have a parent yet. The node will be owned by this group.
void addChildNode( QgsLayerTreeNode* node /Transfer/ );

//! Remove a child node from this group. The node will be deleted.
void removeChildNode( QgsLayerTreeNode* node );
//! Remove map layer's node from this group. The node will be deleted.
void removeLayer( QgsMapLayer* layer );
//! Remove child nodes from index "from". The nodes will be deleted.

QgsLayerTreeGroup( const QString &name = QString(), bool checked = true );
%Docstring
Constructor
%End


virtual QString name() const;
%Docstring
Returns the group's name.
:rtype: str
%End

virtual void setName( const QString &n );
%Docstring
Sets the group's name.
%End

QgsLayerTreeGroup *insertGroup( int index, const QString &name );
%Docstring
Insert a new group node with given name at specified position. The newly created node is owned by this group.
:rtype: QgsLayerTreeGroup
%End

QgsLayerTreeGroup *addGroup( const QString &name );
%Docstring
Append a new group node with given name. Newly created node is owned by this group.
:rtype: QgsLayerTreeGroup
%End

QgsLayerTreeLayer *insertLayer( int index, QgsMapLayer *layer );
%Docstring
Insert a new layer node for given map layer at specified position. The newly created node is owned by this group.
:rtype: QgsLayerTreeLayer
%End

QgsLayerTreeLayer *addLayer( QgsMapLayer *layer );
%Docstring
Append a new layer node for given map layer. The newly created node is owned by this group.
:rtype: QgsLayerTreeLayer
%End

void insertChildNodes( int index, const QList<QgsLayerTreeNode *> &nodes /Transfer/ );
%Docstring
Insert existing nodes at specified position. The nodes must not have a parent yet. The nodes will be owned by this group.
%End

void insertChildNode( int index, QgsLayerTreeNode *node /Transfer/ );
%Docstring
Insert existing node at specified position. The node must not have a parent yet. The node will be owned by this group.
%End

void addChildNode( QgsLayerTreeNode *node /Transfer/ );
%Docstring
Append an existing node. The node must not have a parent yet. The node will be owned by this group.
%End

void removeChildNode( QgsLayerTreeNode *node );
%Docstring
Remove a child node from this group. The node will be deleted.
%End

void removeLayer( QgsMapLayer *layer );
%Docstring
Remove map layer's node from this group. The node will be deleted.
%End

void removeChildren( int from, int count );
//! Remove all child group nodes without layers. The groupnodes will be deleted.
%Docstring
Remove child nodes from index "from". The nodes will be deleted.
%End

void removeChildrenGroupWithoutLayers();
//! Remove all child nodes. The nodes will be deleted.
%Docstring
Remove all child group nodes without layers. The groupnodes will be deleted.
%End

void removeAllChildren();
%Docstring
Remove all child nodes. The nodes will be deleted.
%End

QgsLayerTreeLayer *findLayer( QgsMapLayer *layer ) const;
%Docstring
Find layer node representing the map layer. Searches recursively the whole sub-tree.
.. versionadded:: 3.0
:rtype: QgsLayerTreeLayer
%End

QgsLayerTreeLayer *findLayer( const QString &layerId ) const;
%Docstring
Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tree.
:rtype: QgsLayerTreeLayer
%End

QList<QgsLayerTreeLayer *> findLayers() const;
%Docstring
Find all layer nodes. Searches recursively the whole sub-tree.
:rtype: list of QgsLayerTreeLayer
%End

//! Find layer node representing the map layer. Searches recursively the whole sub-tree.
//! @note added in 3.0
QgsLayerTreeLayer* findLayer( QgsMapLayer* layer ) const;
//! Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tree.
QgsLayerTreeLayer* findLayer( const QString& layerId );
//! Find all layer nodes. Searches recursively the whole sub-tree.
QList<QgsLayerTreeLayer*> findLayers() const;
//! Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
QStringList findLayerIds() const;
//! Find group node with specified name. Searches recursively the whole sub-tree.
QgsLayerTreeGroup* findGroup( const QString& name );

//! Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
static QgsLayerTreeGroup* readXml( QDomElement& element ) /Factory/;
//! Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
//! Also resolves textual references to layers from the project (calls resolveReferences() internally).
//! @note added in 3.0
static QgsLayerTreeGroup* readXml( QDomElement& element, const QgsProject* project ) /Factory/;

//! Write group (tree) as XML element <layer-tree-group> and add it to the given parent element
virtual void writeXml( QDomElement& parentElement );
//! Read children from XML and append them to the group.
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
void readChildrenFromXml( QDomElement& element );

//! Return text representation of the tree. For debugging purposes only.
%Docstring
Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
:rtype: list of str
%End

QgsLayerTreeGroup *findGroup( const QString &name );
%Docstring
Find group node with specified name. Searches recursively the whole sub-tree.
:rtype: QgsLayerTreeGroup
%End

static QgsLayerTreeGroup *readXml( QDomElement &element ) /Factory/;
%Docstring
Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
:rtype: QgsLayerTreeGroup
%End

static QgsLayerTreeGroup *readXml( QDomElement &element, const QgsProject *project ) /Factory/;
%Docstring
Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
Also resolves textual references to layers from the project (calls resolveReferences() internally).
.. versionadded:: 3.0
:rtype: QgsLayerTreeGroup
%End

virtual void writeXml( QDomElement &parentElement );
%Docstring
Write group (tree) as XML element <layer-tree-group> and add it to the given parent element
%End

void readChildrenFromXml( QDomElement &element );
%Docstring
Read children from XML and append them to the group.
Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
%End

virtual QString dump() const;
%Docstring
Return text representation of the tree. For debugging purposes only.
:rtype: str
%End

//! Return a clone of the group. The children are cloned too.
virtual QgsLayerTreeGroup* clone() const /Factory/;
virtual QgsLayerTreeGroup *clone() const /Factory/;
%Docstring
Return a clone of the group. The children are cloned too.
:rtype: QgsLayerTreeGroup
%End

//! Calls resolveReferences() on child tree nodes
//! @note added in 3.0
virtual void resolveReferences( const QgsProject* project );
virtual void resolveReferences( const QgsProject *project, bool looseMatching = false );
%Docstring
Calls resolveReferences() on child tree nodes
.. versionadded:: 3.0
%End

virtual void setItemVisibilityCheckedRecursive( bool checked );
%Docstring
Check or uncheck a node and all its children (taking into account exclusion rules)
%End

//! Return whether the group is mutually exclusive (only one child can be checked at a time)
//! @note added in 2.12
bool isMutuallyExclusive() const;
//! Set whether the group is mutually exclusive (only one child can be checked at a time).
//! The initial child index determines which child should be initially checked. The default value
//! of -1 will determine automatically (either first one currently checked or none)
//! @note added in 2.12
%Docstring
Return whether the group is mutually exclusive (only one child can be checked at a time)
.. versionadded:: 2.12
:rtype: bool
%End

void setIsMutuallyExclusive( bool enabled, int initialChildIndex = -1 );
%Docstring
Set whether the group is mutually exclusive (only one child can be checked at a time).
The initial child index determines which child should be initially checked. The default value
of -1 will determine automatically (either first one currently checked or none)
.. versionadded:: 2.12
%End

protected slots:
void nodeVisibilityChanged( QgsLayerTreeNode* node );
void nodeVisibilityChanged( QgsLayerTreeNode *node );

protected:

//! Set check state of children - if mutually exclusive
void updateChildVisibilityMutuallyExclusive();
%Docstring
Set check state of children - if mutually exclusive
%End





private:
QgsLayerTreeGroup( const QgsLayerTreeGroup& other );

QgsLayerTreeGroup( const QgsLayerTreeGroup &other );
%Docstring
Copies are not allowed
%End
};


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layertree/qgslayertreegroup.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
Loading

0 comments on commit 33b6c41

Please sign in to comment.