mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
- sync sip binding of QgsVectorLayer
- [API] introduce signal QgsVectorLayer::beforeRollBack() - merge consecutive geometry changes (fixes #7929) - avoid validation in nodetool on rollback
This commit is contained in:
parent
798d17b12a
commit
59788cb8fc
@ -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;
|
||||
@ -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:
|
||||
|
@ -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,
|
||||
@ -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 );
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -218,7 +249,11 @@ 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();
|
||||
|
||||
/**
|
||||
@ -226,6 +261,8 @@ class QgsVectorLayer : QgsMapLayer
|
||||
*
|
||||
* @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 );
|
||||
|
||||
@ -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 */
|
||||
@ -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 );
|
||||
@ -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
|
||||
*/
|
||||
@ -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.
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
@ -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 & );
|
||||
|
@ -112,6 +112,9 @@ void QgsSelectedFeature::setSelectedFeature( QgsFeatureId featureId, QgsVectorLa
|
||||
// feature was deleted
|
||||
connect( mVlayer, SIGNAL( featureDeleted( QgsFeatureId ) ), this, SLOT( featureDeleted( QgsFeatureId ) ) );
|
||||
|
||||
// rolling back
|
||||
connect( mVlayer, SIGNAL( beforeRollBack() ), this, SLOT( beforeRollBack() ) );
|
||||
|
||||
// projection or extents changed
|
||||
connect( canvas->mapRenderer(), SIGNAL( destinationSrsChanged() ), this, SLOT( updateVertexMarkersPosition() ) );
|
||||
connect( canvas, SIGNAL( extentsChanged() ), this, SLOT( updateVertexMarkersPosition() ) );
|
||||
@ -122,6 +125,13 @@ void QgsSelectedFeature::setSelectedFeature( QgsFeatureId featureId, QgsVectorLa
|
||||
replaceVertexMap();
|
||||
}
|
||||
|
||||
void QgsSelectedFeature::beforeRollBack()
|
||||
{
|
||||
QgsDebugCall;
|
||||
disconnect( mVlayer, SIGNAL( geometryChanged( QgsFeatureId, QgsGeometry & ) ), this, SLOT( geometryChanged( QgsFeatureId, QgsGeometry & ) ) );
|
||||
deleteVertexMap();
|
||||
}
|
||||
|
||||
void QgsSelectedFeature::beginGeometryChange()
|
||||
{
|
||||
Q_ASSERT( !mChangingGeometry );
|
||||
@ -163,6 +173,7 @@ void QgsSelectedFeature::geometryChanged( QgsFeatureId fid, QgsGeometry &geom )
|
||||
|
||||
void QgsSelectedFeature::validateGeometry( QgsGeometry *g )
|
||||
{
|
||||
QgsDebugCall;
|
||||
QSettings settings;
|
||||
if ( settings.value( "/qgis/digitizing/validate_geometries", 1 ).toInt() == 0 )
|
||||
return;
|
||||
@ -293,6 +304,9 @@ void QgsSelectedFeature::deleteSelectedVertexes()
|
||||
}
|
||||
}
|
||||
|
||||
if ( nSelected > 0 )
|
||||
endGeometryChange();
|
||||
|
||||
if ( count > 0 )
|
||||
{
|
||||
mVlayer->endEditCommand();
|
||||
@ -356,6 +370,9 @@ void QgsSelectedFeature::moveSelectedVertexes( const QgsVector &v )
|
||||
}
|
||||
}
|
||||
|
||||
if ( nUpdates > 0 )
|
||||
endGeometryChange();
|
||||
|
||||
mVlayer->endEditCommand();
|
||||
}
|
||||
|
||||
|
@ -170,6 +170,11 @@ class QgsSelectedFeature: public QObject
|
||||
*/
|
||||
void canvasLayersChanged();
|
||||
|
||||
/*
|
||||
* the changes are rolling back - stop monitoring the geometry
|
||||
*/
|
||||
void beforeRollBack();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Deletes whole vertex map.
|
||||
|
@ -2609,6 +2609,8 @@ bool QgsVectorLayer::rollBack( bool deleteBuffer )
|
||||
return false;
|
||||
}
|
||||
|
||||
emit beforeRollBack();
|
||||
|
||||
mEditBuffer->rollBack();
|
||||
|
||||
if ( isModified() )
|
||||
|
@ -1101,6 +1101,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
|
||||
/** return string representing 'true' for a checkbox (added in 1.4)
|
||||
* @note not available in python bindings
|
||||
* FIXME: need SIP binding for QPair<QString, QString>
|
||||
*/
|
||||
QPair<QString, QString> checkedState( int idx );
|
||||
|
||||
@ -1304,6 +1305,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
|
||||
QString metadata();
|
||||
|
||||
/** @note not available in python bindings */
|
||||
inline QgsGeometryCache* cache() { return mCache; }
|
||||
|
||||
/**
|
||||
@ -1338,6 +1340,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
/** 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}
|
||||
|
@ -24,9 +24,6 @@
|
||||
#include "qgslogger.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QgsVectorLayerUndoCommandAddFeature::QgsVectorLayerUndoCommandAddFeature( QgsVectorLayerEditBuffer* buffer, QgsFeature& f )
|
||||
: QgsVectorLayerUndoCommand( buffer )
|
||||
{
|
||||
@ -115,10 +112,9 @@ void QgsVectorLayerUndoCommandDeleteFeature::redo()
|
||||
|
||||
|
||||
QgsVectorLayerUndoCommandChangeGeometry::QgsVectorLayerUndoCommandChangeGeometry( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid, QgsGeometry* newGeom )
|
||||
: QgsVectorLayerUndoCommand( buffer ),
|
||||
mFid( fid )
|
||||
: QgsVectorLayerUndoCommand( buffer )
|
||||
, mFid( fid )
|
||||
{
|
||||
|
||||
if ( FID_IS_NEW( mFid ) )
|
||||
{
|
||||
QgsFeatureMap::const_iterator it = mBuffer->mAddedFeatures.find( mFid );
|
||||
@ -136,6 +132,28 @@ QgsVectorLayerUndoCommandChangeGeometry::QgsVectorLayerUndoCommandChangeGeometry
|
||||
mNewGeom = new QgsGeometry( *newGeom );
|
||||
}
|
||||
|
||||
int QgsVectorLayerUndoCommandChangeGeometry::id() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool QgsVectorLayerUndoCommandChangeGeometry::mergeWith( const QUndoCommand *other )
|
||||
{
|
||||
if ( other->id() != id() )
|
||||
return false;
|
||||
|
||||
const QgsVectorLayerUndoCommandChangeGeometry *merge = dynamic_cast<const QgsVectorLayerUndoCommandChangeGeometry *>( other );
|
||||
if ( !merge )
|
||||
return false;
|
||||
|
||||
delete mNewGeom;
|
||||
mNewGeom = merge->mNewGeom;
|
||||
merge->mNewGeom = 0;
|
||||
|
||||
QgsDebugMsg( "geometry changes merged" );
|
||||
return true;
|
||||
}
|
||||
|
||||
QgsVectorLayerUndoCommandChangeGeometry::~QgsVectorLayerUndoCommandChangeGeometry()
|
||||
{
|
||||
delete mOldGeom;
|
||||
@ -197,17 +215,13 @@ void QgsVectorLayerUndoCommandChangeGeometry::redo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QgsVectorLayerUndoCommandChangeAttribute::QgsVectorLayerUndoCommandChangeAttribute( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid, int fieldIndex, const QVariant& newValue )
|
||||
: QgsVectorLayerUndoCommand( buffer ),
|
||||
mFid( fid ),
|
||||
mFieldIndex( fieldIndex ),
|
||||
mNewValue( newValue ),
|
||||
mFirstChange( true )
|
||||
: QgsVectorLayerUndoCommand( buffer )
|
||||
, mFid( fid )
|
||||
, mFieldIndex( fieldIndex )
|
||||
, mNewValue( newValue )
|
||||
, mFirstChange( true )
|
||||
{
|
||||
|
||||
if ( FID_IS_NEW( mFid ) )
|
||||
{
|
||||
// work with added feature
|
||||
@ -293,13 +307,9 @@ void QgsVectorLayerUndoCommandChangeAttribute::redo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QgsVectorLayerUndoCommandAddAttribute::QgsVectorLayerUndoCommandAddAttribute( QgsVectorLayerEditBuffer* buffer, const QgsField& field )
|
||||
: QgsVectorLayerUndoCommand( buffer ),
|
||||
mField( field )
|
||||
: QgsVectorLayerUndoCommand( buffer )
|
||||
, mField( field )
|
||||
{
|
||||
mFieldIndex = layer()->pendingFields().count();
|
||||
}
|
||||
@ -325,12 +335,9 @@ void QgsVectorLayerUndoCommandAddAttribute::redo()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QgsVectorLayerUndoCommandDeleteAttribute::QgsVectorLayerUndoCommandDeleteAttribute( QgsVectorLayerEditBuffer* buffer, int fieldIndex )
|
||||
: QgsVectorLayerUndoCommand( buffer ),
|
||||
mFieldIndex( fieldIndex )
|
||||
: QgsVectorLayerUndoCommand( buffer )
|
||||
, mFieldIndex( fieldIndex )
|
||||
{
|
||||
const QgsFields& fields = layer()->pendingFields();
|
||||
QgsFields::FieldOrigin origin = fields.fieldOrigin( mFieldIndex );
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "qgsfield.h"
|
||||
#include "qgsfeature.h"
|
||||
#include "qgslogger.h"
|
||||
|
||||
class QgsGeometry;
|
||||
class QgsGeometryCache;
|
||||
@ -35,9 +36,15 @@ class QgsGeometryCache;
|
||||
class QgsVectorLayerUndoCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
QgsVectorLayerUndoCommand( QgsVectorLayerEditBuffer* buffer ) : mBuffer( buffer ) {}
|
||||
inline QgsVectorLayer* layer() { return mBuffer->L; }
|
||||
inline QgsGeometryCache* cache() { return mBuffer->L->cache(); }
|
||||
QgsVectorLayerUndoCommand( QgsVectorLayerEditBuffer *buffer )
|
||||
: QUndoCommand()
|
||||
, mBuffer( buffer )
|
||||
{}
|
||||
inline QgsVectorLayer *layer() { return mBuffer->L; }
|
||||
inline QgsGeometryCache *cache() { return mBuffer->L->cache(); }
|
||||
|
||||
virtual int id() const { return -1; }
|
||||
virtual bool mergeWith( QUndoCommand * ) { return -1; }
|
||||
|
||||
protected:
|
||||
QgsVectorLayerEditBuffer* mBuffer;
|
||||
@ -79,11 +86,13 @@ class QgsVectorLayerUndoCommandChangeGeometry : public QgsVectorLayerUndoCommand
|
||||
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
virtual int id() const;
|
||||
virtual bool mergeWith( const QUndoCommand * );
|
||||
|
||||
private:
|
||||
QgsFeatureId mFid;
|
||||
QgsGeometry* mOldGeom;
|
||||
QgsGeometry* mNewGeom;
|
||||
mutable QgsGeometry* mNewGeom;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user