qgis / QGIS-Enhancement-Proposals

QEP's (QGIS Enhancement Proposals) are used in the process of creating and discussing new enhancements for QGIS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updated Field Calculator

esnyder-rve opened this issue · comments

QGIS Enhancement: Updated Field Calculator

Date 2022/09/27

Author Ethan Snyder (@esnyder-rve)

Contact ethan dot snyder at rve dot com

maintainer @esnyder-rve

Version QGIS 3.?

Summary

This enhancement proposal is for the upgrade of the field calculator to be more flexible and usable. The proposed enhancements/changes are:

  1. Make the Field Calculator window non-modal
  2. Add a layer selection drop-down to the top
  3. Rename "Ok" button to "Apply" or add "Apply" button
  4. Change the Toolbar button to a toggle button
  5. Add toggle to show/hide hidden fields
  6. (Optional) Make it more obvious that either a selection is being used or all features

Some History

There has been some discussion around 1 and 3, but it hasn't gone anywhere (qgis/QGIS#28239, although a duplicate of qgis/QGIS#23887 but with discussion). I also posed this in the QGIS-Developer's mailing list with only one reply from Tim Sutton (https://lists.osgeo.org/pipermail/qgis-developer/2022-May/064736.html).

Proposed Solution

  1. Make the Field Calculator window non-modal

    • This allows the other changes more practical
    • Allows the user to change the feature selection before applying the calculation (instead of canceling, changing selection, then re-entering the expression)
    • Dockable panel???
  2. Add a layer selection drop-down to the top

    • Similar to the floating Layer Styling Panel
    • List will be limited to vector layers
    • Would change to the currently selected layer from the layers panel just like the Layer Styling Panel (with possible toggle to enable/disable this behavior)
    • Would default to no active layer if a non-vector layer is selected
    • The expression would not change or clear when the layer is changed (it would however, re-validate the expression against the new layer)
  3. Rename "Ok" button to "Apply" or add "Apply" button

    • Keeps the field calculator open after running a calculation
    • Useful for repeated similar expressions either against different fields of the same layer, or against multiple layers
  4. Change the Toolbar button to a toggle button

    • Because 1 would imply this being done
  5. Add toggle to show/hide hidden fields

  6. (Optional) Make it more obvious that either a selection is being used or all features

    • I've had times where I didn't realize that I had a selection and wanted it to run against all, and when I wanted a selection and accidentally ran against all features.
    • It would be nice to make this behavior more obvious (but not obnoxious like a popup prompt asking)
    • Possibly have the Apply/Ok button read something like "Apply to x features" or "Apply to all features"
    • Open to suggestions about this

Affected Files

Field Calculator

Performance Implications

Depending on the calculation, this could freeze the QGIS GUI (which the field calculator already does, but the window is modal).

Further Considerations/Improvements

Some additional requests may be tacked on to this if reasonable, and fits into this scope.

Backwards Compatibility

None

Issue Tracking ID(s)

qgis/QGIS#23887

Votes

(required)

commented

So you would simply make a field generator that can operate on any layer?

That would require to change the element in the layer scope, it seems doable.

@roya0045

So you would simply make a field generator that can operate on any layer?

I guess? But it would only operate on one layer at a time.

That would require to change the element in the layer scope, it seems doable.

Thanks for the tip.

In my opinion, the field calculator tool should be made more friendly to newcomers. At the moment the UI is definitely not the cleanest it could and I'm afraid that changing to a non modal dialog and adding yet another widget for layer selection could lead to user confusion.

How about getting the same functionality by upgrading the Field Calculator Processing Algorithm to allow editing features in-place instead?

In my opinion, the field calculator tool should be made more friendly to newcomers. At the moment the UI is definitely not the cleanest it could and I'm afraid that changing to a non modal dialog and adding yet another widget for layer selection could lead to user confusion.

I feel that to a newcomer, the dialog being modal is more frustrating by needing to close and loose the current expression to do something (like change the selected layer, change selected features, etc...). Also, the manual & documentation does exist for a reason.

How about getting the same functionality by upgrading the Field Calculator Processing Algorithm to allow editing features in-place instead?

Creating an Edit in Place field calculator processing tool may be useful, but would be a whole separate thing and is outside the scope of this QEP.

@uclaros What issues do you have with the current UI? Do you have any suggestions for fixing them?