Skip to content

Commit

Permalink
Merge pull request #40 from QGEP/fixattributeform
Browse files Browse the repository at this point in the history
Update QgsAttributeForm to API 3
  • Loading branch information
m-kuhn authored Jun 11, 2019
2 parents 98f726c + cc87de3 commit 994ad5c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/tools/qgepmaptooladdfeature.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from builtins import range
from qgis.gui import (
QgsAttributeForm,
QgsAttributeEditorContext,
QgsMapToolAdvancedDigitizing,
QgsMapTool,
QgsRubberBand,
Expand Down Expand Up @@ -150,7 +151,7 @@ def right_clicked(self, _):
f = QgsFeature(self.layer.fields())
f.setGeometry(self.rubberband.asGeometry())
dlg = self.iface.getFeatureForm(self.layer, f)
dlg.setMode(QgsAttributeForm.AddFeatureMode)
dlg.setMode(QgsAttributeEditorContext.AddFeatureMode)
dlg.exec_()
self.rubberband.reset3D()
self.temp_rubberband.reset()
Expand Down Expand Up @@ -274,12 +275,12 @@ def snap(self, event):
req = QgsFeatureRequest(match.featureId())
f = next(match.layer().getFeatures(req))
assert f.isValid()
if match.layer().wkbType() == QgsWkbTypes.WKBPoint25D:
point = QgsPoint(f.geometry().geometry())
if match.layer().geometryType() == QgsWkbTypes.PointGeometry:
point = QgsPoint(f.geometry().constGet())
else:
(ok, vertex_id) = f.geometry().vertexIdFromVertexNr(match.vertexIndex())
assert ok
point = f.geometry().geometry().vertexAt(vertex_id)
point = f.geometry().constGet().vertexAt(vertex_id)
assert type(point) == QgsPoint
return point, match
else:
Expand Down Expand Up @@ -332,7 +333,7 @@ def right_clicked(self, _):
f.setAttribute(level_field_index, self.rubberband.points[pt_idx].z())

dlg = self.iface.getFeatureForm(self.layer, f)
dlg.setMode(QgsAttributeForm.AddFeatureMode)
dlg.setMode(QgsAttributeEditorContext.AddFeatureMode)
dlg.exec_()

self.rubberband.reset3D()
Expand Down

0 comments on commit 994ad5c

Please sign in to comment.