parameters: (self, dlg)
docstring: Populate layers on QGIS into our layers and group tree view.
docstring_summary: Populate layers on QGIS into our layers and group tree view.
docstring_tokens: Populate layers on QGIS into our layers and group tree view .
function: def populate_layers_and_groups(self, dlg):
          """Populate layers on QGIS into our layers and group tree view."""
          root_node = QgsProject.instance().layerTreeRoot()
          tree_groups = []
          tree_layers = root_node.findLayers()
          self.layers_item = QTreeWidgetItem()
          self.layers_item.setText(0, "Layers and Groups")
          self.layersTree.setColumnCount(3)
  
          for tree_layer in tree_layers:
              layer = tree_layer.layer()
              if (layer.type() != QgsMapLayer.PluginLayer and
                      (layer.type() != QgsMapLayer.VectorLayer or
                       layer.wkbType() != QgsWkbTypes.NoGeometry) and
                      layer.customProperty("ol_layer_type") is None):
                  try:
                      # if layer.type() == QgsMapLayer.VectorLayer:
                      #    testDump = layer.renderer().dump()
                      layer_parent = tree_layer.parent()
                      if layer_parent.parent() is None:
                          item = TreeLayerItem(self.iface, layer,
                                               self.layersTree, dlg)
                          self.layers_item.addChild(item)
                      else:
                          if layer_parent not in tree_groups:
                              tree_groups.append(layer_parent)
                  except Exception:
                      QgsMessageLog.logMessage(traceback.format_exc(),
                                               "qgis2web",
                                               level=Qgis.Critical)
  
          for tree_group in tree_groups:
              group_name = tree_group.name()
              group_layers = [
                  tree_layer.layer() for tree_layer in tree_group.findLayers()]
              item = TreeGroupItem(group_name, group_layers, self.layersTree)
              self.layers_item.addChild(item)
  
          self.layersTree.addTopLevelItem(self.layers_item)
          self.layersTree.expandAll()
          self.layersTree.resizeColumnToContents(0)
          self.layersTree.resizeColumnToContents(1)
          for i in range(self.layers_item.childCount()):
              item = self.layers_item.child(i)
              if item.checkState(0) != Qt.Checked:
                  item.setExpanded(False)
function_tokens: def populate_layers_and_groups ( self , dlg ) : root_node = QgsProject . instance ( ) . layerTreeRoot ( ) tree_groups = [ ] tree_layers = root_node . findLayers ( ) self . layers_item = QTreeWidgetItem ( ) self . layers_item . setText ( 0 , "Layers and Groups" ) self . layersTree . setColumnCount ( 3 ) for tree_layer in tree_layers : layer = tree_layer . layer ( ) if ( layer . type ( ) != QgsMapLayer . PluginLayer and ( layer . type ( ) != QgsMapLayer . VectorLayer or layer . wkbType ( ) != QgsWkbTypes . NoGeometry ) and layer . customProperty ( "ol_layer_type" ) is None ) : try : # if layer.type() == QgsMapLayer.VectorLayer: #    testDump = layer.renderer().dump() layer_parent = tree_layer . parent ( ) if layer_parent . parent ( ) is None : item = TreeLayerItem ( self . iface , layer , self . layersTree , dlg ) self . layers_item . addChild ( item ) else : if layer_parent not in tree_groups : tree_groups . append ( layer_parent ) except Exception : QgsMessageLog . logMessage ( traceback . format_exc ( ) , "qgis2web" , level = Qgis . Critical ) for tree_group in tree_groups : group_name = tree_group . name ( ) group_layers = [ tree_layer . layer ( ) for tree_layer in tree_group . findLayers ( ) ] item = TreeGroupItem ( group_name , group_layers , self . layersTree ) self . layers_item . addChild ( item ) self . layersTree . addTopLevelItem ( self . layers_item ) self . layersTree . expandAll ( ) self . layersTree . resizeColumnToContents ( 0 ) self . layersTree . resizeColumnToContents ( 1 ) for i in range ( self . layers_item . childCount ( ) ) : item = self . layers_item . child ( i ) if item . checkState ( 0 ) != Qt . Checked : item . setExpanded ( False )