QGIS API Documentation
2.4.0-Chugiak
|
#include <qgsattributeform.h>
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 QgsFeature & | feature () |
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... | |
QgsVectorLayer * | layer () |
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 | |
QgsVectorLayer * | mLayer |
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 |
Definition at line 29 of file qgsattributeform.h.
|
explicit |
Definition at line 40 of file qgsattributeform.cpp.
References init(), initPython(), onAttributeAdded(), onAttributeDeleted(), and setFeature().
QgsAttributeForm::~QgsAttributeForm | ( | ) |
Definition at line 57 of file qgsattributeform.cpp.
References cleanPython(), and mInterfaces.
|
inlineslot |
void QgsAttributeForm::addInterface | ( | QgsAttributeFormInterface * | iface | ) |
Takes ownership.
iface |
Definition at line 78 of file qgsattributeform.cpp.
References mInterfaces.
Referenced by initPython().
|
signal |
Notifies about changes of attributes.
attribute | The name of the attribute that changed. |
value | The new value of the attribute. |
Referenced by onAttributeChanged().
|
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.
ok | Set this parameter to false if you don't want the form to be saved |
Referenced by save().
|
slot |
Call this to change the content of a given attribute.
Will update the editor(s) related to this field.
field | The field to change |
value | The new value |
Definition at line 95 of file qgsattributeform.cpp.
References mWidgets.
|
private |
Definition at line 443 of file qgsattributeform.cpp.
References mPyFormVarName, and QgsPythonRunner::run().
Referenced by initPython(), and ~QgsAttributeForm().
|
private |
Definition at line 660 of file qgsattributeform.cpp.
References mWidgets, and onAttributeChanged().
Referenced by init().
|
private |
Definition at line 508 of file qgsattributeform.cpp.
References QgsAttributeEditorElement::AeTypeContainer, QgsAttributeEditorElement::AeTypeField, QgsAttributeEditorElement::AeTypeRelation, QgsVectorLayer::attributeDisplayName(), QgsAttributeEditorContainer::children(), QgsVectorLayer::editorWidgetV2(), QgsVectorLayer::editorWidgetV2Config(), QgsAttributeEditorField::idx(), index, QgsAttributeEditorContainer::isGroupBox(), QgsVectorLayer::labelOnTop(), mContext, mLayer, mWidgets, QgsAttributeEditorElement::name(), QgsDebugMsg, QgsAttributeEditorRelation::relation(), and QgsAttributeEditorElement::type().
Referenced by init().
|
private |
Creates widget wrappers for all suitable widgets found.
Called once maximally.
Definition at line 621 of file qgsattributeform.cpp.
References QgsVectorLayer::editorWidgetV2(), QgsVectorLayer::editorWidgetV2Config(), QgsVectorLayer::fieldNameIndex(), QgsProject::instance(), QgsRelation::isValid(), mContext, mLayer, mWidgets, QgsField::name(), QgsVectorLayer::pendingFields(), QgsRelationManager::relation(), QgsProject::relationManager(), and QgsFields::toList().
Referenced by init().
bool QgsAttributeForm::editable | ( | ) |
Returns if the form is currently in editable mode.
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)
object | The object for which the event has been sent |
event | The event which is being filtered |
Definition at line 672 of file qgsattributeform.cpp.
|
inline |
Definition at line 37 of file qgsattributeform.h.
Referenced by QgsAttributeFormInterface::feature(), and setFeature().
|
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().
|
private |
Definition at line 293 of file qgsattributeform.cpp.
References accept(), QgsAttributeEditorElement::AeTypeContainer, QgsVectorLayer::attributeDisplayName(), QgsVectorLayer::attributeEditorElements(), connectWrappers(), createWidgetFromDef(), createWrappers(), QgsVectorLayer::editForm(), QgsVectorLayer::editorLayout(), QgsVectorLayer::editorWidgetV2(), QgsVectorLayer::editorWidgetV2Config(), QgsVectorLayer::fieldNameIndex(), file, QgsAttributeFormInterface::initForm(), QgsProject::instance(), QgsVectorLayer::labelOnTop(), mButtonBox, mContext, mInterfaces, mLayer, mWidgets, QgsField::name(), QgsAttributeEditorElement::name(), QgsVectorLayer::pendingFields(), QgsDebugMsg, resetValues(), QgsAttributeEditorContainer::setIsGroupBox(), synchronizeEnabledState(), QgsVectorLayer::TabLayout, QgsFields::toList(), QgsAttributeEditorElement::type(), and QgsVectorLayer::UiFileLayout.
Referenced by onAttributeAdded(), onAttributeDeleted(), and QgsAttributeForm().
|
private |
Definition at line 452 of file qgsattributeform.cpp.
References addInterface(), cleanPython(), QgsVectorLayer::editFormInit(), QgsPythonRunner::eval(), mFormNr, mLayer, mPyFormVarName, QgsDebugMsg, and QgsPythonRunner::run().
Referenced by QgsAttributeForm().
|
inline |
Returns the layer for which this form is shown.
Definition at line 60 of file qgsattributeform.h.
Referenced by onAttributeAdded(), onAttributeDeleted(), and QgsAttributeFormLegacyInterface::QgsAttributeFormLegacyInterface().
|
privateslot |
Definition at line 246 of file qgsattributeform.cpp.
References QgsFeature::attributes(), init(), QgsFeature::isValid(), layer(), mFeature, QgsFeature::setAttributes(), setFeature(), and QgsFeature::setFields().
Referenced by QgsAttributeForm().
|
privateslot |
Definition at line 237 of file qgsattributeform.cpp.
References attributeChanged().
Referenced by connectWrappers().
|
privateslot |
Definition at line 260 of file qgsattributeform.cpp.
References QgsFeature::attributes(), init(), QgsFeature::isValid(), layer(), mFeature, QgsFeature::setAttributes(), setFeature(), and QgsFeature::setFields().
Referenced by QgsAttributeForm().
|
inlineslot |
|
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().
|
slot |
Save all the values from the editors to the layer.
Definition at line 121 of file qgsattributeform.cpp.
References QgsAttributeFormInterface::acceptChanges(), QgsVectorLayer::addFeature(), QgsFeature::attributes(), beforeSave(), QgsVectorLayer::beginEditCommand(), QgsVectorLayer::changeAttributeValue(), QgsVectorLayer::destroyEditCommand(), QgsVectorLayer::endEditCommand(), featureSaved(), QgsFeature::id(), isNull(), QgsFeature::isValid(), mEditCommandMessage, mFeature, mInterfaces, mIsAddDialog, mIsSaving, mLayer, mWidgets, QgsDebugMsg, QgsFeature::setAttributes(), and QgsFeature::setValid().
Referenced by QgsAttributeDialog::accept(), hideButtonBox(), QgsDualView::on_mFeatureList_aboutToChangeEditSelection(), QgsDualView::on_mFeatureList_currentEditSelectionChanged(), QgsDualView::saveEditChanges(), and showButtonBox().
|
inline |
Sets the edit command message (Undo) that will be used when the dialog is accepted.
message | The message |
Definition at line 83 of file qgsattributeform.h.
|
slot |
Update all editors to correspond to a different feature.
feature | The 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.
isAddDialog | If 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().
|
privateslot |
Definition at line 273 of file qgsattributeform.cpp.
References QgsVectorLayer::fieldEditable(), QgsVectorLayer::isEditable(), QgsFeature::isValid(), mButtonBox, mFeature, mIsAddDialog, mLayer, and mWidgets.
Referenced by init(), setFeature(), and setIsAddDialog().
|
private |
Definition at line 188 of file qgsattributeform.h.
Referenced by hideButtonBox(), init(), showButtonBox(), and synchronizeEnabledState().
|
private |
Definition at line 187 of file qgsattributeform.h.
Referenced by createWidgetFromDef(), createWrappers(), and init().
|
private |
Definition at line 200 of file qgsattributeform.h.
Referenced by save().
|
private |
Definition at line 185 of file qgsattributeform.h.
Referenced by editable(), onAttributeAdded(), onAttributeDeleted(), resetValues(), save(), setFeature(), and synchronizeEnabledState().
|
private |
Definition at line 193 of file qgsattributeform.h.
Referenced by initPython().
|
private |
Definition at line 189 of file qgsattributeform.h.
Referenced by addInterface(), init(), save(), setFeature(), and ~QgsAttributeForm().
|
private |
Definition at line 198 of file qgsattributeform.h.
Referenced by save(), setIsAddDialog(), and synchronizeEnabledState().
|
private |
Set to true while saving to prevent recursive saves.
Definition at line 197 of file qgsattributeform.h.
Referenced by save().
|
private |
Definition at line 184 of file qgsattributeform.h.
Referenced by createWidgetFromDef(), createWrappers(), editable(), hideButtonBox(), init(), initPython(), save(), showButtonBox(), and synchronizeEnabledState().
|
private |
Definition at line 194 of file qgsattributeform.h.
Referenced by cleanPython(), and initPython().
|
private |
Definition at line 186 of file qgsattributeform.h.
Referenced by changeAttribute(), connectWrappers(), createWidgetFromDef(), createWrappers(), init(), resetValues(), save(), and synchronizeEnabledState().
|
staticprivate |
Definition at line 192 of file qgsattributeform.h.