Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- sync sip binding of QgsVectorLayer
- [API] introduce signal QgsVectorLayer::beforeRollBack()
- merge consecutive geometry changes (fixes #7929)
- avoid validation in nodetool on rollback
  • Loading branch information
jef-n committed May 29, 2013
1 parent 798d17b commit 59788cb
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 81 deletions.
10 changes: 5 additions & 5 deletions python/core/qgsmaplayer.sip
Expand Up @@ -86,13 +86,13 @@ class QgsMapLayer : QObject

void setKeywordList( const QString& kwdList );
const QString& keywordList() const;

/* Layer attribution information */
void setAttribution( const QString& attrib );
const QString& attribution() const;
void setAttributionUrl( const QString& attribUrl );
const QString& attributionUrl() const;

/* Layer metadataUrl information */
void setMetadataUrl( const QString& metaUrl );
const QString& metadataUrl() const;
Expand Down Expand Up @@ -323,11 +323,11 @@ class QgsMapLayer : QObject
* @note This method was added in QGIS 1.4 **/
void setCacheImage( QImage * thepImage /Transfer/ );

/* Returns the current blending mode for a layer
/* Returns the current blending mode for a layer
@note added in version 1.9*/
const QPainter::CompositionMode blendMode() const;
/* Sets the blending mode for a layer
@note added in version 1.9*/
/* Sets the blending mode for a layer
@note added in version 1.9*/
void setBlendMode( const QPainter::CompositionMode blendMode );

public slots:
Expand Down
208 changes: 162 additions & 46 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -88,7 +88,7 @@ class QgsVectorLayer : QgsMapLayer
%End

public:

/** The different types to layout the attribute editor. @note added in 1.9 */
enum EditorLayout
{
GeneratedLayout,
Expand Down Expand Up @@ -163,7 +163,19 @@ class QgsVectorLayer : QgsMapLayer
QList<QgsVectorLayer::GroupData> mGroups;
};

/** Constructor */
/** Constructor - creates a vector layer
*
* The QgsVectorLayer is constructed by instantiating a data provider. The provider
* interprets the supplied path (url) of the data source to connect to and access the
* data.
*
* @param path The path or url of the parameter. Typically this encodes
* parameters used by the data provider as url query items.
* @param baseName The name used to represent the layer in the legend
* @param providerLib The name of the data provider, eg "memory", "postgres"
* @param loadDefaultStyleFlag whether to load the default style
*
*/
QgsVectorLayer( QString path = QString::null, QString baseName = QString::null,
QString providerLib = QString::null, bool loadDefaultStyleFlag = true );

Expand All @@ -185,6 +197,25 @@ class QgsVectorLayer : QgsMapLayer
/** Returns the primary display field name used in the identify results dialog */
const QString displayField() const;

/** Set the preview expression, used to create a human readable preview string.
* Used e.g. in the attribute table feature list. Uses { @link QgsExpression }.
*
* @param displayExpression The expression which will be used to preview features
* for this layer
* @note added in 2.0
*/
void setDisplayExpression( const QString displayExpression );

/**
* Get the preview expression, used to create a human readable preview string.
* Uses { @link QgsExpression }
*
* @return The expression which will be used to preview features for this layer
*
* @note added in 2.0
*/
const QString displayExpression();

/** Returns the data provider */
QgsVectorDataProvider* dataProvider();

Expand Down Expand Up @@ -218,14 +249,20 @@ class QgsVectorLayer : QgsMapLayer

QgsAttributeAction *actions();

/** The number of features that are selected in this layer */
/**
* The number of features that are selected in this layer
*
* @return See description
*/
int selectedFeatureCount();

/**
* Select features found within the search rectangle (in layer's coordinates)
*
* @param rect The search rectangle
* @param addToSelection If set to true will not clear before selecting
*
* @see invertSelectionInRectangle(QgsRectangle & rect)
*/
void select( QgsRectangle & rect, bool addToSelection );

Expand All @@ -234,25 +271,53 @@ class QgsVectorLayer : QgsMapLayer
*
* @param selectIds Select these ids
* @param deselectIds Deselect these ids
*
* @see select(QgsFeatureIds)
* @see select(QgsFeatureId)
* @see deselect(QgsFeatureIds)
* @see deselect(QgsFeatureId)
*/
void modifySelection(QgsFeatureIds selectIds, QgsFeatureIds deselectIds );
void modifySelection( QgsFeatureIds selectIds, QgsFeatureIds deselectIds );

/** Select not selected features and deselect selected ones */
void invertSelection();

/** Select all the features */
void selectAll();

/** Invert selection of features found within the search rectangle (in layer's coordinates) */
/**
* Invert selection of features found within the search rectangle (in layer's coordinates)
*
* @param rect The rectangle in which the selection of features will be inverted
*
* @see invertSelection()
*/
void invertSelectionInRectangle( QgsRectangle & rect );

/** Get a copy of the user-selected features */
QList<QgsFeature> selectedFeatures();
/**
* Get a copy of the user-selected features
*
* @return A list of { @link QgsFeature } 's
*
* @see selectedFeaturesIds()
*/
QgsFeatureList selectedFeatures();

/** Return reference to identifiers of selected features */
/**
* Return reference to identifiers of selected features
*
* @return A list of { @link QgsFeatureId } 's
* @see selectedFeatures()
*/
const QgsFeatureIds &selectedFeaturesIds() const;

/** Change selection to the new set of features */
/**
* Change selection to the new set of features. Dismisses the current selection.
* Will emit the { @link selectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) } signal with the
* clearAndSelect flag set.
*
* @param ids The ids which will be the new selection
*/
void setSelectedFeatures( const QgsFeatureIds &ids );

/** Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned */
Expand All @@ -273,12 +338,12 @@ class QgsVectorLayer : QgsMapLayer
*/
void setRendererV2( QgsFeatureRendererV2* r /Transfer/ );

/** Draw layer with renderer V2.
/** Draw layer with renderer V2. QgsFeatureRenderer::startRender() needs to be called before using this method
* @note added in 1.4
*/
void drawRendererV2( QgsFeatureIterator &fit, QgsRenderContext& rendererContext, bool labeling );

/** Draw layer with renderer V2 using symbol levels.
/** Draw layer with renderer V2 using symbol levels. QgsFeatureRenderer::startRender() needs to be called before using this method
* @note added in 1.4
*/
void drawRendererV2Levels( QgsFeatureIterator &fit, QgsRenderContext& rendererContext, bool labeling );
Expand Down Expand Up @@ -321,9 +386,9 @@ class QgsVectorLayer : QgsMapLayer

/**
* Lists all the style in db split into related to the layer and not related to
* @param ids the QVector in which will be stored the style db ids
* @param names the QVector in which will be stored the style names
* @param descriptions the QVector in which will be stored the style descriptions
* @param ids the list in which will be stored the style db ids
* @param names the list in which will be stored the style names
* @param descriptions the list in which will be stored the style descriptions
* @param msgError
* @return the number of styles related to current layer
*/
Expand All @@ -335,7 +400,20 @@ class QgsVectorLayer : QgsMapLayer
*/
virtual QString getStyleFromDatabase( QString styleId, QString &msgError );

virtual QString loadNamedStyle( const QString theURI, bool &theResultFlag, bool loadFromLocalDb = false );
/**
* Load a named style from file/local db/datasource db
* @param theURI the URI of the style or the URI of the layer
* @param theResultFlag will be set to true if a named style is correctly loaded
* @param loadFromLocalDb if true forces to load from local db instead of datasource one
*/
virtual QString loadNamedStyle( const QString theURI, bool &theResultFlag, bool loadFromLocalDb );

/**
* Calls loadNamedStyle( theURI, theResultFlag, false );
* Retained for backward compatibility
*/
virtual QString loadNamedStyle( const QString theURI, bool &theResultFlag );

virtual bool applyNamedStyle( QString namedStyle , QString errorMsg );

/** convert a saved attribute editor element into a AttributeEditor structure as it's used internally.
Expand Down Expand Up @@ -758,25 +836,7 @@ class QgsVectorLayer : QgsMapLayer
@note this method was added in version 1.1
*/
QgsVectorOverlay* findOverlayByType( const QString& typeName );

/* Set the blending mode used for rendering each feature
* @note added in 2.0
*/
void setFeatureBlendMode( const QPainter::CompositionMode blendMode );
/* Returns the current blending mode for features
* @note added in 2.0
*/
const QPainter::CompositionMode featureBlendMode() const;

/* Set the transparency for the vector layer
* @note added in 2.0
*/
void setLayerTransparency( const int layerTransparency );
/* Returns the current transparency for the vector layer
* @note added in 2.0
*/
const int layerTransparency() const;


//! Buffer with uncommitted editing operations. Only valid after editing has been turned on.
QgsVectorLayerEditBuffer* editBuffer();

Expand Down Expand Up @@ -833,36 +893,66 @@ class QgsVectorLayer : QgsMapLayer
@note added in 1.7*/
QVariant maximumValue( int index );

/* Set the blending mode used for rendering each feature
* @note added in 2.0
*/
void setFeatureBlendMode( const QPainter::CompositionMode blendMode );
/* Returns the current blending mode for features
* @note added in 2.0
*/
QPainter::CompositionMode featureBlendMode() const;

/* Set the transparency for the vector layer
* @note added in 2.0
*/
void setLayerTransparency( int layerTransparency );
/* Returns the current transparency for the vector layer
* @note added in 2.0
*/
int layerTransparency() const;

public slots:
/**
* Select feature by its ID
*
* @param featureId The id of the feature to select
*
* @see select(QgsFeatureIds)
*/
void select( QgsFeatureId featureId );
void select( const QgsFeatureId &featureId );

/**
* Select features by their ID
*
* @param featureIds The ids of the features to select
*
* @see select(QgsFeatureId)
*/
void select( QgsFeatureIds featureIds );
void select( const QgsFeatureIds& featureIds );

/**
* Deselect feature by its ID
*
* @param featureId The id of the feature to deselect
*
* @see deselect(QgsFeatureIds)
*/
void deselect( QgsFeatureId featureId );
void deselect( const QgsFeatureId featureId );

/**
* Deselect features by their ID
*
* @param featureIds The ids of the features to deselect
*
* @see deselect(QgsFeatureId)
*/
void deselect( QgsFeatureIds featureIds );
void deselect( const QgsFeatureIds& featureIds );

/** Clear selection */
/**
* Clear selection
*
* @see setSelectedFeatures(const QgsFeatureIds&)
*/
void removeSelection();

void triggerRepaint();
Expand All @@ -878,45 +968,71 @@ class QgsVectorLayer : QgsMapLayer

QString metadata();

/** @note not available in python bindings */
// QgsGeometryCache* cache();

/**
* @brief Is called when the cache image is being deleted. Overwrite and use to clean up.
* @note added in 2.0
*/
virtual void onCacheImageDelete();

signals:

/**
* This signal is emitted when selection was changed
*
* @param selected Newly selected feature ids
* @param deselected Ids of all features which have previously been selected but are not any more
* @param clearAndSelect In case this is set to true, the old selection was dismissed and the new selection corresponds to selected
*/
void selectionChanged( const QgsFeatureIds selected, const QgsFeatureIds deselected, const bool clearAndSelect );

/** This signal is emitted when selection was changed */
void selectionChanged();

/** This signal is emitted when modifications has been done on layer */
void layerModified();

/** Is emitted, when editing on this layer has started*/
void editingStarted();

/** Is emitted, when edited changes successfully have been written to the data provider */
void editingStopped();

/** Is emitted, before changes are commited to the data provider */
void beforeCommitChanges();

/** Is emitted, before changes are rolled back*/
void beforeRollBack();

/**
* Will be emitted, when a new attribute has been added to this vector layer.
* Applies only to types {@link QgsFields::OriginEdit} and {@link QgsFields::OriginProvider}
*
* @param The index of the new attribute
* @param idx The index of the new attribute
*
* @see updatedFields()
*/
void attributeAdded( int idx );

/**
* Will be emitted, when an attribute has been deleted from this vector layer.
* Applies only to types {@link QgsFields::OriginEdit} and {@link QgsFields::OriginProvider}
*
* @param The index of the deleted attribute
* @param idx The index of the deleted attribute
*
* @see updatedFields()
*/
void attributeDeleted( int idx );
void featureAdded( QgsFeatureId fid ); // added in 1.7

void featureDeleted( QgsFeatureId fid );
/**
* Is emitted, whenever the fields available from this layer have been changed.
* This can be due to manually adding attributes or due to a join.
*
* @note Added in 2.0
*/
void updatedFields();

void featureDeleted( QgsFeatureId fid );
void layerDeleted();

void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
Expand Down

0 comments on commit 59788cb

Please sign in to comment.