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

Enable editing of Polymorphic Relation name #59065

Open
jeremyferris opened this issue Oct 14, 2024 · 3 comments
Open

Enable editing of Polymorphic Relation name #59065

jeremyferris opened this issue Oct 14, 2024 · 3 comments

Comments

@jeremyferris
Copy link

jeremyferris commented Oct 14, 2024

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.

image
image

This screenshot indicates that I can edit the name of a regular relationship.
image

Also, when I copy/paste style>attribute_forms, I am left with the other form's relationship:
image

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.

@jeremyferris
Copy link
Author

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.

@jeremyferris
Copy link
Author

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.

@jeremyferris
Copy link
Author

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.

image

image

I imagine that if I left it this way, I could end up with unexpected results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant