Derive additional action availability from model
Derive additional action availability from model
Description
Replace hardcoded expression with iteration over the model to determine whether any entry is visible, in both the AdditionalActionsList and the AdditionalCustomActionsList.
This removes the maintenance burden of updating the expression whenever actions are added, removed, or a special condition is added to their availability (e.g., only appearing in Advanced Mode).
Checklist:
- [X] Review Contribution Guidelines.
- [X] Review Code of Conduct.
- [X] I have tested my changes.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Not sure if those copilot suggestions matter but if so maybe something like this could help. I've been wanting to try it out.
I think they're nonsense (the suggested changes sure are) since I tested it and it was reactive. But I'll test it out a bit more thoroughly when I can.
The reactivity bug Copilot mentions doesn't actually exist because the model is recomputed whenever a visibility flag changes. But if the model is mutated in place rather than reassigned then yes, anyActionAvailable may be out of date. But of course, the same was true with the old code. Neither a Syncronizer nor a Binding alone would fix this, since we're using a plain JS array of vars for the model: I think that would also require using a Qt model like a ListModel or to keep the JS array but to make its elements QtObjects.
The changes work but I guess the implementation isn't the best, that much is true.
I think the discussion above is about what happens when 'visible' on an item changes with respect anyActionAvailable. I still don't see how the Additional Actions buttons will show/hide when either all actions go invisible or it transitions from all actions invisible to one or more visible.
I think the discussion above is about what happens when 'visible' on an item changes with respect
anyActionAvailable. I still don't see how the Additional Actions buttons will show/hide when either all actions go invisible or it transitions from all actions invisible to one or more visible.
Yes, this change is non-functional. It's just meant to avoid having to change anyActionAvailable whenever you add an action, since it can be easily derived from the model itself. In our QGC custom build we have a couple custom actions that are nonetheless implemented as normal AdditionalActions (rather than AdditionalCustomActions) and everytime something is added or removed upstream it causes merge conflicts on that line.
Not sure what to do with this since it doesn't work?
Not sure what to do with this since it doesn't work?
What do you mean? I think it works.
Edit: By non-functional I mean that it doesn't intend to change any of the functionality. It's just a simple change from a hardcoded visibility expression to a generic one.