mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
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.
32 lines
1.5 KiB
Plaintext
32 lines
1.5 KiB
Plaintext
|
|
/** \ingroup core
|
|
* \class QgsVectorLayerUtils
|
|
* \brief Contains utility methods for working with QgsVectorLayers.
|
|
*
|
|
* \note Added in version 3.0
|
|
*/
|
|
class QgsVectorLayerUtils
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgsvectorlayerutils.h>
|
|
%End
|
|
public:
|
|
|
|
/**
|
|
* Returns true if the specified value already exists within a field. This method can be used to test for uniqueness
|
|
* of values inside a layer's attributes. An optional list of ignored feature IDs can be provided, if so, any features
|
|
* with IDs within this list are ignored when testing for existance of the value.
|
|
*/
|
|
static bool valueExists( const QgsVectorLayer* layer, int fieldIndex, const QVariant& value, const QgsFeatureIds& ignoreIds = QgsFeatureIds() );
|
|
|
|
/**
|
|
* Tests an attribute value to check whether it passes all constraints which are present on the corresponding field.
|
|
* Returns true if the attribute value is valid for the field. Any constraint failures will be reported in the errors argument.
|
|
* If the strength or origin parameter is set then only constraints with a matching strength/origin will be checked.
|
|
*/
|
|
static bool validateAttribute( const QgsVectorLayer* layer, const QgsFeature& feature, int attributeIndex, QStringList& errors /Out/,
|
|
QgsFieldConstraints::ConstraintStrength strength = QgsFieldConstraints::ConstraintStrengthNotSet,
|
|
QgsFieldConstraints::ConstraintOrigin origin = QgsFieldConstraints::ConstraintOriginNotSet );
|
|
|
|
};
|