12 Commits

Author SHA1 Message Date
Denis Rouzaud
1df3c51606 sipify batch 2017-05-22 10:12:08 +02:00
Denis Rouzaud
7d459149c7 [sip] align missing bits and replace nullptr by 0 2017-05-02 08:09:53 +02:00
Denis Rouzaud
93971d5ed3 [sip] align pointer and reference in blacklisted files
this will facilitate sip diff checking
2017-05-01 17:49:43 +02:00
Denis Rouzaud
0a63d1f2c2 [spellcheck] properly look into various cases and add more fixes" 2017-01-16 16:39:20 +01:00
Harrissou Sant-anna
ef85cdcf83 Replace "eg" by "e.g." or "for example" 2016-12-30 00:03:22 +01:00
Nyall Dawson
b5864cd432 [FEATURE] Improve handling of defaults (inc provider default clauses,
literal defaults, and qgis expression defaults) and automatically
handle unique value constraints on layers

Add a new method QgsVectorLayerUtils::createFeature which returns
a new feature which includes all relevant defaults. Any fields
with unique value constraints will be guaranteed to have a value
which is unique for the field.

Currently only in use by the split feature tool.

Sponsored by Canton of Zug and the QGEP project
2016-11-16 14:19:24 +01:00
Nyall Dawson
747097d43d New method QgsVectorLayerUtils::createUniqueValue
Returns a new unique attribute value for a layer. For numeric
fields this is the max attribute value + 1, for strings we
attempt to create a unique value by append _1, _2, etc to either
a specified 'seed' value, or failing that to the end of the
value of that field from the first feature in the layer.
2016-11-16 14:19:24 +01:00
Nyall Dawson
3f2a7810cf Respect non-enforced constraints when editing/adding features
Warnings are shown, but features can be committed. Fields which
fail an unenforced constraint are now shaded in yellow to differentiate
from the red failure for enforced constraints.
2016-11-02 13:42:22 +10:00
Nyall Dawson
cb94b68d88 Move constraint handling to QgsFieldConstraints
Avoids cluttering QgsField API
2016-11-02 11:07:07 +10:00
Nyall Dawson
a6319a47d7 If the layer is NOT being edited then only check layer based constraints
and not any constraints enforced by the provider

Because:

1. we want to keep browsing features nice and responsive. It's nice to give
 feedback as to whether the value checks out, but not if it's too slow to
 do so. Some constraints (eg unique) can be expensive to test. A user can
 freely remove a layer-based constraint if it proves to be too slow to
 test, but they are unlikely to have any control over provider-side
 constraints

2. the provider has already accepted the value, so presumably it doesn't
 violate the constraint and there's no point rechecking!
2016-11-02 11:07:07 +10:00
Nyall Dawson
c98d380dc1 Move responsibility for testing for attribute against constraints
to QgsVectorLayerUtils::validateAttribute()

Also clean up some strings shown to the user when a constraint
check fails
2016-11-02 11:07:07 +10:00
Nyall Dawson
b7d0fd6f90 New class QgsVectorLayerUtils
Contains static helper methods for working with vector layers.
Initially only contains a method to test whether a value
exists within a layer's attributes.
2016-11-02 11:07:07 +10:00