<div dir="ltr">Hello all,<div><br></div><div>I'm trying to finish a plugin that was initially designed for 1.8.</div><div><br></div><div>Our workflow is currently on QGIS 2.2, but we will update in the future, so I'm doing some test in 2.4 and in master.<br>
<div><br></div><div>My goal is to open the feature form of a temporary feature in a layer, and keep it's attribute values for future actions.</div><div><br></div><div>The code is something like this:</div><div><br></div>
<div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">mc = iface.mapCanvas()<br>layer = mc.currentLayer()<br>
temp_feature = QgsFeature()<br>attributes = []<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"># getting default values (for primary keys) </blockquote>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">provider = layer.dataProvider()<br>for j in layer.pendingAllAttributesList():<br>
    if provider.defaultValue(j):<br>        attributes.append(provider.defaultValue(j))<br>    else:<br>        attributes.append(None)<br>temp_feature.setAttributes(attributes)<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 <br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">iface.openFeatureForm(layer, temp_feature)<br>
</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
print temp_feature.attributes()</blockquote></div><div><br></div><div>My "problems" are:</div><div><br></div><div>In 2.2, after I edit the feature form and press the OK button, the temp_feature attributes are updated, but so is the first (already commited) feature of my layer...weird.</div>
<div><br></div><div>In 2.4, the Feature Form always open in non editng mode, even when the current layer is editable.</div><div><br></div><div>In master (2.5 1b205be), after pressing the feature form ok button, a new feature is automaticly added to the attribute table, and the temporary feature attributes are not updated.</div>
<div><br></div><div>I though it might be something to do with <b>updateFeatureOnly</b> boolean value, but setting it to True does not seems to make any difference.</div><div><br></div><div>Can anyone of you QGIS developing masters throw some light into my poor brain?</div>
<div><br></div><div>Thanks,</div><div><br></div><div>Alexandre Neto</div></div></div>