示例#1
0
    def polygonLayersToCombo(self):
        """Populate the combo with all polygon layers loaded in QGIS."""

        myRegistry = QgsMapLayerRegistry.instance()
        myLayers = myRegistry.mapLayers().values()
        myFoundFlag = False
        for myLayer in myLayers:
            myName = myLayer.name()
            mySource = str(myLayer.id())
            #check if layer is a vector polygon layer
            if isPolygonLayer(myLayer) or isPointLayer(myLayer):
                myFoundFlag = True
                addComboItemInOrder(self.cboPolygonLayers, myName, mySource)
        if myFoundFlag:
            self.cboPolygonLayers.setCurrentIndex(0)
示例#2
0
    def polygonLayersToCombo(self):
        """Populate the combo with all polygon layers loaded in QGIS."""

        myRegistry = QgsMapLayerRegistry.instance()
        myLayers = myRegistry.mapLayers().values()
        myFoundFlag = False
        for myLayer in myLayers:
            myName = myLayer.name()
            mySource = str(myLayer.id())
            #check if layer is a vector polygon layer
            if isPolygonLayer(myLayer) or isPointLayer(myLayer):
                myFoundFlag = True
                addComboItemInOrder(self.cboPolygonLayers, myName, mySource)
        if myFoundFlag:
            self.cboPolygonLayers.setCurrentIndex(0)
示例#3
0
    def on_cboPolygonLayers_currentIndexChanged(self, theIndex=None):
        """Automatic slot executed when the layer is changed to update fields.

        Args:
           theIndex: int - passed by the signal that triggers this slot.
        Returns:
           None.
        Raises:
           no exceptions explicitly raised."""
        myLayerId = self.cboPolygonLayers.itemData(theIndex, QtCore.Qt.UserRole).toString()
        myLayer = QgsMapLayerRegistry.instance().mapLayer(myLayerId)
        myFields = myLayer.dataProvider().fieldNameMap().keys()
        self.cboFields.clear()
        for myField in myFields:
            addComboItemInOrder(self.cboFields, myField, myField)
示例#4
0
    def on_cboPolygonLayers_currentIndexChanged(self, theIndex=None):
        """Automatic slot executed when the layer is changed to update fields.

        Args:
           theIndex: int - passed by the signal that triggers this slot.
        Returns:
           None.
        Raises:
           no exceptions explicitly raised."""
        myLayerId = self.cboPolygonLayers.itemData(
            theIndex, QtCore.Qt.UserRole).toString()
        myLayer = QgsMapLayerRegistry.instance().mapLayer(myLayerId)
        myFields = myLayer.dataProvider().fieldNameMap().keys()
        self.cboFields.clear()
        for myField in myFields:
            addComboItemInOrder(self.cboFields, myField, myField)