Open jeremyferris opened 1 month ago
I managed to locate the code where the name is set in: QGIS/src/core /qgspolymorphicrelation.cpp
line 393.
relation.setName( QStringLiteral( "Generated for \"%1\"" ).arg( referencedLayerName ) );
If this could instead start with 'referencingLayerName' "for" 'referencedLayerName' (or some such arrangement) it would make my life easier in my particular situation as the full relationship would show in the drag-and-drop-designer for attribute forms.
I also had a look in my raw project (.qgs) file to see if I could rename the relations there, but I do not see an immediate way to affect the names of polymorphic sub-relationships. The change suggested in my comment above is likely the simplest as it should not require any changes to how the polymorphic relationships are captured in the project file.
As an aside, and my apologies if this is really not the place for it, but I also noticed when I copy/paste the attribute-form style, the polymorphic relationships from the copied layer are populated in the paste layer and appear to function in the resulting form.
I imagine that if I left it this way, I could end up with unexpected results.
I also wanted to bring this "bug" to the attention, but I see @jeremyferris already did a good job explaining the issue. You don't need to have 150 layers to find this behaviour time-consuming. Even with two polymorphic relationships refering to the same layers this allready causes the above mentioned problems.
The solution proposed by @jeremyferris seems to me to be the right way to go!
Feature description
It would be very helpful to be able to edit the names of polymorphic relationships.
I am working on a project where I am utilizing the awesome postgres feature of Inheritance to greatly reduce the number of association tables I have to create. My database reduces from 860+ tables to less than 200, and my QGIS project is much more manageable.
My struggle is that all of the polymorphic relation names are 'Created for "xxx_layer"', xxx_layer being the layer I am creating forms in. In my case, I have twelve such relationships for ~150 layers and the relationship naming is not very helpful. I currently have to select each relationship, drag it into the 'form layout' section of the 'drag and drop designer', then click on the 'cardinality' dropdown before I know which layer relationship I am working with.
EDIT: At minimum, it would be nice to have the automatic name reference both the referencing and referenced layers (see my comment below).
To be able to double-click the name of the specific sub relationship and type in a new one in the Relationship section of the project properties would also be good, but ideally, it would be nice to be able to enter an expression in the polymorphic relationship dialogue.
This screenshot indicates that I can edit the name of a regular relationship.
Also, when I copy/paste style>attribute_forms, I am left with the other form's relationship:
Additional context
I would love to be involved in what it takes to implement this change, if accepted. I am not a developer, per se, but can do some coding and would be interested in sitting in on any coding sessions to learn the process and how to navigate the code.