5 Commits

Author SHA1 Message Date
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