Skip to content

Commit

Permalink
Add method to change the geometry for the feature shown in a QgsAttri…
Browse files Browse the repository at this point in the history
…buteForm
  • Loading branch information
nyalldawson committed Nov 23, 2022
1 parent 6d74da2 commit ff03e4c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion python/gui/auto_generated/qgsattributeform.sip.in
Expand Up @@ -269,7 +269,6 @@ Emitted when the user chooses to open the attribute table dialog with a filtered
.. versionadded:: 3.24
%End


public slots:

void changeAttribute( const QString &field, const QVariant &value, const QString &hintText = QString() );
Expand All @@ -279,6 +278,13 @@ Call this to change the content of a given attribute. Will update the editor(s)
:param field: The field to change
:param value: The new value
:param hintText: A hint text for non existent joined features
%End

void changeGeometry( const QgsGeometry &geometry );
%Docstring
Changes the ``geometry`` of the feature attached to the form.

.. versionadded:: 3.30
%End

void setFeature( const QgsFeature &feature );
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -289,6 +289,11 @@ void QgsAttributeForm::changeAttribute( const QString &field, const QVariant &va
}
}

void QgsAttributeForm::changeGeometry( const QgsGeometry &geometry )
{
mFeature.setGeometry( geometry );
}

void QgsAttributeForm::setFeature( const QgsFeature &feature )
{
mIsSettingFeature = true;
Expand Down
8 changes: 7 additions & 1 deletion src/gui/qgsattributeform.h
Expand Up @@ -282,7 +282,6 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
*/
void openFilteredFeaturesAttributeTable( const QString &filter );


public slots:

/**
Expand All @@ -294,6 +293,13 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
*/
void changeAttribute( const QString &field, const QVariant &value, const QString &hintText = QString() );

/**
* Changes the \a geometry of the feature attached to the form.
*
* \since QGIS 3.30
*/
void changeGeometry( const QgsGeometry &geometry );

/**
* Update all editors to correspond to a different feature.
*
Expand Down

0 comments on commit ff03e4c

Please sign in to comment.