legend groups and layer position/order qgis 1.8

المشرف العام

Administrator
طاقم الإدارة
I'm tring to programmatically create layer sequence also using groups.Simple python code:

layer = QgsVectorLayer("004cp000.shp", "004cp000", "ogr")QgsMapLayerRegistry.instance().addMapLayer(layer)legend = qgis.utils.iface.legendInterface()index = legend.addGroup ("G1")index = legend.addGroup ("G2",index)legend.moveLayer (legend.layers()[0],index)
  • How it is possible to remove a nested group ? qgis.utils.iface.legendInterface().removeGroup only works with top level groups.
  • How a layer can be moved into a nested group?qgis.utils.iface.legendInterface().moveLayer only works with top level groups.
  • How can I move a layer before or after a another layer inside the same group?
After some research into QGis Source code I've discovered that it is not possible to move a layer into a sub group and also it is not possible to delete a soub group.

void QgsLegend::moveLayer( QgsMapLayer *ml, int groupIndex ){ if ( !ml ) return; QgsLegendLayer *layer = findLegendLayer( ml->id() ); if ( !layer ) return; QgsLegendGroup *group = dynamic_cast( topLevelItem( groupIndex ) ); if ( !group ) return; insertItem( layer, group ); emit itemMovedGroup( dynamic_cast( layer ), groupIndex );}void QgsLegend::removeGroup( int groupIndex ){ QgsLegendGroup * lg = dynamic_cast( topLevelItem( groupIndex ) ); if ( lg ) { removeGroup( lg ); }}

أكثر...
 
أعلى