Skip to content

Commit

Permalink
Handle overview status changes properly.
Browse files Browse the repository at this point in the history
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 ebd8aea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/layertree/qgslayertreenode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/core/layertree/qgslayertreenode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/gui/layertree/qgslayertreemapcanvasbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ QgsLayerTreeMapCanvasBridge::QgsLayerTreeMapCanvasBridge(QgsLayerTreeGroup *root
, mHasCustomLayerOrder(false)
{
connectToNode(root);
connect(root, SIGNAL(customPropertyChanged(QgsLayerTreeNode*,QString)), this, SLOT(nodeCustomPropertyChanged(QgsLayerTreeNode*,QString)));

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

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

1 change: 1 addition & 0 deletions src/gui/layertree/qgslayertreemapcanvasbridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected slots:
void nodeAddedChildren(int indexFrom, int indexTo);
void nodeRemovedChildren();
void nodeVisibilityChanged();
void nodeCustomPropertyChanged(QgsLayerTreeNode* node, QString key);

void setCanvasLayers();

Expand Down

0 comments on commit ebd8aea

Please sign in to comment.