QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Slots | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
QgsAttributeForm Class Reference

#include <qgsattributeform.h>

Collaboration diagram for QgsAttributeForm:
Collaboration graph
[legend]

Public Slots

void changeAttribute (const QString &field, const QVariant &value)
 Call this to change the content of a given attribute.
void setFeature (const QgsFeature &feature)
 Update all editors to correspond to a different feature.
bool save ()
 Save all the values from the editors to the layer.
Q_DECL_DEPRECATED void accept ()
 Alias for save()
Q_DECL_DEPRECATED void reject ()
 Alias for resetValues()
void resetValues ()
 Sets all values to the values of the current feature.

Signals

void attributeChanged (QString attribute, const QVariant &value)
 Notifies about changes of attributes.
void beforeSave (bool &ok)
 Will be emitted before the feature is saved.
void featureSaved (const QgsFeature &feature)
 Is emitted, when a feature is changed or added.

Public Member Functions

 QgsAttributeForm (QgsVectorLayer *vl, const QgsFeature feature=QgsFeature(), QgsAttributeEditorContext context=QgsAttributeEditorContext(), QWidget *parent=0)
 ~QgsAttributeForm ()
const QgsFeaturefeature ()
void hideButtonBox ()
 Hides the button box (Ok/Cancel) and enables auto-commit.
void showButtonBox ()
 Shows the button box (Ok/Cancel) and disables auto-commit.
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.
void addInterface (QgsAttributeFormInterface *iface)
 Takes ownership.
QgsVectorLayerlayer ()
 Returns the layer for which this form is shown.
bool editable ()
 Returns if the form is currently in editable mode.
void setIsAddDialog (bool isAddDialog)
 Toggles the form mode between edit feature and add feature.
void setEditCommandMessage (const QString &message)
 Sets the edit command message (Undo) that will be used when the dialog is accepted.
bool eventFilter (QObject *object, QEvent *event)
 Intercepts keypress on custom form (escape should not close it)

Private Slots

void onAttributeChanged (const QVariant &value)
void onAttributeAdded (int idx)
void onAttributeDeleted (int idx)
void synchronizeEnabledState ()

Private Member Functions

void init ()
void cleanPython ()
void initPython ()
QWidget * createWidgetFromDef (const QgsAttributeEditorElement *widgetDef, QWidget *parent, QgsVectorLayer *vl, QgsAttributeEditorContext &context, QString &labelText, bool &labelOnTop)
void addWidgetWrapper (QgsEditorWidgetWrapper *eww)
void createWrappers ()
 Creates widget wrappers for all suitable widgets found.
void connectWrappers ()

Private Attributes

QgsVectorLayermLayer
QgsFeature mFeature
QList< QgsWidgetWrapper * > mWidgets
QgsAttributeEditorContext mContext
QDialogButtonBox * mButtonBox
QList
< QgsAttributeFormInterface * > 
mInterfaces
int mFormNr
QString mPyFormVarName
bool mIsSaving
 Set to true while saving to prevent recursive saves.
bool mIsAddDialog
QString mEditCommandMessage

Static Private Attributes

static int sFormCounter = 0

Detailed Description

Definition at line 29 of file qgsattributeform.h.

Constructor & Destructor Documentation

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

Definition at line 57 of file qgsattributeform.cpp.

References cleanPython(), and mInterfaces.

Member Function Documentation

Q_DECL_DEPRECATED void QgsAttributeForm::accept ( )
inlineslot

Alias for save()

Deprecated:

Definition at line 153 of file qgsattributeform.h.

Referenced by disconnectButtonBox(), and init().

void QgsAttributeForm::addInterface ( QgsAttributeFormInterface iface)

Takes ownership.

Parameters
iface

Definition at line 85 of file qgsattributeform.cpp.

References mInterfaces.

Referenced by initPython().

void QgsAttributeForm::addWidgetWrapper ( QgsEditorWidgetWrapper eww)
private

Definition at line 644 of file qgsattributeform.cpp.

References QgsEditorWidgetWrapper::field(), and mWidgets.

Referenced by createWidgetFromDef(), createWrappers(), and init().

void QgsAttributeForm::attributeChanged ( 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.

Referenced by onAttributeChanged().

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

Referenced by save().

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 102 of file qgsattributeform.cpp.

References QgsEditorWidgetWrapper::field(), mWidgets, QgsField::name(), and QgsEditorWidgetWrapper::setValue().

void QgsAttributeForm::cleanPython ( )
private

Definition at line 463 of file qgsattributeform.cpp.

References mPyFormVarName, and QgsPythonRunner::run().

Referenced by initPython(), and ~QgsAttributeForm().

void QgsAttributeForm::connectWrappers ( )
private

Definition at line 702 of file qgsattributeform.cpp.

References mWidgets, onAttributeChanged(), and QgsWidgetWrapper::widget().

Referenced by init().

QWidget * QgsAttributeForm::createWidgetFromDef ( const QgsAttributeEditorElement widgetDef,
QWidget *  parent,
QgsVectorLayer vl,
QgsAttributeEditorContext context,
QString &  labelText,
bool &  labelOnTop 
)
private
void QgsAttributeForm::createWrappers ( )
private
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 79 of file qgsattributeform.cpp.

References accept(), mButtonBox, and resetValues().

Referenced by QgsAttributeDialog::init().

bool QgsAttributeForm::editable ( )

Returns if the form is currently in editable mode.

Returns
Editable mode of this form

Definition at line 90 of file qgsattributeform.cpp.

References QgsVectorLayer::isEditable(), QgsFeature::isValid(), mFeature, and mLayer.

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

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 724 of file qgsattributeform.cpp.

const QgsFeature& QgsAttributeForm::feature ( )
inline

Definition at line 37 of file qgsattributeform.h.

Referenced by QgsAttributeFormInterface::feature(), and setFeature().

void QgsAttributeForm::featureSaved ( const QgsFeature feature)
signal

Is emitted, when a feature is changed or added.

Referenced by save().

void QgsAttributeForm::hideButtonBox ( )

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

Definition at line 63 of file qgsattributeform.cpp.

References mButtonBox, mIsAddDialog, mLayer, and save().

Referenced by QgsDualView::init(), and QgsAttributeDialog::QgsAttributeDialog().

void QgsAttributeForm::init ( )
private
void QgsAttributeForm::initPython ( )
private
QgsVectorLayer* QgsAttributeForm::layer ( )
inline

Returns the layer for which this form is shown.

Returns
Layer

Definition at line 66 of file qgsattributeform.h.

Referenced by onAttributeAdded(), onAttributeDeleted(), and QgsAttributeFormLegacyInterface::QgsAttributeFormLegacyInterface().

void QgsAttributeForm::onAttributeAdded ( int  idx)
privateslot
void QgsAttributeForm::onAttributeChanged ( const QVariant &  value)
privateslot
void QgsAttributeForm::onAttributeDeleted ( int  idx)
privateslot
Q_DECL_DEPRECATED void QgsAttributeForm::reject ( )
inlineslot

Alias for resetValues()

Deprecated:

Definition at line 160 of file qgsattributeform.h.

void QgsAttributeForm::resetValues ( )
slot

Sets all values to the values of the current feature.

Definition at line 243 of file qgsattributeform.cpp.

References mFeature, mWidgets, and QgsWidgetWrapper::setFeature().

Referenced by disconnectButtonBox(), init(), and setFeature().

bool QgsAttributeForm::save ( )
slot
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 89 of file qgsattributeform.h.

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 114 of file qgsattributeform.cpp.

References feature(), QgsAttributeFormInterface::featureChanged(), mFeature, mInterfaces, resetValues(), and synchronizeEnabledState().

Referenced by QgsDualView::on_mFeatureList_currentEditSelectionChanged(), onAttributeAdded(), onAttributeDeleted(), and QgsAttributeForm().

void QgsAttributeForm::setIsAddDialog ( bool  isAddDialog)

Toggles the form mode between edit feature and add feature.

If set to true, the dialog will be editable even with an invalid feature. If set to true, the dialog will add a new feature when the form is accepted.

Parameters
isAddDialogIf set to true, turn this dialog into an add feature dialog.

Definition at line 95 of file qgsattributeform.cpp.

References mIsAddDialog, and synchronizeEnabledState().

void QgsAttributeForm::showButtonBox ( )

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

Definition at line 72 of file qgsattributeform.cpp.

References mButtonBox, mLayer, and save().

void QgsAttributeForm::synchronizeEnabledState ( )
privateslot

Member Data Documentation

QDialogButtonBox* QgsAttributeForm::mButtonBox
private
QgsAttributeEditorContext QgsAttributeForm::mContext
private

Definition at line 195 of file qgsattributeform.h.

Referenced by createWidgetFromDef(), createWrappers(), and init().

QString QgsAttributeForm::mEditCommandMessage
private

Definition at line 208 of file qgsattributeform.h.

Referenced by save().

QgsFeature QgsAttributeForm::mFeature
private
int QgsAttributeForm::mFormNr
private

Definition at line 201 of file qgsattributeform.h.

Referenced by initPython().

QList<QgsAttributeFormInterface*> QgsAttributeForm::mInterfaces
private

Definition at line 197 of file qgsattributeform.h.

Referenced by addInterface(), init(), save(), setFeature(), and ~QgsAttributeForm().

bool QgsAttributeForm::mIsAddDialog
private

Definition at line 206 of file qgsattributeform.h.

Referenced by hideButtonBox(), save(), setIsAddDialog(), and synchronizeEnabledState().

bool QgsAttributeForm::mIsSaving
private

Set to true while saving to prevent recursive saves.

Definition at line 205 of file qgsattributeform.h.

Referenced by save().

QgsVectorLayer* QgsAttributeForm::mLayer
private
QString QgsAttributeForm::mPyFormVarName
private

Definition at line 202 of file qgsattributeform.h.

Referenced by cleanPython(), and initPython().

QList<QgsWidgetWrapper*> QgsAttributeForm::mWidgets
private
int QgsAttributeForm::sFormCounter = 0
staticprivate

Definition at line 200 of file qgsattributeform.h.


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