20 , mEditorLayout( GeneratedLayout )
21 , mInitCodeSource( CodeSourceNone )
22 , mSuppressForm( SuppressDefault )
29 if ( fieldIdx < 0 || fieldIdx >= mFields.
count() )
32 return mEditorWidgetV2Types.
value( mFields.
at( fieldIdx ).
name(),
"TextEdit" );
37 return mEditorWidgetV2Types.
value( fieldName,
"TextEdit" );
42 if ( fieldIdx < 0 || fieldIdx >= mFields.
count() )
45 return mWidgetConfigs.
value( mFields.
at( fieldIdx ).
name() );
50 return mWidgetConfigs.
value( widgetName );
53 void QgsEditFormConfig::setFields(
const QgsFields& fields )
60 if ( attrIdx >= 0 && attrIdx < mFields.
count() )
66 if ( attrIdx >= 0 && attrIdx < mFields.
count() )
67 mWidgetConfigs[ mFields.
at( attrIdx ).
name()] = config;
72 mWidgetConfigs[widgetName] = config;
77 return mWidgetConfigs.
remove( widgetName ) != 0;
82 if ( fieldIdx < 0 || fieldIdx >= mFields.
count() )
85 return mWidgetConfigs.
remove( mFields.
at( fieldIdx ).
name() );
103 if ( idx >= 0 && idx < mFields.
count() )
108 return !mFieldEditables.
value( mFields.
at( idx ).
name(), true );
116 if ( idx >= 0 && idx < mFields.
count() )
117 return mLabelOnTop.
value( mFields.
at( idx ).
name(), false );
126 if ( idx >= 0 && idx < mFields.
count() )
134 if ( idx >= 0 && idx < mFields.
count() )
135 mConstraints[ mFields.
at( idx ).
name()] = str;
142 if ( idx >= 0 && idx < mFields.
count() )
143 description = mConstraintsDescription[ mFields.
at( idx ).
name()];
150 if ( idx >= 0 && idx < mFields.
count() )
151 mConstraintsDescription[ mFields.
at( idx ).
name()] = descr;
156 if ( idx >= 0 && idx < mFields.
count() )
157 return mNotNull.
value( mFields.
at( idx ).
name(), false );
164 if ( idx >= 0 && idx < mFields.
count() )
170 if ( idx >= 0 && idx < mFields.
count() )
171 mLabelOnTop[ mFields.
at( idx ).
name()] = onTop;
176 if ( idx >= 0 && idx < mFields.
count() )
177 mNotNull[ mFields.
at( idx ).
name()] = notnull;
183 if ( !editFormNode.
isNull() )
190 if ( !editFormInitNode.
isNull() )
195 QDomNode editFormInitCodeSourceNode = node.
namedItem(
"editforminitcodesource" );
202 if ( !editFormInitCodeNode.
isNull() )
221 if ( !editFormInitFilePathNode.isNull() || ( !editFormInitFilePathNode.isNull() && !editFormInitFilePathNode.toElement().text().isEmpty() ) )
227 if ( fFSuppNode.
isNull() )
239 if ( editorLayoutNode.
isNull() )
249 else if ( editorLayoutNode.
toElement().
text() ==
"tablayout" )
264 for (
int i = 0; i < attributeEditorFormNodeList.
size(); i++ )
269 addTab( attributeEditorWidget );
282 for (
int i = 0; i < widgetConfigsElems.
size(); ++i )
297 for (
int j = 0; j < optionElements.
size(); ++j )
313 QDomElement efField = doc.createElement(
"editform" );
318 QDomElement efiField = doc.createElement(
"editforminit" );
323 QDomElement eficsField = doc.createElement(
"editforminitcodesource" );
327 QDomElement efifpField = doc.createElement(
"editforminitfilepath" );
331 QDomElement eficField = doc.createElement(
"editforminitcode" );
335 QDomElement fFSuppElem = doc.createElement(
"featformsuppress" );
341 QDomElement editorLayoutElem = doc.createElement(
"editorlayout" );
345 editorLayoutElem.
appendChild( doc.createTextNode(
"uifilelayout" ) );
349 editorLayoutElem.
appendChild( doc.createTextNode(
"tablayout" ) );
354 editorLayoutElem.
appendChild( doc.createTextNode(
"generatedlayout" ) );
361 if (
tabs().size() > 0 )
363 QDomElement tabsElem = doc.createElement(
"attributeEditorForm" );
367 QDomElement attributeEditorWidgetElem = ( *it )->toDomElement( doc );
377 QDomElement widgetsElem = doc.createElement(
"widgets" );
381 while ( configIt != mWidgetConfigs.
constEnd() )
385 QDomElement widgetElem = doc.createElement(
"widget" );
389 QDomElement configElem = doc.createElement(
"config" );
392 QgsEditorWidgetConfig::ConstIterator cfgIt( configIt.value().constBegin() );
394 while ( cfgIt != configIt.value().constEnd() )
396 QDomElement optionElem = doc.createElement(
"option" );
398 optionElem.
setAttribute(
"value", cfgIt.value().toString() );
417 if ( elem.
tagName() ==
"attributeEditorContainer" )
430 container->
setIsGroupBox( qobject_cast<QgsAttributeEditorContainer*>( parent ) );
432 bool visibilityExpressionEnabled = elem.
attribute(
"visibilityExpressionEnabled" ).
toInt( &ok );
436 visibilityExpression.
setEnabled( visibilityExpressionEnabled );
443 for (
int i = 0; i < childNodeList.
size(); i++ )
451 newElement = container;
453 else if ( elem.
tagName() ==
"attributeEditorField" )
459 else if ( elem.
tagName() ==
"attributeEditorRelation" )
467 newElement = relElement;
478 void QgsEditFormConfig::onRelationsLoaded()
508 mColumnCount = columnCount;
511 void QgsAttributeEditorContainer::saveConfiguration(
QDomElement& elem )
const 515 elem.
setAttribute(
"visibilityExpressionEnabled", mVisibilityExpression.enabled() ? 1 : 0 );
516 elem.
setAttribute(
"visibilityExpression", mVisibilityExpression->expression() );
527 return mVisibilityExpression;
532 mVisibilityExpression = visibilityExpression;
535 QString QgsAttributeEditorContainer::typeIdentifier()
const 537 return "attributeEditorContainer";
542 mChildren.append( widget );
556 if ( elem->
type() == type )
561 if ( elem->
type() == AeTypeContainer )
572 void QgsAttributeEditorField::saveConfiguration(
QDomElement &elem )
const 577 QString QgsAttributeEditorField::typeIdentifier()
const 579 return "attributeEditorField";
588 saveConfiguration( elem );
599 mShowLabel = showLabel;
602 void QgsAttributeEditorRelation::saveConfiguration(
QDomElement& elem )
const 606 elem.
setAttribute(
"showUnlinkButton", mShowUnlinkButton );
609 QString QgsAttributeEditorRelation::typeIdentifier()
const 611 return "attributeEditorRelation";
616 return mShowUnlinkButton;
621 mShowUnlinkButton = showUnlinkButton;
626 mRelation = relationManager->
relation( mRelationId );
632 return mShowLinkButton;
637 mShowLinkButton = showLinkButton;
QObject * child(const char *objName, const char *inheritsClass, bool recursiveSearch) const
Class for parsing and evaluation of expressions (formerly called "search strings").
QDomNodeList elementsByTagName(const QString &tagname) const
bool isValid() const
Returns the validity of this relation.
bool init(QgsRelationManager *relManager)
Initializes the relation from the id.
field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
void setName(const QString &name)
Change the name of this container.
This is an abstract base class for any elements of a drag and drop form.
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
QDomNode appendChild(const QDomNode &newChild)
void setVisibilityExpression(const QgsOptionalExpression &visibilityExpression)
An expression that controls the visibility of this container.
QString attribute(const QString &name, const QString &defValue) const
const_iterator constBegin() const
virtual QList< QgsAttributeEditorElement * > findElements(AttributeEditorType type) const
Traverses the element tree to find any element of the specified type.
Container of fields for a vector layer.
This element will load a field's widget onto the form.
QDomElement toDomElement(QDomDocument &doc) const
Get the XML Dom element to save this element.
This element will load a relation editor onto the form.
void setColumnCount(int columnCount)
Set the number of columns in this group.
QDomNodeList childNodes() const
int count() const
Return number of items.
AttributeEditorType type() const
The type of this element.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
QDomElement toElement() const
const char * name() const
void setData(const T &data)
Set the payload data.
QString number(int n, int base)
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
An expression with an additional enabled flag.
void append(const T &value)
void setShowLabel(bool showLabel)
Controls if this element should be labeled with a title (field, relation or groupname).
bool showUnlinkButton() const
Determines if the "unlink feature" button should be shown.
QString & insert(int position, QChar ch)
QDomDocument ownerDocument() const
bool hasAttribute(const QString &name) const
void setAttribute(const QString &name, const QString &value)
int toInt(bool *ok, int base) const
const_iterator constEnd() const
bool showLabel() const
Controls if this element should be labeled with a title (field, relation or groupname).
QgsOptionalExpression visibilityExpression() const
An expression that controls the visibility of this container.
QDomNode namedItem(const QString &name) const
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name also looks up case-insensitive if there is no match otherwise...
void setShowLinkButton(bool showLinkButton)
Determines if the "link feature" button should be shown.
void setShowUnlinkButton(bool showUnlinkButton)
Determines if the "unlink feature" button should be shown.
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
QString mid(int position, int n) const
virtual void setIsGroupBox(bool isGroupBox)
Determines if this container is rendered as collapsible group box or tab in a tabwidget.
This class manages a set of relations between layers.
int columnCount() const
Get the number of columns in this group.
QString readPath(QString filename, const QString &relativeBasePath=QString()) const
Turn filename read from the project file to an absolute path.
static QgsProject * instance()
Returns the QgsProject singleton instance.
This is a container for attribute editors, used to group them visually in the attribute form if it is...
QString left(int n) const
virtual void addChildElement(QgsAttributeEditorElement *element)
Add a child element to this container.
bool showLinkButton() const
Determines if the "link feature" button should be shown.
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
const_iterator constBegin() const
QDomNode item(int index) const
void setEnabled(bool enabled)
Set if this optional is enabled.
QgsRelation relation(const QString &id) const
Get access to a relation by its id.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
field is calculated from an expression
QDomNode at(int index) const
const T value(const Key &key) const
QDomNamedNodeMap attributes() const
int remove(const Key &key)
QString writePath(const QString &filename, const QString &relativeBasePath=QString()) const
Prepare a filename to save it to the project file.