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 );