20 , mEditorLayout( GeneratedLayout )
21 , mInitCodeSource( CodeSourceNone )
22 , mSuppressForm( SuppressDefault )
29 if ( fieldIdx < 0 || fieldIdx >= mFields.
count() )
32 return mEditorWidgetV2Types.
value( mFields[fieldIdx].
name(),
"TextEdit" );
37 return mEditorWidgetV2Types.
value( fieldName,
"TextEdit" );
42 if ( fieldIdx < 0 || fieldIdx >= mFields.
count() )
45 return mWidgetConfigs.value( mFields[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[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 );
124 if ( idx >= 0 && idx < mFields.
count() )
130 if ( idx >= 0 && idx < mFields.
count() )
131 mLabelOnTop[ mFields.
at( idx ).
name()] = onTop;
137 if ( !editFormNode.
isNull() )
144 if ( !editFormInitNode.
isNull() )
149 QDomNode editFormInitCodeSourceNode = node.
namedItem(
"editforminitcodesource" );
156 if ( !editFormInitCodeNode.
isNull() )
175 if ( !editFormInitFilePathNode.isNull() || ( !editFormInitFilePathNode.isNull() && !editFormInitFilePathNode.toElement().text().isEmpty() ) )
181 if ( fFSuppNode.
isNull() )
193 if ( editorLayoutNode.
isNull() )
203 else if ( editorLayoutNode.
toElement().
text() ==
"tablayout" )
218 for (
int i = 0; i < attributeEditorFormNodeList.
size(); i++ )
223 addTab( attributeEditorWidget );
234 for (
int i = 0; i < widgetConfigsElems.
size(); ++i )
249 for (
int j = 0; j < optionElements.
size(); ++j )
265 QDomElement efField = doc.createElement(
"editform" );
270 QDomElement efiField = doc.createElement(
"editforminit" );
275 QDomElement eficsField = doc.createElement(
"editforminitcodesource" );
279 QDomElement efifpField = doc.createElement(
"editforminitfilepath" );
284 QDomElement eficField = doc.createElement(
"editforminitcode" );
288 QDomElement fFSuppElem = doc.createElement(
"featformsuppress" );
294 QDomElement editorLayoutElem = doc.createElement(
"editorlayout" );
298 editorLayoutElem.
appendChild( doc.createTextNode(
"uifilelayout" ) );
302 editorLayoutElem.
appendChild( doc.createTextNode(
"tablayout" ) );
307 editorLayoutElem.
appendChild( doc.createTextNode(
"generatedlayout" ) );
314 if (
tabs().size() > 0 )
316 QDomElement tabsElem = doc.createElement(
"attributeEditorForm" );
320 QDomElement attributeEditorWidgetElem = ( *it )->toDomElement( doc );
330 QDomElement widgetsElem = doc.createElement(
"widgets" );
334 while ( configIt != mWidgetConfigs.constEnd() )
338 QDomElement widgetElem = doc.createElement(
"widget" );
341 QDomElement configElem = doc.createElement(
"config" );
346 while ( cfgIt != configIt.value().constEnd() )
348 QDomElement optionElem = doc.createElement(
"option" );
350 optionElem.
setAttribute(
"value", cfgIt.value().toString() );
369 if ( elem.
tagName() ==
"attributeEditorContainer" )
375 for (
int i = 0; i < childNodeList.size(); i++ )
383 newElement = container;
385 else if ( elem.
tagName() ==
"attributeEditorField" )
391 else if ( elem.
tagName() ==
"attributeEditorRelation" )
401 void QgsEditFormConfig::onRelationsLoaded()
QDomNodeList elementsByTagName(const QString &tagname) const
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...
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)
QString attribute(const QString &name, const QString &defValue) const
QString writePath(const QString &filename, const QString &relativeBasePath=QString::null) const
Prepare a filename to save it to the project file.
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.
This element will load a relation editor onto the form.
QDomNodeList childNodes() const
int count() const
Return number of items.
AttributeEditorType type() const
The type of this element.
QString name() const
Gets the name of the field.
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
QString number(int n, int base)
QDomDocument ownerDocument() const
void setAttribute(const QString &name, const QString &value)
int toInt(bool *ok, int base) const
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...
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
QString mid(int position, int n) const
static QgsProject * instance()
access to canonical QgsProject 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
QString readPath(QString filename) const
Turn filename read from the project file to an absolute path.
virtual void addChildElement(QgsAttributeEditorElement *element)
Add a child element to this container.
iterator insert(const Key &key, const T &value)
const_iterator constEnd() const
const_iterator constBegin() const
QDomNode item(int index) const
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