Fix unavailable style-categories listed in qml-file #59605
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short: On loading a stylecategorymodel the last used category selection is passed to it. Since categories from vector layers can divert to categories from raster layers, this leaded to weird info in the qml-files. This change only passes the categories that the target layer allows (crops them).
When changing a layer, the previously stored or loaded category-selection is taken over.
This is nice and makes sense on layer with the same type. On other types it don't mind that much, but are neither useful.
Anyway, the problem was, that with this in the
styleCategories
in the qml-file style categories where listed, that did not even exist for that layer type.Not that bad, because there was no more content of them (since the
writeSymbology
methods are all layer-type-specific overrides) but still it's confusing.So I decide that on taking over the
lastStyleCategories
in the model they are "cropped" to the possible style categories according to the Categories-List of the layer type.This leads to the situation that when storing styles of raster and then open the dialog for a vector, the categories that are available in the vector layers but not in the rasters are disabled. IMO a behavior that is acceptable.