2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
class QgsVectorDataProvider : QgsDataProvider
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsvectordataprovider.h>
|
|
|
|
%End
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
public:
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2013-01-28 01:39:58 +01:00
|
|
|
// If you add to this, please also add to capabilitiesString()
|
|
|
|
/**
|
|
|
|
* enumeration with capabilities that providers might implement
|
|
|
|
*/
|
|
|
|
enum Capability
|
|
|
|
{
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Provider has no capabilities */
|
2014-05-27 23:22:50 +02:00
|
|
|
NoCapabilities,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Allows adding features */
|
2014-05-27 23:22:50 +02:00
|
|
|
AddFeatures,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Allows deletion of features */
|
2014-05-27 23:22:50 +02:00
|
|
|
DeleteFeatures,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Allows modification of attribute values */
|
2014-05-27 23:22:50 +02:00
|
|
|
ChangeAttributeValues,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Allows addition of new attributes (fields) */
|
2014-05-27 23:22:50 +02:00
|
|
|
AddAttributes,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Allows deletion of attributes (fields) */
|
2014-05-27 23:22:50 +02:00
|
|
|
DeleteAttributes,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Allows creation of spatial index */
|
2014-05-27 23:22:50 +02:00
|
|
|
CreateSpatialIndex,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Fast access to features using their ID */
|
2014-05-27 23:22:50 +02:00
|
|
|
SelectAtId,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Allows modifications of geometries */
|
2014-05-27 23:22:50 +02:00
|
|
|
ChangeGeometries,
|
2016-09-15 06:16:28 +10:00
|
|
|
/** Can create indexes on provider's fields */
|
2014-05-27 23:22:50 +02:00
|
|
|
CreateAttributeIndex,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Allows user to select encoding */
|
2014-05-27 23:22:50 +02:00
|
|
|
SelectEncoding,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Supports simplification of geometries on provider side according to a distance tolerance */
|
2014-05-27 23:22:50 +02:00
|
|
|
SimplifyGeometries,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Supports topological simplification of geometries on provider side according to a distance tolerance */
|
2014-05-27 23:22:50 +02:00
|
|
|
SimplifyGeometriesWithTopologicalValidation,
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Supports transactions*/
|
2016-01-15 10:10:58 +01:00
|
|
|
TransactionSupport,
|
|
|
|
/** Supports circular geometry types (circularstring, compoundcurve, curvepolygon)*/
|
|
|
|
CircularGeometries,
|
|
|
|
/** Supports joint updates for attributes and geometry
|
|
|
|
* Providers supporting this should still define ChangeGeometries | ChangeAttributeValues
|
|
|
|
*/
|
2016-05-30 22:17:32 +10:00
|
|
|
ChangeFeatures,
|
|
|
|
/** Supports renaming attributes (fields). Added in QGIS 2.16 */
|
|
|
|
RenameAttributes,
|
2016-12-27 13:52:40 +10:00
|
|
|
//! Supports fast truncation of the layer (removing all features). Added in QGIS 3.0
|
|
|
|
FastTruncate,
|
2013-01-28 01:39:58 +01:00
|
|
|
};
|
2016-07-25 11:30:04 +10:00
|
|
|
typedef QFlags<QgsVectorDataProvider::Capability> Capabilities;
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Bitmask of all provider's editing capabilities */
|
2012-09-24 02:28:15 +02:00
|
|
|
static const int EditingCapabilities;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor of the vector provider
|
|
|
|
* @param uri uniform resource locator (URI) for a dataset
|
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
QgsVectorDataProvider( const QString& uri = QString() );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
virtual ~QgsVectorDataProvider();
|
|
|
|
|
2013-12-05 18:27:45 +07:00
|
|
|
/**
|
|
|
|
* Return feature source object that can be used for querying provider's data. The returned feature source
|
|
|
|
* is independent from provider - any changes to provider's state (e.g. change of subset string) will not be
|
|
|
|
* reflected in the feature source, therefore it can be safely used for processing in background without
|
|
|
|
* having to care about possible changes within provider that may happen concurrently. Also, even in the case
|
|
|
|
* of provider being deleted, any feature source obtained from the provider will be kept alive and working
|
|
|
|
* (they are independent and owned by the caller).
|
|
|
|
*
|
|
|
|
* Sometimes there are cases when some data needs to be shared between vector data provider and its feature source.
|
|
|
|
* In such cases, the implementation must ensure that the data is not susceptible to run condition. For example,
|
|
|
|
* if it is possible that both feature source and provider may need reading/writing to some shared data at the
|
|
|
|
* same time, some synchronization mechanisms must be used (e.g. mutexes) to prevent data corruption.
|
|
|
|
*
|
2014-02-21 17:33:09 +07:00
|
|
|
* @note added in 2.4
|
2013-12-05 18:27:45 +07:00
|
|
|
* @return new instance of QgsAbstractFeatureSource (caller is responsible for deleting it)
|
|
|
|
*/
|
2016-06-02 11:37:35 +02:00
|
|
|
virtual QgsAbstractFeatureSource *featureSource() const = 0 /Factory/;
|
2013-12-05 18:27:45 +07:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**
|
|
|
|
* Returns the permanent storage type for this layer as a friendly name.
|
|
|
|
*/
|
|
|
|
virtual QString storageType() const;
|
|
|
|
|
2012-10-09 20:57:35 +02:00
|
|
|
/**
|
|
|
|
* Query the provider for features specified in request.
|
2016-07-10 21:30:19 +10:00
|
|
|
* @param request feature request describing parameters of features to return
|
|
|
|
* @returns iterator for matching features from provider
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() ) const = 0;
|
2012-10-09 20:57:35 +02:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**
|
2016-08-04 09:10:08 +02:00
|
|
|
* Returns the geometry type which is returned by this layer
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
2016-08-04 09:10:08 +02:00
|
|
|
virtual QgsWkbTypes::Type wkbType() const = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of features in the layer
|
|
|
|
* @return long containing number of features
|
|
|
|
*/
|
|
|
|
virtual long featureCount() const = 0;
|
|
|
|
|
|
|
|
/**
|
2016-07-10 22:28:17 +10:00
|
|
|
* Returns the fields associated with this data provider.
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
2016-07-10 22:28:17 +10:00
|
|
|
virtual QgsFields fields() const = 0;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a short comment for the data that this provider is
|
|
|
|
* providing access to (e.g. the comment for postgres table).
|
|
|
|
*/
|
|
|
|
virtual QString dataComment() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the minimum value of an attribute
|
|
|
|
* @param index the index of the attribute
|
|
|
|
*
|
|
|
|
* Default implementation walks all numeric attributes and caches minimal
|
|
|
|
* and maximal values. If provider has facilities to retrieve minimal
|
|
|
|
* value directly, override this function.
|
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
virtual QVariant minimumValue( int index ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the maximum value of an attribute
|
|
|
|
* @param index the index of the attribute
|
|
|
|
*
|
|
|
|
* Default implementation walks all numeric attributes and caches minimal
|
|
|
|
* and maximal values. If provider has facilities to retrieve maximal
|
|
|
|
* value directly, override this function.
|
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
virtual QVariant maximumValue( int index ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return unique values of an attribute
|
|
|
|
* @param index the index of the attribute
|
|
|
|
* @param uniqueValues values reference to the list to fill
|
2014-11-21 01:17:21 +01:00
|
|
|
* @param limit maxmum number of the values to return
|
2012-09-24 02:28:15 +02:00
|
|
|
*
|
|
|
|
* Default implementation simply iterates the features
|
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
virtual void uniqueValues( int index, QList<QVariant> &uniqueValues /Out/, int limit = -1 ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-08-22 10:45:58 +10:00
|
|
|
/**
|
|
|
|
* Returns unique string values of an attribute which contain a specified subset string. Subset
|
|
|
|
* matching is done in a case-insensitive manner.
|
|
|
|
* @param index the index of the attribute
|
|
|
|
* @param substring substring to match (case insensitive)
|
|
|
|
* @param limit maxmum number of the values to return, or -1 to return all unique values
|
2017-01-16 22:27:14 +01:00
|
|
|
* @param feedback optional feedback object for canceling request
|
2017-01-12 22:01:50 +01:00
|
|
|
* @returns list of unique strings containing substring
|
2016-08-22 10:45:58 +10:00
|
|
|
*/
|
|
|
|
virtual QStringList uniqueStringsMatching( int index, const QString& substring, int limit = -1,
|
|
|
|
QgsFeedback* feedback = nullptr ) const;
|
|
|
|
|
2016-05-16 14:36:04 +10:00
|
|
|
/** Calculates an aggregated value from the layer's features. The base implementation does nothing,
|
|
|
|
* but subclasses can override this method to handoff calculation of aggregates to the provider.
|
|
|
|
* @param aggregate aggregate to calculate
|
|
|
|
* @param index the index of the attribute to calculate aggregate over
|
[FEATURE] Aggregates for expressions
This commit adds a number of different forms of aggregates to
the expression engine.
1. Aggregates within the current layer, eg sum("passengers")
Supports sub expressions (ie sum("passengers"/2) ), group by
( sum("passengers", group_by:="line_segment") ), and optional
filters ( sum("passengers", filter:= "station_class" > 3 ) )
2. Relational aggregates, which calculate an aggregate over
all matching child features from a relation, eg
relation_aggregate( 'my_relation', 'mean', "some_child_field" )
3. A summary aggregate function, for calculating aggregates
on other layers. Eg aggregate('rail_station_layer','sum',"passengers")
The summary aggregate function supports an optional filter,
making it possible to calculate things like:
aggregate('rail_stations','sum',"passengers",
intersects(@atlas_geometry, $geometry ) )
for calculating the total number of passengers for the stations
inside the current atlas feature
In all cases the calculations are cached inside the expression
context, so they only need to be calculated once for each
set of expression evaluations.
Sponsored by Kanton of Zug, Switzerland
2016-05-16 17:30:07 +10:00
|
|
|
* @param parameters parameters controlling aggregate calculation
|
2016-05-16 14:36:04 +10:00
|
|
|
* @param context expression context for filter
|
|
|
|
* @param ok will be set to true if calculation was successfully performed by the data provider
|
|
|
|
* @return calculated aggregate value
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
*/
|
|
|
|
virtual QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
|
|
|
|
int index,
|
[FEATURE] Aggregates for expressions
This commit adds a number of different forms of aggregates to
the expression engine.
1. Aggregates within the current layer, eg sum("passengers")
Supports sub expressions (ie sum("passengers"/2) ), group by
( sum("passengers", group_by:="line_segment") ), and optional
filters ( sum("passengers", filter:= "station_class" > 3 ) )
2. Relational aggregates, which calculate an aggregate over
all matching child features from a relation, eg
relation_aggregate( 'my_relation', 'mean', "some_child_field" )
3. A summary aggregate function, for calculating aggregates
on other layers. Eg aggregate('rail_station_layer','sum',"passengers")
The summary aggregate function supports an optional filter,
making it possible to calculate things like:
aggregate('rail_stations','sum',"passengers",
intersects(@atlas_geometry, $geometry ) )
for calculating the total number of passengers for the stations
inside the current atlas feature
In all cases the calculations are cached inside the expression
context, so they only need to be calculated once for each
set of expression evaluations.
Sponsored by Kanton of Zug, Switzerland
2016-05-16 17:30:07 +10:00
|
|
|
const QgsAggregateCalculator::AggregateParameters& parameters,
|
2016-05-16 14:36:04 +10:00
|
|
|
QgsExpressionContext* context,
|
2016-07-10 21:30:19 +10:00
|
|
|
bool& ok ) const;
|
2016-05-16 14:36:04 +10:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
/**
|
|
|
|
* Returns the possible enum values of an attribute. Returns an empty stringlist if a provider does not support enum types
|
|
|
|
* or if the given attribute is not an enum type.
|
2012-09-24 02:28:15 +02:00
|
|
|
* @param index the index of the attribute
|
|
|
|
* @param enumList reference to the list to fill
|
2014-01-26 18:35:21 +01:00
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
virtual void enumValues( int index, QStringList& enumList /Out/ ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a list of features
|
|
|
|
* @return true in case of success and false in case of failure
|
|
|
|
*/
|
2013-01-28 01:39:58 +01:00
|
|
|
virtual bool addFeatures( QList<QgsFeature> &flist /In,Out/ );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
2016-12-27 13:52:40 +10:00
|
|
|
* Deletes one or more features from the provider. This requires the DeleteFeatures capability.
|
2012-09-24 02:28:15 +02:00
|
|
|
* @param id list containing feature ids to delete
|
|
|
|
* @return true in case of success and false in case of failure
|
2016-12-27 13:52:40 +10:00
|
|
|
* @see truncate()
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
2016-12-27 13:52:40 +10:00
|
|
|
virtual bool deleteFeatures( const QgsFeatureIds &id );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all features from the layer. This requires either the FastTruncate or DeleteFeatures capability.
|
|
|
|
* Providers with the FastTruncate capability will use an optimised method to truncate the layer.
|
|
|
|
* @returns true in case of success and false in case of failure.
|
|
|
|
* @note added in QGIS 3.0
|
|
|
|
* @see deleteFeatures()
|
|
|
|
*/
|
|
|
|
virtual bool truncate();
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds new attributes
|
|
|
|
* @param attributes list of new attributes
|
|
|
|
* @return true in case of success and false in case of failure
|
|
|
|
*/
|
|
|
|
virtual bool addAttributes( const QList<QgsField> &attributes );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes existing attributes
|
|
|
|
* @param attributes a set containing indices of attributes
|
|
|
|
* @return true in case of success and false in case of failure
|
|
|
|
*/
|
|
|
|
virtual bool deleteAttributes( const QSet<int> &attributes );
|
|
|
|
|
2016-05-30 22:17:32 +10:00
|
|
|
/**
|
|
|
|
* Renames existing attributes.
|
|
|
|
* @param renamedAttributes map of attribute index to new attribute name
|
|
|
|
* @return true in case of success and false in case of failure
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
*/
|
|
|
|
virtual bool renameAttributes( const QgsFieldNameMap& renamedAttributes );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**
|
|
|
|
* Changes attribute values of existing features.
|
|
|
|
* @param attr_map a map containing changed attributes
|
|
|
|
* @return true in case of success and false in case of failure
|
|
|
|
*/
|
|
|
|
virtual bool changeAttributeValues( const QMap<qint64, QMap<int, QVariant> > &attr_map );
|
|
|
|
|
2016-01-15 10:10:58 +01:00
|
|
|
/**
|
|
|
|
* Changes attribute values and geometries of existing features.
|
|
|
|
* @param attr_map a map containing changed attributes
|
|
|
|
* @param geometry_map A QgsGeometryMap whose index contains the feature IDs
|
|
|
|
* that will have their geometries changed.
|
|
|
|
* The second map parameter being the new geometries themselves
|
|
|
|
* @return true in case of success and false in case of failure
|
|
|
|
*/
|
|
|
|
virtual bool changeFeatures( const QMap<qint64, QMap<int, QVariant> > &attr_map,
|
|
|
|
const QMap<qint64, QgsGeometry> &geometry_map );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**
|
2016-11-07 14:27:17 +10:00
|
|
|
* Returns any literal default values which are present at the provider for a specified
|
2016-11-14 10:07:52 +10:00
|
|
|
* field index. Important - this should ONLY be called when creating an attribute to insert
|
|
|
|
* directly into the database. Do not call this method for non-feature creation or modification,
|
2016-12-30 00:01:08 +01:00
|
|
|
* e.g., when validating an attribute or to compare it against an existing value, as calling it
|
|
|
|
* can cause changes to the underlying data source (e.g., Postgres provider where the default value
|
2016-11-14 10:07:52 +10:00
|
|
|
* is calculated as a result of a sequence). It is recommended that you instead use the methods
|
|
|
|
* in QgsVectorLayerUtils such as QgsVectorLayerUtils::createFeature()
|
|
|
|
* so that default value handling and validation is automatically carried out.
|
2016-11-07 14:27:17 +10:00
|
|
|
* @see defaultValueClause()
|
|
|
|
*/
|
|
|
|
virtual QVariant defaultValue( int fieldIndex ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns any default value clauses which are present at the provider for a specified
|
|
|
|
* field index. These clauses are usually SQL fragments which must be evaluated by the
|
2016-12-30 00:01:08 +01:00
|
|
|
* provider, e.g., sequence values.
|
2016-11-07 14:27:17 +10:00
|
|
|
* @see defaultValue()
|
|
|
|
* @note added in QGIS 3.0
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
2016-11-07 14:27:17 +10:00
|
|
|
virtual QString defaultValueClause( int fieldIndex ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-10-19 10:40:32 +10:00
|
|
|
/**
|
|
|
|
* Returns any constraints which are present at the provider for a specified
|
|
|
|
* field index.
|
|
|
|
* @note added in QGIS 3.0
|
2016-11-14 10:07:52 +10:00
|
|
|
* @see skipConstraintCheck()
|
2016-10-19 10:40:32 +10:00
|
|
|
*/
|
2016-11-01 18:41:22 +10:00
|
|
|
QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
|
2016-10-19 10:40:32 +10:00
|
|
|
|
2016-11-14 10:07:52 +10:00
|
|
|
/**
|
2016-12-30 00:01:08 +01:00
|
|
|
* Returns true if a constraint check should be skipped for a specified field (e.g., if
|
2016-11-14 10:07:52 +10:00
|
|
|
* the value returned by defaultValue() is trusted implicitly. An optional attribute value can be
|
|
|
|
* passed which can help refine the skip constraint check.
|
|
|
|
* @note added in QGIS 3.0
|
|
|
|
* @see fieldConstraints()
|
|
|
|
*/
|
|
|
|
virtual bool skipConstraintCheck( int fieldIndex, QgsFieldConstraints::Constraint constraint, const QVariant& value = QVariant() ) const;
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**
|
|
|
|
* Changes geometries of existing features
|
2013-01-28 01:39:58 +01:00
|
|
|
* @param geometry_map A QgsGeometryMap whose index contains the feature IDs
|
|
|
|
* that will have their geometries changed.
|
|
|
|
* The second map parameter being the new geometries themselves
|
|
|
|
* @return True in case of success and false in case of failure
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
2016-01-15 10:10:58 +01:00
|
|
|
virtual bool changeGeometryValues( const QMap<qint64, QgsGeometry> &geometry_map );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a spatial index on the datasource (if supported by the provider type).
|
|
|
|
* @return true in case of success
|
|
|
|
*/
|
|
|
|
virtual bool createSpatialIndex();
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Create an attribute index on the datasource*/
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual bool createAttributeIndex( int field );
|
|
|
|
|
|
|
|
/** Returns a bitmask containing the supported capabilities
|
2016-07-25 11:30:04 +10:00
|
|
|
@note, some capabilities may change depending on whether
|
2012-09-24 02:28:15 +02:00
|
|
|
a spatial filter is active on this provider, so it may
|
|
|
|
be prudent to check this value per intended operation.
|
|
|
|
*/
|
2016-07-25 11:30:04 +10:00
|
|
|
virtual Capabilities capabilities() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the above in friendly format.
|
|
|
|
*/
|
|
|
|
QString capabilitiesString() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set encoding used for accessing data from layer
|
|
|
|
*/
|
|
|
|
virtual void setEncoding( const QString& e );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get encoding which is used for accessing data
|
|
|
|
*/
|
|
|
|
QString encoding() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the index of a field name or -1 if the field does not exist
|
|
|
|
*/
|
|
|
|
int fieldNameIndex( const QString& fieldName ) const;
|
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
/**
|
|
|
|
* Return a map where the key is the name of the field and the value is its index
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
QMap<QString, int> fieldNameMap() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return list of indexes to fetch all attributes in nextFeature()
|
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
virtual QList<int> attributeIndexes() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2013-01-28 01:39:58 +01:00
|
|
|
/**
|
|
|
|
* Return list of indexes of fields that make up the primary key
|
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
virtual QList<int> pkAttributeIndexes() const;
|
2013-01-28 01:39:58 +01:00
|
|
|
|
2013-02-06 05:28:43 -07:00
|
|
|
/**
|
|
|
|
* Return list of indexes to names for QgsPalLabeling fix
|
|
|
|
*/
|
|
|
|
virtual QHash<int, QString> palAttributeIndexNames() const;
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**
|
|
|
|
* check if provider supports type of field
|
|
|
|
*/
|
|
|
|
bool supportedType( const QgsField &field ) const;
|
|
|
|
|
|
|
|
struct NativeType
|
|
|
|
{
|
2016-09-07 14:30:10 +02:00
|
|
|
NativeType( const QString& typeDesc, const QString& typeName, QVariant::Type type, int minLen = 0, int maxLen = 0, int minPrec = 0, int maxPrec = 0, QVariant::Type subType = QVariant::Invalid );
|
2013-01-23 23:46:56 +01:00
|
|
|
|
|
|
|
QString mTypeDesc;
|
|
|
|
QString mTypeName;
|
|
|
|
QVariant::Type mType;
|
|
|
|
int mMinLen;
|
|
|
|
int mMaxLen;
|
|
|
|
int mMinPrec;
|
|
|
|
int mMaxPrec;
|
2016-09-07 14:30:10 +02:00
|
|
|
QVariant::Type mSubType;
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
2012-01-16 08:57:07 +01:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**
|
|
|
|
* Returns the names of the supported types
|
|
|
|
*/
|
2017-01-14 13:46:26 +10:00
|
|
|
QList< QgsVectorDataProvider::NativeType > nativeTypes() const;
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/**
|
|
|
|
* Returns true if the provider is strict about the type of inserted features
|
|
|
|
* (e.g. no multipolygon in a polygon layer)
|
|
|
|
*/
|
2016-06-02 11:37:35 +02:00
|
|
|
virtual bool doesStrictFeatureTypeCheck() const;
|
2009-06-26 17:37:59 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/** Returns a list of available encodings */
|
2016-07-10 21:30:19 +10:00
|
|
|
static QStringList availableEncodings();
|
2009-06-26 17:37:59 +00:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
/**
|
|
|
|
* Provider has errors to report
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
bool hasErrors() const;
|
2009-06-26 17:37:59 +00:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
/**
|
|
|
|
* Clear recorded errors
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
|
|
|
void clearErrors();
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
/**
|
|
|
|
* Get recorded errors
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
QStringList errors() const;
|
2010-03-27 00:38:59 +00:00
|
|
|
|
2013-05-03 00:23:23 +02:00
|
|
|
/**
|
|
|
|
* It returns false by default.
|
|
|
|
* Must be implemented by providers that support saving and loading styles to db returning true
|
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
virtual bool isSaveAndLoadStyleToDBSupported() const;
|
2013-05-03 00:23:23 +02:00
|
|
|
|
2015-10-07 11:55:34 +11:00
|
|
|
static QVariant convertValue( QVariant::Type type, const QString& value );
|
2010-12-17 15:00:17 +00:00
|
|
|
|
2015-02-03 02:21:52 +01:00
|
|
|
/**
|
|
|
|
* Returns the transaction this data provider is included in, if any.
|
|
|
|
*/
|
2015-01-12 19:07:29 +01:00
|
|
|
virtual QgsTransaction* transaction() const;
|
|
|
|
|
2016-01-15 10:10:58 +01:00
|
|
|
/**
|
|
|
|
* Forces a reload of the underlying datasource if the provider implements this
|
|
|
|
* method.
|
|
|
|
* In particular on the OGR provider, a pooled connection will be invalidated.
|
|
|
|
* This forces QGIS to reopen a file or connection.
|
|
|
|
* This can be required if the underlying file is replaced.
|
|
|
|
*/
|
2015-08-29 20:50:58 +02:00
|
|
|
virtual void forceReload();
|
|
|
|
|
2016-01-04 14:58:11 +01:00
|
|
|
/**
|
|
|
|
* Get the list of layer ids on which this layer depends. This in particular determines the order of layer loading.
|
|
|
|
*/
|
2016-08-31 09:18:45 +02:00
|
|
|
virtual QSet<QgsMapLayerDependency> dependencies() const;
|
2016-01-04 14:58:11 +01:00
|
|
|
|
2016-09-26 13:51:37 +02:00
|
|
|
/**
|
|
|
|
* Discover the available relations with the given layers.
|
|
|
|
* @param self the layer using this data provider.
|
|
|
|
* @param layers the other layers.
|
|
|
|
* @return the list of N-1 relations from this provider.
|
|
|
|
* @note added in QGIS 3.0
|
|
|
|
*/
|
|
|
|
virtual QList<QgsRelation> discoverRelations( const QgsVectorLayer* self, const QList<QgsVectorLayer*>& layers ) const;
|
|
|
|
|
2016-11-04 12:56:44 +01:00
|
|
|
/**
|
|
|
|
* Get some metadata that will be display in the metadata tab of the layer properties.
|
|
|
|
* @return The provider metadata
|
|
|
|
*/
|
2016-11-08 23:16:11 +01:00
|
|
|
virtual QVariantMap metadata() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the translated metadata key.
|
|
|
|
* @param mdKey The metadata key
|
|
|
|
* @return The translated metadata value
|
|
|
|
*/
|
|
|
|
virtual QString translateMetadataKey( const QString& mdKey ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the translated metadata value.
|
|
|
|
* @param mdKey The metadata key
|
|
|
|
* @param value The metadata value
|
|
|
|
* @return The translated metadata value
|
|
|
|
*/
|
|
|
|
virtual QString translateMetadataValue( const QString& mdKey, const QVariant& value ) const;
|
2016-11-04 12:56:44 +01:00
|
|
|
|
2016-02-20 17:21:57 +01:00
|
|
|
signals:
|
2016-10-21 12:49:45 +02:00
|
|
|
/**
|
|
|
|
* Signals an error in this provider
|
|
|
|
*
|
|
|
|
* @note Added const in QGIS 3.0
|
|
|
|
*/
|
|
|
|
void raiseError( const QString& msg ) const;
|
2016-02-20 17:21:57 +01:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
protected:
|
2016-10-21 12:49:45 +02:00
|
|
|
/**
|
|
|
|
* Invalidates the min/max cache. This will force the provider to recalculate the
|
|
|
|
* cache the next time it is requested.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void clearMinMaxCache();
|
2016-07-10 21:30:19 +10:00
|
|
|
|
2016-10-21 12:49:45 +02:00
|
|
|
/**
|
|
|
|
* Populates the cache of minimum and maximum attribute values.
|
|
|
|
*/
|
2016-07-10 21:30:19 +10:00
|
|
|
void fillMinMaxCache() const;
|
2010-12-17 15:00:17 +00:00
|
|
|
|
2016-10-22 13:19:32 +10:00
|
|
|
/**
|
2016-10-21 12:49:45 +02:00
|
|
|
* Push a notification about errors that happened in this providers scope.
|
|
|
|
* Errors should be translated strings that require the users immediate
|
|
|
|
* attention.
|
|
|
|
*
|
|
|
|
* For general debug information use QgsMessageLog::logMessage() instead.
|
|
|
|
*
|
|
|
|
* @note Added in QGIS 3.0
|
2016-10-22 13:19:32 +10:00
|
|
|
*/
|
|
|
|
void pushError( const QString& msg ) const;
|
|
|
|
|
2016-10-21 12:49:45 +02:00
|
|
|
/**
|
|
|
|
* Converts the geometry to the provider type if possible / necessary
|
|
|
|
* @return the converted geometry or nullptr if no conversion was necessary or possible
|
|
|
|
*/
|
2016-08-01 16:25:46 +10:00
|
|
|
QgsGeometry* convertToProviderType( const QgsGeometry& geom ) const /Factory/;
|
2016-10-21 12:49:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the list of native types supported by this provider.
|
|
|
|
* Usually done in the constructor.
|
|
|
|
*
|
|
|
|
* @note Added in QGIS 3.0
|
|
|
|
*/
|
|
|
|
void setNativeTypes(const QList<QgsVectorDataProvider::NativeType>& nativeTypes);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get this providers encoding
|
|
|
|
*
|
|
|
|
* @note Added in QGIS 3.0
|
|
|
|
*/
|
|
|
|
QTextCodec* textEncoding() const;
|
|
|
|
|
2007-01-09 02:39:15 +00:00
|
|
|
};
|
2016-07-25 11:30:04 +10:00
|
|
|
|
|
|
|
QFlags<QgsVectorDataProvider::Capability> operator|(QgsVectorDataProvider::Capability f1, QFlags<QgsVectorDataProvider::Capability> f2);
|