diff --git a/EasyCustomLabeling/EasyCustomLabeling.py b/EasyCustomLabeling/EasyCustomLabeling.py index 67a3c46..904c1cd 100644 --- a/EasyCustomLabeling/EasyCustomLabeling.py +++ b/EasyCustomLabeling/EasyCustomLabeling.py @@ -420,13 +420,16 @@ def runLabel(self): #end of general tests and user interaction -------------------------------------------------- sourceLayerProvider = sourceLayer.dataProvider() - sourceLayerFields = sourceLayerProvider.fields() + if hasattr(sourceLayer, "fields"): + sourceLayerFields = sourceLayer.fields() + else: + sourceLayerFields = sourceLayer.pendingFields() feat = QgsFeature() #asks for default field to use as labeling (thanks to Victor Axbom Layer to labeled layer plugin) # create the dialog - self.dlg = EasyCustomLabelingDialog(sourceLayerProvider) + self.dlg = EasyCustomLabelingDialog(sourceLayerFields) ret_dlg_field = self.dlg.exec_() #cancels if user cancels dialog: if ret_dlg_field == 0 : diff --git a/EasyCustomLabeling/EasyCustomLabelingDialog.py b/EasyCustomLabeling/EasyCustomLabelingDialog.py index 2f2930b..f12ee6b 100644 --- a/EasyCustomLabeling/EasyCustomLabelingDialog.py +++ b/EasyCustomLabeling/EasyCustomLabelingDialog.py @@ -36,15 +36,14 @@ class EasyCustomLabelingDialog(QDialog, Ui_EasyCustomLabeling): - def __init__(self, ldp): + def __init__(self, layerFields): QDialog.__init__(self) # Set up the user interface from Designer. self.setupUi(self) - self.loadFields(ldp) + self.loadFields(layerFields) - def loadFields(self, ldp): - fields = ldp.fieldNameMap() - for fieldname, index in fields.iteritems(): - self.labelfield.addItem(fieldname) + def loadFields(self, layerFields): + for field in layerFields: + self.labelfield.addItem(field.name()) \ No newline at end of file