2016-10-25 16:05:34 +10:00
|
|
|
|
|
|
|
/** \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() );
|
|
|
|
|
2016-10-26 10:35:07 +10:00
|
|
|
/**
|
|
|
|
* 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.
|
2016-10-26 10:59:38 +10:00
|
|
|
* If the origin parameter is set then only constraints with a matching origin will be checked.
|
2016-10-26 10:35:07 +10:00
|
|
|
*/
|
2016-10-26 10:59:38 +10:00
|
|
|
static bool validateAttribute( const QgsVectorLayer* layer, const QgsFeature& feature, int attributeIndex, QStringList& errors /Out/,
|
2016-11-01 18:41:22 +10:00
|
|
|
QgsFieldConstraints::ConstraintOrigin origin = QgsFieldConstraints::ConstraintOriginNotSet );
|
2016-10-26 10:35:07 +10:00
|
|
|
|
2016-10-25 16:05:34 +10:00
|
|
|
};
|