18 #ifndef QGSVECTORLAYER_H
19 #define QGSVECTORLAYER_H
24 #include <QStringList>
42 class QgsEditorWidgetWrapper;
45 class QgsGeometryVertexIndex;
81 : QObject( parent ), mType( type ), mName( name ) {}
85 QString
name()
const {
return mName; }
88 virtual QDomElement toDomElement( QDomDocument& doc )
const = 0;
101 , mIsGroupBox( true )
106 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
110 QList<QgsAttributeEditorElement*>
children()
const {
return mChildren; }
111 virtual QList<QgsAttributeEditorElement*> findElements( AttributeEditorType type )
const;
127 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
128 int idx()
const {
return mIdx; }
140 , mRelationId( relationId ) {}
144 , mRelationId( relation.id() )
145 , mRelation( relation ) {}
149 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
507 RangeData() { mMin = QVariant( 0 ); mMax = QVariant( 5 ); mStep = QVariant( 1 );}
508 RangeData( QVariant theMin, QVariant theMax, QVariant theStep )
509 : mMin( theMin ), mMax( theMax ), mStep( theStep ) {}
519 ValueRelationData( QString layer, QString key, QString value,
bool allowNull,
bool orderByValue,
520 bool allowMulti =
false,
521 QString filterExpression = QString::null )
525 , mFilterExpression( filterExpression )
526 , mAllowNull( allowNull )
527 , mOrderByValue( orderByValue )
528 , mAllowMulti( allowMulti )
544 : mName( name ), mFields( fields ) {}
552 TabData( QString name , QList<QString> fields , QList<GroupData> groups )
553 : mName( name ), mFields( fields ), mGroups( groups ) {}
572 QgsVectorLayer( QString path = QString::null, QString baseName = QString::null,
573 QString providerLib = QString::null,
bool loadDefaultStyleFlag =
true );
579 QString storageType()
const;
582 QString capabilitiesString()
const;
585 QString dataComment()
const;
588 void setDisplayField( QString fldName =
"" );
591 const QString displayField()
const;
600 void setDisplayExpression(
const QString &displayExpression );
610 const QString displayExpression();
621 void setProviderEncoding(
const QString& encoding );
624 void setCoordinateSystem();
633 void removeJoin(
const QString& joinLayerId );
636 const QList< QgsVectorJoinInfo >& vectorJoins()
const;
650 int selectedFeatureCount();
660 void select(
QgsRectangle & rect,
bool addToSelection );
676 void invertSelection();
743 bool hasGeometryType()
const;
749 QString providerType()
const;
754 virtual bool readXml(
const QDomNode& layer_node );
759 virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc );
769 virtual void saveStyleToDatabase( QString name, QString description,
770 bool useAsDefault, QString uiFileContent,
781 virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
782 QStringList &descriptions, QString &msgError );
787 virtual QString getStyleFromDatabase( QString styleId, QString &msgError );
795 virtual QString
loadNamedStyle(
const QString &theURI,
bool &theResultFlag,
bool loadFromLocalDb );
801 virtual QString
loadNamedStyle(
const QString &theURI,
bool &theResultFlag );
803 virtual bool applyNamedStyle( QString namedStyle , QString errorMsg );
816 bool readSymbology(
const QDomNode& node, QString& errorMessage );
824 bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const;
826 bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const;
827 bool readSld(
const QDomNode& node, QString& errorMessage );
836 virtual long featureCount()
const;
851 bool countSymbolFeatures(
bool showProgress =
true );
860 virtual bool setSubsetString( QString subset );
866 virtual QString subsetString();
878 bool addFeature(
QgsFeature& f,
bool alsoUpdateExtent =
true );
893 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
899 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
903 bool deleteVertex(
QgsFeatureId atFeatureId,
int atVertex );
908 bool deleteSelectedFeatures();
919 int addRing(
const QList<QgsPoint>& ring );
931 int addPart(
const QList<QgsPoint>& ring );
938 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
947 int splitParts(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
956 int splitFeatures(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
982 int addTopologicalPoints(
const QgsPoint& p );
989 int insertSegmentVerticesForSnap(
const QList<QgsSnappingResult>& snapResults );
992 void enableLabels(
bool on );
995 bool hasLabelsEnabled()
const;
1003 virtual bool isReadOnly()
const;
1006 virtual bool isModified()
const;
1014 bool snapPoint(
QgsPoint& point,
double tolerance );
1023 int snapWithContext(
const QgsPoint& startPoint,
1024 double snappingTolerance,
1025 QMultiMap < double, QgsSnappingResult > &snappingResults,
1060 int pendingFeatureCount();
1066 bool setReadOnly(
bool readonly =
true );
1069 bool startEditing();
1081 Q_DECL_DEPRECATED
bool changeAttributeValue(
QgsFeatureId fid,
int field, QVariant value,
bool emitSignal );
1093 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant() );
1098 bool addAttribute(
const QgsField &field );
1104 void addAttributeAlias(
int attIndex, QString aliasString );
1119 const QString editorWidgetV2(
int fieldIdx )
const;
1130 const QString editorWidgetV2(
const QString& fieldName )
const;
1156 QList< QgsAttributeEditorElement* > &attributeEditorElements();
1161 void clearAttributeEditorWidgets();
1167 QString attributeAlias(
int attributeIndex )
const;
1173 QString attributeDisplayName(
int attributeIndex )
const;
1184 bool deleteAttribute(
int attr );
1193 bool deleteAttributes( QList<int> attrs );
1196 bool addFeatures(
QgsFeatureList features,
bool makeSelected =
true );
1216 bool commitChanges();
1217 const QStringList &commitErrors();
1222 bool rollBack(
bool deleteBuffer =
true );
1229 Q_DECL_DEPRECATED EditType editType(
int idx );
1236 Q_DECL_DEPRECATED
void setEditType(
int idx, EditType edit );
1239 EditorLayout editorLayout();
1242 void setEditorLayout( EditorLayout editorLayout );
1250 void setEditorWidgetV2(
int attrIdx,
const QString& widgetType );
1265 Q_DECL_DEPRECATED
void setCheckedState(
int idx, QString checked, QString notChecked );
1271 void setEditForm( QString ui );
1285 void setAnnotationForm(
const QString& ui );
1288 QString editFormInit();
1291 void setEditFormInit( QString
function );
1297 Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap(
int idx );
1304 Q_DECL_DEPRECATED RangeData range(
int idx );
1311 ValueRelationData valueRelation(
int idx );
1319 QList<QgsRelation> referencingRelations(
int idx );
1328 Q_DECL_DEPRECATED QString dateFormat(
int idx );
1337 Q_DECL_DEPRECATED QSize widgetSize(
int idx );
1342 bool fieldEditable(
int idx );
1347 bool labelOnTop(
int idx );
1352 void setFieldEditable(
int idx,
bool editable );
1357 void setLabelOnTop(
int idx,
bool onTop );
1366 void beginEditCommand( QString text );
1369 void endEditCommand();
1372 void destroyEditCommand();
1377 int fieldNameIndex(
const QString& fieldName )
const;
1394 void updateFields();
1398 void createJoinCaches();
1405 void uniqueValues(
int index, QList<QVariant> &uniqueValues,
int limit = -1 );
1409 QVariant minimumValue(
int index );
1413 QVariant maximumValue(
int index );
1418 void setFeatureBlendMode(
const QPainter::CompositionMode &blendMode );
1422 QPainter::CompositionMode featureBlendMode()
const;
1427 void setLayerTransparency(
int layerTransparency );
1431 int layerTransparency()
const;
1495 void removeSelection();
1497 void triggerRepaint();
1502 virtual void updateExtents();
1506 void checkJoinLayerRemove( QString theLayerId );
1509 void invalidateSymbolCountedFlag();
1523 void selectionChanged();
1526 void layerModified();
1529 void beforeModifiedCheck()
const;
1532 void editingStarted();
1535 void editingStopped();
1538 void beforeCommitChanges();
1541 void beforeRollBack();
1551 void attributeAdded(
int idx );
1560 void attributeDeleted(
int idx );
1569 void updatedFields();
1570 void layerDeleted();
1572 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant & );
1577 void committedAttributesDeleted(
const QString& layerId,
const QgsAttributeList& deletedAttributes );
1578 void committedAttributesAdded(
const QString& layerId,
const QList<QgsField>& addedAttributes );
1579 void committedFeaturesAdded(
const QString& layerId,
const QgsFeatureList& addedFeatures );
1580 void committedFeaturesRemoved(
const QString& layerId,
const QgsFeatureIds& deletedFeatureIds );
1581 void committedAttributeValuesChanges(
const QString& layerId,
const QgsChangedAttributesMap& changedAttributesValues );
1582 void committedGeometriesChanges(
const QString& layerId,
const QgsGeometryMap& changedGeometries );
1584 void saveLayerToProject();
1589 void labelingFontNotFound(
QgsVectorLayer* layer,
const QString& fontfamily );
1592 void featureBlendModeChanged(
const QPainter::CompositionMode &blendMode );
1595 void layerTransparencyChanged(
int layerTransparency );
1602 void editCommandStarted(
const QString& text );
1609 void editCommandEnded();
1616 void editCommandDestroyed();
1619 void onRelationsLoaded();
1637 bool setDataProvider( QString
const & provider );
1650 void snapToGeometry(
const QgsPoint& startPoint,
1653 double sqrSnappingTolerance,
1654 QMultiMap<double, QgsSnappingResult>& snappingResults,
1661 void readSldLabeling(
const QDomNode& node );
virtual bool isEditable() const
True if the layer can be edited.
EditorLayout mEditorLayout
Defines the default layout to use for the attribute editor (Drag and drop, UI File, Generated)
int mWkbType
Geometry type as defined in enum WkbType (qgis.h)
Wrapper for iterator of features from vector data provider or vector layer.
QString annotationForm() const
get annotation form (added in 1.5)
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
int mCurrentVertexMarkerSize
The current size of editing marker.
A rectangle specified with double values.
Base class for all map layer types.
QSet< QString > mExcludeAttributesWFS
Attributes which are not published in WFS.
QgsVectorLayer::FeatureFormSuppress mFeatureFormSuppress
Type of feature form suppression after feature creation.
QString joinFieldName
Join field in the source layer.
const QSet< QString > & excludeAttributesWMS() const
QgsVectorDataProvider * mDataProvider
Pointer to data provider derived from the abastract base class QgsDataProvider.
QgsVectorLayer::VertexMarkerType mCurrentVertexMarkerType
The current type of editing marker.
void setExcludeAttributesWFS(const QSet< QString > &att)
virtual QString metadata()
Obtain Metadata for this layer.
QString targetFieldName
Join field in the target layer.
virtual void drawLabels(QgsRenderContext &rendererContext)
Draw labels.
virtual bool isGroupBox() const
RangeData(QVariant theMin, QVariant theMax, QVariant theStep)
QgsAttributeAction * actions()
EditorLayout
The different types to layout the attribute editor.
QMap< QString, QgsEditorWidgetConfig > mEditorWidgetV2Configs
The attribute value should not be changed in the attribute form.
QSet< QgsFeatureId > QgsFeatureIds
QList< QgsFeature > QgsFeatureList
QList< QgsAttributeEditorElement * > mAttributeEditorElements
Stores a list of attribute editor elements (Each holding a tree structure for a tab in the attribute ...
void setExcludeAttributesWMS(const QSet< QString > &att)
QgsFeatureRendererV2 * mRendererV2
Renderer object which holds the information about how to display the features.
int joinFieldIndex
Join field index in the source layer.
virtual bool readSymbology(const QDomNode &node, QString &errorMessage)=0
Read the symbology for the current layer from the Dom node supplied.
Storage and management of actions associated with Qgis layer attributes.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
virtual void reload()
Synchronises with changes in the datasource.
VertexMarkerType
Editing vertex markers.
QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const
Type of feature form pop-up suppression after feature creation (overrides app setting) ...
SimplifyHint
Simplification flags for fast rendering of features.
QString mDisplayExpression
the preview expression used to generate a human readable preview string for features ...
Container of fields for a vector layer.
WkbType
Used for symbology operations.
QMap< QString, bool > mFieldEditables
virtual ~QgsAttributeEditorElement()
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context...
const QgsRelation & relation() const
bool memoryCache
True if the join is cached in virtual memory.
int targetFieldIndex
Join field index in the target layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
const QgsDiagramLayerSettings * diagramLayerSettings() const
QStringList mCommitErrors
QgsAttributeEditorField(QString name, int idx, QObject *parent)
TabData(QString name, QList< QString > fields, QList< GroupData > groups)
bool mVertexMarkerOnlyForSelection
Flag if the vertex markers should be drawn only for selection (true) or for all features (false) ...
virtual bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage) const =0
Write the symbology for the layer into the docment provided.
QgsGeometryCache * cache()
QgsAttributeEditorRelation(QString name, const QString &relationId, QObject *parent)
Returns diagram settings for a feature.
Manages joined fields for a vector layer.
virtual bool draw(QgsRenderContext &rendererContext)
This is the method that does the actual work of drawing the layer onto a paint device.
Perform transforms between map coordinates and device coordinates.
SnappingType
Snap to vertex, to segment or both.
QList< QgsAttributeEditorElement * > mChildren
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
bool mLabelFontNotFoundNotified
Whether 'labeling font not found' has be shown for this layer (only show once in QgsMessageBar, on first rendering)
QgsGeometryCache * mCache
cache for some vector layer data - currently only geometries for faster editing
virtual bool writeXml(QDomNode &layer_node, QDomDocument &document)
called by writeLayerXML(), used by children to write state specific to them to project files...
The attribute value should not be shown in the attribute form.
const QSet< QString > & excludeAttributesWFS() const
virtual void setExtent(const QgsRectangle &rect)
Set the extent.
~QgsAttributeEditorRelation()
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
AttributeEditorType type() const
bool mSymbolFeatureCounted
~QgsAttributeEditorField()
QgsVectorSimplifyMethod mSimplifyMethod
Simplification object which holds the information about how to simplify the features for fast renderi...
QgsDiagramLayerSettings * mDiagramLayerSettings
Encapsulate a field in an attribute table or data source.
QMap< QgsSymbolV2 *, long > mSymbolFeatureCountMap
const QMap< QString, QString > & attributeAliases() const
const QgsDiagramRendererV2 * diagramRenderer() const
A class to represent a point geometry.
virtual bool readSld(const QDomNode &node, QString &errorMessage)
QMap< QString, QString > mAttributeAliasMap
Map that stores the aliases for attributes.
QList< TabData > mTabs
Map that stores the tab for attributes in the edit form.
QList< QgsAttributeEditorElement * > children() const
QgsVectorLayerEditBuffer * mEditBuffer
stores information about uncommitted changes to layer
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
QgsMapLayer & operator=(QgsMapLayer const &)
private assign operator - QgsMapLayer not copyable
A class to render labels.
~QgsAttributeEditorContainer()
uuid generator - readonly and automatically intialized
QgsDiagramRendererV2 * mDiagramRenderer
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
ValueRelationData(QString layer, QString key, QString value, bool allowNull, bool orderByValue, bool allowMulti=false, QString filterExpression=QString::null)
QString mDisplayField
index of the primary label field
virtual QDomElement toDomElement(QDomDocument &doc) const =0
QSet< QString > mExcludeAttributesWMS
Attributes which are not published in WMS.
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) ...
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
QMap< QString, QString > mEditorWidgetV2Types
bool mLabelOn
Display labels.
QgsVectorLayerJoinBuffer * mJoinBuffer
GroupData(QString name, QList< QString > fields)
virtual void setIsGroupBox(bool isGroupBox)
This class manages a set of relations between layers.
virtual bool readXml(const QDomNode &layer_node)
called by readLayerXML(), used by children to read state specific to them from project files...
QString mFilterExpression
QgsAttributeEditorRelation(QString name, const QgsRelation &relation, QObject *parent)
QMap< QString, bool > mLabelOnTop
void setSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Set the simplification settings for fast rendering of features.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
void setFeatureFormSuppress(QgsVectorLayer::FeatureFormSuppress s)
Set type of feature form pop-up suppression after feature creation (overrides app setting) ...
int mLayerTransparency
Layer transparency.
virtual QString loadNamedStyle(const QString &theURI, bool &theResultFlag)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
QgsAttributeEditorElement(AttributeEditorType type, QString name, QObject *parent=NULL)
QSet< int > QgsAttributeIds
QgsAttributeEditorContainer(QString name, QObject *parent)
FeatureFormSuppress
Types of feature form suppression after feature creation.
This is the base class for vector data providers.
QList< int > QgsAttributeList
QgsFields mUpdatedFields
field map to commit
QPainter::CompositionMode mFeatureBlendMode
Blend mode for features.
virtual QgsRectangle extent()
Return the extent of the layer.
Represents a vector layer which manages a vector based data sets.
bool mReadOnly
Flag indicating whether the layer is in read-only mode (editing disabled) or not. ...
QgsFeatureIds mSelectedFeatureIds
Set holding the feature IDs that are activated.
QString joinLayerId
Source layer.
AttributeEditorType mType
Abstract base class for simplify geometries using a specific algorithm.
QString mProviderKey
Data provider key.
QgsAttributeAction * mActions
The user-defined actions that are accessed from the Identify Results dialog box.
QList< GroupData > mGroups