[Qgis-developer] [Solved] Undo/Redo when adding/changing features from Python

bernhard.stroebl at jena.de bernhard.stroebl at jena.de
Wed Mar 7 05:11:05 EST 2012


Marco,

many thanks, that does the trick!

Bernhard

Am 07.03.2012 10:48, schrieb Marco Hugentobler:
> Hi Bernhard
>
> Use QgsVectorLayer::beginEditCommand before adding the feature, then
> endEditCommand or destroyEditCommand after.
>
> Regards,
> Marco
>
> On 07.03.2012 10:40, bernhard.stroebl at jena.de wrote:
>> Dear list,
>>
>> I am currently doing a Python plugin that adds/changes features in an
>> editable QgsVectorLayer:
>>
>> <code>
>> # case 1 change
>> myLayer.changeGeometry(myFid, newGeometry)
>> # case 2 add
>> if self.iface.openFeatureForm(myLayer, newFeature):
>> myLayer.addFeature(newFeature)
>> </code>
>>
>> The Undo/Redo Window does not list anything to undo in case 1 (change)
>> and only the attributes changed if I accept the featureForm in case 2.
>> I would expect "Feature changed" in case 1 and "Feature added" in case
>> 2. If I digitize a feature the feature form pops up as soon I have
>> finished digitizing and accepting it gives me a "Feature added"-undo
>> option.
>> I found the QgsUndoCommand class in the docs but get a
>> NameError: name 'QgsUndoCommand' is not defined
>>
>> any help appreciated
>>
>> Bernhard
>>
>>
>>
>> ________ Information from NOD32 ________
>> This message was checked by NOD32 Antivirus System for Linux Mail Server.
>> http://www.nod32.com
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>

-- 
Bernhard Ströbl
Anwendungsbetreuer GIS

Kommunale Immobilien Jena
Am Anger 26
07743 Jena

Tel.: 03641 49- 5190
E-Mail: bernhard.stroebl at jena.de
Internet: www.kij.de



Kommunale Immobilien Jena
Eigenbetrieb der Stadt Jena
Werkleiter: Thomas Dirkes


________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Server.
http://www.nod32.com


More information about the Qgis-developer mailing list