2010-12-27 21:27:01 +00:00
|
|
|
|
|
|
|
typedef QList<int> QgsAttributeList;
|
|
|
|
typedef QSet<int> QgsAttributeIds;
|
|
|
|
|
2015-08-20 23:06:05 +10:00
|
|
|
|
2011-03-03 22:45:21 +00:00
|
|
|
struct QgsVectorJoinInfo
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsvectorlayer.h"
|
|
|
|
%End
|
2016-06-13 22:08:36 +10:00
|
|
|
QgsVectorJoinInfo();
|
2011-03-03 22:45:21 +00:00
|
|
|
|
2015-05-03 17:10:32 +02:00
|
|
|
/** Join field in the target layer*/
|
2012-12-17 21:22:42 +01:00
|
|
|
QString targetFieldName;
|
2015-05-03 17:10:32 +02:00
|
|
|
/** Source layer*/
|
2011-03-03 22:45:21 +00:00
|
|
|
QString joinLayerId;
|
2015-05-03 17:10:32 +02:00
|
|
|
/** Join field in the source layer*/
|
2012-12-17 21:22:42 +01:00
|
|
|
QString joinFieldName;
|
2015-05-03 17:10:32 +02:00
|
|
|
/** True if the join is cached in virtual memory*/
|
2011-03-03 22:45:21 +00:00
|
|
|
bool memoryCache;
|
2016-06-13 22:08:36 +10:00
|
|
|
/** True if the cached join attributes need to be updated*/
|
|
|
|
bool cacheDirty;
|
2015-05-03 17:10:32 +02:00
|
|
|
/** Cache for joined attributes to provide fast lookup (size is 0 if no memory caching)
|
2016-02-14 03:50:23 +01:00
|
|
|
* @note not available in python bindings
|
|
|
|
*/
|
2011-03-03 22:45:21 +00:00
|
|
|
// QHash< QString, QgsAttributeMap> cachedAttributes;
|
2014-09-13 13:36:45 +07:00
|
|
|
|
2015-01-22 15:52:02 +01:00
|
|
|
/** An optional prefix. If it is a Null string "{layername}_" will be used
|
|
|
|
* @note Added in 2.8
|
|
|
|
*/
|
|
|
|
QString prefix;
|
|
|
|
|
2015-11-08 19:18:00 +00:00
|
|
|
bool operator==( const QgsVectorJoinInfo& other ) const;
|
|
|
|
|
2014-09-13 13:36:45 +07:00
|
|
|
/** Set subset of fields to be used from joined layer. Takes ownership of the passed pointer. Null pointer tells to use all fields.
|
|
|
|
@note added in 2.6 */
|
|
|
|
void setJoinFieldNamesSubset( QStringList* fieldNamesSubset /Transfer/ );
|
|
|
|
/** Get subset of fields to be used from joined layer. All fields will be used if null is returned.
|
|
|
|
@note added in 2.6 */
|
|
|
|
QStringList* joinFieldNamesSubset() const;
|
2011-03-03 22:45:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-01-09 02:39:15 +00:00
|
|
|
class QgsVectorLayer : QgsMapLayer
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
handling vector data geometry and attribute updates refactored
QgsVectorLayer:
- move attribute part of editing to vector layer class and unify with geometry handling:
* remove commitAttributeChanges(), addedFeatures(), deletedFeatureIds(), changedAttributes()
and replace with changeAttributeValue(), deleteFeature(), addAttribute()
and deleteAttribute()
* add pendingFields(), pendingAttributeList(), pendingFeatureCount()
* emit signals on start editing and commit, change of attribute values, adding/deleting of
attributes and layer or feature removal (currently used in the attribute table)
- new commitErrors() method to query errors from commitChanges()
- replaced featuresInRectangle with select/getNextFeature combo
- edit types added to support more input widgets and input constraints
QgsFeature:
- remove update aware ctor
- unify geometry handling in ctors
QgsVectorDataProvider:
- add QVariant::Type to supportNativeTypes()
QgisApp:
- add instance() method to query QgisApp object
- replace code at various place to use it instead of passing the pointer
arround or searching it in the widget tree.
- move toggleEditing() code from the legend here
QgsAttributeTable/QgsAttributeTableDisplay:
- move attribute table creation legend here
- make attribute table dockable (from Tim)
- most editing logic moved to QgsVectorLayer
- adding/deleting attributes moved to QgsVectorLayerProperties
QgsIdentifyResults:
- add support for attribute editing when it edit mode
QgsVectorLayerProperties:
add a new tab to show attribute list:
* start/stop editing
* add/delete attributes
* assign edit type to attributes (unique values, value map, ranges)
QgsAttributeDialog:
add support for attribute edit types:
* selection from unique value render classes (combobox)
* selection from unique values of existing features (combobox or line edits with completion)
* spinboxes for ranges
QgsPostgresProvider:
- use read-only connection for cursors and read-write connection for updates
- updated native types
QgsOgrProvider:
- remove unused references to GEOS geometry factory
- updated native types
git-svn-id: http://svn.osgeo.org/qgis/trunk@9092 c8812cc2-4d05-0410-92ff-de0c093fc19c
2008-08-20 12:15:14 +00:00
|
|
|
#include "qgsvectorlayer.h"
|
2007-01-09 02:39:15 +00:00
|
|
|
%End
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
public:
|
2016-02-14 03:50:23 +01:00
|
|
|
struct GroupData
|
|
|
|
{
|
|
|
|
GroupData();
|
|
|
|
GroupData( const QString& name, const QList<QString>& fields );
|
|
|
|
QString mName;
|
|
|
|
QList<QString> mFields;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TabData
|
|
|
|
{
|
|
|
|
TabData();
|
|
|
|
TabData( const QString& name, const QList<QString>& fields, const QList<QgsVectorLayer::GroupData>& groups );
|
|
|
|
QString mName;
|
|
|
|
QList<QString> mFields;
|
|
|
|
QList<QgsVectorLayer::GroupData> mGroups;
|
|
|
|
};
|
|
|
|
|
2013-01-28 01:39:58 +01:00
|
|
|
enum EditorLayout
|
|
|
|
{
|
|
|
|
GeneratedLayout,
|
|
|
|
TabLayout,
|
2014-05-24 03:52:19 +02:00
|
|
|
UiFileLayout
|
2013-01-28 01:39:58 +01:00
|
|
|
};
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
struct RangeData
|
|
|
|
{
|
|
|
|
//! @deprecated Use the editorWidgetV2() system instead
|
|
|
|
RangeData() /Deprecated/;
|
|
|
|
//! @deprecated Use the editorWidgetV2() system instead
|
|
|
|
RangeData( const QVariant& theMin, const QVariant& theMax, const QVariant& theStep ) /Deprecated/;
|
|
|
|
|
|
|
|
QVariant mMin;
|
|
|
|
QVariant mMax;
|
|
|
|
QVariant mStep;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ValueRelationData
|
|
|
|
{
|
|
|
|
ValueRelationData();
|
|
|
|
ValueRelationData( const QString& layer, const QString& key, const QString& value, bool allowNull, bool orderByValue,
|
|
|
|
bool allowMulti = false,
|
|
|
|
const QString& filterExpression = QString::null );
|
|
|
|
|
|
|
|
QString mLayer;
|
|
|
|
QString mKey;
|
|
|
|
QString mValue;
|
|
|
|
QString mFilterExpression;
|
|
|
|
bool mAllowNull;
|
|
|
|
bool mOrderByValue;
|
|
|
|
bool mAllowMulti; /* allow selection of multiple keys */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Types of feature form suppression after feature creation
|
|
|
|
* @note added in 2.1
|
|
|
|
* @deprecated in 2.14, Use QgsEditFormConfig instead
|
|
|
|
*/
|
|
|
|
enum FeatureFormSuppress
|
|
|
|
{
|
|
|
|
SuppressDefault, // use the application-wide setting
|
|
|
|
SuppressOn,
|
|
|
|
SuppressOff,
|
|
|
|
};
|
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
|
|
|
* @deprecated Use the editorWidgetV2() system instead
|
|
|
|
*/
|
2012-08-28 22:32:17 +02:00
|
|
|
enum EditType
|
|
|
|
{
|
|
|
|
LineEdit,
|
|
|
|
UniqueValues,
|
|
|
|
UniqueValuesEditable,
|
|
|
|
ValueMap,
|
|
|
|
Classification,
|
|
|
|
EditRange,
|
|
|
|
SliderRange,
|
2014-11-21 01:17:21 +01:00
|
|
|
CheckBox,
|
2012-08-28 22:32:17 +02:00
|
|
|
FileName,
|
|
|
|
Enumeration,
|
2014-01-03 23:06:49 +01:00
|
|
|
Immutable, /**< The attribute value should not be changed in the attribute form */
|
2014-11-21 01:17:21 +01:00
|
|
|
Hidden, /**< The attribute value should not be shown in the attribute form */
|
|
|
|
TextEdit, /**< multiline edit */
|
|
|
|
Calendar, /**< calendar widget */
|
|
|
|
DialRange, /**< dial range */
|
|
|
|
ValueRelation, /**< value map from an table */
|
|
|
|
UuidGenerator, /**< uuid generator - readonly and automatically intialized */
|
|
|
|
Photo, /**< phote widget */
|
|
|
|
WebView, /**< webview widget */
|
|
|
|
Color, /**< color */
|
2014-01-03 23:06:49 +01:00
|
|
|
EditorWidgetV2, /**< modularized edit widgets @note added in 2.1 */
|
2012-08-28 22:32:17 +02:00
|
|
|
};
|
2016-01-28 20:50:18 +11:00
|
|
|
|
2016-01-27 20:11:26 +11:00
|
|
|
//! Result of an edit operation
|
|
|
|
enum EditResult
|
|
|
|
{
|
|
|
|
Success, /**< Edit operation was successful */
|
|
|
|
EmptyGeometry, /**< Edit operation resulted in an empty geometry */
|
|
|
|
EditFailed, /**< Edit operation failed */
|
|
|
|
FetchFeatureFailed, /**< Unable to fetch requested feature */
|
|
|
|
InvalidLayer, /**< Edit failed due to invalid layer */
|
|
|
|
};
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-05-19 06:36:20 +10:00
|
|
|
//! Selection behaviour
|
|
|
|
enum SelectBehaviour
|
|
|
|
{
|
|
|
|
SetSelection, /**< Set selection, removing any existing selection */
|
|
|
|
AddToSelection, /**< Add selection to current selection */
|
|
|
|
IntersectSelection, /**< Modify current selection to include only select features which match */
|
|
|
|
RemoveFromSelection, /**< Remove from current selection */
|
|
|
|
};
|
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/** Constructor - creates a vector layer
|
|
|
|
*
|
|
|
|
* The QgsVectorLayer is constructed by instantiating a data provider. The provider
|
|
|
|
* interprets the supplied path (url) of the data source to connect to and access the
|
|
|
|
* data.
|
|
|
|
*
|
|
|
|
* @param path The path or url of the parameter. Typically this encodes
|
|
|
|
* parameters used by the data provider as url query items.
|
|
|
|
* @param baseName The name used to represent the layer in the legend
|
|
|
|
* @param providerLib The name of the data provider, eg "memory", "postgres"
|
|
|
|
* @param loadDefaultStyleFlag whether to load the default style
|
|
|
|
*
|
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
QgsVectorLayer( const QString& path = QString::null, const QString& baseName = QString::null,
|
|
|
|
const QString& providerLib = QString::null, bool loadDefaultStyleFlag = true );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Destructor */
|
|
|
|
virtual ~QgsVectorLayer();
|
|
|
|
|
|
|
|
/** Returns the permanent storage type for this layer as a friendly name. */
|
|
|
|
QString storageType() const;
|
handling vector data geometry and attribute updates refactored
QgsVectorLayer:
- move attribute part of editing to vector layer class and unify with geometry handling:
* remove commitAttributeChanges(), addedFeatures(), deletedFeatureIds(), changedAttributes()
and replace with changeAttributeValue(), deleteFeature(), addAttribute()
and deleteAttribute()
* add pendingFields(), pendingAttributeList(), pendingFeatureCount()
* emit signals on start editing and commit, change of attribute values, adding/deleting of
attributes and layer or feature removal (currently used in the attribute table)
- new commitErrors() method to query errors from commitChanges()
- replaced featuresInRectangle with select/getNextFeature combo
- edit types added to support more input widgets and input constraints
QgsFeature:
- remove update aware ctor
- unify geometry handling in ctors
QgsVectorDataProvider:
- add QVariant::Type to supportNativeTypes()
QgisApp:
- add instance() method to query QgisApp object
- replace code at various place to use it instead of passing the pointer
arround or searching it in the widget tree.
- move toggleEditing() code from the legend here
QgsAttributeTable/QgsAttributeTableDisplay:
- move attribute table creation legend here
- make attribute table dockable (from Tim)
- most editing logic moved to QgsVectorLayer
- adding/deleting attributes moved to QgsVectorLayerProperties
QgsIdentifyResults:
- add support for attribute editing when it edit mode
QgsVectorLayerProperties:
add a new tab to show attribute list:
* start/stop editing
* add/delete attributes
* assign edit type to attributes (unique values, value map, ranges)
QgsAttributeDialog:
add support for attribute edit types:
* selection from unique value render classes (combobox)
* selection from unique values of existing features (combobox or line edits with completion)
* spinboxes for ranges
QgsPostgresProvider:
- use read-only connection for cursors and read-write connection for updates
- updated native types
QgsOgrProvider:
- remove unused references to GEOS geometry factory
- updated native types
git-svn-id: http://svn.osgeo.org/qgis/trunk@9092 c8812cc2-4d05-0410-92ff-de0c093fc19c
2008-08-20 12:15:14 +00:00
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/** Capabilities for this layer in a friendly format. */
|
|
|
|
QString capabilitiesString() const;
|
|
|
|
|
|
|
|
/** Returns a comment for the data in the layer */
|
|
|
|
QString dataComment() const;
|
|
|
|
|
|
|
|
/** Set the primary display field to be used in the identify results dialog */
|
2015-10-07 11:55:34 +11:00
|
|
|
void setDisplayField( const QString& fldName = "" );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Returns the primary display field name used in the identify results dialog */
|
|
|
|
const QString displayField() const;
|
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/** Set the preview expression, used to create a human readable preview string.
|
|
|
|
* Used e.g. in the attribute table feature list. Uses { @link QgsExpression }.
|
|
|
|
*
|
|
|
|
* @param displayExpression The expression which will be used to preview features
|
|
|
|
* for this layer
|
|
|
|
*/
|
2014-01-26 18:35:21 +01:00
|
|
|
void setDisplayExpression( const QString &displayExpression );
|
2013-05-29 21:38:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the preview expression, used to create a human readable preview string.
|
|
|
|
* Uses { @link QgsExpression }
|
|
|
|
*
|
|
|
|
* @return The expression which will be used to preview features for this layer
|
|
|
|
*/
|
|
|
|
const QString displayExpression();
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/** Returns the data provider */
|
|
|
|
QgsVectorDataProvider* dataProvider();
|
|
|
|
|
|
|
|
/** Returns the data provider in a const-correct manner
|
2016-02-14 03:50:23 +01:00
|
|
|
* @note not available in python bindings
|
|
|
|
*/
|
2014-01-26 18:35:21 +01:00
|
|
|
// const QgsVectorDataProvider* dataProvider() const;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Sets the textencoding of the data provider */
|
|
|
|
void setProviderEncoding( const QString& encoding );
|
|
|
|
|
2014-10-28 12:22:42 +01:00
|
|
|
/** Setup the coordinate system transformation for the layer */
|
2012-08-28 22:32:17 +02:00
|
|
|
void setCoordinateSystem();
|
|
|
|
|
|
|
|
/** Joins another vector layer to this layer
|
|
|
|
@param joinInfo join object containing join layer id, target and source field
|
2014-09-16 11:54:31 +07:00
|
|
|
@note since 2.6 returns bool indicating whether the join can be added */
|
|
|
|
bool addJoin( const QgsVectorJoinInfo& joinInfo );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-01-30 10:45:12 -05:00
|
|
|
/** Removes a vector layer join
|
|
|
|
@returns true if join was found and successfully removed */
|
|
|
|
bool removeJoin( const QString& joinLayerId );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-11-08 19:18:00 +00:00
|
|
|
const QList<QgsVectorJoinInfo> vectorJoins() const;
|
2009-06-26 17:04:31 +00:00
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
virtual QSet<QString> layerDependencies() const;
|
|
|
|
|
2014-05-26 10:29:53 +02:00
|
|
|
/**
|
|
|
|
* Add a new field which is calculated by the expression specified
|
|
|
|
*
|
|
|
|
* @param exp The expression which calculates the field
|
2014-11-21 01:17:21 +01:00
|
|
|
* @param fld The field to calculate
|
2014-05-26 10:29:53 +02:00
|
|
|
*
|
2015-03-24 11:37:56 +01:00
|
|
|
* @return The index of the new field
|
|
|
|
*
|
|
|
|
* @note added in 2.6, return value added in 2.9
|
2014-05-26 10:29:53 +02:00
|
|
|
*/
|
2015-03-24 11:37:56 +01:00
|
|
|
int addExpressionField( const QString& exp, const QgsField& fld );
|
2014-05-26 10:29:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an expression field
|
|
|
|
*
|
2014-11-21 01:17:21 +01:00
|
|
|
* @param index The index of the field
|
2014-05-26 10:29:53 +02:00
|
|
|
*
|
|
|
|
* @note added in 2.6
|
|
|
|
*/
|
|
|
|
void removeExpressionField( int index );
|
|
|
|
|
2015-03-24 11:37:56 +01:00
|
|
|
/**
|
|
|
|
* Returns the expressoin used for a given expression field
|
|
|
|
*
|
|
|
|
* @param index An index of an epxression based (virtual) field
|
|
|
|
*
|
|
|
|
* @return The expression for the field at index
|
|
|
|
*
|
|
|
|
* @note added in 2.9
|
|
|
|
*/
|
|
|
|
const QString expressionField( int index );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes the expression used to define an expression based (virtual) field
|
|
|
|
*
|
|
|
|
* @param index The index of the expression to change
|
|
|
|
*
|
|
|
|
* @param exp The new expression to set
|
|
|
|
*
|
|
|
|
* @note added in 2.9
|
|
|
|
*/
|
|
|
|
void updateExpressionField( int index, const QString& exp );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/** Get the label rendering properties associated with this layer */
|
2012-08-28 22:32:17 +02:00
|
|
|
QgsLabel *label();
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/** Get the label rendering properties associated with this layer
|
|
|
|
* @note not available in python bindings
|
|
|
|
*/
|
2012-08-29 00:45:18 +02:00
|
|
|
// const QgsLabel *label() const;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-04-18 17:32:58 +02:00
|
|
|
QgsActionManager *actions();
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/**
|
|
|
|
* The number of features that are selected in this layer
|
|
|
|
*
|
|
|
|
* @return See description
|
|
|
|
*/
|
2012-08-28 22:32:17 +02:00
|
|
|
int selectedFeatureCount();
|
|
|
|
|
2013-04-09 11:52:43 +02:00
|
|
|
/**
|
|
|
|
* Select features found within the search rectangle (in layer's coordinates)
|
|
|
|
*
|
|
|
|
* @param rect The search rectangle
|
|
|
|
* @param addToSelection If set to true will not clear before selecting
|
2013-05-29 21:38:33 +02:00
|
|
|
*
|
|
|
|
* @see invertSelectionInRectangle(QgsRectangle & rect)
|
2016-05-19 06:36:20 +10:00
|
|
|
* @see selectByExpression()
|
2016-05-19 12:30:32 +10:00
|
|
|
* @deprecated use selectByRect() instead
|
2013-04-09 11:52:43 +02:00
|
|
|
*/
|
2016-05-19 12:30:32 +10:00
|
|
|
void select( QgsRectangle & rect, bool addToSelection ) /Deprecated/;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select features found within the search rectangle (in layer's coordinates)
|
|
|
|
* @param rect search rectangle
|
|
|
|
* @param behaviour selection type, allows adding to current selection, removing
|
|
|
|
* from selection, etc.
|
|
|
|
* @see invertSelectionInRectangle(QgsRectangle & rect)
|
|
|
|
* @see selectByExpression()
|
|
|
|
* @see selectByIds()
|
|
|
|
*/
|
|
|
|
void selectByRect( QgsRectangle & rect, SelectBehaviour behaviour = SetSelection );
|
2013-04-09 11:52:43 +02:00
|
|
|
|
2016-05-19 06:36:20 +10:00
|
|
|
/** Select matching features using an expression.
|
|
|
|
* @param expression expression to evaluate to select features
|
|
|
|
* @param behaviour selection type, allows adding to current selection, removing
|
|
|
|
* from selection, etc.
|
|
|
|
* @note added in QGIS 2.16
|
2016-05-19 12:30:32 +10:00
|
|
|
* @see selectByRect()
|
|
|
|
* @see selectByIds()
|
2016-05-19 06:36:20 +10:00
|
|
|
*/
|
|
|
|
void selectByExpression( const QString& expression, SelectBehaviour behaviour = SetSelection );
|
|
|
|
|
2016-05-19 12:30:32 +10:00
|
|
|
/** Select matching features using a list of feature IDs. Will emit the
|
|
|
|
* selectionChanged() signal with the clearAndSelect flag set.
|
|
|
|
* @param ids feature IDs to select
|
|
|
|
* @param behaviour selection type, allows adding to current selection, removing
|
|
|
|
* from selection, etc.
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
* @see selectByRect()
|
|
|
|
* @see selectByExpression()
|
|
|
|
*/
|
|
|
|
void selectByIds( const QgsFeatureIds &ids, SelectBehaviour behaviour = SetSelection );
|
|
|
|
|
2013-04-09 11:52:43 +02:00
|
|
|
/**
|
|
|
|
* Modifies the current selection on this layer
|
|
|
|
*
|
|
|
|
* @param selectIds Select these ids
|
|
|
|
* @param deselectIds Deselect these ids
|
2013-05-29 21:38:33 +02:00
|
|
|
*
|
|
|
|
* @see select(QgsFeatureIds)
|
|
|
|
* @see select(QgsFeatureId)
|
|
|
|
* @see deselect(QgsFeatureIds)
|
|
|
|
* @see deselect(QgsFeatureId)
|
2016-05-19 06:36:20 +10:00
|
|
|
* @see selectByExpression()
|
2013-04-09 11:52:43 +02:00
|
|
|
*/
|
2013-05-29 21:38:33 +02:00
|
|
|
void modifySelection( QgsFeatureIds selectIds, QgsFeatureIds deselectIds );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Select not selected features and deselect selected ones */
|
|
|
|
void invertSelection();
|
2013-05-29 21:38:33 +02:00
|
|
|
|
2013-05-22 11:34:25 +02:00
|
|
|
/** Select all the features */
|
|
|
|
void selectAll();
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2013-09-09 15:58:27 +02:00
|
|
|
/** Get all feature Ids */
|
2013-09-15 15:43:55 +02:00
|
|
|
QgsFeatureIds allFeatureIds();
|
2013-09-09 15:58:27 +02:00
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/**
|
|
|
|
* Invert selection of features found within the search rectangle (in layer's coordinates)
|
|
|
|
*
|
|
|
|
* @param rect The rectangle in which the selection of features will be inverted
|
|
|
|
*
|
|
|
|
* @see invertSelection()
|
|
|
|
*/
|
2012-08-28 22:32:17 +02:00
|
|
|
void invertSelectionInRectangle( QgsRectangle & rect );
|
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/**
|
|
|
|
* Get a copy of the user-selected features
|
|
|
|
*
|
|
|
|
* @return A list of { @link QgsFeature } 's
|
|
|
|
*
|
|
|
|
* @see selectedFeaturesIds()
|
2014-11-21 01:17:21 +01:00
|
|
|
* @see selectedFeaturesIterator() which is more memory friendly when handling large selections
|
2013-05-29 21:38:33 +02:00
|
|
|
*/
|
|
|
|
QgsFeatureList selectedFeatures();
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2014-09-22 18:34:37 +02:00
|
|
|
/**
|
|
|
|
* Get an iterator of the selected features
|
|
|
|
*
|
|
|
|
* @param request You may specify a request, e.g. to limit the set of requested attributes.
|
|
|
|
* Any filter on the request will be discarded.
|
|
|
|
*
|
|
|
|
* @return Iterator over the selected features
|
|
|
|
*
|
|
|
|
* @see selectedFeaturesIds()
|
2014-11-21 01:17:21 +01:00
|
|
|
* @see selectedFeatures()
|
2014-09-22 18:34:37 +02:00
|
|
|
*/
|
|
|
|
QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() );
|
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/**
|
|
|
|
* Return reference to identifiers of selected features
|
|
|
|
*
|
2016-02-14 03:50:23 +01:00
|
|
|
* @return A list of { @link QgsFeatureId } 's
|
2013-05-29 21:38:33 +02:00
|
|
|
* @see selectedFeatures()
|
|
|
|
*/
|
2012-10-21 13:21:35 +02:00
|
|
|
const QgsFeatureIds &selectedFeaturesIds() const;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/**
|
|
|
|
* Change selection to the new set of features. Dismisses the current selection.
|
2016-02-14 03:50:23 +01:00
|
|
|
* Will emit the { @link selectionChanged( const QgsFeatureIds&, const QgsFeatureIds&qt_check_for_QOBJECT_macro, bool ) } signal with the
|
2013-05-29 21:38:33 +02:00
|
|
|
* clearAndSelect flag set.
|
|
|
|
*
|
|
|
|
* @param ids The ids which will be the new selection
|
2016-05-19 12:30:32 +10:00
|
|
|
* @deprecated use selectByIds() instead
|
2013-05-29 21:38:33 +02:00
|
|
|
*/
|
2016-05-19 12:30:32 +10:00
|
|
|
void setSelectedFeatures( const QgsFeatureIds &ids ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned */
|
|
|
|
QgsRectangle boundingBoxOfSelected();
|
|
|
|
|
2015-04-13 20:45:32 +10:00
|
|
|
/** Returns whether the layer contains labels which are enabled and should be drawn.
|
|
|
|
* @return true if layer contains enabled labels
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
*/
|
|
|
|
bool labelsEnabled() const;
|
|
|
|
|
2015-04-09 17:50:18 +10:00
|
|
|
/** Returns whether the layer contains diagrams which are enabled and should be drawn.
|
|
|
|
* @return true if layer contains enabled diagrams
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
*/
|
|
|
|
bool diagramsEnabled() const;
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/** Sets diagram rendering object (takes ownership) */
|
2012-09-26 17:56:27 +02:00
|
|
|
void setDiagramRenderer( QgsDiagramRendererV2* r /Transfer/ );
|
2012-09-24 02:28:15 +02:00
|
|
|
const QgsDiagramRendererV2* diagramRenderer() const;
|
|
|
|
|
|
|
|
void setDiagramLayerSettings( const QgsDiagramLayerSettings& s );
|
|
|
|
const QgsDiagramLayerSettings *diagramLayerSettings() const;
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Return renderer V2. */
|
2012-08-28 22:32:17 +02:00
|
|
|
QgsFeatureRendererV2* rendererV2();
|
2016-02-14 03:50:23 +01:00
|
|
|
|
|
|
|
/** Return const renderer V2.
|
|
|
|
* @note not available in python bindings
|
|
|
|
*/
|
|
|
|
// const QgsFeatureRendererV2* rendererV2() const { return mRendererV2; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set renderer which will be invoked to represent this layer.
|
|
|
|
* Ownership is transferred.
|
|
|
|
*/
|
2012-08-28 22:32:17 +02:00
|
|
|
void setRendererV2( QgsFeatureRendererV2* r /Transfer/ );
|
|
|
|
|
|
|
|
/** Returns point, line or polygon */
|
|
|
|
QGis::GeometryType geometryType() const;
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeometry */
|
2012-08-28 22:32:17 +02:00
|
|
|
bool hasGeometryType() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns the WKBType or WKBUnknown in case of error*/
|
2012-08-28 22:32:17 +02:00
|
|
|
QGis::WkbType wkbType() const;
|
|
|
|
|
|
|
|
/** Return the provider type for this layer */
|
|
|
|
QString providerType() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Reads vector layer specific state from project file Dom node.
|
2016-02-14 03:50:23 +01:00
|
|
|
* @note Called by QgsMapLayer::readXML().
|
2012-08-28 22:32:17 +02:00
|
|
|
*/
|
|
|
|
virtual bool readXml( const QDomNode& layer_node );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Write vector layer specific state to project file Dom node.
|
2016-02-14 03:50:23 +01:00
|
|
|
* @note Called by QgsMapLayer::writeXML().
|
2012-08-28 22:32:17 +02:00
|
|
|
*/
|
|
|
|
virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc );
|
|
|
|
|
2013-05-03 00:23:23 +02:00
|
|
|
/**
|
|
|
|
* Save named and sld style of the layer to the style table in the db.
|
|
|
|
* @param name
|
|
|
|
* @param description
|
|
|
|
* @param useAsDefault
|
|
|
|
* @param uiFileContent
|
|
|
|
* @param msgError
|
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
virtual void saveStyleToDatabase( const QString& name, const QString& description,
|
|
|
|
bool useAsDefault, const QString& uiFileContent,
|
2013-05-03 00:23:23 +02:00
|
|
|
QString &msgError );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lists all the style in db split into related to the layer and not related to
|
2013-05-29 21:38:33 +02:00
|
|
|
* @param ids the list in which will be stored the style db ids
|
|
|
|
* @param names the list in which will be stored the style names
|
|
|
|
* @param descriptions the list in which will be stored the style descriptions
|
2013-05-03 00:23:23 +02:00
|
|
|
* @param msgError
|
|
|
|
* @return the number of styles related to current layer
|
|
|
|
*/
|
2016-01-20 14:36:20 +02:00
|
|
|
virtual int listStylesInDatabase( QStringList &ids /Out/, QStringList &names /Out/,
|
|
|
|
QStringList &descriptions /Out/, QString &msgError /Out/ );
|
2013-05-03 00:23:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Will return the named style corresponding to style id provided
|
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError );
|
2013-05-03 00:23:23 +02:00
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/**
|
|
|
|
* Load a named style from file/local db/datasource db
|
|
|
|
* @param theURI the URI of the style or the URI of the layer
|
|
|
|
* @param theResultFlag will be set to true if a named style is correctly loaded
|
|
|
|
* @param loadFromLocalDb if true forces to load from local db instead of datasource one
|
|
|
|
*/
|
2014-01-03 23:06:49 +01:00
|
|
|
virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDb );
|
2013-05-29 21:38:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls loadNamedStyle( theURI, theResultFlag, false );
|
|
|
|
* Retained for backward compatibility
|
|
|
|
*/
|
2014-01-03 23:06:49 +01:00
|
|
|
virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag );
|
2013-05-29 21:38:33 +02:00
|
|
|
|
2015-01-21 12:39:37 +01:00
|
|
|
/**
|
|
|
|
* Will load a named style from a provided QML string.
|
|
|
|
*
|
|
|
|
* @param namedStyle A QML string
|
|
|
|
* @param errorMsg An error message indicating problems if any
|
|
|
|
*
|
|
|
|
* @return true on success
|
|
|
|
*
|
|
|
|
* @deprecated Will be removed for QGIS 3 in favor of importNamedStyle
|
|
|
|
*/
|
2015-12-07 21:54:40 +11:00
|
|
|
virtual bool applyNamedStyle( const QString& namedStyle, QString &errorMsg /Out/ ) /Deprecated/;
|
2013-05-03 00:23:23 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Convert a saved attribute editor element into a AttributeEditor structure as it's used internally.
|
2013-01-28 01:39:58 +01:00
|
|
|
* @param elem the DOM element
|
|
|
|
* @param parent the QObject which will own this object
|
|
|
|
*/
|
|
|
|
QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent );
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/** Read the symbology for the current layer from the Dom node supplied.
|
|
|
|
* @param node node that will contain the symbology definition for this layer.
|
|
|
|
* @param errorMessage reference to string that will be updated with any error messages
|
|
|
|
* @return true in case of success.
|
|
|
|
*/
|
|
|
|
bool readSymbology( const QDomNode& node, QString& errorMessage );
|
|
|
|
|
2016-05-10 10:32:30 +10:00
|
|
|
/** Read the style for the current layer from the Dom node supplied.
|
|
|
|
* @param node node that will contain the style definition for this layer.
|
|
|
|
* @param errorMessage reference to string that will be updated with any error messages
|
|
|
|
* @return true in case of success.
|
|
|
|
*/
|
|
|
|
bool readStyle( const QDomNode& node, QString& errorMessage );
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/** Write the symbology for the layer into the docment provided.
|
|
|
|
* @param node the node that will have the style element added to it.
|
|
|
|
* @param doc the document that will have the QDomNode added.
|
|
|
|
* @param errorMessage reference to string that will be updated with any error messages
|
|
|
|
* @return true in case of success.
|
|
|
|
*/
|
|
|
|
bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
|
|
|
|
|
2016-05-10 10:32:30 +10:00
|
|
|
/** Write just the style information for the layer into the document
|
|
|
|
* @param node the node that will have the style element added to it.
|
|
|
|
* @param doc the document that will have the QDomNode added.
|
|
|
|
* @param errorMessage reference to string that will be updated with any error messages
|
|
|
|
* @return true in case of success.
|
|
|
|
*/
|
|
|
|
bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
|
|
|
|
bool readSld( const QDomNode& node, QString& errorMessage );
|
|
|
|
|
2015-11-08 19:18:00 +00:00
|
|
|
/**
|
|
|
|
* Number of features rendered with specified symbol. Features must be first
|
|
|
|
* calculated by countSymbolFeatures()
|
|
|
|
* @param symbol the symbol
|
|
|
|
* @return number of features rendered by symbol or -1 if failed or counts are not available
|
|
|
|
*/
|
|
|
|
long featureCount( QgsSymbolV2* symbol );
|
|
|
|
|
2015-06-22 19:25:07 +10:00
|
|
|
/**
|
|
|
|
* Update the data source of the layer. The layer's renderer and legend will be preserved only
|
|
|
|
* if the geometry type of the new data source matches the current geometry type of the layer.
|
|
|
|
* @param dataSource new layer data source
|
|
|
|
* @param baseName base name of the layer
|
|
|
|
* @param provider provider string
|
|
|
|
* @param loadDefaultStyleFlag set to true to reset the layer's style to the default for the
|
|
|
|
* data source
|
|
|
|
* @note added in QGIS 2.10
|
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
void setDataSource( const QString& dataSource, const QString& baseName, const QString& provider, bool loadDefaultStyleFlag = false );
|
2015-05-17 19:54:20 +10:00
|
|
|
|
2013-01-28 01:39:58 +01:00
|
|
|
/**
|
|
|
|
* Count features for symbols. Feature counts may be get by featureCount( QgsSymbolV2*).
|
|
|
|
* @param showProgress show progress dialog
|
|
|
|
* @return true if calculated, false if failed or was canceled by user
|
|
|
|
*/
|
|
|
|
bool countSymbolFeatures( bool showProgress = true );
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/**
|
|
|
|
* Set the string (typically sql) used to define a subset of the layer
|
|
|
|
* @param subset The subset string. This may be the where clause of a sql statement
|
|
|
|
* or other defintion string specific to the underlying dataprovider
|
|
|
|
* and data store.
|
2014-11-21 01:17:21 +01:00
|
|
|
* @return true, when setting the subset string was successful, false otherwise
|
2012-08-28 22:32:17 +02:00
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
virtual bool setSubsetString( const QString& subset );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the string (typically sql) used to define a subset of the layer
|
|
|
|
* @return The subset string or QString::null if not implemented by the provider
|
|
|
|
*/
|
|
|
|
virtual QString subsetString();
|
|
|
|
|
2012-12-17 21:22:42 +01:00
|
|
|
/**
|
|
|
|
* Query the provider for features specified in request.
|
|
|
|
*/
|
|
|
|
QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/** Adds a feature
|
|
|
|
@param f feature to add
|
|
|
|
@param alsoUpdateExtent If True, will also go to the effort of e.g. updating the extents.
|
|
|
|
@return True in case of success and False in case of error
|
|
|
|
*/
|
|
|
|
bool addFeature( QgsFeature& f, bool alsoUpdateExtent = true );
|
|
|
|
|
2014-01-03 23:06:49 +01:00
|
|
|
/** Updates an existing feature. This method needs to query the datasource
|
|
|
|
on every call. Consider using {@link changeAttributeValue()} or
|
|
|
|
{@link changeGeometry()} instead.
|
|
|
|
@param f Feature to update
|
|
|
|
@return True in case of success and False in case of error
|
2012-08-28 22:32:17 +02:00
|
|
|
*/
|
|
|
|
bool updateFeature( QgsFeature &f );
|
|
|
|
|
|
|
|
/** Insert a new vertex before the given vertex number,
|
|
|
|
* in the given ring, item (first number is index 0), and feature
|
|
|
|
* Not meaningful for Point geometries
|
|
|
|
*/
|
2012-10-21 13:21:35 +02:00
|
|
|
bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Moves the vertex at the given position number,
|
|
|
|
* ring and item (first number is index 0), and feature
|
|
|
|
* to the given coordinates
|
|
|
|
*/
|
2012-10-21 13:21:35 +02:00
|
|
|
bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-11-08 19:18:00 +00:00
|
|
|
/** Moves the vertex at the given position number,
|
2016-02-14 03:50:23 +01:00
|
|
|
* ring and item (first number is index 0), and feature
|
|
|
|
* to the given coordinates
|
|
|
|
* @note available in python as moveVertexV2
|
2015-11-08 19:18:00 +00:00
|
|
|
*/
|
|
|
|
bool moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex ) /PyName=moveVertexV2/;
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/** Deletes a vertex from a feature
|
2016-01-27 20:11:26 +11:00
|
|
|
* @deprecated use deleteVertexV2() instead
|
|
|
|
*/
|
|
|
|
bool deleteVertex( QgsFeatureId atFeatureId, int atVertex ) /Deprecated/;
|
|
|
|
|
|
|
|
/** Deletes a vertex from a feature.
|
|
|
|
* @param featureId ID of feature to remove vertex from
|
|
|
|
* @param vertex index of vertex to delete
|
|
|
|
* @note added in QGIS 2.14
|
2012-08-28 22:32:17 +02:00
|
|
|
*/
|
2016-01-27 20:11:26 +11:00
|
|
|
//TODO QGIS 3.0 - rename back to deleteVertex
|
|
|
|
EditResult deleteVertexV2( QgsFeatureId featureId, int vertex );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Deletes the selected features
|
|
|
|
* @return true in case of success and false otherwise
|
|
|
|
*/
|
2015-02-03 02:21:52 +01:00
|
|
|
bool deleteSelectedFeatures( int *deletedCount = 0 );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Adds a ring to polygon/multipolygon features
|
2015-10-08 22:40:58 +11:00
|
|
|
* @param ring ring to add
|
|
|
|
* @param featureId if specified, feature ID for feature ring was added to will be stored in this parameter
|
2016-02-14 03:50:23 +01:00
|
|
|
* @return
|
|
|
|
* 0 in case of success,
|
|
|
|
* 1 problem with feature type,
|
|
|
|
* 2 ring not closed,
|
|
|
|
* 3 ring not valid,
|
|
|
|
* 4 ring crosses existing rings,
|
|
|
|
* 5 no feature found where ring can be inserted
|
|
|
|
* 6 layer not editable
|
|
|
|
*/
|
2015-10-08 22:40:58 +11:00
|
|
|
int addRing( const QList<QgsPoint>& ring, QgsFeatureId* featureId = 0 );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-11-08 19:18:00 +00:00
|
|
|
/** Adds a ring to polygon/multipolygon features (takes ownership)
|
|
|
|
* @param ring ring to add
|
|
|
|
* @param featureId if specified, feature ID for feature ring was added to will be stored in this parameter
|
2016-02-14 03:50:23 +01:00
|
|
|
* @return
|
|
|
|
* 0 in case of success
|
|
|
|
* 1 problem with feature type
|
|
|
|
* 2 ring not closed
|
|
|
|
* 6 layer not editable
|
|
|
|
* @note available in python as addCurvedRing
|
2015-11-08 19:18:00 +00:00
|
|
|
*/
|
|
|
|
int addRing( QgsCurveV2* ring /Transfer/, QgsFeatureId* featureId = 0 ) /PyName=addCurvedRing/;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Adds a new part polygon to a multipart feature
|
2016-02-14 03:50:23 +01:00
|
|
|
* @return
|
|
|
|
* 0 in case of success,
|
|
|
|
* 1 if selected feature is not multipart,
|
|
|
|
* 2 if ring is not a valid geometry,
|
|
|
|
* 3 if new polygon ring not disjoint with existing rings,
|
|
|
|
* 4 if no feature was selected,
|
|
|
|
* 5 if several features are selected,
|
|
|
|
* 6 if selected geometry not found
|
|
|
|
* 7 layer not editable
|
2015-11-08 19:18:00 +00:00
|
|
|
*/
|
2012-08-28 22:32:17 +02:00
|
|
|
int addPart( const QList<QgsPoint>& ring );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/** Adds a new part polygon to a multipart feature
|
|
|
|
* @return
|
|
|
|
* 0 in case of success,
|
|
|
|
* 1 if selected feature is not multipart,
|
|
|
|
* 2 if ring is not a valid geometry,
|
|
|
|
* 3 if new polygon ring not disjoint with existing rings,
|
|
|
|
* 4 if no feature was selected,
|
|
|
|
* 5 if several features are selected,
|
|
|
|
* 6 if selected geometry not found
|
|
|
|
* 7 layer not editable
|
|
|
|
* @note available in python bindings as addPartV2
|
|
|
|
*/
|
|
|
|
int addPart( const QList<QgsPointV2>& ring ) /PyName=addPartV2/;
|
|
|
|
|
2015-11-08 19:18:00 +00:00
|
|
|
//! @note available in python as addCurvedPart
|
|
|
|
int addPart( QgsCurveV2* ring /Transfer/ ) /PyName=addCurvedPart/;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Translates feature by dx, dy
|
2016-02-14 03:50:23 +01:00
|
|
|
* @param featureId id of the feature to translate
|
|
|
|
* @param dx translation of x-coordinate
|
|
|
|
* @param dy translation of y-coordinate
|
|
|
|
* @return 0 in case of success
|
|
|
|
*/
|
2012-10-21 13:21:35 +02:00
|
|
|
int translateFeature( QgsFeatureId featureId, double dx, double dy );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Splits parts cut by the given line
|
2014-01-03 23:06:49 +01:00
|
|
|
* @param splitLine line that splits the layer features
|
|
|
|
* @param topologicalEditing true if topological editing is enabled
|
|
|
|
* @return
|
|
|
|
* 0 in case of success,
|
|
|
|
* 4 if there is a selection but no feature split
|
|
|
|
*/
|
|
|
|
int splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Splits features cut by the given line
|
2012-08-28 22:32:17 +02:00
|
|
|
* @param splitLine line that splits the layer features
|
|
|
|
* @param topologicalEditing true if topological editing is enabled
|
|
|
|
* @return
|
2012-08-29 00:45:18 +02:00
|
|
|
* 0 in case of success,
|
|
|
|
* 4 if there is a selection but no feature split
|
2012-08-28 22:32:17 +02:00
|
|
|
*/
|
|
|
|
int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Changes the specified geometry such that it has no intersections with other
|
2012-08-28 22:32:17 +02:00
|
|
|
* polygon (or multipolygon) geometries in this vector layer
|
|
|
|
* @param geom geometry to modify
|
2012-09-25 14:28:06 +02:00
|
|
|
* @param ignoreFeatures list of feature ids where intersections should be ignored
|
2012-08-28 22:32:17 +02:00
|
|
|
* @return 0 in case of success
|
2014-02-07 11:58:59 +07:00
|
|
|
*
|
|
|
|
* @deprecated since 2.2 - not being used for "avoid intersections" functionality anymore
|
2012-08-28 22:32:17 +02:00
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
int removePolygonIntersections( QgsGeometry* geom, const QgsFeatureIds& ignoreFeatures = QgsFeatureIds() ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Adds topological points for every vertex of the geometry.
|
|
|
|
* @param geom the geometry where each vertex is added to segments of other features
|
|
|
|
* @note geom is not going to be modified by the function
|
|
|
|
* @return 0 in case of success
|
|
|
|
*/
|
2015-05-11 19:46:32 +10:00
|
|
|
int addTopologicalPoints( const QgsGeometry* geom );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Adds a vertex to segments which intersect point p but don't
|
|
|
|
* already have a vertex there. If a feature already has a vertex at position p,
|
|
|
|
* no additional vertex is inserted. This method is useful for topological
|
|
|
|
* editing.
|
|
|
|
* @param p position of the vertex
|
|
|
|
* @return 0 in case of success
|
|
|
|
*/
|
|
|
|
int addTopologicalPoints( const QgsPoint& p );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Inserts vertices to the snapped segments.
|
2012-08-28 22:32:17 +02:00
|
|
|
* This is useful for topological editing if snap to segment is enabled.
|
|
|
|
* @param snapResults results collected from the snapping operation
|
|
|
|
* @return 0 in case of success
|
|
|
|
*/
|
|
|
|
int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
|
|
|
|
|
2015-04-13 20:45:32 +10:00
|
|
|
/** Set labels on
|
|
|
|
* @deprecated this method is for the old labeling engine
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2015-04-13 20:45:32 +10:00
|
|
|
void enableLabels( bool on ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-04-13 20:45:32 +10:00
|
|
|
/** Label is on
|
|
|
|
* @deprecated this method is for the old labeling engine, use labelsEnabled instead
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2015-04-13 20:45:32 +10:00
|
|
|
bool hasLabelsEnabled() const /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/** Access to labeling configuration.
|
|
|
|
* @note added in 2.12
|
|
|
|
* @note not available in Python bindings
|
|
|
|
*/
|
|
|
|
// const QgsAbstractVectorLayerLabeling* labeling() const { return mLabeling; }
|
|
|
|
|
|
|
|
/** Set labeling configuration. Takes ownership of the object.
|
|
|
|
* @note added in 2.12
|
|
|
|
* @note not available in Python bindings
|
|
|
|
*/
|
|
|
|
// void setLabeling( QgsAbstractVectorLayerLabeling* labeling );
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/** Returns true if the provider is in editing mode */
|
|
|
|
virtual bool isEditable() const;
|
|
|
|
|
2016-03-16 12:35:45 +11:00
|
|
|
virtual bool isSpatial() const;
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Returns true if the provider is in read-only mode */
|
2012-08-28 22:32:17 +02:00
|
|
|
virtual bool isReadOnly() const;
|
|
|
|
|
|
|
|
/** Returns true if the provider has been modified since the last commit */
|
|
|
|
virtual bool isModified() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Snaps a point to the closest vertex if there is one within the snapping tolerance
|
2012-08-28 22:32:17 +02:00
|
|
|
* @param point The point which is set to the position of a vertex if there is one within the snapping tolerance.
|
|
|
|
* If there is no point within this tolerance, point is left unchanged.
|
|
|
|
* @param tolerance The snapping tolerance
|
|
|
|
* @return true if the point has been snapped, false if no vertex within search tolerance
|
|
|
|
*/
|
|
|
|
bool snapPoint( QgsPoint& point, double tolerance );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Snaps to segment or vertex within given tolerance
|
2012-08-28 22:32:17 +02:00
|
|
|
* @param startPoint point to snap (in layer coordinates)
|
|
|
|
* @param snappingTolerance distance tolerance for snapping
|
|
|
|
* @param snappingResults snapping results. Key is the distance between startPoint and snapping target
|
|
|
|
* @param snap_to to segment / to vertex
|
|
|
|
* @return 0 in case of success
|
|
|
|
*/
|
|
|
|
int snapWithContext( const QgsPoint& startPoint,
|
|
|
|
double snappingTolerance,
|
|
|
|
QMultiMap < double, QgsSnappingResult > &snappingResults /Out/,
|
|
|
|
QgsSnapper::SnappingType snap_to );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Synchronises with changes in the datasource */
|
2012-08-28 22:32:17 +02:00
|
|
|
virtual void reload();
|
|
|
|
|
2013-12-05 18:27:45 +07:00
|
|
|
/** Return new instance of QgsMapLayerRenderer that will be used for rendering of given context
|
2014-02-21 17:33:09 +07:00
|
|
|
* @note added in 2.4
|
2013-12-05 18:27:45 +07:00
|
|
|
*/
|
|
|
|
virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) /Factory/;
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/** Draws the layer
|
|
|
|
* @return false if an error occurred during drawing
|
|
|
|
*/
|
|
|
|
bool draw( QgsRenderContext& rendererContext );
|
|
|
|
|
2015-04-13 20:45:32 +10:00
|
|
|
/** Draws the layer labels using the old labeling engine
|
2015-12-07 21:54:40 +11:00
|
|
|
* @deprecated will be removed in QGIS 3.0
|
2016-02-14 03:50:23 +01:00
|
|
|
*/
|
2015-04-13 20:45:32 +10:00
|
|
|
void drawLabels( QgsRenderContext& rendererContext ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/** Return the extent of the layer */
|
2012-08-28 22:32:17 +02:00
|
|
|
QgsRectangle extent();
|
|
|
|
|
2015-07-14 15:35:08 +02:00
|
|
|
/**
|
|
|
|
* Returns the list of fields of this layer.
|
|
|
|
* This also includes fields which have not yet been saved to the provider.
|
|
|
|
*
|
|
|
|
* @return A list of fields
|
|
|
|
*/
|
2015-08-05 15:00:40 +10:00
|
|
|
QgsFields fields() const;
|
2015-08-01 23:15:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of fields of this layer.
|
|
|
|
* This also includes fields which have not yet been saved to the provider.
|
|
|
|
* Alias for {@link fields()}
|
|
|
|
*
|
|
|
|
* @return A list of fields
|
|
|
|
*/
|
2015-08-02 09:09:01 +02:00
|
|
|
QgsFields pendingFields() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
|
|
|
|
* Alias for {@link attributeList()}
|
|
|
|
*/
|
|
|
|
QgsAttributeList pendingAllAttributesList() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
|
|
|
|
* Alias for {@link attributeList()}
|
|
|
|
*/
|
|
|
|
QgsAttributeList attributeList() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns list of attributes making up the primary key
|
|
|
|
* Alias for {@link pkAttributeList()}
|
|
|
|
*/
|
|
|
|
QgsAttributeList pendingPkAttributesList() const;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-08-02 09:09:01 +02:00
|
|
|
/** Returns list of attributes making up the primary key */
|
|
|
|
QgsAttributeList pkAttributeList() const;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-08-02 09:09:01 +02:00
|
|
|
/**
|
|
|
|
* Returns feature count including changes which have not yet been committed
|
|
|
|
* Alias for {@link featureCount()}
|
|
|
|
*/
|
|
|
|
long pendingFeatureCount() const;
|
2013-01-28 01:39:58 +01:00
|
|
|
|
2015-08-02 09:09:01 +02:00
|
|
|
/**
|
|
|
|
* Returns feature count including changes which have not yet been committed
|
|
|
|
* If you need only the count of committed features call this method on this layer's provider.
|
|
|
|
*/
|
|
|
|
long featureCount() const;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Make layer read-only (editing disabled) or not
|
|
|
|
* @return false if the layer is in editing yet
|
|
|
|
*/
|
2015-11-20 15:04:54 +01:00
|
|
|
bool setReadOnly( bool readonly = true );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Change feature's geometry */
|
2012-10-21 13:21:35 +02:00
|
|
|
bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2014-01-07 11:42:35 +01:00
|
|
|
/**
|
|
|
|
* Changes an attribute value (but does not commit it)
|
|
|
|
*
|
|
|
|
* @deprecated The emitSignal parameter is obsolete and not considered at the moment. It will
|
|
|
|
* be removed in future releases. Remove it to be prepared for the future. (Since 2.1)
|
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant& value, bool emitSignal ) /Deprecated/;
|
2014-01-07 11:42:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes an attribute value (but does not commit it)
|
|
|
|
*
|
|
|
|
* @param fid The feature id of the feature to be changed
|
|
|
|
* @param field The index of the field to be updated
|
2014-02-08 23:26:15 +01:00
|
|
|
* @param newValue The value which will be assigned to the field
|
|
|
|
* @param oldValue The previous value to restore on undo (will otherwise be retrieved)
|
2014-01-07 11:42:35 +01:00
|
|
|
*
|
|
|
|
* @return true in case of success
|
|
|
|
*/
|
2014-02-08 23:26:15 +01:00
|
|
|
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Add an attribute field (but does not commit it)
|
2016-02-14 03:50:23 +01:00
|
|
|
* returns true if the field was added
|
|
|
|
*/
|
2012-08-28 22:32:17 +02:00
|
|
|
bool addAttribute( const QgsField &field );
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Sets an alias (a display name) for attributes to display in dialogs */
|
2015-10-07 11:55:34 +11:00
|
|
|
void addAttributeAlias( int attIndex, const QString& aliasString );
|
2009-07-03 15:42:42 +00:00
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Removes an alias (a display name) for attributes to display in dialogs */
|
|
|
|
void remAttributeAlias( int attIndex );
|
|
|
|
|
2016-05-31 10:05:54 +10:00
|
|
|
/** Renames an attribute field (but does not commit it).
|
|
|
|
* @param attIndex attribute index
|
|
|
|
* @param newName new name of field
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
*/
|
|
|
|
bool renameAttribute( int attIndex, const QString& newName );
|
|
|
|
|
2014-01-03 23:06:49 +01:00
|
|
|
/**
|
|
|
|
* Adds a tab (for the attribute editor form) holding groups and fields
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->addTab()` instead
|
2014-01-03 23:06:49 +01:00
|
|
|
*/
|
2016-02-14 03:50:23 +01:00
|
|
|
void addAttributeEditorWidget( QgsAttributeEditorElement* data ) /Deprecated/;
|
2014-01-03 23:06:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the id for the editor widget used to represent the field at the given index
|
|
|
|
*
|
|
|
|
* @param fieldIdx The index of the field
|
|
|
|
*
|
|
|
|
* @return The id for the editor widget or a NULL string if not applicable
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->widgetType()` instead
|
2014-01-03 23:06:49 +01:00
|
|
|
*/
|
2016-02-14 03:50:23 +01:00
|
|
|
const QString editorWidgetV2( int fieldIdx ) const /Deprecated/;
|
2014-05-24 03:52:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the id for the editor widget used to represent the field at the given index
|
|
|
|
*
|
|
|
|
* @param fieldName The name of the field
|
|
|
|
*
|
|
|
|
* @return The id for the editor widget or a NULL string if not applicable
|
|
|
|
*
|
|
|
|
* @note python method name editorWidgetV2ByName
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->widgetType()` instead
|
2014-05-24 03:52:19 +02:00
|
|
|
*/
|
2016-02-14 03:50:23 +01:00
|
|
|
const QString editorWidgetV2( const QString& fieldName ) const /PyName=editorWidgetV2ByName, Deprecated/;
|
2014-01-03 23:06:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the configuration for the editor widget used to represent the field at the given index
|
|
|
|
*
|
|
|
|
* @param fieldIdx The index of the field
|
|
|
|
*
|
2014-05-24 03:52:19 +02:00
|
|
|
* @return The configuration for the editor widget or an empty config if the field does not exist
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->widgetConfig()` instead
|
2014-01-03 23:06:49 +01:00
|
|
|
*/
|
2016-02-14 03:50:23 +01:00
|
|
|
const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const /Deprecated/;
|
2014-05-24 03:52:19 +02:00
|
|
|
|
|
|
|
/**
|
2015-11-08 19:18:00 +00:00
|
|
|
* Get the configuration for the editor widget used to represent the field with the given name
|
2014-05-24 03:52:19 +02:00
|
|
|
*
|
|
|
|
* @param fieldName The name of the field
|
|
|
|
*
|
|
|
|
* @return The configuration for the editor widget or an empty config if the field does not exist
|
|
|
|
*
|
|
|
|
* @note python method name is editorWidgetV2ConfigByName
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->widgetConfig()` instead
|
2014-05-24 03:52:19 +02:00
|
|
|
*/
|
2016-02-14 03:50:23 +01:00
|
|
|
const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const /PyName=editorWidgetV2ConfigByName, Deprecated/;
|
2014-01-03 23:06:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a list of tabs holding groups and fields
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->tabs()` instead
|
2014-01-03 23:06:49 +01:00
|
|
|
*/
|
2016-02-14 03:50:23 +01:00
|
|
|
QList< QgsAttributeEditorElement* > attributeEditorElements() /Deprecated/;
|
2015-11-19 09:09:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the configuration of the form used to represent this vector layer.
|
|
|
|
* This is a writable configuration that can directly be changed in place.
|
|
|
|
*
|
|
|
|
* @return The configuration of this layers' form
|
|
|
|
*/
|
|
|
|
QgsEditFormConfig* editFormConfig() const;
|
|
|
|
|
2014-01-03 23:06:49 +01:00
|
|
|
/**
|
|
|
|
* Clears all the tabs for the attribute editor form
|
|
|
|
*/
|
2013-01-28 01:39:58 +01:00
|
|
|
void clearAttributeEditorWidgets();
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Returns the alias of an attribute name or an empty string if there is no alias */
|
2012-08-28 22:32:17 +02:00
|
|
|
QString attributeAlias( int attributeIndex ) const;
|
2009-07-03 15:42:42 +00:00
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Convenience function that returns the attribute alias if defined or the field name else */
|
2012-08-28 22:32:17 +02:00
|
|
|
QString attributeDisplayName( int attributeIndex ) const;
|
|
|
|
|
2012-10-21 13:21:35 +02:00
|
|
|
const QMap< QString, QString >& attributeAliases() const;
|
|
|
|
|
|
|
|
const QSet<QString>& excludeAttributesWMS() const;
|
|
|
|
void setExcludeAttributesWMS( const QSet<QString>& att );
|
|
|
|
|
|
|
|
const QSet<QString>& excludeAttributesWFS() const;
|
|
|
|
void setExcludeAttributesWFS( const QSet<QString>& att );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Delete an attribute field (but does not commit it) */
|
2012-08-28 22:32:17 +02:00
|
|
|
bool deleteAttribute( int attr );
|
|
|
|
|
2013-04-02 16:34:50 +02:00
|
|
|
/**
|
|
|
|
* Deletes a list of attribute fields (but does not commit it)
|
|
|
|
*
|
|
|
|
* @param attrs the indices of the attributes to delete
|
|
|
|
* @return true if at least one attribute has been deleted
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
bool deleteAttributes( QList<int> attrs );
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/** Insert a copy of the given features into the layer (but does not commit it) */
|
|
|
|
bool addFeatures( QList<QgsFeature> features, bool makeSelected = true );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Delete a feature from the layer (but does not commit it) */
|
2012-10-21 13:21:35 +02:00
|
|
|
bool deleteFeature( QgsFeatureId fid );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-11-30 21:18:49 +01:00
|
|
|
/**
|
|
|
|
* Deletes a set of features from the layer (but does not commit it)
|
|
|
|
* @param fids The feature ids to delete
|
|
|
|
*
|
|
|
|
* @return false if the layer is not in edit mode or does not support deleting
|
|
|
|
* in case of an active transaction depends on the provider implementation
|
|
|
|
*/
|
2016-02-02 19:46:18 +11:00
|
|
|
bool deleteFeatures( const QgsFeatureIds& fids );
|
2015-11-30 21:18:49 +01:00
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/**
|
2016-02-14 03:50:23 +01:00
|
|
|
* Attempts to commit any changes to disk. Returns the result of the attempt.
|
|
|
|
* If a commit fails, the in-memory changes are left alone.
|
|
|
|
*
|
|
|
|
* This allows editing to continue if the commit failed on e.g. a
|
|
|
|
* disallowed value in a Postgres database - the user can re-edit and try
|
|
|
|
* again.
|
|
|
|
*
|
|
|
|
* The commits occur in distinct stages,
|
|
|
|
* (add attributes, add features, change attribute values, change
|
|
|
|
* geometries, delete features, delete attributes)
|
|
|
|
* so if a stage fails, it's difficult to roll back cleanly.
|
|
|
|
* Therefore any error message also includes which stage failed so
|
|
|
|
* that the user has some chance of repairing the damage cleanly.
|
2012-08-28 22:32:17 +02:00
|
|
|
*/
|
|
|
|
bool commitChanges();
|
|
|
|
const QStringList &commitErrors();
|
|
|
|
|
2013-03-20 13:35:56 +01:00
|
|
|
/** Stop editing and discard the edits
|
2014-11-21 01:17:21 +01:00
|
|
|
* @param deleteBuffer whether to delete editing buffer
|
2013-03-20 13:35:56 +01:00
|
|
|
*/
|
|
|
|
bool rollBack( bool deleteBuffer = true );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
|
|
|
* Get edit type
|
|
|
|
*
|
2016-02-14 03:50:23 +01:00
|
|
|
* @deprecated Use `editFormConfig()->widgetType()` instead
|
2014-05-24 03:52:19 +02:00
|
|
|
*/
|
|
|
|
EditType editType( int idx ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
2016-02-14 03:50:23 +01:00
|
|
|
* Set edit type
|
2014-05-24 03:52:19 +02:00
|
|
|
*
|
2016-02-14 03:50:23 +01:00
|
|
|
* @deprecated Use `editFormConfig()->setWidgetType()` instead
|
2014-05-24 03:52:19 +02:00
|
|
|
*/
|
|
|
|
void setEditType( int idx, EditType edit ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Get the active layout for the attribute editor for this layer
|
|
|
|
* @deprecated Use `editFormConfig()->layout()` instead
|
|
|
|
*/
|
|
|
|
EditorLayout editorLayout() /Deprecated/;
|
2012-11-08 08:56:01 +01:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Set the active layout for the attribute editor for this layer
|
|
|
|
* @deprecated Use `editFormConfig()->setLayout()` instead
|
|
|
|
*/
|
|
|
|
void setEditorLayout( EditorLayout editorLayout ) /Deprecated/;
|
2012-11-08 08:56:01 +01:00
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
|
|
|
* Set the editor widget type for a field
|
|
|
|
*
|
2014-11-21 01:17:21 +01:00
|
|
|
* QGIS ships the following widget types, additional types may be available depending
|
|
|
|
* on plugins.
|
|
|
|
*
|
|
|
|
* <ul>
|
|
|
|
* <li>CheckBox (QgsCheckboxWidgetWrapper)</li>
|
|
|
|
* <li>Classification (QgsClassificationWidgetWrapper)</li>
|
|
|
|
* <li>Color (QgsColorWidgetWrapper)</li>
|
|
|
|
* <li>DateTime (QgsDateTimeEditWrapper)</li>
|
|
|
|
* <li>Enumeration (QgsEnumerationWidgetWrapper)</li>
|
|
|
|
* <li>FileName (QgsFileNameWidgetWrapper)</li>
|
|
|
|
* <li>Hidden (QgsHiddenWidgetWrapper)</li>
|
|
|
|
* <li>Photo (QgsPhotoWidgetWrapper)</li>
|
|
|
|
* <li>Range (QgsRangeWidgetWrapper)</li>
|
|
|
|
* <li>RelationReference (QgsRelationReferenceWidgetWrapper)</li>
|
|
|
|
* <li>TextEdit (QgsTextEditWrapper)</li>
|
|
|
|
* <li>UniqueValues (QgsUniqueValuesWidgetWrapper)</li>
|
|
|
|
* <li>UuidGenerator (QgsUuidWidgetWrapper)</li>
|
|
|
|
* <li>ValueMap (QgsValueMapWidgetWrapper)</li>
|
|
|
|
* <li>ValueRelation (QgsValueRelationWidgetWrapper)</li>
|
|
|
|
* <li>WebView (QgsWebViewWidgetWrapper)</li>
|
|
|
|
* </ul>
|
|
|
|
*
|
2014-05-24 03:52:19 +02:00
|
|
|
* @param attrIdx Index of the field
|
|
|
|
* @param widgetType Type id of the editor widget to use
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->setWidgetType()` instead
|
2014-05-24 03:52:19 +02:00
|
|
|
*/
|
2016-02-14 03:50:23 +01:00
|
|
|
void setEditorWidgetV2( int attrIdx, const QString& widgetType ) /Deprecated/;
|
2014-01-03 23:06:49 +01:00
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
2014-11-21 01:17:21 +01:00
|
|
|
* Set the editor widget config for a field.
|
|
|
|
*
|
|
|
|
* Python: Will accept a map.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* \code{.py}
|
|
|
|
* layer.setEditorWidgetV2Config( 1, { 'Layer': 'otherlayerid_1234', 'Key': 'Keyfield', 'Value': 'ValueField' } )
|
|
|
|
* \endcode
|
2014-05-24 03:52:19 +02:00
|
|
|
*
|
|
|
|
* @param attrIdx Index of the field
|
|
|
|
* @param config The config to set for this field
|
2014-11-21 01:17:21 +01:00
|
|
|
*
|
|
|
|
* @see setEditorWidgetV2() for a list of widgets and choose the widget to see the available options.
|
2016-02-14 03:50:23 +01:00
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->setWidgetConfig()` instead
|
2014-05-24 03:52:19 +02:00
|
|
|
*/
|
2016-02-14 03:50:23 +01:00
|
|
|
void setEditorWidgetV2Config( int attrIdx, const QMap<QString, QVariant>& config ) /Deprecated/;
|
2014-01-03 23:06:49 +01:00
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
2014-11-21 01:17:21 +01:00
|
|
|
* Set string representing 'true' for a checkbox
|
2014-05-24 03:52:19 +02:00
|
|
|
*
|
2016-02-14 03:50:23 +01:00
|
|
|
* @deprecated Use @deprecated Use `editFormConfig()->setWidgetConfig()` instead
|
2014-05-24 03:52:19 +02:00
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
void setCheckedState( int idx, const QString& checked, const QString& notChecked ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Get edit form
|
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->uiForm()` instead
|
|
|
|
*/
|
|
|
|
QString editForm() /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Set edit form
|
|
|
|
* @deprecated Use `editFormConfig()->setUiForm()` instead
|
|
|
|
*/
|
|
|
|
void setEditForm( const QString& ui ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2013-09-06 17:31:47 -06:00
|
|
|
/** Type of feature form pop-up suppression after feature creation (overrides app setting)
|
2016-02-14 03:50:23 +01:00
|
|
|
* @note added in 2.1
|
|
|
|
* @deprecated Use `editFormConfig()->suppress()` instead
|
|
|
|
*/
|
|
|
|
QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const /Deprecated/;
|
2013-09-06 17:31:47 -06:00
|
|
|
|
|
|
|
/** Set type of feature form pop-up suppression after feature creation (overrides app setting)
|
2016-02-14 03:50:23 +01:00
|
|
|
* @note added in 2.1
|
|
|
|
* @deprecated Use `editFormConfig()->setSuppress()` instead
|
|
|
|
*/
|
|
|
|
void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) /Deprecated/;
|
2013-09-06 17:31:47 -06:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Get annotation form */
|
2012-08-28 22:32:17 +02:00
|
|
|
QString annotationForm() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Set annotation form for layer */
|
2012-08-28 22:32:17 +02:00
|
|
|
void setAnnotationForm( const QString& ui );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Get python function for edit form initialization
|
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->initFunction()` instead
|
|
|
|
*/
|
|
|
|
QString editFormInit() /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Set python function for edit form initialization
|
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->setInitFunction()` instead
|
|
|
|
*/
|
|
|
|
void setEditFormInit( const QString& function ) /Deprecated/;
|
2015-11-08 19:18:00 +00:00
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
|
|
|
* Access value map
|
2016-02-14 03:50:23 +01:00
|
|
|
* @deprecated Use `editFormConfig()->widgetConfig()` instead
|
2014-05-24 03:52:19 +02:00
|
|
|
*/
|
|
|
|
QMap<QString, QVariant> valueMap( int idx ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
|
|
|
* Access range widget config data
|
|
|
|
*
|
2016-02-14 03:50:23 +01:00
|
|
|
* @deprecated Use `editFormConfig()->widgetConfig()` instead
|
2014-05-24 03:52:19 +02:00
|
|
|
*/
|
2014-01-05 14:50:07 +01:00
|
|
|
RangeData range( int idx ) /Deprecated/;
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Access value relation widget data */
|
2014-05-24 03:52:19 +02:00
|
|
|
ValueRelationData valueRelation( int idx );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2014-01-03 23:06:49 +01:00
|
|
|
/**
|
|
|
|
* Get relations, where the foreign key is on this layer
|
|
|
|
*
|
|
|
|
* @param idx Only get relations, where idx forms part of the foreign key
|
|
|
|
* @return A list of relations
|
|
|
|
*/
|
|
|
|
QList<QgsRelation> referencingRelations( int idx );
|
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
|
|
|
* Access date format
|
|
|
|
*
|
2016-02-14 03:50:23 +01:00
|
|
|
* @deprecated Use `editFormConfig()->widgetConfig()` instead
|
2013-03-20 13:35:56 +01:00
|
|
|
*/
|
2014-01-05 14:50:07 +01:00
|
|
|
QString dateFormat( int idx ) /Deprecated/;
|
2013-03-20 13:35:56 +01:00
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
|
|
|
* Access widget size for photo and webview widget
|
|
|
|
*
|
2016-02-14 03:50:23 +01:00
|
|
|
* @deprecated Use `editFormConfig()->widgetConfig()` instead
|
2013-04-02 16:34:50 +02:00
|
|
|
*/
|
2014-01-05 14:50:07 +01:00
|
|
|
QSize widgetSize( int idx ) /Deprecated/;
|
2013-04-02 16:34:50 +02:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Is edit widget editable
|
|
|
|
*
|
|
|
|
* @deprecated Use `editFormConfig()->fieldEditable()` instead
|
|
|
|
*/
|
2013-03-20 13:35:56 +01:00
|
|
|
bool fieldEditable( int idx );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Label widget on top
|
|
|
|
* @deprecated Use `editFormConfig()->labelOnTop()` instead
|
|
|
|
*/
|
2013-06-23 16:00:16 +02:00
|
|
|
bool labelOnTop( int idx );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Set edit widget editable
|
|
|
|
* @deprecated Use `editFormConfig()->setFieldEditable()` instead
|
|
|
|
*/
|
2013-03-20 13:35:56 +01:00
|
|
|
void setFieldEditable( int idx, bool editable );
|
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
/**
|
|
|
|
* Label widget on top
|
|
|
|
* @deprecated Use `editFormConfig()->setLabelOnTop()` instead
|
|
|
|
*/
|
2013-06-23 16:00:16 +02:00
|
|
|
void setLabelOnTop( int idx, bool onTop );
|
|
|
|
|
2012-12-17 21:22:42 +01:00
|
|
|
//! Buffer with uncommitted editing operations. Only valid after editing has been turned on.
|
|
|
|
QgsVectorLayerEditBuffer* editBuffer();
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
/**
|
|
|
|
* Create edit command for undo/redo operations
|
|
|
|
* @param text text which is to be displayed in undo window
|
|
|
|
*/
|
2015-10-07 11:55:34 +11:00
|
|
|
void beginEditCommand( const QString& text );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Finish edit command and add it to undo/redo stack */
|
|
|
|
void endEditCommand();
|
|
|
|
|
|
|
|
/** Destroy active command and reverts all changes in it */
|
|
|
|
void destroyEditCommand();
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Returns the index of a field name or -1 if the field does not exist */
|
2012-08-28 22:32:17 +02:00
|
|
|
int fieldNameIndex( const QString& fieldName ) const;
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Editing vertex markers */
|
2012-08-28 22:32:17 +02:00
|
|
|
enum VertexMarkerType
|
|
|
|
{
|
|
|
|
SemiTransparentCircle,
|
|
|
|
Cross,
|
2014-11-21 01:17:21 +01:00
|
|
|
NoMarker
|
2012-08-28 22:32:17 +02:00
|
|
|
};
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Draws a vertex symbol at (screen) coordinates x, y. (Useful to assist vertex editing.) */
|
2012-08-28 22:32:17 +02:00
|
|
|
static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Assembles mUpdatedFields considering provider fields, joined fields and added fields */
|
2013-04-02 16:34:50 +02:00
|
|
|
void updateFields();
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Caches joined attributes if required (and not already done) */
|
2012-08-28 22:32:17 +02:00
|
|
|
void createJoinCaches();
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns unique values for column
|
2016-02-14 03:50:23 +01:00
|
|
|
* @param index column index for attribute
|
|
|
|
* @param uniqueValues out: result list
|
|
|
|
* @param limit maximum number of values to return (-1 if unlimited)
|
|
|
|
*/
|
2012-08-28 22:32:17 +02:00
|
|
|
void uniqueValues( int index, QList<QVariant> &uniqueValues /Out/, int limit = -1 );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns minimum value for an attribute column or invalid variant in case of error */
|
2012-08-28 22:32:17 +02:00
|
|
|
QVariant minimumValue( int index );
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Returns maximum value for an attribute column or invalid variant in case of error */
|
2012-08-28 22:32:17 +02:00
|
|
|
QVariant maximumValue( int index );
|
2015-05-03 17:10:32 +02:00
|
|
|
|
2016-05-16 14:36:04 +10:00
|
|
|
/** Calculates an aggregated value from the layer's features.
|
|
|
|
* @param aggregate aggregate to calculate
|
|
|
|
* @param fieldOrExpression source field or expression to use as basis for aggregated values.
|
[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 expressions and filters
|
|
|
|
* @param ok if specified, will be set to true if aggregate calculation was successful
|
|
|
|
* @return calculated aggregate value
|
|
|
|
* @note added in QGIS 2.16
|
|
|
|
*/
|
|
|
|
QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
|
|
|
|
const QString& fieldOrExpression,
|
[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 = QgsAggregateCalculator::AggregateParameters(),
|
2016-05-16 14:36:04 +10:00
|
|
|
QgsExpressionContext* context = nullptr,
|
|
|
|
bool* ok = nullptr );
|
|
|
|
|
2015-05-02 20:32:16 +10:00
|
|
|
/** Fetches all values from a specified field name or expression.
|
|
|
|
* @param fieldOrExpression field name or an expression string
|
|
|
|
* @param ok will be set to false if field or expression is invalid, otherwise true
|
2015-05-17 23:28:59 +10:00
|
|
|
* @param selectedOnly set to true to get values from selected features only
|
2015-05-02 20:32:16 +10:00
|
|
|
* @returns list of fetched values
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see getDoubleValues
|
|
|
|
*/
|
2015-05-17 23:28:59 +10:00
|
|
|
QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
|
2015-05-03 17:10:32 +02:00
|
|
|
|
2015-05-02 20:32:16 +10:00
|
|
|
/** Fetches all double values from a specified field name or expression. Null values or
|
|
|
|
* invalid expression results are skipped.
|
|
|
|
* @param fieldOrExpression field name or an expression string evaluating to a double value
|
|
|
|
* @param ok will be set to false if field or expression is invalid, otherwise true
|
2015-05-17 23:28:59 +10:00
|
|
|
* @param selectedOnly set to true to get values from selected features only
|
2015-05-23 02:52:32 +10:00
|
|
|
* @param nullCount optional pointer to integer to store number of null values encountered in
|
2015-05-02 20:32:16 +10:00
|
|
|
* @returns list of fetched values
|
|
|
|
* @note added in QGIS 2.9
|
|
|
|
* @see getValues
|
|
|
|
*/
|
2015-05-23 02:52:32 +10:00
|
|
|
QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = 0 );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2015-04-30 17:26:58 +10:00
|
|
|
/** Set the blending mode used for rendering each feature */
|
2016-02-02 19:46:18 +11:00
|
|
|
void setFeatureBlendMode( QPainter::CompositionMode blendMode );
|
2015-04-30 17:26:58 +10:00
|
|
|
/** Returns the current blending mode for features */
|
2013-05-29 21:38:33 +02:00
|
|
|
QPainter::CompositionMode featureBlendMode() const;
|
|
|
|
|
2015-04-30 17:26:58 +10:00
|
|
|
/** Set the transparency for the vector layer */
|
2013-05-29 21:38:33 +02:00
|
|
|
void setLayerTransparency( int layerTransparency );
|
2015-04-30 17:26:58 +10:00
|
|
|
/** Returns the current transparency for the vector layer */
|
2013-05-29 21:38:33 +02:00
|
|
|
int layerTransparency() const;
|
|
|
|
|
2014-01-03 23:06:49 +01:00
|
|
|
QString metadata();
|
|
|
|
|
|
|
|
/** @note not available in python bindings */
|
|
|
|
// inline QgsGeometryCache* cache();
|
|
|
|
|
2014-02-21 11:40:09 +07:00
|
|
|
/** Set the simplification settings for fast rendering of features
|
|
|
|
* @note added in 2.2
|
|
|
|
*/
|
2014-01-06 22:54:07 +01:00
|
|
|
void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod );
|
2014-02-21 11:40:09 +07:00
|
|
|
/** Returns the simplification settings for fast rendering of features
|
|
|
|
* @note added in 2.2
|
|
|
|
*/
|
2014-01-06 22:54:07 +01:00
|
|
|
const QgsVectorSimplifyMethod& simplifyMethod() const;
|
2013-12-29 09:41:00 +11:00
|
|
|
|
2014-02-21 11:40:09 +07:00
|
|
|
/** Returns whether the VectorLayer can apply the specified simplification hint
|
|
|
|
* @note Do not use in 3rd party code - may be removed in future version!
|
|
|
|
* @note added in 2.2
|
|
|
|
*/
|
|
|
|
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
|
2013-05-29 21:38:33 +02:00
|
|
|
|
2015-08-21 05:45:49 +10:00
|
|
|
/**
|
2015-08-25 21:08:52 +10:00
|
|
|
* @brief Return the conditional styles that are set for this layer. Style information is
|
|
|
|
* used to render conditional formatting in the attribute table.
|
2015-08-26 06:52:02 +10:00
|
|
|
* @return Return a QgsConditionalLayerStyles object holding the conditional attribute
|
2015-08-25 21:08:52 +10:00
|
|
|
* style information. Style information is generic and can be used for anything.
|
2015-08-21 05:45:49 +10:00
|
|
|
* @note added in QGIS 2.12
|
|
|
|
*/
|
2015-08-25 21:08:52 +10:00
|
|
|
QgsConditionalLayerStyles *conditionalStyles() const;
|
2015-08-21 05:45:49 +10:00
|
|
|
|
2016-04-28 15:47:43 +02:00
|
|
|
/**
|
|
|
|
* Get the attribute table configuration object.
|
|
|
|
* This defines the appearance of the attribute table.
|
|
|
|
*/
|
|
|
|
QgsAttributeTableConfig attributeTableConfig() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the attribute table configuration object.
|
|
|
|
* This defines the appearance of the attribute table.
|
|
|
|
*/
|
|
|
|
void setAttributeTableConfig( const QgsAttributeTableConfig& attributeTableConfig );
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
public slots:
|
2013-04-09 11:52:43 +02:00
|
|
|
/**
|
|
|
|
* Select feature by its ID
|
|
|
|
*
|
|
|
|
* @param featureId The id of the feature to select
|
2013-05-29 21:38:33 +02:00
|
|
|
*
|
|
|
|
* @see select(QgsFeatureIds)
|
2013-04-09 11:52:43 +02:00
|
|
|
*/
|
2015-12-30 22:51:32 +11:00
|
|
|
void select( QgsFeatureId featureId );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2013-04-09 11:52:43 +02:00
|
|
|
/**
|
|
|
|
* Select features by their ID
|
|
|
|
*
|
|
|
|
* @param featureIds The ids of the features to select
|
2013-05-29 21:38:33 +02:00
|
|
|
*
|
|
|
|
* @see select(QgsFeatureId)
|
2013-04-09 11:52:43 +02:00
|
|
|
*/
|
2013-05-29 21:38:33 +02:00
|
|
|
void select( const QgsFeatureIds& featureIds );
|
2013-04-09 11:52:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Deselect feature by its ID
|
|
|
|
*
|
|
|
|
* @param featureId The id of the feature to deselect
|
2013-05-29 21:38:33 +02:00
|
|
|
*
|
|
|
|
* @see deselect(QgsFeatureIds)
|
2013-04-09 11:52:43 +02:00
|
|
|
*/
|
2013-05-29 21:38:33 +02:00
|
|
|
void deselect( const QgsFeatureId featureId );
|
2013-04-09 11:52:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Deselect features by their ID
|
|
|
|
*
|
|
|
|
* @param featureIds The ids of the features to deselect
|
2013-05-29 21:38:33 +02:00
|
|
|
*
|
|
|
|
* @see deselect(QgsFeatureId)
|
2013-04-09 11:52:43 +02:00
|
|
|
*/
|
2013-05-29 21:38:33 +02:00
|
|
|
void deselect( const QgsFeatureIds& featureIds );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/**
|
|
|
|
* Clear selection
|
|
|
|
*
|
|
|
|
* @see setSelectedFeatures(const QgsFeatureIds&)
|
|
|
|
*/
|
2013-04-09 11:52:43 +02:00
|
|
|
void removeSelection();
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
/** Update the extents for the layer. This is necessary if features are
|
|
|
|
* added/deleted or the layer has been subsetted.
|
|
|
|
*/
|
|
|
|
virtual void updateExtents();
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Check if there is a join with a layer that will be removed */
|
2015-10-07 11:55:34 +11:00
|
|
|
void checkJoinLayerRemove( const QString& theLayerId );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2016-01-15 09:31:19 +01:00
|
|
|
/**
|
|
|
|
* Make layer editable.
|
|
|
|
* This starts an edit session on this layer. Changes made in this edit session will not
|
|
|
|
* be made persistent until {@link commitChanges()} is called and can be reverted by calling
|
|
|
|
* {@link rollBack()}.
|
|
|
|
*/
|
|
|
|
bool startEditing();
|
|
|
|
|
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
protected slots:
|
|
|
|
void invalidateSymbolCountedFlag();
|
|
|
|
|
2012-08-28 22:32:17 +02:00
|
|
|
signals:
|
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/**
|
|
|
|
* This signal is emitted when selection was changed
|
|
|
|
*
|
|
|
|
* @param selected Newly selected feature ids
|
|
|
|
* @param deselected Ids of all features which have previously been selected but are not any more
|
|
|
|
* @param clearAndSelect In case this is set to true, the old selection was dismissed and the new selection corresponds to selected
|
|
|
|
*/
|
2015-10-26 22:46:25 +11:00
|
|
|
void selectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, const bool clearAndSelect );
|
2013-05-29 21:38:33 +02:00
|
|
|
|
2013-05-03 19:27:56 +02:00
|
|
|
/** This signal is emitted when selection was changed */
|
2012-08-28 22:32:17 +02:00
|
|
|
void selectionChanged();
|
|
|
|
|
|
|
|
/** This signal is emitted when modifications has been done on layer */
|
2012-12-17 21:22:42 +01:00
|
|
|
void layerModified();
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/** Is emitted, when layer is checked for modifications. Use for last-minute additions */
|
|
|
|
void beforeModifiedCheck() const;
|
|
|
|
|
2016-01-15 09:31:19 +01:00
|
|
|
/** Is emitted, before editing on this layer is started */
|
|
|
|
void beforeEditingStarted();
|
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/** Is emitted, when editing on this layer has started*/
|
2012-08-28 22:32:17 +02:00
|
|
|
void editingStarted();
|
2013-05-29 21:38:33 +02:00
|
|
|
|
|
|
|
/** Is emitted, when edited changes successfully have been written to the data provider */
|
2012-08-28 22:32:17 +02:00
|
|
|
void editingStopped();
|
2013-04-13 19:44:48 +03:00
|
|
|
|
2013-05-29 21:38:33 +02:00
|
|
|
/** Is emitted, before changes are commited to the data provider */
|
|
|
|
void beforeCommitChanges();
|
|
|
|
|
|
|
|
/** Is emitted, before changes are rolled back*/
|
|
|
|
void beforeRollBack();
|
|
|
|
|
2013-04-13 19:44:48 +03:00
|
|
|
/**
|
|
|
|
* Will be emitted, when a new attribute has been added to this vector layer.
|
2015-11-08 19:18:00 +00:00
|
|
|
* Applies only to types {@link QgsFields::OriginEdit}, {@link QgsFields::OriginProvider} and {@link QgsFields::OriginExpression }
|
2013-04-13 19:44:48 +03:00
|
|
|
*
|
2013-05-29 21:38:33 +02:00
|
|
|
* @param idx The index of the new attribute
|
2013-04-13 19:44:48 +03:00
|
|
|
*
|
|
|
|
* @see updatedFields()
|
|
|
|
*/
|
2012-08-28 22:32:17 +02:00
|
|
|
void attributeAdded( int idx );
|
2015-11-08 19:18:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Will be emitted, when an expression field is going to be added to this vector layer.
|
|
|
|
* Applies only to types {@link QgsFields::OriginExpression }
|
|
|
|
*
|
|
|
|
* @param fieldName The name of the attribute to be added
|
|
|
|
*/
|
|
|
|
void beforeAddingExpressionField( const QString& fieldName );
|
|
|
|
|
2013-04-13 19:44:48 +03:00
|
|
|
/**
|
|
|
|
* Will be emitted, when an attribute has been deleted from this vector layer.
|
2015-11-08 19:18:00 +00:00
|
|
|
* Applies only to types {@link QgsFields::OriginEdit}, {@link QgsFields::OriginProvider} and {@link QgsFields::OriginExpression }
|
2013-04-13 19:44:48 +03:00
|
|
|
*
|
2013-05-29 21:38:33 +02:00
|
|
|
* @param idx The index of the deleted attribute
|
2013-04-13 19:44:48 +03:00
|
|
|
*
|
|
|
|
* @see updatedFields()
|
|
|
|
*/
|
2012-08-28 22:32:17 +02:00
|
|
|
void attributeDeleted( int idx );
|
2015-11-08 19:18:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Will be emitted, when an expression field is going to be deleted from this vector layer.
|
|
|
|
* Applies only to types {@link QgsFields::OriginExpression }
|
|
|
|
*
|
|
|
|
* @param idx The index of the attribute to be deleted
|
|
|
|
*/
|
|
|
|
void beforeRemovingExpressionField( int idx );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Emitted when a new feature has been added to the layer
|
|
|
|
*
|
|
|
|
* @param fid The id of the new feature
|
|
|
|
*/
|
2014-11-21 01:17:21 +01:00
|
|
|
void featureAdded( QgsFeatureId fid );
|
2015-11-08 19:18:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Emitted when a feature has been deleted.
|
|
|
|
*
|
|
|
|
* If you do expensive operations in a slot connected to this, you should prever to use
|
|
|
|
* {@link featuresDeleted( const QgsFeatureIds& )}.
|
|
|
|
*
|
|
|
|
* @param fid The id of the feature which has been deleted
|
|
|
|
*/
|
2013-05-29 21:38:33 +02:00
|
|
|
void featureDeleted( QgsFeatureId fid );
|
2015-11-08 19:18:00 +00:00
|
|
|
|
2015-05-27 20:51:51 +02:00
|
|
|
/**
|
|
|
|
* Emitted when features have been deleted.
|
|
|
|
*
|
|
|
|
* If features are deleted within an edit command, this will only be emitted once at the end
|
|
|
|
* to allow connected slots to minimize the overhead.
|
2015-11-08 19:18:00 +00:00
|
|
|
* If features are deleted outside of an edit command, this signal will be emitted once per feature.
|
2015-05-27 20:51:51 +02:00
|
|
|
*
|
|
|
|
* @param fids The feature ids that have been deleted.
|
|
|
|
*/
|
2015-10-26 22:46:25 +11:00
|
|
|
void featuresDeleted( const QgsFeatureIds& fids );
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2013-04-13 19:44:48 +03:00
|
|
|
/**
|
|
|
|
* Is emitted, whenever the fields available from this layer have been changed.
|
|
|
|
* This can be due to manually adding attributes or due to a join.
|
|
|
|
*/
|
|
|
|
void updatedFields();
|
2012-08-28 22:32:17 +02:00
|
|
|
void layerDeleted();
|
|
|
|
|
|
|
|
void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
|
2014-11-21 01:17:21 +01:00
|
|
|
void geometryChanged( QgsFeatureId fid, QgsGeometry &geom );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Signals emitted after committing changes */
|
2013-01-28 01:39:58 +01:00
|
|
|
void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
|
2012-08-28 22:32:17 +02:00
|
|
|
void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
|
|
|
|
void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
|
|
|
|
void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
|
|
|
|
void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
|
|
|
|
void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
|
|
|
|
|
2014-01-03 23:06:49 +01:00
|
|
|
void saveLayerToProject();
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/** Emitted when the font family defined for labeling layer is not found on system */
|
2013-06-09 18:04:55 -06:00
|
|
|
void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
|
|
|
|
|
2013-09-09 09:47:05 +02:00
|
|
|
/** Signal emitted when setFeatureBlendMode() is called */
|
2016-02-02 19:46:18 +11:00
|
|
|
void featureBlendModeChanged( QPainter::CompositionMode blendMode );
|
2013-09-09 09:47:05 +02:00
|
|
|
|
|
|
|
/** Signal emitted when setLayerTransparency() is called */
|
|
|
|
void layerTransparencyChanged( int layerTransparency );
|
|
|
|
|
2014-05-24 03:52:19 +02:00
|
|
|
/**
|
|
|
|
* Signal emitted when a new edit command has been started
|
|
|
|
*
|
|
|
|
* @param text Description for this edit command
|
|
|
|
*/
|
|
|
|
void editCommandStarted( const QString& text );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal emitted, when an edit command successfully ended
|
|
|
|
* @note This does not mean it is also committed, only that it is written
|
|
|
|
* to the edit buffer. See {@link beforeCommitChanges()}
|
|
|
|
*/
|
|
|
|
void editCommandEnded();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal emitted, whan an edit command is destroyed
|
|
|
|
* @note This is not a rollback, it is only related to the current edit command.
|
|
|
|
* See {@link beforeRollBack()}
|
|
|
|
*/
|
|
|
|
void editCommandDestroyed();
|
|
|
|
|
2014-11-21 01:17:21 +01:00
|
|
|
/**
|
|
|
|
* Signal emitted whenever the symbology (QML-file) for this layer is being read.
|
|
|
|
* If there is custom style information saved in the file, you can connect to this signal
|
|
|
|
* and update the layer style accordingly.
|
|
|
|
*
|
|
|
|
* @param element The XML layer style element.
|
|
|
|
*
|
|
|
|
* @param errorMessage Write error messages into this string.
|
|
|
|
*/
|
|
|
|
void readCustomSymbology( const QDomElement& element, QString& errorMessage );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal emitted whenever the symbology (QML-file) for this layer is being written.
|
|
|
|
* If there is custom style information you want to save to the file, you can connect
|
|
|
|
* to this signal and update the element accordingly.
|
|
|
|
*
|
|
|
|
* @param element The XML element where you can add additional style information to.
|
|
|
|
* @param doc The XML document that you can use to create new XML nodes.
|
|
|
|
* @param errorMessage Write error messages into this string.
|
|
|
|
*/
|
|
|
|
void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
|
|
|
|
|
2016-02-20 17:21:57 +01:00
|
|
|
/**
|
|
|
|
* Signals an error related to this vector layer.
|
|
|
|
*/
|
|
|
|
void raiseError( const QString& msg );
|
2014-11-21 01:17:21 +01:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
protected:
|
|
|
|
/** Set the extent */
|
|
|
|
void setExtent( const QgsRectangle &rect );
|
2012-08-28 22:32:17 +02:00
|
|
|
|
|
|
|
private: // Private methods
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Vector layers are not copyable */
|
2012-08-28 22:32:17 +02:00
|
|
|
QgsVectorLayer( const QgsVectorLayer & rhs );
|
|
|
|
|
handling vector data geometry and attribute updates refactored
QgsVectorLayer:
- move attribute part of editing to vector layer class and unify with geometry handling:
* remove commitAttributeChanges(), addedFeatures(), deletedFeatureIds(), changedAttributes()
and replace with changeAttributeValue(), deleteFeature(), addAttribute()
and deleteAttribute()
* add pendingFields(), pendingAttributeList(), pendingFeatureCount()
* emit signals on start editing and commit, change of attribute values, adding/deleting of
attributes and layer or feature removal (currently used in the attribute table)
- new commitErrors() method to query errors from commitChanges()
- replaced featuresInRectangle with select/getNextFeature combo
- edit types added to support more input widgets and input constraints
QgsFeature:
- remove update aware ctor
- unify geometry handling in ctors
QgsVectorDataProvider:
- add QVariant::Type to supportNativeTypes()
QgisApp:
- add instance() method to query QgisApp object
- replace code at various place to use it instead of passing the pointer
arround or searching it in the widget tree.
- move toggleEditing() code from the legend here
QgsAttributeTable/QgsAttributeTableDisplay:
- move attribute table creation legend here
- make attribute table dockable (from Tim)
- most editing logic moved to QgsVectorLayer
- adding/deleting attributes moved to QgsVectorLayerProperties
QgsIdentifyResults:
- add support for attribute editing when it edit mode
QgsVectorLayerProperties:
add a new tab to show attribute list:
* start/stop editing
* add/delete attributes
* assign edit type to attributes (unique values, value map, ranges)
QgsAttributeDialog:
add support for attribute edit types:
* selection from unique value render classes (combobox)
* selection from unique values of existing features (combobox or line edits with completion)
* spinboxes for ranges
QgsPostgresProvider:
- use read-only connection for cursors and read-write connection for updates
- updated native types
QgsOgrProvider:
- remove unused references to GEOS geometry factory
- updated native types
git-svn-id: http://svn.osgeo.org/qgis/trunk@9092 c8812cc2-4d05-0410-92ff-de0c093fc19c
2008-08-20 12:15:14 +00:00
|
|
|
|
2007-01-09 02:39:15 +00:00
|
|
|
};
|
|
|
|
|