18 #ifndef QGSVECTORLAYER_H
19 #define QGSVECTORLAYER_H
24 #include <QStringList>
41 class QgsGeometryVertexIndex;
74 : QObject( parent ), mType( type ), mName( name ) {}
78 QString
name()
const {
return mName; }
81 virtual QDomElement toDomElement( QDomDocument& doc )
const = 0;
97 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
99 QList<QgsAttributeEditorElement*>
children()
const {
return mChildren; }
114 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
115 int idx()
const {
return mIdx; }
452 RangeData( QVariant theMin, QVariant theMax, QVariant theStep )
453 : mMin( theMin ), mMax( theMax ), mStep( theStep ) {}
463 ValueRelationData( QString layer, QString key, QString value,
bool allowNull,
bool orderByValue,
464 bool allowMulti =
false,
465 QString filterExpression = QString::null )
469 , mFilterExpression( filterExpression )
470 , mAllowNull( allowNull )
471 , mOrderByValue( orderByValue )
472 , mAllowMulti( allowMulti )
488 : mName( name ), mFields( fields ) {}
496 TabData( QString name , QList<QString> fields , QList<GroupData> groups )
497 : mName( name ), mFields( fields ), mGroups( groups ) {}
516 QgsVectorLayer( QString path = QString::null, QString baseName = QString::null,
517 QString providerLib = QString::null,
bool loadDefaultStyleFlag =
true );
523 QString storageType()
const;
526 QString capabilitiesString()
const;
529 QString dataComment()
const;
532 void setDisplayField( QString fldName =
"" );
535 const QString displayField()
const;
544 void setDisplayExpression(
const QString displayExpression );
554 const QString displayExpression();
565 void setProviderEncoding(
const QString& encoding );
568 void setCoordinateSystem();
577 void removeJoin(
const QString& joinLayerId );
580 const QList< QgsVectorJoinInfo >& vectorJoins()
const;
594 int selectedFeatureCount();
604 void select(
QgsRectangle & rect,
bool addToSelection );
620 void invertSelection();
694 bool hasGeometryType()
const;
700 QString providerType()
const;
705 virtual bool readXml(
const QDomNode& layer_node );
710 virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc );
720 virtual void saveStyleToDatabase( QString name, QString description,
721 bool useAsDefault, QString uiFileContent,
732 virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
733 QStringList &descriptions, QString &msgError );
738 virtual QString getStyleFromDatabase( QString styleId, QString &msgError );
746 virtual QString
loadNamedStyle(
const QString theURI,
bool &theResultFlag,
bool loadFromLocalDb );
752 virtual QString
loadNamedStyle(
const QString theURI,
bool &theResultFlag );
754 virtual bool applyNamedStyle( QString namedStyle , QString errorMsg );
767 bool readSymbology(
const QDomNode& node, QString& errorMessage );
775 bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const;
777 bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const;
778 bool readSld(
const QDomNode& node, QString& errorMessage );
787 virtual long featureCount()
const;
802 bool countSymbolFeatures(
bool showProgress =
true );
811 virtual bool setSubsetString( QString subset );
817 virtual QString subsetString();
829 bool addFeature(
QgsFeature& f,
bool alsoUpdateExtent =
true );
842 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
848 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
852 bool deleteVertex(
QgsFeatureId atFeatureId,
int atVertex );
857 bool deleteSelectedFeatures();
868 int addRing(
const QList<QgsPoint>& ring );
880 int addPart(
const QList<QgsPoint>& ring );
887 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
896 int splitFeatures(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
920 int addTopologicalPoints(
const QgsPoint& p );
927 int insertSegmentVerticesForSnap(
const QList<QgsSnappingResult>& snapResults );
930 void enableLabels(
bool on );
933 bool hasLabelsEnabled()
const;
941 virtual bool isReadOnly()
const;
944 virtual bool isModified()
const;
952 bool snapPoint(
QgsPoint& point,
double tolerance );
961 int snapWithContext(
const QgsPoint& startPoint,
962 double snappingTolerance,
963 QMultiMap < double, QgsSnappingResult > &snappingResults,
993 int pendingFeatureCount();
999 bool setReadOnly(
bool readonly =
true );
1002 bool startEditing();
1009 bool changeAttributeValue(
QgsFeatureId fid,
int field, QVariant value,
bool emitSignal =
true );
1014 bool addAttribute(
const QgsField &field );
1018 void addAttributeAlias(
int attIndex, QString aliasString );
1026 QList< QgsAttributeEditorElement* > &attributeEditorElements();
1029 void clearAttributeEditorWidgets();
1033 QString attributeAlias(
int attributeIndex )
const;
1037 QString attributeDisplayName(
int attributeIndex )
const;
1048 bool deleteAttribute(
int attr );
1057 bool deleteAttributes( QList<int> attrs );
1060 bool addFeatures(
QgsFeatureList features,
bool makeSelected =
true );
1080 bool commitChanges();
1081 const QStringList &commitErrors();
1086 bool rollBack(
bool deleteBuffer =
true );
1089 EditType editType(
int idx );
1092 void setEditType(
int idx, EditType edit );
1095 EditorLayout editorLayout();
1098 void setEditorLayout( EditorLayout editorLayout );
1101 void setCheckedState(
int idx, QString checked, QString notChecked );
1107 QPair<QString, QString> checkedState(
int idx );
1113 void setEditForm( QString ui );
1119 void setAnnotationForm(
const QString& ui );
1122 QString editFormInit();
1125 void setEditFormInit( QString
function );
1128 QMap<QString, QVariant> &valueMap(
int idx );
1131 RangeData &range(
int idx );
1136 ValueRelationData &valueRelation(
int idx );
1141 QString &dateFormat(
int idx );
1146 QSize &widgetSize(
int idx );
1151 bool fieldEditable(
int idx );
1156 bool labelOnTop(
int idx );
1161 void setFieldEditable(
int idx,
bool editable );
1166 void setLabelOnTop(
int idx,
bool onTop );
1175 void beginEditCommand( QString text );
1178 void endEditCommand();
1181 void destroyEditCommand();
1186 int fieldNameIndex(
const QString& fieldName )
const;
1203 void updateFields();
1207 void createJoinCaches();
1214 void uniqueValues(
int index, QList<QVariant> &uniqueValues,
int limit = -1 );
1218 QVariant minimumValue(
int index );
1222 QVariant maximumValue(
int index );
1227 void setFeatureBlendMode(
const QPainter::CompositionMode blendMode );
1231 QPainter::CompositionMode featureBlendMode()
const;
1236 void setLayerTransparency(
int layerTransparency );
1240 int layerTransparency()
const;
1284 void removeSelection();
1286 void triggerRepaint();
1291 virtual void updateExtents();
1295 void checkJoinLayerRemove( QString theLayerId );
1309 void invalidateSymbolCountedFlag();
1323 void selectionChanged();
1326 void layerModified();
1329 void editingStarted();
1332 void editingStopped();
1335 void beforeCommitChanges();
1338 void beforeRollBack();
1348 void attributeAdded(
int idx );
1357 void attributeDeleted(
int idx );
1366 void updatedFields();
1367 void layerDeleted();
1369 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant & );
1374 void committedAttributesDeleted(
const QString& layerId,
const QgsAttributeList& deletedAttributes );
1375 void committedAttributesAdded(
const QString& layerId,
const QList<QgsField>& addedAttributes );
1376 void committedFeaturesAdded(
const QString& layerId,
const QgsFeatureList& addedFeatures );
1377 void committedFeaturesRemoved(
const QString& layerId,
const QgsFeatureIds& deletedFeatureIds );
1378 void committedAttributeValuesChanges(
const QString& layerId,
const QgsChangedAttributesMap& changedAttributesValues );
1379 void committedGeometriesChanges(
const QString& layerId,
const QgsGeometryMap& changedGeometries );
1384 void labelingFontNotFound(
QgsVectorLayer* layer,
const QString& fontfamily );
1402 bool setDataProvider( QString
const & provider );
1415 void snapToGeometry(
const QgsPoint& startPoint,
1418 double sqrSnappingTolerance,
1419 QMultiMap<double, QgsSnappingResult>& snappingResults,
1426 static int currentVertexMarkerSize();
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.
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.
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.
virtual void reload()
Synchronises with changes in the datasource.
VertexMarkerType
Editing vertex markers.
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 ...
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.
A geometry is the spatial representation of a feature.
WkbType
Used for symbology operations.
QMap< QString, bool > mFieldEditables
virtual ~QgsAttributeEditorElement()
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
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.
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()
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
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)
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
QMap< QString, bool > mLabelOnTop
int mLayerTransparency
Layer transparency.
QgsAttributeEditorElement(AttributeEditorType type, QString name, QObject *parent=NULL)
QSet< int > QgsAttributeIds
QgsAttributeEditorContainer(QString name, QObject *parent)
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
QString mProviderKey
Data provider key.
QgsAttributeAction * mActions
The user-defined actions that are accessed from the Identify Results dialog box.
QList< GroupData > mGroups