[Qgis-developer] Labeling: data-defined fields shifted after new vector API?

Larry Shaffer larrys at dakotacarto.com
Tue Feb 5 19:25:10 PST 2013


Hi,

martin Dobias wrote:
>

>
The source of the problem is that before, it was possible to have
> "holes" in attribute field indices: e.g. three attributes with indices
> 0,2,3. Whether such holes appeared depended on the provider being
> used. The support for holes has been removed for performance and
> simplicity - many developers were not even aware of this thing.
>
> As a quick fix I think you'll need to update your project file. The
> proper fix should change writing of attributes as names in
> data-defined properties (for new labeling).
>

Ok, I've looked into fixing this (and have a couple of ideas), but need a
clarification first:

Is mFields[i].originIndex (where mFields is a QgsFields vector) the same
index used for the keys in QgsFieldMap?

In other words, will this new method, QgsFields::toQgsFieldMap(), function
correctly [0]? If so, I can use it to attempt to auto-convert
QgsFieldMap-index-based data defined properties over to field-name-based
properties, without having think about reintroducing any QgsFieldMap
functionality at the provider level.

If adding that method is a reasonable approach, do I need to filter the
added fields in any way (e.g. by FieldOrigin)?

[0] http://drive.dakotacarto.com/qgis/qgsfields-qgsfieldmap_patch.diff

Regards,

Larry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130205/3b57e337/attachment.html>


More information about the Qgis-developer mailing list