Skip to content
Permalink
Browse files
Handle overview status changes properly.
Added signal about changed custom properties.
Changes to custom properties are propagated to the root node,
so it is not necessary to connect to all children
  • Loading branch information
wonder-sk committed May 21, 2014
1 parent 6beb7d7 commit ebd8aea6a24c6fac5a070b8993acc87afcc2091f
@@ -39,6 +39,7 @@ QgsLayerTreeNode* QgsLayerTreeNode::readXML(QDomElement& element)
void QgsLayerTreeNode::setCustomProperty(const QString &key, const QVariant &value)
{
mProperties.setValue(key, value);
emit customPropertyChanged(this, key);
}

QVariant QgsLayerTreeNode::customProperty(const QString &key, const QVariant &defaultValue) const
@@ -49,6 +50,7 @@ QVariant QgsLayerTreeNode::customProperty(const QString &key, const QVariant &de
void QgsLayerTreeNode::removeCustomProperty(const QString &key)
{
mProperties.remove(key);
emit customPropertyChanged(this, key);
}

QStringList QgsLayerTreeNode::customProperties() const
@@ -169,6 +171,8 @@ void QgsLayerTreeGroup::connectToChildNode(QgsLayerTreeNode* node)
}

connect(node, SIGNAL(visibilityChanged(Qt::CheckState)), this, SLOT(updateVisibilityFromChildren()));
// forward the signal towards the root
connect(node, SIGNAL(customPropertyChanged(QgsLayerTreeNode*,QString)), this, SIGNAL(customPropertyChanged(QgsLayerTreeNode*,QString)));
}

void QgsLayerTreeGroup::insertChildNode(int index, QgsLayerTreeNode* node)
@@ -57,6 +57,8 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject

void visibilityChanged(Qt::CheckState state);

void customPropertyChanged(QgsLayerTreeNode* node, QString key);

protected:

QgsLayerTreeNode(NodeType t);
@@ -11,6 +11,7 @@ QgsLayerTreeMapCanvasBridge::QgsLayerTreeMapCanvasBridge(QgsLayerTreeGroup *root
, mHasCustomLayerOrder(false)
{
connectToNode(root);
connect(root, SIGNAL(customPropertyChanged(QgsLayerTreeNode*,QString)), this, SLOT(nodeCustomPropertyChanged(QgsLayerTreeNode*,QString)));

setCanvasLayers();
}
@@ -162,3 +163,10 @@ void QgsLayerTreeMapCanvasBridge::nodeVisibilityChanged()
deferredSetCanvasLayers();
}

void QgsLayerTreeMapCanvasBridge::nodeCustomPropertyChanged(QgsLayerTreeNode* node, QString key)
{
Q_UNUSED(node);
if (key == "overview")
deferredSetCanvasLayers();
}

@@ -43,6 +43,7 @@ protected slots:
void nodeAddedChildren(int indexFrom, int indexTo);
void nodeRemovedChildren();
void nodeVisibilityChanged();
void nodeCustomPropertyChanged(QgsLayerTreeNode* node, QString key);

void setCanvasLayers();

0 comments on commit ebd8aea

Please sign in to comment.