-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
add configuration flags to QgsFields #38634
Conversation
Before going any further, I'd like to know if there is any objections to adding such flags to QgsField. |
884bcec
to
9556157
Compare
@3nids I like the idea of the flags but we need to clear up the semantics: are these flags if directly related to the data source? For example, for the server flags: they are basically set by the user and are part of the layer configuration in the server context. I would keep them separate, but I like the flags approach though. |
first use case it to define if fields are searchable in active layer locator filter
9556157
to
26f60a9
Compare
yes, it's intended to be set by the user.
So you would add a new list as a property of the layer? I like the idea of moving this to field because the information is where you need it, you already have iterators for the fields. It was a bit the same we did for the editable, searchable, required layers lists which were moved as flagd in QgsMapLayer (89830f6) I can go for a more descriptive phrasing, like |
No, as long as it is clear what the flags are and they are homogeneous this is probably not necessary. Can you make a preliminary list of what settings will be stored as flags (you mentioned server configuration flags such as exposure as wms/wfs and the like).
Yes, that makes it clearer. |
@@ -282,6 +296,18 @@ class CORE_EXPORT QgsField | |||
*/ | |||
void setAlias( const QString &alias ); | |||
|
|||
/** | |||
* Returns the Flags for the field (searchable, …) | |||
* \since QGIS 3.16 |
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.
\warning these will be totally broken on some python versions 😆
@@ -282,6 +296,18 @@ class CORE_EXPORT QgsField | |||
*/ | |||
void setAlias( const QString &alias ); | |||
|
|||
/** | |||
* Returns the Flags for the field (searchable, …) |
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.
* Returns the Flags for the field (searchable, …) | |
* Returns the Flags for the field (searchable, ...) |
I'd skip the unicode characters in dox -- it's likely to open up a world of hurt
I'm not against storing extra stuff in QgsField (e.g. I'd like to add an optional QgsNumericFormat value to it at some stage). The tricky bit is handling expectations from users who assume that changing the field's flags will automatically do ... something...! You'll need to add a massive /warning note to the dox to state that changing the flags doesn't actually change the layer settings, and point users to the correct api to use to actually set these flags on the layer/provider level. I'm also wondering... I get the love for enum classes, but I'm thinking it's just too premature to use these widely. Could we hold back on that until post QGIS 3.16 when we do the proposed massive dependency requirement bump? |
I think it would make sense to bring WMS, WFS. Editable could come to mind (it can be discussed if it's related to widget or field). |
Since this preliminary work is required, I would propose to no publish them in the PyQGIS API, only in C++ (until 3.18). Sounds like a plan? |
Can we separate the server specific flags from the desktop flags? Or maybe we need a more complex struct and use the same "origin" or "domain" concept similar to what we have for constraints? WFS editable can be both a field property of a remote WFS that we are accessing from the desktop and a user-settable flag that we set for a field in a project that will be served from QGIS Server. What I was trying to say with my first comment is that we should possibly avoid to mix the flags that are user-configurable and those that are "hard" coming from the provider that cannot be overridden by the API (if a remote WFS field is not editable there is nothing we can do about it but in case we are designing a WFS for QGIS Server it's up to us to decide if a field is editable or not)
Is that different from queryable ? |
mmm actually queryable in WMS context applies to the whole layer so it might not be a good example, I'm not sure if we want to propagate layer properties to the field flags. |
I understand your point now. Last commit renames the flags to ConfigurationFlags and I added some text in the docstring. For searchable, this flags is here mainly for the active layer features locator filter, to determine in which field it can search by default. |
@3nids For Python users, we are tagging Do you see any inconvenient to expose |
On the current master, layer = iface.activeLayer()
layer.excludeAttributesWfs()
set()
layer.excludeAttributesWms()
set() |
I made a PR to fix the deprecated methods: #40602 Regarding the availability in Python, I am waiting on the bump on the requirements to have a more recent sip to avoid issues with scoped enums. |
This is a preliminary work to allow defining if fields are searchable in active layer locator filter
(feature request: #36701)
The idea to use flags is to make this future proof and easily extend the flags.
Saving/reading to XML will be handy using QMetaEnum::valueToKeys
(Later on, WMS/WFS capabilities could be moved to these flags)