QGIS API Documentation  2.99.0-Master (e077efd)
Classes | Public Types | Public Slots | Signals | Public Member Functions | Friends | List of all members
QgsAttributeForm Class Reference

#include <qgsattributeform.h>

Inheritance diagram for QgsAttributeForm:
Inheritance graph
[legend]

Public Types

enum  FilterType { ReplaceFilter, FilterAnd, FilterOr }
 Filter types. More...
 
enum  Mode { SingleEditMode, AddFeatureMode, MultiEditMode, SearchMode }
 Form modes. More...
 

Public Slots

void changeAttribute (const QString &field, const QVariant &value)
 Call this to change the content of a given attribute. More...
 
void refreshFeature ()
 reload current feature More...
 
void resetSearch ()
 Resets the search/filter form values. More...
 
void resetValues ()
 Sets all values to the values of the current feature. More...
 
bool save ()
 Save all the values from the editors to the layer. More...
 
void setFeature (const QgsFeature &feature)
 Update all editors to correspond to a different feature. More...
 

Signals

void attributeChanged (const QString &attribute, const QVariant &value)
 Notifies about changes of attributes. More...
 
void beforeSave (bool &ok)
 Will be emitted before the feature is saved. More...
 
void closed ()
 Emitted when the user selects the close option from the form's button bar. More...
 
void featureSaved (const QgsFeature &feature)
 Is emitted, when a feature is changed or added. More...
 
void filterExpressionSet (const QString &expression, QgsAttributeForm::FilterType type)
 Is emitted when a filter expression is set using the form. More...
 
void modeChanged (QgsAttributeForm::Mode mode)
 Emitted when the form changes mode. More...
 

Public Member Functions

 QgsAttributeForm (QgsVectorLayer *vl, const QgsFeature &feature=QgsFeature(), const QgsAttributeEditorContext &context=QgsAttributeEditorContext(), QWidget *parent=nullptr)
 
 ~QgsAttributeForm ()
 
void addInterface (QgsAttributeFormInterface *iface)
 Takes ownership. More...
 
void disconnectButtonBox ()
 Disconnects the button box (Ok/Cancel) from the accept/resetValues slots If this method is called, you have to create these connections from outside. More...
 
bool editable ()
 Returns if the form is currently in editable mode. More...
 
bool eventFilter (QObject *object, QEvent *event) override
 Intercepts keypress on custom form (escape should not close it) More...
 
const QgsFeaturefeature ()
 
void hideButtonBox ()
 Hides the button box (Ok/Cancel) and enables auto-commit. More...
 
QgsVectorLayerlayer ()
 Returns the layer for which this form is shown. More...
 
Mode mode () const
 Returns the current mode of the form. More...
 
void setEditCommandMessage (const QString &message)
 Sets the edit command message (Undo) that will be used when the dialog is accepted. More...
 
void setMessageBar (QgsMessageBar *messageBar)
 Sets the message bar to display feedback from the form in. More...
 
void setMode (Mode mode)
 Sets the current mode of the form. More...
 
void setMultiEditFeatureIds (const QgsFeatureIds &fids)
 Sets all feature IDs which are to be edited if the form is in multiedit mode. More...
 
void showButtonBox ()
 Shows the button box (Ok/Cancel) and disables auto-commit. More...
 

Friends

class TestQgsAttributeForm
 
class TestQgsDualView
 

Detailed Description

Definition at line 38 of file qgsattributeform.h.

Member Enumeration Documentation

§ FilterType

Filter types.

Enumerator
ReplaceFilter 

Filter should replace any existing filter.

FilterAnd 

Filter should be combined using "AND".

FilterOr 

Filter should be combined using "OR".

Definition at line 55 of file qgsattributeform.h.

§ Mode

Form modes.

Enumerator
SingleEditMode 

Single edit mode, for editing a single feature.

AddFeatureMode 

Add feature mode, for setting attributes for a new feature. In this mode the dialog will be editable even with an invalid feature and will add a new feature when the form is accepted.

MultiEditMode 

Multi edit mode, for editing fields of multiple features at once.

SearchMode 

Form values are used for searching/filtering the layer.

Definition at line 45 of file qgsattributeform.h.

Constructor & Destructor Documentation

§ QgsAttributeForm()

QgsAttributeForm::QgsAttributeForm ( QgsVectorLayer vl,
const QgsFeature feature = QgsFeature(),
const QgsAttributeEditorContext context = QgsAttributeEditorContext(),
QWidget *  parent = nullptr 
)
explicit

Definition at line 54 of file qgsattributeform.cpp.

§ ~QgsAttributeForm()

QgsAttributeForm::~QgsAttributeForm ( )

Definition at line 87 of file qgsattributeform.cpp.

Member Function Documentation

§ addInterface()

void QgsAttributeForm::addInterface ( QgsAttributeFormInterface iface)

Takes ownership.

Parameters
iface

Definition at line 115 of file qgsattributeform.cpp.

§ attributeChanged

void QgsAttributeForm::attributeChanged ( const QString &  attribute,
const QVariant &  value 
)
signal

Notifies about changes of attributes.

Parameters
attributeThe name of the attribute that changed.
valueThe new value of the attribute.

§ beforeSave

void QgsAttributeForm::beforeSave ( bool &  ok)
signal

Will be emitted before the feature is saved.

Use this signal to perform sanity checks. You can set the parameter ok to false to notify the form that you don't want it to be saved. If you want the form to be saved, leave the parameter untouched.

Parameters
okSet this parameter to false if you don't want the form to be saved
Note
not available in python bindings

§ changeAttribute

void QgsAttributeForm::changeAttribute ( const QString &  field,
const QVariant &  value 
)
slot

Call this to change the content of a given attribute.

Will update the editor(s) related to this field.

Parameters
fieldThe field to change
valueThe new value

Definition at line 223 of file qgsattributeform.cpp.

§ closed

void QgsAttributeForm::closed ( )
signal

Emitted when the user selects the close option from the form's button bar.

Note
added in QGIS 2.16

§ disconnectButtonBox()

void QgsAttributeForm::disconnectButtonBox ( )

Disconnects the button box (Ok/Cancel) from the accept/resetValues slots If this method is called, you have to create these connections from outside.

Definition at line 109 of file qgsattributeform.cpp.

§ editable()

bool QgsAttributeForm::editable ( )

Returns if the form is currently in editable mode.

Returns
Editable mode of this form

Definition at line 120 of file qgsattributeform.cpp.

§ eventFilter()

bool QgsAttributeForm::eventFilter ( QObject *  object,
QEvent *  event 
)
override

Intercepts keypress on custom form (escape should not close it)

Parameters
objectThe object for which the event has been sent
eventThe event which is being filtered
Returns
true if the event has been handled (key was ESC)

Definition at line 1761 of file qgsattributeform.cpp.

§ feature()

const QgsFeature& QgsAttributeForm::feature ( )
inline

Definition at line 66 of file qgsattributeform.h.

§ featureSaved

void QgsAttributeForm::featureSaved ( const QgsFeature feature)
signal

Is emitted, when a feature is changed or added.

§ filterExpressionSet

void QgsAttributeForm::filterExpressionSet ( const QString &  expression,
QgsAttributeForm::FilterType  type 
)
signal

Is emitted when a filter expression is set using the form.

Parameters
expressionfilter expression
typefilter type
Note
added in QGIS 2.16

§ hideButtonBox()

void QgsAttributeForm::hideButtonBox ( )

Hides the button box (Ok/Cancel) and enables auto-commit.

Note
set Embed in QgsAttributeEditorContext in constructor instead

Definition at line 93 of file qgsattributeform.cpp.

§ layer()

QgsVectorLayer* QgsAttributeForm::layer ( )
inline

Returns the layer for which this form is shown.

Returns
Layer

Definition at line 100 of file qgsattributeform.h.

§ mode()

Mode QgsAttributeForm::mode ( ) const
inline

Returns the current mode of the form.

Note
added in QGIS 2.16
See also
setMode()

Definition at line 113 of file qgsattributeform.h.

§ modeChanged

void QgsAttributeForm::modeChanged ( QgsAttributeForm::Mode  mode)
signal

Emitted when the form changes mode.

Parameters
modenew mode

§ refreshFeature

void QgsAttributeForm::refreshFeature ( )
slot

reload current feature

Definition at line 958 of file qgsattributeform.cpp.

§ resetSearch

void QgsAttributeForm::resetSearch ( )
slot

Resets the search/filter form values.

Note
added in QGIS 2.16

Definition at line 595 of file qgsattributeform.cpp.

§ resetValues

void QgsAttributeForm::resetValues ( )
slot

Sets all values to the values of the current feature.

Definition at line 587 of file qgsattributeform.cpp.

§ save

bool QgsAttributeForm::save ( )
slot

Save all the values from the editors to the layer.

Returns
True if successful

Definition at line 553 of file qgsattributeform.cpp.

§ setEditCommandMessage()

void QgsAttributeForm::setEditCommandMessage ( const QString &  message)
inline

Sets the edit command message (Undo) that will be used when the dialog is accepted.

Parameters
messageThe message

Definition at line 127 of file qgsattributeform.h.

§ setFeature

void QgsAttributeForm::setFeature ( const QgsFeature feature)
slot

Update all editors to correspond to a different feature.

Parameters
featureThe feature which will be represented by the form

Definition at line 235 of file qgsattributeform.cpp.

§ setMessageBar()

void QgsAttributeForm::setMessageBar ( QgsMessageBar messageBar)

Sets the message bar to display feedback from the form in.

This is used in the search/filter mode to display the count of selected features.

Parameters
messageBartarget message bar
Note
added in QGIS 2.16

Definition at line 1879 of file qgsattributeform.cpp.

§ setMode()

void QgsAttributeForm::setMode ( QgsAttributeForm::Mode  mode)

Sets the current mode of the form.

Parameters
modeform mode
Note
added in QGIS 2.16
See also
mode()

Definition at line 125 of file qgsattributeform.cpp.

§ setMultiEditFeatureIds()

void QgsAttributeForm::setMultiEditFeatureIds ( const QgsFeatureIds fids)

Sets all feature IDs which are to be edited if the form is in multiedit mode.

Parameters
fidsfeature ID list
Note
added in QGIS 2.16

Definition at line 1832 of file qgsattributeform.cpp.

§ showButtonBox()

void QgsAttributeForm::showButtonBox ( )

Shows the button box (Ok/Cancel) and disables auto-commit.

Note
set Embed in QgsAttributeEditorContext in constructor instead

Definition at line 102 of file qgsattributeform.cpp.

Friends And Related Function Documentation

§ TestQgsAttributeForm

friend class TestQgsAttributeForm
friend

Definition at line 386 of file qgsattributeform.h.

§ TestQgsDualView

friend class TestQgsDualView
friend

Definition at line 385 of file qgsattributeform.h.


The documentation for this class was generated from the following files: