QGIS API Documentation  2.4.0-Chugiak
 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>

Inheritance diagram for QgsAttributeForm:
Inheritance graph
[legend]
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. More...
 
void setFeature (const QgsFeature &feature)
 Update all editors to correspond to a different feature. More...
 
bool save ()
 Save all the values from the editors to the layer. More...
 
Q_DECL_DEPRECATED void accept ()
 Alias for save() More...
 
Q_DECL_DEPRECATED void reject ()
 Alias for resetValues() More...
 
void resetValues ()
 Sets all values to the values of the current feature. More...
 

Signals

void attributeChanged (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 featureSaved (const QgsFeature &feature)
 Is emitted, when a feature is changed or added. More...
 

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

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 createWrappers ()
 Creates widget wrappers for all suitable widgets found. More...
 
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. More...
 
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 147 of file qgsattributeform.h.

Referenced by init().

void QgsAttributeForm::addInterface ( QgsAttributeFormInterface iface)

Takes ownership.

Parameters
iface

Definition at line 78 of file qgsattributeform.cpp.

References mInterfaces.

Referenced by initPython().

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

References mWidgets.

void QgsAttributeForm::cleanPython ( )
private

Definition at line 443 of file qgsattributeform.cpp.

References mPyFormVarName, and QgsPythonRunner::run().

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

void QgsAttributeForm::connectWrappers ( )
private

Definition at line 660 of file qgsattributeform.cpp.

References mWidgets, and onAttributeChanged().

Referenced by init().

QWidget * QgsAttributeForm::createWidgetFromDef ( const QgsAttributeEditorElement widgetDef,
QWidget *  parent,
QgsVectorLayer vl,
QgsAttributeEditorContext context,
QString &  labelText,
bool &  labelOnTop 
)
private
void QgsAttributeForm::createWrappers ( )
private
bool QgsAttributeForm::editable ( )

Returns if the form is currently in editable mode.

Returns
Editable mode of this form

Definition at line 83 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 672 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, 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 60 of file qgsattributeform.h.

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

void QgsAttributeForm::onAttributeAdded ( int  idx)
privateslot
void QgsAttributeForm::onAttributeChanged ( const QVariant &  value)
privateslot

Definition at line 237 of file qgsattributeform.cpp.

References attributeChanged().

Referenced by connectWrappers().

void QgsAttributeForm::onAttributeDeleted ( int  idx)
privateslot
Q_DECL_DEPRECATED void QgsAttributeForm::reject ( )
inlineslot

Alias for resetValues()

Deprecated:

Definition at line 154 of file qgsattributeform.h.

void QgsAttributeForm::resetValues ( )
slot

Sets all values to the values of the current feature.

Definition at line 229 of file qgsattributeform.cpp.

References mFeature, and mWidgets.

Referenced by 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 83 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 107 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 88 of file qgsattributeform.cpp.

References mIsAddDialog, and synchronizeEnabledState().

void QgsAttributeForm::showButtonBox ( )

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

Definition at line 71 of file qgsattributeform.cpp.

References mButtonBox, mLayer, and save().

void QgsAttributeForm::synchronizeEnabledState ( )
privateslot

Member Data Documentation

QDialogButtonBox* QgsAttributeForm::mButtonBox
private

Definition at line 188 of file qgsattributeform.h.

Referenced by hideButtonBox(), init(), showButtonBox(), and synchronizeEnabledState().

QgsAttributeEditorContext QgsAttributeForm::mContext
private

Definition at line 187 of file qgsattributeform.h.

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

QString QgsAttributeForm::mEditCommandMessage
private

Definition at line 200 of file qgsattributeform.h.

Referenced by save().

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

Definition at line 193 of file qgsattributeform.h.

Referenced by initPython().

QList<QgsAttributeFormInterface*> QgsAttributeForm::mInterfaces
private

Definition at line 189 of file qgsattributeform.h.

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

bool QgsAttributeForm::mIsAddDialog
private

Definition at line 198 of file qgsattributeform.h.

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

bool QgsAttributeForm::mIsSaving
private

Set to true while saving to prevent recursive saves.

Definition at line 197 of file qgsattributeform.h.

Referenced by save().

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

Definition at line 194 of file qgsattributeform.h.

Referenced by cleanPython(), and initPython().

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

Definition at line 192 of file qgsattributeform.h.


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