18 #ifndef QGSVECTORLAYER_H
19 #define QGSVECTORLAYER_H
24 #include <QStringList>
51 class QgsGeometryVertexIndex;
81 : QObject( parent ), mType( type ), mName( name ) {}
85 QString
name()
const {
return mName; }
88 virtual QDomElement toDomElement( QDomDocument& doc )
const = 0;
100 , mIsGroupBox( true )
105 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
109 QList<QgsAttributeEditorElement*>
children()
const {
return mChildren; }
110 virtual QList<QgsAttributeEditorElement*> findElements( AttributeEditorType type )
const;
114 QList<QgsAttributeEditorElement*> mChildren;
126 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
127 int idx()
const {
return mIdx; }
139 , mRelationId( relationId ) {}
143 , mRelationId( relation.id() )
144 , mRelation( relation ) {}
148 virtual QDomElement
toDomElement( QDomDocument& doc )
const;
196 void setJoinFieldNamesSubset( QStringList* fieldNamesSubset ) { joinFieldsSubset = QSharedPointer<QStringList>( fieldNamesSubset ); }
520 RangeData() { mMin = QVariant( 0 ); mMax = QVariant( 5 ); mStep = QVariant( 1 );}
521 RangeData( QVariant theMin, QVariant theMax, QVariant theStep )
522 : mMin( theMin ), mMax( theMax ), mStep( theStep ) {}
532 ValueRelationData( QString layer, QString key, QString value,
bool allowNull,
bool orderByValue,
533 bool allowMulti =
false,
534 QString filterExpression = QString::null )
538 , mFilterExpression( filterExpression )
539 , mAllowNull( allowNull )
540 , mOrderByValue( orderByValue )
541 , mAllowMulti( allowMulti )
557 : mName( name ), mFields( fields ) {}
565 TabData( QString name, QList<QString> fields, QList<GroupData> groups )
566 : mName( name ), mFields( fields ), mGroups( groups ) {}
585 QgsVectorLayer( QString path = QString::null, QString baseName = QString::null,
586 QString providerLib = QString::null,
bool loadDefaultStyleFlag =
true );
592 QString storageType()
const;
595 QString capabilitiesString()
const;
598 QString dataComment()
const;
601 void setDisplayField( QString fldName =
"" );
604 const QString displayField()
const;
612 void setDisplayExpression(
const QString &displayExpression );
620 const QString displayExpression();
631 void setProviderEncoding(
const QString& encoding );
634 void setCoordinateSystem();
642 void removeJoin(
const QString& joinLayerId );
644 const QList< QgsVectorJoinInfo >& vectorJoins()
const;
654 void addExpressionField(
const QString& exp,
const QgsField& fld );
663 void removeExpressionField(
int index );
677 int selectedFeatureCount();
687 void select(
QgsRectangle & rect,
bool addToSelection );
703 void invertSelection();
780 bool hasGeometryType()
const;
786 QString providerType()
const;
791 virtual bool readXml(
const QDomNode& layer_node );
796 virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc );
806 virtual void saveStyleToDatabase( QString name, QString description,
807 bool useAsDefault, QString uiFileContent,
818 virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
819 QStringList &descriptions, QString &msgError );
824 virtual QString getStyleFromDatabase( QString styleId, QString &msgError );
832 virtual QString
loadNamedStyle(
const QString &theURI,
bool &theResultFlag,
bool loadFromLocalDb );
838 virtual QString
loadNamedStyle(
const QString &theURI,
bool &theResultFlag );
840 virtual bool applyNamedStyle( QString namedStyle, QString errorMsg );
853 bool readSymbology(
const QDomNode& node, QString& errorMessage );
861 bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const;
863 bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const;
864 bool readSld(
const QDomNode& node, QString& errorMessage );
873 virtual long featureCount()
const;
888 bool countSymbolFeatures(
bool showProgress =
true );
897 virtual bool setSubsetString( QString subset );
903 virtual QString subsetString();
915 bool addFeature(
QgsFeature& f,
bool alsoUpdateExtent =
true );
929 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
935 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
939 bool deleteVertex(
QgsFeatureId atFeatureId,
int atVertex );
944 bool deleteSelectedFeatures();
955 int addRing(
const QList<QgsPoint>& ring );
967 int addPart(
const QList<QgsPoint>& ring );
974 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
983 int splitParts(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
992 int splitFeatures(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
1018 int addTopologicalPoints(
const QgsPoint& p );
1025 int insertSegmentVerticesForSnap(
const QList<QgsSnappingResult>& snapResults );
1028 void enableLabels(
bool on );
1031 bool hasLabelsEnabled()
const;
1038 virtual bool isReadOnly()
const;
1041 virtual bool isModified()
const;
1049 bool snapPoint(
QgsPoint& point,
double tolerance );
1058 int snapWithContext(
const QgsPoint& startPoint,
1059 double snappingTolerance,
1060 QMultiMap < double, QgsSnappingResult > &snappingResults,
1092 int pendingFeatureCount();
1097 bool setReadOnly(
bool readonly =
true );
1100 bool startEditing();
1111 Q_DECL_DEPRECATED
bool changeAttributeValue(
QgsFeatureId fid,
int field, QVariant value,
bool emitSignal );
1123 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant() );
1128 bool addAttribute(
const QgsField &field );
1131 void addAttributeAlias(
int attIndex, QString aliasString );
1134 void remAttributeAlias(
int attIndex );
1148 const QString editorWidgetV2(
int fieldIdx )
const;
1159 const QString editorWidgetV2(
const QString& fieldName )
const;
1184 QList< QgsAttributeEditorElement* > &attributeEditorElements();
1188 void clearAttributeEditorWidgets();
1191 QString attributeAlias(
int attributeIndex )
const;
1194 QString attributeDisplayName(
int attributeIndex )
const;
1205 bool deleteAttribute(
int attr );
1214 bool deleteAttributes( QList<int> attrs );
1217 bool addFeatures(
QgsFeatureList features,
bool makeSelected =
true );
1237 bool commitChanges();
1238 const QStringList &commitErrors();
1243 bool rollBack(
bool deleteBuffer =
true );
1250 Q_DECL_DEPRECATED EditType editType(
int idx );
1257 Q_DECL_DEPRECATED
void setEditType(
int idx, EditType edit );
1260 EditorLayout editorLayout();
1263 void setEditorLayout( EditorLayout editorLayout );
1293 void setEditorWidgetV2(
int attrIdx,
const QString& widgetType );
1317 Q_DECL_DEPRECATED
void setCheckedState(
int idx, QString checked, QString notChecked );
1323 void setEditForm( QString ui );
1337 void setAnnotationForm(
const QString& ui );
1340 QString editFormInit();
1343 void setEditFormInit( QString
function );
1349 Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap(
int idx );
1356 Q_DECL_DEPRECATED RangeData range(
int idx );
1359 ValueRelationData valueRelation(
int idx );
1367 QList<QgsRelation> referencingRelations(
int idx );
1374 Q_DECL_DEPRECATED QString dateFormat(
int idx );
1381 Q_DECL_DEPRECATED QSize widgetSize(
int idx );
1384 bool fieldEditable(
int idx );
1387 bool labelOnTop(
int idx );
1390 void setFieldEditable(
int idx,
bool editable );
1393 void setLabelOnTop(
int idx,
bool onTop );
1402 void beginEditCommand( QString text );
1405 void endEditCommand();
1408 void destroyEditCommand();
1412 int fieldNameIndex(
const QString& fieldName )
const;
1428 void updateFields();
1431 void createJoinCaches();
1437 void uniqueValues(
int index, QList<QVariant> &uniqueValues,
int limit = -1 );
1440 QVariant minimumValue(
int index );
1443 QVariant maximumValue(
int index );
1446 void setFeatureBlendMode(
const QPainter::CompositionMode &blendMode );
1448 QPainter::CompositionMode featureBlendMode()
const;
1451 void setLayerTransparency(
int layerTransparency );
1453 int layerTransparency()
const;
1517 void removeSelection();
1522 virtual void updateExtents();
1525 void checkJoinLayerRemove( QString theLayerId );
1528 void invalidateSymbolCountedFlag();
1542 void selectionChanged();
1545 void layerModified();
1548 void beforeModifiedCheck()
const;
1551 void editingStarted();
1554 void editingStopped();
1557 void beforeCommitChanges();
1560 void beforeRollBack();
1570 void attributeAdded(
int idx );
1579 void attributeDeleted(
int idx );
1586 void updatedFields();
1587 void layerDeleted();
1589 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant & );
1593 void committedAttributesDeleted(
const QString& layerId,
const QgsAttributeList& deletedAttributes );
1594 void committedAttributesAdded(
const QString& layerId,
const QList<QgsField>& addedAttributes );
1595 void committedFeaturesAdded(
const QString& layerId,
const QgsFeatureList& addedFeatures );
1596 void committedFeaturesRemoved(
const QString& layerId,
const QgsFeatureIds& deletedFeatureIds );
1597 void committedAttributeValuesChanges(
const QString& layerId,
const QgsChangedAttributesMap& changedAttributesValues );
1598 void committedGeometriesChanges(
const QString& layerId,
const QgsGeometryMap& changedGeometries );
1600 void saveLayerToProject();
1603 void labelingFontNotFound(
QgsVectorLayer* layer,
const QString& fontfamily );
1606 void featureBlendModeChanged(
const QPainter::CompositionMode &blendMode );
1609 void layerTransparencyChanged(
int layerTransparency );
1616 void editCommandStarted(
const QString& text );
1623 void editCommandEnded();
1630 void editCommandDestroyed();
1641 void readCustomSymbology(
const QDomElement& element, QString& errorMessage );
1652 void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage )
const;
1655 void onRelationsLoaded();
1656 void onJoinedFieldsChanged();
1674 bool setDataProvider( QString
const & provider );
1687 void snapToGeometry(
const QgsPoint& startPoint,
1690 double sqrSnappingTolerance,
1691 QMultiMap<double, QgsSnappingResult>& snappingResults,
1698 void readSldLabeling(
const QDomNode& node );
1706 QString mDisplayField;
1709 QString mDisplayExpression;
1712 QString mProviderKey;
1730 QMap< QString, QString > mAttributeAliasMap;
1733 QList< QgsAttributeEditorElement* > mAttributeEditorElements;
1736 QSet<QString> mExcludeAttributesWMS;
1738 QSet<QString> mExcludeAttributesWFS;
1741 QList< TabData > mTabs;
1759 bool mLabelFontNotFoundNotified;
1762 QPainter::CompositionMode mFeatureBlendMode;
1765 int mLayerTransparency;
1771 int mCurrentVertexMarkerSize;
1774 bool mVertexMarkerOnlyForSelection;
1776 QStringList mCommitErrors;
1778 QMap< QString, bool> mFieldEditables;
1779 QMap< QString, bool> mLabelOnTop;
1781 QMap<QString, QString> mEditorWidgetV2Types;
1782 QMap<QString, QgsEditorWidgetConfig > mEditorWidgetV2Configs;
1785 EditorLayout mEditorLayout;
1787 QString mEditForm, mEditFormInit;
1794 QString mAnnotationForm;
1819 bool mSymbolFeatureCounted;
1822 QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;