-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Set display expression when adding fields through attribute table (fix #28353) #46978
Conversation
src/app/qgsattributetabledialog.cpp
Outdated
@@ -890,14 +890,18 @@ void QgsAttributeTableDialog::mActionAddAttribute_triggered() | |||
if ( mLayer->addAttribute( dialog.field() ) ) | |||
{ | |||
mLayer->endEditCommand(); | |||
|
|||
if ( mLayer->displayExpression() == QStringLiteral( "'[Please define preview text]'" ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this working?
Normally the dual view shouldn't be setting the layer display expression from there directly.
Otherwise the code should be adapted in dual view too.
At the same time, it would be worth making the text translated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, this text is set as a display expression in the dual view https://github.com/qgis/QGIS/blob/master/src/gui/attributetable/qgsdualview.cpp#L222 and it is not translated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes as display expression for the dual view, but I am not sure it's set back on the layer
It depends on what QgsFeatureListModel::setDisplayExpression
returns. This needs to be tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks to the changes in #47016 you can now test if it is empty
if ( mLayer->displayExpression() == QStringLiteral( "'[Please define preview text]'" ) ) | |
if ( mLayer->displayExpression().isEmpty() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, changed.
Description
If vector layer created without any attributes and then new fields are added via attributes table then display expression is not set. As a result "Features in All layers" locator filter shows
[Please define preview text]
instead of the real values.Fixes #28353.