Skip to content
Permalink
Browse files
[TopoViewer] fix layer visibility after QgsLegendInterface API changes
It was broken with 2.4, whereas QgsLegendInterface::moveLayer started
forcing layer visibility on (undocumented behaviour).

Fixes #11382
  • Loading branch information
Sandro Santilli committed Oct 14, 2014
1 parent cc3579e commit 1ff2ad3cc3fa4bdca691f83497f96e83a6cc898b
Showing with 12 additions and 12 deletions.
  1. +12 −12 python/plugins/db_manager/db_plugins/postgis/plugins/qgis_topoview/__init__.py
@@ -114,9 +114,9 @@ def run(item, action, mainwindow):
layer = QgsVectorLayer(uri.uri(), u'%s.face_mbr' % toponame, provider)
layer.loadNamedStyle(os.path.join(template_dir, 'face_mbr.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)
face_extent = layer.extent()

# face geometry
@@ -129,9 +129,9 @@ def run(item, action, mainwindow):
layer.setExtent(face_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'face.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)

# face_seed
sql = u'SELECT face_id, ST_PointOnSurface(topology.ST_GetFaceGeometry(%s, face_id)) as geom ' \
@@ -143,9 +143,9 @@ def run(item, action, mainwindow):
layer.setExtent(face_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'face_seed.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)

# TODO: add polygon0, polygon1 and polygon2 ?

@@ -162,9 +162,9 @@ def run(item, action, mainwindow):
layer = QgsVectorLayer(uri.uri(), u'%s.node' % toponame, provider)
layer.loadNamedStyle(os.path.join(template_dir, 'node.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)
node_extent = layer.extent()

# node labels
@@ -175,9 +175,9 @@ def run(item, action, mainwindow):
layer.setExtent(node_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'node_label.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)

# EDGES
group = legend.addGroup(u'Edges', False, supergroup)
@@ -190,9 +190,9 @@ def run(item, action, mainwindow):
uri.setWkbType( QGis.WKBLineString )
layer = QgsVectorLayer(uri.uri(), u'%s.edge' % toponame, provider)
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)
edge_extent = layer.extent()

# directed edge
@@ -203,9 +203,9 @@ def run(item, action, mainwindow):
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'edge.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)


# edge labels
@@ -216,9 +216,9 @@ def run(item, action, mainwindow):
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'edge_label.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)

# face_left
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
@@ -228,9 +228,9 @@ def run(item, action, mainwindow):
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'face_left.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)

# face_right
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
@@ -240,9 +240,9 @@ def run(item, action, mainwindow):
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'face_right.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)

# next_left
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
@@ -252,9 +252,9 @@ def run(item, action, mainwindow):
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'next_left.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)

# next_right
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
@@ -264,9 +264,9 @@ def run(item, action, mainwindow):
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'next_right.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)

finally:
# restore canvas render flag

0 comments on commit 1ff2ad3

Please sign in to comment.