Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QgsAttributeForm not entering edit mode #19678

Closed
qgib opened this issue Oct 13, 2014 · 7 comments
Closed

QgsAttributeForm not entering edit mode #19678

qgib opened this issue Oct 13, 2014 · 7 comments
Labels
Attribute Table Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@qgib
Copy link
Contributor

qgib commented Oct 13, 2014

Author Name: Andrew McClure (Andrew McClure)
Original Redmine Issue: 11395
Affected QGIS version: 2.4.0
Redmine category:attribute_table
Assignee: Matthias Kuhn


Use case:

Pre conditions:

A valid UI file and Init function have been specified via layer.setEditForm and layer.setEditFormInit

Steps:

  1. User enters Attribute Table
  2. Selects edit mode
  3. Switches to Open form

Form opens but is not editable

Alternative flow 1.

  1. Switch to open Form
  2. Select edit mode

Form is still not in edit mode

Alternative flow 2.

  1. Select layer
  2. Select feature
  3. Select "Toggle Editing" to enable editing
  4. Click 'i' Identify Features
  5. Edit Form opens (if configured to open directly) but dialog is not editable.

Finally, to force the form to open as editable it is necessary to programmatically start editing then directly call openFeatureForm:

@ layer.startEditing()
iface.openFeatureForm(layer, feature, True)
@

Example available using this plugin:

http://plugins.qgis.org/plugins/TelemetryLayer/


@qgib
Copy link
Contributor Author

qgib commented Oct 13, 2014

Author Name: Matthias Kuhn (@m-kuhn)


In your screenshot you did not select a feature. We could think about pre-selecting the first feature to make it more intuitive.

I recently discussed with Alexandre about this (or a similar issue) and realized, that we were talking about two different things.
He wanted a feature form to edit feature attributes without saving them to the feature but just to get an edited feature back (in a python plugin). Is this your use-case as well?


  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Oct 16, 2014

Author Name: Andrew McClure (Andrew McClure)


There are a number of use cases.

  1. Be able to enter edit mode using a custom form from the Attribute Table dialog. Currently the custom feature form only opens as not editable regardless of layer state

  2. Be able to enter an editable OR non editable version of the feature by selecting 'i' from the layer itself - and respecting the layer's edit value

  3. Programmatically be able to edit the feature by calling openFeatureForm with an existing issue. I have found a work around for this and posted it to the mailing list and included it below:

    • Use a feature saved say to a widget's data properties.
    • On a callback, copy the attributes the current layer.getFeatures() to ensure the old feature is in sync.
    • Make the layer editable and pass the "updated" feature to the openFeatureForm

@qgib
Copy link
Contributor Author

qgib commented Oct 16, 2014

Author Name: Matthias Kuhn (@m-kuhn)


Is there something wrong with the first two scenarios? These were working nicely last time I looked.

Related to python code, there was a problem when directly using QgsAttributeDialog and toggling edit mode after opening the dialog. This has been solved in a3dad24. openFeatureForm should have always worked.

Can you clarify what you are trying to do, what is not working, point to some sample code (exact locations, not a whole plugin. Most appreciated would be a minimal working example that can be run from the python console). It could also be related to the provider you use or if a subset string is set on your layer.

@qgib
Copy link
Contributor Author

qgib commented Oct 17, 2014

Author Name: Andrew McClure (Andrew McClure)


Hi Matthias

I would certainly love this to be a problem with my own code!

Unfortunately, for you to view the flow/recreate it is not as trivial as running a few lines of code. However, I can point to the places in my code. And there is also the feature form available from the AttributeTable if you simply run the plugin TelemetryLayer and follow the steps to create a new Telemetry Layer.

As for what is not working/what we are trying to do, this should be clear from my last issue update. I simply want the edit mode of the layer to be respected with regards opening a custom feature form.

As to the code, here are the critical bits:

  1. This is the custom edit form init:

https://github.com/nzfarmer1/telemetrylayer/blob/master/topicmanagers/editformfactory.py

  1. Here is the class that gets invoked and performs the dialog logic. You can see the debug statement showing the editable state.

https://github.com/nzfarmer1/telemetrylayer/blob/master/tltopicmanager.py : Line 107

class tlSysFeatureDialog(tlFeatureDialog):

  1. Here is the code that programmatically opens a featureForm using a feature stored in a QWidget which has been refreshed.
    (Note by changing the feature that is passed to the one that is returned from Layer.getFeature, the dialog fails to open in edit mode regardless of the layer's state.)

https://github.com/nzfarmer1/telemetrylayer/blob/master/tlbrokerconfig.py : Line 177+

@qgib
Copy link
Contributor Author

qgib commented Dec 20, 2015

Author Name: Giovanni Manghi (@gioman)


  • status_id was changed from Feedback to Open

@qgib
Copy link
Contributor Author

qgib commented Apr 30, 2017

Author Name: Giovanni Manghi (@gioman)


  • regression was configured as 0
  • easy_fix was configured as 0

@qgib
Copy link
Contributor Author

qgib commented Mar 9, 2019

Author Name: Giovanni Manghi (@gioman)


End of life notice: QGIS 2.18 LTR

Source:
http://blog.qgis.org/2019/03/09/end-of-life-notice-qgis-2-18-ltr/


  • resolution was changed from to end of life
  • status_id was changed from Open to Closed

@qgib qgib closed this as completed Mar 9, 2019
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Attribute Table labels May 25, 2019
@qgib qgib added this to the Future Release - Nice to have milestone May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Attribute Table Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

No branches or pull requests

1 participant