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;
104 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
107 QList<QgsAttributeEditorElement*>
children()
const {
return mChildren; }
108 virtual QList<QgsAttributeEditorElement*> findElements( AttributeEditorType type )
const;
123 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
124 int idx()
const {
return mIdx; }
136 , mRelationId( relationId ) {}
140 , mRelationId( relation.id() )
141 , mRelation( relation ) {}
145 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
501 RangeData( QVariant theMin, QVariant theMax, QVariant theStep )
502 : mMin( theMin ), mMax( theMax ), mStep( theStep ) {}
512 ValueRelationData( QString layer, QString key, QString value,
bool allowNull,
bool orderByValue,
513 bool allowMulti =
false,
514 QString filterExpression = QString::null )
518 , mFilterExpression( filterExpression )
519 , mAllowNull( allowNull )
520 , mOrderByValue( orderByValue )
521 , mAllowMulti( allowMulti )
537 : mName( name ), mFields( fields ) {}
545 TabData( QString name , QList<QString> fields , QList<GroupData> groups )
546 : mName( name ), mFields( fields ), mGroups( groups ) {}
565 QgsVectorLayer( QString path = QString::null, QString baseName = QString::null,
566 QString providerLib = QString::null,
bool loadDefaultStyleFlag =
true );
572 QString storageType()
const;
575 QString capabilitiesString()
const;
578 QString dataComment()
const;
581 void setDisplayField( QString fldName =
"" );
584 const QString displayField()
const;
593 void setDisplayExpression(
const QString &displayExpression );
603 const QString displayExpression();
614 void setProviderEncoding(
const QString& encoding );
617 void setCoordinateSystem();
626 void removeJoin(
const QString& joinLayerId );
629 const QList< QgsVectorJoinInfo >& vectorJoins()
const;
643 int selectedFeatureCount();
653 void select(
QgsRectangle & rect,
bool addToSelection );
669 void invertSelection();
746 bool hasGeometryType()
const;
752 QString providerType()
const;
757 virtual bool readXml(
const QDomNode& layer_node );
762 virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc );
772 virtual void saveStyleToDatabase( QString name, QString description,
773 bool useAsDefault, QString uiFileContent,
784 virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
785 QStringList &descriptions, QString &msgError );
790 virtual QString getStyleFromDatabase( QString styleId, QString &msgError );
798 virtual QString
loadNamedStyle(
const QString &theURI,
bool &theResultFlag,
bool loadFromLocalDb );
804 virtual QString
loadNamedStyle(
const QString &theURI,
bool &theResultFlag );
806 virtual bool applyNamedStyle( QString namedStyle , QString errorMsg );
819 bool readSymbology(
const QDomNode& node, QString& errorMessage );
827 bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const;
829 bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const;
830 bool readSld(
const QDomNode& node, QString& errorMessage );
839 virtual long featureCount()
const;
854 bool countSymbolFeatures(
bool showProgress =
true );
863 virtual bool setSubsetString( QString subset );
869 virtual QString subsetString();
881 bool addFeature(
QgsFeature& f,
bool alsoUpdateExtent =
true );
896 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
902 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
906 bool deleteVertex(
QgsFeatureId atFeatureId,
int atVertex );
911 bool deleteSelectedFeatures();
922 int addRing(
const QList<QgsPoint>& ring );
934 int addPart(
const QList<QgsPoint>& ring );
941 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
950 int splitParts(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
959 int splitFeatures(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
985 int addTopologicalPoints(
const QgsPoint& p );
992 int insertSegmentVerticesForSnap(
const QList<QgsSnappingResult>& snapResults );
995 void enableLabels(
bool on );
998 bool hasLabelsEnabled()
const;
1006 virtual bool isReadOnly()
const;
1009 virtual bool isModified()
const;
1017 bool snapPoint(
QgsPoint& point,
double tolerance );
1026 int snapWithContext(
const QgsPoint& startPoint,
1027 double snappingTolerance,
1028 QMultiMap < double, QgsSnappingResult > &snappingResults,
1058 int pendingFeatureCount();
1064 bool setReadOnly(
bool readonly =
true );
1067 bool startEditing();
1079 Q_DECL_DEPRECATED
bool changeAttributeValue(
QgsFeatureId fid,
int field, QVariant value,
bool emitSignal );
1091 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant() );
1096 bool addAttribute(
const QgsField &field );
1102 void addAttributeAlias(
int attIndex, QString aliasString );
1117 const QString editorWidgetV2(
int fieldIdx );
1132 QList< QgsAttributeEditorElement* > &attributeEditorElements();
1137 void clearAttributeEditorWidgets();
1143 QString attributeAlias(
int attributeIndex )
const;
1149 QString attributeDisplayName(
int attributeIndex )
const;
1160 bool deleteAttribute(
int attr );
1169 bool deleteAttributes( QList<int> attrs );
1172 bool addFeatures(
QgsFeatureList features,
bool makeSelected =
true );
1192 bool commitChanges();
1193 const QStringList &commitErrors();
1198 bool rollBack(
bool deleteBuffer =
true );
1201 EditType editType(
int idx );
1204 void setEditType(
int idx, EditType edit );
1207 EditorLayout editorLayout();
1210 void setEditorLayout( EditorLayout editorLayout );
1212 void setEditorWidgetV2(
int attrIdx,
const QString& widgetType );
1214 void setEditorWidgetV2Config(
int attrIdx,
const QMap<QString, QVariant>& config );
1217 void setCheckedState(
int idx, QString checked, QString notChecked );
1223 QPair<QString, QString> checkedState(
int idx );
1229 void setEditForm( QString ui );
1243 void setAnnotationForm(
const QString& ui );
1246 QString editFormInit();
1249 void setEditFormInit( QString
function );
1252 QMap<QString, QVariant> &valueMap(
int idx );
1255 RangeData &range(
int idx );
1260 ValueRelationData &valueRelation(
int idx );
1268 QList<QgsRelation> referencingRelations(
int idx );
1273 QString &dateFormat(
int idx );
1278 QSize &widgetSize(
int idx );
1283 bool fieldEditable(
int idx );
1288 bool labelOnTop(
int idx );
1293 void setFieldEditable(
int idx,
bool editable );
1298 void setLabelOnTop(
int idx,
bool onTop );
1307 void beginEditCommand( QString text );
1310 void endEditCommand();
1313 void destroyEditCommand();
1318 int fieldNameIndex(
const QString& fieldName )
const;
1335 void updateFields();
1339 void createJoinCaches();
1346 void uniqueValues(
int index, QList<QVariant> &uniqueValues,
int limit = -1 );
1350 QVariant minimumValue(
int index );
1354 QVariant maximumValue(
int index );
1359 void setFeatureBlendMode(
const QPainter::CompositionMode &blendMode );
1363 QPainter::CompositionMode featureBlendMode()
const;
1368 void setLayerTransparency(
int layerTransparency );
1372 int layerTransparency()
const;
1436 void removeSelection();
1438 void triggerRepaint();
1443 virtual void updateExtents();
1447 void checkJoinLayerRemove( QString theLayerId );
1456 void invalidateSymbolCountedFlag();
1470 void selectionChanged();
1473 void layerModified();
1476 void editingStarted();
1479 void editingStopped();
1482 void beforeCommitChanges();
1485 void beforeRollBack();
1495 void attributeAdded(
int idx );
1504 void attributeDeleted(
int idx );
1513 void updatedFields();
1514 void layerDeleted();
1516 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant & );
1521 void committedAttributesDeleted(
const QString& layerId,
const QgsAttributeList& deletedAttributes );
1522 void committedAttributesAdded(
const QString& layerId,
const QList<QgsField>& addedAttributes );
1523 void committedFeaturesAdded(
const QString& layerId,
const QgsFeatureList& addedFeatures );
1524 void committedFeaturesRemoved(
const QString& layerId,
const QgsFeatureIds& deletedFeatureIds );
1525 void committedAttributeValuesChanges(
const QString& layerId,
const QgsChangedAttributesMap& changedAttributesValues );
1526 void committedGeometriesChanges(
const QString& layerId,
const QgsGeometryMap& changedGeometries );
1528 void saveLayerToProject();
1533 void labelingFontNotFound(
QgsVectorLayer* layer,
const QString& fontfamily );
1536 void rendererChanged();
1539 void featureBlendModeChanged(
const QPainter::CompositionMode &blendMode );
1542 void layerTransparencyChanged(
int layerTransparency );
1549 void editCommandStarted(
const QString& text );
1556 void editCommandEnded();
1563 void editCommandDestroyed();
1566 void onRelationsLoaded();
1584 bool setDataProvider( QString
const & provider );
1597 void snapToGeometry(
const QgsPoint& startPoint,
1600 double sqrSnappingTolerance,
1601 QMultiMap<double, QgsSnappingResult>& snappingResults,
1608 static int currentVertexMarkerSize();
1623 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.
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.
bool mEnableBackbuffer
Enables backbuffering for the map window.
WkbType
Used for symbology operations.
QMap< QString, bool > mFieldEditables
virtual ~QgsAttributeEditorElement()
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()
QgsFeatureIterator mProviderIterator
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.
QMap< int, QString > mEditorWidgetV2Types
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
QMap< QString, QPair< QString, QString > > mCheckedStates
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
QgsMapLayer & operator=(QgsMapLayer const &)
private assign operator - QgsMapLayer not copyable
QMap< QString, RangeData > mRanges
A class to render labels.
QMap< QString, EditType > mEditTypes
~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
QMap< QString, QSize > mWidgetSize
QgsRenderContext * mCurrentRendererContext
virtual QDomElement toDomElement(QDomDocument &doc) const =0
QSet< QString > mExcludeAttributesWMS
Attributes which are not published in WMS.
QMap< QString, ValueRelationData > mValueRelations
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) ...
QMap< QString, QMap< QString, QVariant > > mValueMaps
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
bool mLabelOn
Display labels.
QgsVectorLayerJoinBuffer * mJoinBuffer
virtual void onCacheImageDelete()
Is called when the cache image is being deleted.
GroupData(QString name, QList< QString > fields)
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
QMap< QString, QString > mDateFormats
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.
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
QMap< int, QMap< QString, QVariant > > mEditorWidgetV2Configs
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
int mUpdateThreshold
Update threshold for drawing features as they are read.
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