mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-17 00:09:36 -04:00
separate QgsAttributeEditorElement into several files
This commit is contained in:
parent
cbfd7b093a
commit
a6404da815
@ -1,4 +1,4 @@
|
||||
# The following has been generated automatically from src/core/qgsattributeeditorelement.h
|
||||
# The following has been generated automatically from src/core/editform/qgsattributeeditorrelation.h
|
||||
QgsAttributeEditorRelation.Button.baseClass = QgsAttributeEditorRelation
|
||||
QgsAttributeEditorRelation.Buttons.baseClass = QgsAttributeEditorRelation
|
||||
Buttons = QgsAttributeEditorRelation # dirty hack since SIP seems to introduce the flags in module
|
@ -1,4 +1,4 @@
|
||||
# The following has been generated automatically from src/core/qgseditformconfig.h
|
||||
# The following has been generated automatically from src/core/editform/qgseditformconfig.h
|
||||
QgsEditFormConfig.EditorLayout.baseClass = QgsEditFormConfig
|
||||
QgsEditFormConfig.FeatureFormSuppress.baseClass = QgsEditFormConfig
|
||||
QgsEditFormConfig.PythonInitCodeSource.baseClass = QgsEditFormConfig
|
||||
|
@ -0,0 +1,140 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorcontainer.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
class QgsAttributeEditorContainer : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
This is a container for attribute editors, used to group them visually in the
|
||||
attribute form if it is set to the drag and drop designer.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorcontainer.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsAttributeEditorContainer( const QString &name, QgsAttributeEditorElement *parent, const QColor &backgroundColor = QColor() );
|
||||
%Docstring
|
||||
Creates a new attribute editor container
|
||||
|
||||
:param name: The name to show as title
|
||||
:param parent: The parent. May be another container.
|
||||
:param backgroundColor: The optional background color of the container.
|
||||
%End
|
||||
|
||||
|
||||
~QgsAttributeEditorContainer();
|
||||
|
||||
virtual void addChildElement( QgsAttributeEditorElement *element /Transfer/ );
|
||||
%Docstring
|
||||
Add a child element to this container. This may be another container, a field or a relation.
|
||||
|
||||
:param element: The element to add as child
|
||||
%End
|
||||
|
||||
virtual void setIsGroupBox( bool isGroupBox );
|
||||
%Docstring
|
||||
Determines if this container is rendered as collapsible group box or tab in a tabwidget
|
||||
|
||||
:param isGroupBox: If ``True``, this will be a group box
|
||||
%End
|
||||
|
||||
virtual bool isGroupBox() const;
|
||||
%Docstring
|
||||
Returns if this container is going to be rendered as a group box
|
||||
|
||||
:return: ``True`` if it will be a group box, ``False`` if it will be a tab
|
||||
%End
|
||||
|
||||
QList<QgsAttributeEditorElement *> children() const;
|
||||
%Docstring
|
||||
Gets a list of the children elements of this container
|
||||
|
||||
:return: A list of elements
|
||||
%End
|
||||
|
||||
virtual QList<QgsAttributeEditorElement *> findElements( AttributeEditorType type ) const;
|
||||
%Docstring
|
||||
Traverses the element tree to find any element of the specified type
|
||||
|
||||
:param type: The type which should be searched
|
||||
|
||||
:return: A list of elements of the type which has been searched for
|
||||
%End
|
||||
|
||||
void clear();
|
||||
%Docstring
|
||||
Clear all children from this container.
|
||||
%End
|
||||
|
||||
void setName( const QString &name );
|
||||
%Docstring
|
||||
Change the name of this container
|
||||
%End
|
||||
|
||||
int columnCount() const;
|
||||
%Docstring
|
||||
Gets the number of columns in this group
|
||||
%End
|
||||
|
||||
void setColumnCount( int columnCount );
|
||||
%Docstring
|
||||
Set the number of columns in this group
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
%Docstring
|
||||
Creates a deep copy of this element. To be implemented by subclasses.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
QgsOptionalExpression visibilityExpression() const;
|
||||
%Docstring
|
||||
The visibility expression is used in the attribute form to
|
||||
show or hide this container based on an expression incorporating
|
||||
the field value controlled by editor widgets.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
void setVisibilityExpression( const QgsOptionalExpression &visibilityExpression );
|
||||
%Docstring
|
||||
The visibility expression is used in the attribute form to
|
||||
show or hide this container based on an expression incorporating
|
||||
the field value controlled by editor widgets.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
QColor backgroundColor() const;
|
||||
%Docstring
|
||||
backgroundColor
|
||||
|
||||
:return: background color of the container
|
||||
|
||||
.. versionadded:: 3.8
|
||||
%End
|
||||
|
||||
void setBackgroundColor( const QColor &backgroundColor );
|
||||
%Docstring
|
||||
Sets the background color to ``backgroundColor``
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorcontainer.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -0,0 +1,133 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorelement.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsAttributeEditorElement /Abstract/
|
||||
{
|
||||
%Docstring
|
||||
This is an abstract base class for any elements of a drag and drop form.
|
||||
|
||||
This can either be a container which will be represented on the screen
|
||||
as a tab widget or a collapsible group box. Or it can be a field which will
|
||||
then be represented based on the QgsEditorWidget type and configuration.
|
||||
Or it can be a relation and embed the form of several children of another
|
||||
layer.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorelement.h"
|
||||
%End
|
||||
%ConvertToSubClassCode
|
||||
switch ( sipCpp->type() )
|
||||
{
|
||||
case QgsAttributeEditorElement::AeTypeContainer:
|
||||
sipType = sipType_QgsAttributeEditorContainer;
|
||||
break;
|
||||
case QgsAttributeEditorElement::AeTypeField:
|
||||
sipType = sipType_QgsAttributeEditorField;
|
||||
break;
|
||||
case QgsAttributeEditorElement::AeTypeRelation:
|
||||
sipType = sipType_QgsAttributeEditorRelation;
|
||||
break;
|
||||
default:
|
||||
sipType = nullptr;
|
||||
break;
|
||||
}
|
||||
%End
|
||||
public:
|
||||
enum AttributeEditorType
|
||||
{
|
||||
AeTypeContainer,
|
||||
AeTypeField,
|
||||
AeTypeRelation,
|
||||
AeTypeInvalid,
|
||||
AeTypeQmlElement,
|
||||
AeTypeHtmlElement
|
||||
};
|
||||
|
||||
QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = 0 );
|
||||
%Docstring
|
||||
Constructor
|
||||
|
||||
:param type: The type of the new element.
|
||||
:param name:
|
||||
:param parent:
|
||||
%End
|
||||
|
||||
virtual ~QgsAttributeEditorElement();
|
||||
|
||||
static QgsAttributeEditorElement *create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = 0 ) /Factory/;
|
||||
%Docstring
|
||||
Constructs the editor element from the given element
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
QString name() const;
|
||||
%Docstring
|
||||
Returns the name of this element
|
||||
|
||||
:return: The name for this element
|
||||
%End
|
||||
|
||||
AttributeEditorType type() const;
|
||||
%Docstring
|
||||
The type of this element
|
||||
|
||||
:return: The type
|
||||
%End
|
||||
|
||||
QgsAttributeEditorElement *parent() const;
|
||||
%Docstring
|
||||
Gets the parent of this element.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
QDomElement toDomElement( QDomDocument &doc ) const;
|
||||
%Docstring
|
||||
Gets the XML Dom element to save this element.
|
||||
|
||||
:param doc: The QDomDocument which is used to create new XML elements
|
||||
|
||||
:return: A DOM element to serialize this element
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const = 0 /Factory/;
|
||||
%Docstring
|
||||
Returns a clone of this element. To be implemented by subclasses.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
bool showLabel() const;
|
||||
%Docstring
|
||||
Controls if this element should be labeled with a title (field, relation or groupname).
|
||||
|
||||
.. versionadded:: 2.18
|
||||
%End
|
||||
|
||||
void setShowLabel( bool showLabel );
|
||||
%Docstring
|
||||
Controls if this element should be labeled with a title (field, relation or groupname).
|
||||
|
||||
.. versionadded:: 2.18
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorelement.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -0,0 +1,49 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorfield.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsAttributeEditorField : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
This element will load a field's widget onto the form.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorfield.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsAttributeEditorField( const QString &name, int idx, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new attribute editor element which represents a field
|
||||
|
||||
:param name: The name of the element
|
||||
:param idx: The index of the field which should be embedded
|
||||
:param parent: The parent of this widget (used as container)
|
||||
%End
|
||||
|
||||
int idx() const;
|
||||
%Docstring
|
||||
Returns the index of the field.
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorfield.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -0,0 +1,57 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorhtmlelement.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsAttributeEditorHtmlElement : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
An attribute editor widget that will represent arbitrary HTML code.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorhtmlelement.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsAttributeEditorHtmlElement( const QString &name, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new element which can display HTML
|
||||
|
||||
:param name: The name of the widget
|
||||
:param parent: The parent (used as container)
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
|
||||
QString htmlCode() const;
|
||||
%Docstring
|
||||
The Html code that will be represented within this widget.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
void setHtmlCode( const QString &htmlCode );
|
||||
%Docstring
|
||||
Sets the HTML code that will be represented within this widget to ``htmlCode``.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorhtmlelement.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -0,0 +1,54 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorqmlelement.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
class QgsAttributeEditorQmlElement : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
An attribute editor widget that will represent arbitrary QML code.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorqmlelement.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsAttributeEditorQmlElement( const QString &name, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new element which can display QML
|
||||
|
||||
:param name: The name of the widget
|
||||
:param parent: The parent (used as container)
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
|
||||
QString qmlCode() const;
|
||||
%Docstring
|
||||
The QML code that will be represented within this widget.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
void setQmlCode( const QString &qmlCode );
|
||||
%Docstring
|
||||
Sets the QML code that will be represented within this widget to ``qmlCode``.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorqmlelement.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -0,0 +1,174 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorrelation.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
class QgsAttributeEditorRelation : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
This element will load a relation editor onto the form.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorrelation.h"
|
||||
%End
|
||||
public:
|
||||
static const QMetaObject staticMetaObject;
|
||||
|
||||
public:
|
||||
|
||||
enum Button
|
||||
{
|
||||
Link,
|
||||
Unlink,
|
||||
SaveChildEdits,
|
||||
AddChildFeature,
|
||||
DuplicateChildFeature,
|
||||
DeleteChildFeature,
|
||||
ZoomToChildFeature,
|
||||
AllButtons
|
||||
};
|
||||
typedef QFlags<QgsAttributeEditorRelation::Button> Buttons;
|
||||
|
||||
|
||||
QgsAttributeEditorRelation( const QString &name, const QString &relationId, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
|
||||
.. deprecated:: QGIS 3.0.2.
|
||||
The name parameter is not used for anything and overwritten by the relationId internally.
|
||||
%End
|
||||
|
||||
QgsAttributeEditorRelation( const QString &name, const QgsRelation &relation, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
|
||||
.. deprecated:: QGIS 3.0.2.
|
||||
The name parameter is not used for anything and overwritten by the relationId internally.
|
||||
%End
|
||||
|
||||
QgsAttributeEditorRelation( const QString &relationId, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new element which embeds a relation.
|
||||
|
||||
:param relationId: The id of the relation to embed
|
||||
:param parent: The parent (used as container)
|
||||
%End
|
||||
|
||||
QgsAttributeEditorRelation( const QgsRelation &relation, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new element which embeds a relation.
|
||||
|
||||
:param relation: The relation to embed
|
||||
:param parent: The parent (used as container)
|
||||
%End
|
||||
|
||||
|
||||
const QgsRelation &relation() const;
|
||||
%Docstring
|
||||
Gets the id of the relation which shall be embedded
|
||||
|
||||
:return: the id
|
||||
%End
|
||||
|
||||
bool init( QgsRelationManager *relManager );
|
||||
%Docstring
|
||||
Initializes the relation from the id
|
||||
|
||||
:param relManager: The relation manager to use for the initialization
|
||||
|
||||
:return: ``True`` if the relation was found in the relationmanager
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
|
||||
bool forceSuppressFormPopup() const;
|
||||
%Docstring
|
||||
Determines the force suppress form popup status.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
void setForceSuppressFormPopup( bool forceSuppressFormPopup );
|
||||
%Docstring
|
||||
Sets force suppress form popup status to ``forceSuppressFormPopup``.
|
||||
This flag is to override the layer and general settings regarding the automatic
|
||||
opening of the attribute form dialog when digitizing is completed.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
QVariant nmRelationId() const;
|
||||
%Docstring
|
||||
Determines the relation id of the second relation involved in an N:M relation.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
void setNmRelationId( const QVariant &nmRelationId = QVariant() );
|
||||
%Docstring
|
||||
Sets ``nmRelationId`` for the relation id of the second relation involved in an N:M relation.
|
||||
If it's empty, then it's considered as a 1:M relationship.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
QString label() const;
|
||||
%Docstring
|
||||
Determines the label of this element
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
void setLabel( const QString &label = QString() );
|
||||
%Docstring
|
||||
Sets ``label`` for this element
|
||||
If it's empty it takes the relation id as label
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
QString relationWidgetTypeId() const;
|
||||
%Docstring
|
||||
Returns the current relation widget type id
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
void setRelationWidgetTypeId( const QString &relationWidgetTypeId );
|
||||
%Docstring
|
||||
Sets the relation widget type
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
QVariantMap relationEditorConfiguration() const;
|
||||
%Docstring
|
||||
Returns the relation editor widget configuration
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
void setRelationEditorConfiguration( const QVariantMap &config );
|
||||
%Docstring
|
||||
Sets the relation editor configuration
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
QFlags<QgsAttributeEditorRelation::Button> operator|(QgsAttributeEditorRelation::Button f1, QFlags<QgsAttributeEditorRelation::Button> f2);
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/editform/qgsattributeeditorrelation.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -1,7 +1,7 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgseditformconfig.h *
|
||||
* src/core/editform/qgseditformconfig.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
@ -316,7 +316,7 @@ Returns data defined property definitions.
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgseditformconfig.h *
|
||||
* src/core/editform/qgseditformconfig.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -1,525 +0,0 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsattributeeditorelement.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsAttributeEditorElement /Abstract/
|
||||
{
|
||||
%Docstring
|
||||
This is an abstract base class for any elements of a drag and drop form.
|
||||
|
||||
This can either be a container which will be represented on the screen
|
||||
as a tab widget or a collapsible group box. Or it can be a field which will
|
||||
then be represented based on the QgsEditorWidget type and configuration.
|
||||
Or it can be a relation and embed the form of several children of another
|
||||
layer.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorelement.h"
|
||||
%End
|
||||
%ConvertToSubClassCode
|
||||
switch ( sipCpp->type() )
|
||||
{
|
||||
case QgsAttributeEditorElement::AeTypeContainer:
|
||||
sipType = sipType_QgsAttributeEditorContainer;
|
||||
break;
|
||||
case QgsAttributeEditorElement::AeTypeField:
|
||||
sipType = sipType_QgsAttributeEditorField;
|
||||
break;
|
||||
case QgsAttributeEditorElement::AeTypeRelation:
|
||||
sipType = sipType_QgsAttributeEditorRelation;
|
||||
break;
|
||||
default:
|
||||
sipType = nullptr;
|
||||
break;
|
||||
}
|
||||
%End
|
||||
public:
|
||||
enum AttributeEditorType
|
||||
{
|
||||
AeTypeContainer,
|
||||
AeTypeField,
|
||||
AeTypeRelation,
|
||||
AeTypeInvalid,
|
||||
AeTypeQmlElement,
|
||||
AeTypeHtmlElement
|
||||
};
|
||||
|
||||
QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = 0 );
|
||||
%Docstring
|
||||
Constructor
|
||||
|
||||
:param type: The type of the new element.
|
||||
:param name:
|
||||
:param parent:
|
||||
%End
|
||||
|
||||
virtual ~QgsAttributeEditorElement();
|
||||
|
||||
static QgsAttributeEditorElement *create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = 0 ) /Factory/;
|
||||
%Docstring
|
||||
Constructs the editor element from the given element
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
QString name() const;
|
||||
%Docstring
|
||||
Returns the name of this element
|
||||
|
||||
:return: The name for this element
|
||||
%End
|
||||
|
||||
AttributeEditorType type() const;
|
||||
%Docstring
|
||||
The type of this element
|
||||
|
||||
:return: The type
|
||||
%End
|
||||
|
||||
QgsAttributeEditorElement *parent() const;
|
||||
%Docstring
|
||||
Gets the parent of this element.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
QDomElement toDomElement( QDomDocument &doc ) const;
|
||||
%Docstring
|
||||
Gets the XML Dom element to save this element.
|
||||
|
||||
:param doc: The QDomDocument which is used to create new XML elements
|
||||
|
||||
:return: A DOM element to serialize this element
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const = 0 /Factory/;
|
||||
%Docstring
|
||||
Returns a clone of this element. To be implemented by subclasses.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
bool showLabel() const;
|
||||
%Docstring
|
||||
Controls if this element should be labeled with a title (field, relation or groupname).
|
||||
|
||||
.. versionadded:: 2.18
|
||||
%End
|
||||
|
||||
void setShowLabel( bool showLabel );
|
||||
%Docstring
|
||||
Controls if this element should be labeled with a title (field, relation or groupname).
|
||||
|
||||
.. versionadded:: 2.18
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class QgsAttributeEditorContainer : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
This is a container for attribute editors, used to group them visually in the
|
||||
attribute form if it is set to the drag and drop designer.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorelement.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsAttributeEditorContainer( const QString &name, QgsAttributeEditorElement *parent, const QColor &backgroundColor = QColor() );
|
||||
%Docstring
|
||||
Creates a new attribute editor container
|
||||
|
||||
:param name: The name to show as title
|
||||
:param parent: The parent. May be another container.
|
||||
:param backgroundColor: The optional background color of the container.
|
||||
%End
|
||||
|
||||
|
||||
~QgsAttributeEditorContainer();
|
||||
|
||||
virtual void addChildElement( QgsAttributeEditorElement *element /Transfer/ );
|
||||
%Docstring
|
||||
Add a child element to this container. This may be another container, a field or a relation.
|
||||
|
||||
:param element: The element to add as child
|
||||
%End
|
||||
|
||||
virtual void setIsGroupBox( bool isGroupBox );
|
||||
%Docstring
|
||||
Determines if this container is rendered as collapsible group box or tab in a tabwidget
|
||||
|
||||
:param isGroupBox: If ``True``, this will be a group box
|
||||
%End
|
||||
|
||||
virtual bool isGroupBox() const;
|
||||
%Docstring
|
||||
Returns if this container is going to be rendered as a group box
|
||||
|
||||
:return: ``True`` if it will be a group box, ``False`` if it will be a tab
|
||||
%End
|
||||
|
||||
QList<QgsAttributeEditorElement *> children() const;
|
||||
%Docstring
|
||||
Gets a list of the children elements of this container
|
||||
|
||||
:return: A list of elements
|
||||
%End
|
||||
|
||||
virtual QList<QgsAttributeEditorElement *> findElements( AttributeEditorType type ) const;
|
||||
%Docstring
|
||||
Traverses the element tree to find any element of the specified type
|
||||
|
||||
:param type: The type which should be searched
|
||||
|
||||
:return: A list of elements of the type which has been searched for
|
||||
%End
|
||||
|
||||
void clear();
|
||||
%Docstring
|
||||
Clear all children from this container.
|
||||
%End
|
||||
|
||||
void setName( const QString &name );
|
||||
%Docstring
|
||||
Change the name of this container
|
||||
%End
|
||||
|
||||
int columnCount() const;
|
||||
%Docstring
|
||||
Gets the number of columns in this group
|
||||
%End
|
||||
|
||||
void setColumnCount( int columnCount );
|
||||
%Docstring
|
||||
Set the number of columns in this group
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
%Docstring
|
||||
Creates a deep copy of this element. To be implemented by subclasses.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
QgsOptionalExpression visibilityExpression() const;
|
||||
%Docstring
|
||||
The visibility expression is used in the attribute form to
|
||||
show or hide this container based on an expression incorporating
|
||||
the field value controlled by editor widgets.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
void setVisibilityExpression( const QgsOptionalExpression &visibilityExpression );
|
||||
%Docstring
|
||||
The visibility expression is used in the attribute form to
|
||||
show or hide this container based on an expression incorporating
|
||||
the field value controlled by editor widgets.
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
QColor backgroundColor() const;
|
||||
%Docstring
|
||||
backgroundColor
|
||||
|
||||
:return: background color of the container
|
||||
|
||||
.. versionadded:: 3.8
|
||||
%End
|
||||
|
||||
void setBackgroundColor( const QColor &backgroundColor );
|
||||
%Docstring
|
||||
Sets the background color to ``backgroundColor``
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
class QgsAttributeEditorField : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
This element will load a field's widget onto the form.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorelement.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsAttributeEditorField( const QString &name, int idx, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new attribute editor element which represents a field
|
||||
|
||||
:param name: The name of the element
|
||||
:param idx: The index of the field which should be embedded
|
||||
:param parent: The parent of this widget (used as container)
|
||||
%End
|
||||
|
||||
int idx() const;
|
||||
%Docstring
|
||||
Returns the index of the field.
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class QgsAttributeEditorRelation : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
This element will load a relation editor onto the form.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorelement.h"
|
||||
%End
|
||||
public:
|
||||
static const QMetaObject staticMetaObject;
|
||||
|
||||
public:
|
||||
|
||||
enum Button
|
||||
{
|
||||
Link,
|
||||
Unlink,
|
||||
SaveChildEdits,
|
||||
AddChildFeature,
|
||||
DuplicateChildFeature,
|
||||
DeleteChildFeature,
|
||||
ZoomToChildFeature,
|
||||
AllButtons
|
||||
};
|
||||
typedef QFlags<QgsAttributeEditorRelation::Button> Buttons;
|
||||
|
||||
|
||||
QgsAttributeEditorRelation( const QString &name, const QString &relationId, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
|
||||
.. deprecated:: QGIS 3.0.2.
|
||||
The name parameter is not used for anything and overwritten by the relationId internally.
|
||||
%End
|
||||
|
||||
QgsAttributeEditorRelation( const QString &name, const QgsRelation &relation, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
|
||||
.. deprecated:: QGIS 3.0.2.
|
||||
The name parameter is not used for anything and overwritten by the relationId internally.
|
||||
%End
|
||||
|
||||
QgsAttributeEditorRelation( const QString &relationId, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new element which embeds a relation.
|
||||
|
||||
:param relationId: The id of the relation to embed
|
||||
:param parent: The parent (used as container)
|
||||
%End
|
||||
|
||||
QgsAttributeEditorRelation( const QgsRelation &relation, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new element which embeds a relation.
|
||||
|
||||
:param relation: The relation to embed
|
||||
:param parent: The parent (used as container)
|
||||
%End
|
||||
|
||||
|
||||
const QgsRelation &relation() const;
|
||||
%Docstring
|
||||
Gets the id of the relation which shall be embedded
|
||||
|
||||
:return: the id
|
||||
%End
|
||||
|
||||
bool init( QgsRelationManager *relManager );
|
||||
%Docstring
|
||||
Initializes the relation from the id
|
||||
|
||||
:param relManager: The relation manager to use for the initialization
|
||||
|
||||
:return: ``True`` if the relation was found in the relationmanager
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
|
||||
bool forceSuppressFormPopup() const;
|
||||
%Docstring
|
||||
Determines the force suppress form popup status.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
void setForceSuppressFormPopup( bool forceSuppressFormPopup );
|
||||
%Docstring
|
||||
Sets force suppress form popup status to ``forceSuppressFormPopup``.
|
||||
This flag is to override the layer and general settings regarding the automatic
|
||||
opening of the attribute form dialog when digitizing is completed.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
QVariant nmRelationId() const;
|
||||
%Docstring
|
||||
Determines the relation id of the second relation involved in an N:M relation.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
void setNmRelationId( const QVariant &nmRelationId = QVariant() );
|
||||
%Docstring
|
||||
Sets ``nmRelationId`` for the relation id of the second relation involved in an N:M relation.
|
||||
If it's empty, then it's considered as a 1:M relationship.
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
QString label() const;
|
||||
%Docstring
|
||||
Determines the label of this element
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
void setLabel( const QString &label = QString() );
|
||||
%Docstring
|
||||
Sets ``label`` for this element
|
||||
If it's empty it takes the relation id as label
|
||||
|
||||
.. versionadded:: 3.16
|
||||
%End
|
||||
|
||||
QString relationWidgetTypeId() const;
|
||||
%Docstring
|
||||
Returns the current relation widget type id
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
void setRelationWidgetTypeId( const QString &relationWidgetTypeId );
|
||||
%Docstring
|
||||
Sets the relation widget type
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
QVariantMap relationEditorConfiguration() const;
|
||||
%Docstring
|
||||
Returns the relation editor widget configuration
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
void setRelationEditorConfiguration( const QVariantMap &config );
|
||||
%Docstring
|
||||
Sets the relation editor configuration
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
QFlags<QgsAttributeEditorRelation::Button> operator|(QgsAttributeEditorRelation::Button f1, QFlags<QgsAttributeEditorRelation::Button> f2);
|
||||
|
||||
|
||||
|
||||
class QgsAttributeEditorQmlElement : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
An attribute editor widget that will represent arbitrary QML code.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorelement.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsAttributeEditorQmlElement( const QString &name, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new element which can display QML
|
||||
|
||||
:param name: The name of the widget
|
||||
:param parent: The parent (used as container)
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
|
||||
QString qmlCode() const;
|
||||
%Docstring
|
||||
The QML code that will be represented within this widget.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
void setQmlCode( const QString &qmlCode );
|
||||
%Docstring
|
||||
Sets the QML code that will be represented within this widget to ``qmlCode``.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
class QgsAttributeEditorHtmlElement : QgsAttributeEditorElement
|
||||
{
|
||||
%Docstring
|
||||
An attribute editor widget that will represent arbitrary HTML code.
|
||||
|
||||
.. versionadded:: 3.8
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsattributeeditorelement.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsAttributeEditorHtmlElement( const QString &name, QgsAttributeEditorElement *parent );
|
||||
%Docstring
|
||||
Creates a new element which can display HTML
|
||||
|
||||
:param name: The name of the widget
|
||||
:param parent: The parent (used as container)
|
||||
%End
|
||||
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
|
||||
|
||||
|
||||
QString htmlCode() const;
|
||||
%Docstring
|
||||
The QML code that will be represented within this widget.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
void setHtmlCode( const QString &htmlCode );
|
||||
%Docstring
|
||||
Sets the HTML code that will be represented within this widget to ``htmlCode``.
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsattributeeditorelement.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -11,7 +11,6 @@
|
||||
%Include auto_generated/qgsanimatedicon.sip
|
||||
%Include auto_generated/qgsapplication.sip
|
||||
%Include auto_generated/qgsarchive.sip
|
||||
%Include auto_generated/qgsattributeeditorelement.sip
|
||||
%Include auto_generated/qgsattributes.sip
|
||||
%Include auto_generated/qgsattributetableconfig.sip
|
||||
%Include auto_generated/qgsauxiliarystorage.sip
|
||||
@ -51,7 +50,6 @@
|
||||
%Include auto_generated/qgsdefaultvalue.sip
|
||||
%Include auto_generated/qgsdiagramrenderer.sip
|
||||
%Include auto_generated/qgsdistancearea.sip
|
||||
%Include auto_generated/qgseditformconfig.sip
|
||||
%Include auto_generated/qgseditorwidgetsetup.sip
|
||||
%Include auto_generated/qgselevationutils.sip
|
||||
%Include auto_generated/qgsellipsoidutils.sip
|
||||
@ -251,6 +249,13 @@
|
||||
%Include auto_generated/diagram/qgsstackedbardiagram.sip
|
||||
%Include auto_generated/diagram/qgstextdiagram.sip
|
||||
%Include auto_generated/dxf/qgsdxfexport.sip
|
||||
%Include auto_generated/editform/qgseditformconfig.sip
|
||||
%Include auto_generated/editform/qgsattributeeditorelement.sip
|
||||
%Include auto_generated/editform/qgsattributeeditorcontainer.sip
|
||||
%Include auto_generated/editform/qgsattributeeditorfield.sip
|
||||
%Include auto_generated/editform/qgsattributeeditorrelation.sip
|
||||
%Include auto_generated/editform/qgsattributeeditorhtmlelement.sip
|
||||
%Include auto_generated/editform/qgsattributeeditorqmlelement.sip
|
||||
%Include auto_generated/effects/qgsblureffect.sip
|
||||
%Include auto_generated/effects/qgscoloreffect.sip
|
||||
%Include auto_generated/effects/qgseffectstack.sip
|
||||
|
@ -84,6 +84,14 @@ set(QGIS_CORE_SRCS
|
||||
diagram/qgsstackedbardiagram.cpp
|
||||
diagram/qgstextdiagram.cpp
|
||||
|
||||
editform/qgseditformconfig.cpp
|
||||
editform/qgsattributeeditorelement.cpp
|
||||
editform/qgsattributeeditorcontainer.cpp
|
||||
editform/qgsattributeeditorfield.cpp
|
||||
editform/qgsattributeeditorrelation.cpp
|
||||
editform/qgsattributeeditorhtmlelement.cpp
|
||||
editform/qgsattributeeditorqmlelement.cpp
|
||||
|
||||
effects/qgsblureffect.cpp
|
||||
effects/qgscoloreffect.cpp
|
||||
effects/qgseffectstack.cpp
|
||||
@ -257,7 +265,6 @@ set(QGIS_CORE_SRCS
|
||||
qgspostgresstringutils.cpp
|
||||
qgsattributes.cpp
|
||||
qgsattributetableconfig.cpp
|
||||
qgsattributeeditorelement.cpp
|
||||
qgsauxiliarystorage.cpp
|
||||
qgsbearingutils.cpp
|
||||
qgsbookmarkmanager.cpp
|
||||
@ -298,7 +305,6 @@ set(QGIS_CORE_SRCS
|
||||
qgsdefaultvalue.cpp
|
||||
qgsdiagramrenderer.cpp
|
||||
qgsdistancearea.cpp
|
||||
qgseditformconfig.cpp
|
||||
qgselevationutils.cpp
|
||||
qgsellipsoidutils.cpp
|
||||
qgserror.cpp
|
||||
@ -836,7 +842,6 @@ set(QGIS_CORE_HDRS
|
||||
qgsanimatedicon.h
|
||||
qgsapplication.h
|
||||
qgsarchive.h
|
||||
qgsattributeeditorelement.h
|
||||
qgsattributes.h
|
||||
qgsattributetableconfig.h
|
||||
qgsauxiliarystorage.h
|
||||
@ -878,7 +883,6 @@ set(QGIS_CORE_HDRS
|
||||
qgsdefaultvalue.h
|
||||
qgsdiagramrenderer.h
|
||||
qgsdistancearea.h
|
||||
qgseditformconfig.h
|
||||
qgseditorwidgetsetup.h
|
||||
qgselevationutils.h
|
||||
qgsellipsoidutils.h
|
||||
@ -1113,6 +1117,14 @@ set(QGIS_CORE_HDRS
|
||||
|
||||
dxf/qgsdxfexport.h
|
||||
|
||||
editform/qgseditformconfig.h
|
||||
editform/qgsattributeeditorelement.h
|
||||
editform/qgsattributeeditorcontainer.h
|
||||
editform/qgsattributeeditorfield.h
|
||||
editform/qgsattributeeditorrelation.h
|
||||
editform/qgsattributeeditorhtmlelement.h
|
||||
editform/qgsattributeeditorqmlelement.h
|
||||
|
||||
effects/qgsblureffect.h
|
||||
effects/qgscoloreffect.h
|
||||
effects/qgseffectstack.h
|
||||
@ -1569,7 +1581,6 @@ set(QGIS_CORE_PRIVATE_HDRS
|
||||
qgscoordinatereferencesystem_p.h
|
||||
qgscoordinatetransformcontext_p.h
|
||||
qgscoordinatetransform_p.h
|
||||
qgseditformconfig_p.h
|
||||
qgsfeature_p.h
|
||||
qgsfield_p.h
|
||||
qgsfields_p.h
|
||||
@ -1577,6 +1588,7 @@ set(QGIS_CORE_PRIVATE_HDRS
|
||||
qgsrelation_p.h
|
||||
qgsspatialindexkdbush_p.h
|
||||
|
||||
editform/qgseditformconfig_p.h
|
||||
textrenderer/qgstextrenderer_p.h
|
||||
)
|
||||
|
||||
@ -1726,6 +1738,7 @@ target_include_directories(qgis_core PUBLIC
|
||||
callouts
|
||||
classification
|
||||
dxf
|
||||
editform
|
||||
effects
|
||||
expression
|
||||
fieldformatter
|
||||
|
166
src/core/editform/qgsattributeeditorcontainer.cpp
Normal file
166
src/core/editform/qgsattributeeditorcontainer.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorcontainer.cpp - QgsAttributeEditorContainer
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsattributeeditorcontainer.h"
|
||||
|
||||
|
||||
void QgsAttributeEditorContainer::addChildElement( QgsAttributeEditorElement *widget )
|
||||
{
|
||||
mChildren.append( widget );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::setName( const QString &name )
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
QgsOptionalExpression QgsAttributeEditorContainer::visibilityExpression() const
|
||||
{
|
||||
return mVisibilityExpression;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::setVisibilityExpression( const QgsOptionalExpression &visibilityExpression )
|
||||
{
|
||||
if ( visibilityExpression == mVisibilityExpression )
|
||||
return;
|
||||
|
||||
mVisibilityExpression = visibilityExpression;
|
||||
}
|
||||
|
||||
QColor QgsAttributeEditorContainer::backgroundColor() const
|
||||
{
|
||||
return mBackgroundColor;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::setBackgroundColor( const QColor &backgroundColor )
|
||||
{
|
||||
mBackgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
QList<QgsAttributeEditorElement *> QgsAttributeEditorContainer::findElements( QgsAttributeEditorElement::AttributeEditorType type ) const
|
||||
{
|
||||
QList<QgsAttributeEditorElement *> results;
|
||||
|
||||
const auto constMChildren = mChildren;
|
||||
for ( QgsAttributeEditorElement *elem : constMChildren )
|
||||
{
|
||||
if ( elem->type() == type )
|
||||
{
|
||||
results.append( elem );
|
||||
}
|
||||
|
||||
if ( elem->type() == AeTypeContainer )
|
||||
{
|
||||
QgsAttributeEditorContainer *cont = dynamic_cast<QgsAttributeEditorContainer *>( elem );
|
||||
if ( cont )
|
||||
results += cont->findElements( type );
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::clear()
|
||||
{
|
||||
qDeleteAll( mChildren );
|
||||
mChildren.clear();
|
||||
}
|
||||
|
||||
int QgsAttributeEditorContainer::columnCount() const
|
||||
{
|
||||
return mColumnCount;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::setColumnCount( int columnCount )
|
||||
{
|
||||
mColumnCount = columnCount;
|
||||
}
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorContainer::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorContainer *element = new QgsAttributeEditorContainer( name(), parent );
|
||||
|
||||
const auto childElements = children();
|
||||
|
||||
for ( QgsAttributeEditorElement *child : childElements )
|
||||
{
|
||||
element->addChildElement( child->clone( element ) );
|
||||
}
|
||||
element->mIsGroupBox = mIsGroupBox;
|
||||
element->mColumnCount = mColumnCount;
|
||||
element->mVisibilityExpression = mVisibilityExpression;
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
elem.setAttribute( QStringLiteral( "columnCount" ), mColumnCount );
|
||||
elem.setAttribute( QStringLiteral( "groupBox" ), mIsGroupBox ? 1 : 0 );
|
||||
elem.setAttribute( QStringLiteral( "visibilityExpressionEnabled" ), mVisibilityExpression.enabled() ? 1 : 0 );
|
||||
elem.setAttribute( QStringLiteral( "visibilityExpression" ), mVisibilityExpression->expression() );
|
||||
if ( mBackgroundColor.isValid() )
|
||||
elem.setAttribute( QStringLiteral( "backgroundColor" ), mBackgroundColor.name( ) );
|
||||
const auto constMChildren = mChildren;
|
||||
for ( QgsAttributeEditorElement *child : constMChildren )
|
||||
{
|
||||
QDomDocument doc = elem.ownerDocument();
|
||||
elem.appendChild( child->toDomElement( doc ) );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
mBackgroundColor = element.attribute( QStringLiteral( "backgroundColor" ), QString() );
|
||||
bool ok;
|
||||
int cc = element.attribute( QStringLiteral( "columnCount" ) ).toInt( &ok );
|
||||
if ( !ok )
|
||||
cc = 0;
|
||||
setColumnCount( cc );
|
||||
|
||||
bool isGroupBox = element.attribute( QStringLiteral( "groupBox" ) ).toInt( &ok );
|
||||
if ( ok )
|
||||
setIsGroupBox( isGroupBox );
|
||||
else
|
||||
setIsGroupBox( mParent );
|
||||
|
||||
bool visibilityExpressionEnabled = element.attribute( QStringLiteral( "visibilityExpressionEnabled" ) ).toInt( &ok );
|
||||
QgsOptionalExpression visibilityExpression;
|
||||
if ( ok )
|
||||
{
|
||||
visibilityExpression.setEnabled( visibilityExpressionEnabled );
|
||||
visibilityExpression.setData( QgsExpression( element.attribute( QStringLiteral( "visibilityExpression" ) ) ) );
|
||||
}
|
||||
setVisibilityExpression( visibilityExpression );
|
||||
|
||||
QDomNodeList childNodeList = element.childNodes();
|
||||
|
||||
for ( int i = 0; i < childNodeList.size(); i++ )
|
||||
{
|
||||
QDomElement childElem = childNodeList.at( i ).toElement();
|
||||
|
||||
QgsAttributeEditorElement *myElem = create( childElem, layerId, fields, context, this );
|
||||
if ( myElem )
|
||||
addChildElement( myElem );
|
||||
}
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorContainer::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorContainer" );
|
||||
}
|
||||
|
155
src/core/editform/qgsattributeeditorcontainer.h
Normal file
155
src/core/editform/qgsattributeeditorcontainer.h
Normal file
@ -0,0 +1,155 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorcontainer.h - QgsAttributeEditorElement
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSATTRIBUTEEDITORCONTAINER_H
|
||||
#define QGSATTRIBUTEEDITORCONTAINER_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgsattributeeditorelement.h"
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* This is a container for attribute editors, used to group them visually in the
|
||||
* attribute form if it is set to the drag and drop designer.
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorContainer : public QgsAttributeEditorElement
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new attribute editor container
|
||||
*
|
||||
* \param name The name to show as title
|
||||
* \param parent The parent. May be another container.
|
||||
* \param backgroundColor The optional background color of the container.
|
||||
*/
|
||||
QgsAttributeEditorContainer( const QString &name, QgsAttributeEditorElement *parent, const QColor &backgroundColor = QColor() )
|
||||
: QgsAttributeEditorElement( AeTypeContainer, name, parent )
|
||||
, mIsGroupBox( true )
|
||||
, mColumnCount( 1 )
|
||||
, mBackgroundColor( backgroundColor )
|
||||
{}
|
||||
|
||||
|
||||
~QgsAttributeEditorContainer() override;
|
||||
|
||||
/**
|
||||
* Add a child element to this container. This may be another container, a field or a relation.
|
||||
*
|
||||
* \param element The element to add as child
|
||||
*/
|
||||
virtual void addChildElement( QgsAttributeEditorElement *element SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Determines if this container is rendered as collapsible group box or tab in a tabwidget
|
||||
*
|
||||
* \param isGroupBox If TRUE, this will be a group box
|
||||
*/
|
||||
virtual void setIsGroupBox( bool isGroupBox ) { mIsGroupBox = isGroupBox; }
|
||||
|
||||
/**
|
||||
* Returns if this container is going to be rendered as a group box
|
||||
*
|
||||
* \returns TRUE if it will be a group box, FALSE if it will be a tab
|
||||
*/
|
||||
virtual bool isGroupBox() const { return mIsGroupBox; }
|
||||
|
||||
/**
|
||||
* Gets a list of the children elements of this container
|
||||
*
|
||||
* \returns A list of elements
|
||||
*/
|
||||
QList<QgsAttributeEditorElement *> children() const { return mChildren; }
|
||||
|
||||
/**
|
||||
* Traverses the element tree to find any element of the specified type
|
||||
*
|
||||
* \param type The type which should be searched
|
||||
*
|
||||
* \returns A list of elements of the type which has been searched for
|
||||
*/
|
||||
virtual QList<QgsAttributeEditorElement *> findElements( AttributeEditorType type ) const;
|
||||
|
||||
/**
|
||||
* Clear all children from this container.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Change the name of this container
|
||||
*/
|
||||
void setName( const QString &name );
|
||||
|
||||
/**
|
||||
* Gets the number of columns in this group
|
||||
*/
|
||||
int columnCount() const;
|
||||
|
||||
/**
|
||||
* Set the number of columns in this group
|
||||
*/
|
||||
void setColumnCount( int columnCount );
|
||||
|
||||
/**
|
||||
* Creates a deep copy of this element. To be implemented by subclasses.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* The visibility expression is used in the attribute form to
|
||||
* show or hide this container based on an expression incorporating
|
||||
* the field value controlled by editor widgets.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QgsOptionalExpression visibilityExpression() const;
|
||||
|
||||
/**
|
||||
* The visibility expression is used in the attribute form to
|
||||
* show or hide this container based on an expression incorporating
|
||||
* the field value controlled by editor widgets.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
void setVisibilityExpression( const QgsOptionalExpression &visibilityExpression );
|
||||
|
||||
/**
|
||||
* \brief backgroundColor
|
||||
* \return background color of the container
|
||||
* \since QGIS 3.8
|
||||
*/
|
||||
QColor backgroundColor() const;
|
||||
|
||||
/**
|
||||
* Sets the background color to \a backgroundColor
|
||||
*/
|
||||
void setBackgroundColor( const QColor &backgroundColor );
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
|
||||
bool mIsGroupBox;
|
||||
QList<QgsAttributeEditorElement *> mChildren;
|
||||
int mColumnCount;
|
||||
QgsOptionalExpression mVisibilityExpression;
|
||||
QColor mBackgroundColor;
|
||||
};
|
||||
|
||||
|
||||
#endif // QGSATTRIBUTEEDITORCONTAINER_H
|
89
src/core/editform/qgsattributeeditorelement.cpp
Normal file
89
src/core/editform/qgsattributeeditorelement.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorelement.cpp - QgsAttributeEditorElement
|
||||
|
||||
---------------------
|
||||
begin : 18.8.2016
|
||||
copyright : (C) 2016 by Matthias Kuhn
|
||||
email : matthias@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsattributeeditorelement.h"
|
||||
|
||||
#include "qgsattributeeditorcontainer.h"
|
||||
#include "qgsattributeeditorfield.h"
|
||||
#include "qgsattributeeditorhtmlelement.h"
|
||||
#include "qgsattributeeditorqmlelement.h"
|
||||
#include "qgsattributeeditorrelation.h"
|
||||
|
||||
|
||||
|
||||
QDomElement QgsAttributeEditorElement::toDomElement( QDomDocument &doc ) const
|
||||
{
|
||||
QDomElement elem = doc.createElement( typeIdentifier() );
|
||||
elem.setAttribute( QStringLiteral( "name" ), mName );
|
||||
elem.setAttribute( QStringLiteral( "showLabel" ), mShowLabel );
|
||||
saveConfiguration( elem, doc );
|
||||
return elem;
|
||||
}
|
||||
|
||||
bool QgsAttributeEditorElement::showLabel() const
|
||||
{
|
||||
return mShowLabel;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorElement::setShowLabel( bool showLabel )
|
||||
{
|
||||
mShowLabel = showLabel;
|
||||
}
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorElement::create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent )
|
||||
{
|
||||
QgsAttributeEditorElement *newElement = nullptr;
|
||||
|
||||
QString name = element.attribute( QStringLiteral( "name" ) );
|
||||
|
||||
if ( element.tagName() == QLatin1String( "attributeEditorContainer" ) )
|
||||
{
|
||||
newElement = new QgsAttributeEditorContainer( context.projectTranslator()->translate( QStringLiteral( "project:layers:%1:formcontainers" ).arg( layerId ),
|
||||
name ), parent );
|
||||
}
|
||||
else if ( element.tagName() == QLatin1String( "attributeEditorField" ) )
|
||||
{
|
||||
int idx = fields.lookupField( name );
|
||||
newElement = new QgsAttributeEditorField( name, idx, parent );
|
||||
}
|
||||
else if ( element.tagName() == QLatin1String( "attributeEditorRelation" ) )
|
||||
{
|
||||
// At this time, the relations are not loaded
|
||||
// So we only grab the id and delegate the rest to onRelationsLoaded()
|
||||
newElement = new QgsAttributeEditorRelation( element.attribute( QStringLiteral( "relation" ), QStringLiteral( "[None]" ) ), parent );
|
||||
}
|
||||
else if ( element.tagName() == QLatin1String( "attributeEditorQmlElement" ) )
|
||||
{
|
||||
newElement = new QgsAttributeEditorQmlElement( element.attribute( QStringLiteral( "name" ) ), parent );
|
||||
}
|
||||
else if ( element.tagName() == QLatin1String( "attributeEditorHtmlElement" ) )
|
||||
{
|
||||
newElement = new QgsAttributeEditorHtmlElement( element.attribute( QStringLiteral( "name" ) ), parent );
|
||||
}
|
||||
|
||||
if ( newElement )
|
||||
{
|
||||
if ( element.hasAttribute( QStringLiteral( "showLabel" ) ) )
|
||||
newElement->setShowLabel( element.attribute( QStringLiteral( "showLabel" ) ).toInt() );
|
||||
else
|
||||
newElement->setShowLabel( true );
|
||||
|
||||
newElement->loadConfiguration( element, layerId, context, fields );
|
||||
}
|
||||
|
||||
return newElement;
|
||||
}
|
||||
|
175
src/core/editform/qgsattributeeditorelement.h
Normal file
175
src/core/editform/qgsattributeeditorelement.h
Normal file
@ -0,0 +1,175 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorelement.h - QgsAttributeEditorElement
|
||||
|
||||
---------------------
|
||||
begin : 18.8.2016
|
||||
copyright : (C) 2016 by Matthias Kuhn
|
||||
email : matthias@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSATTRIBUTEEDITORELEMENT_H
|
||||
#define QGSATTRIBUTEEDITORELEMENT_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgsrelation.h"
|
||||
#include "qgsoptionalexpression.h"
|
||||
#include "qgspropertycollection.h"
|
||||
#include <QColor>
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* This is an abstract base class for any elements of a drag and drop form.
|
||||
*
|
||||
* This can either be a container which will be represented on the screen
|
||||
* as a tab widget or a collapsible group box. Or it can be a field which will
|
||||
* then be represented based on the QgsEditorWidget type and configuration.
|
||||
* Or it can be a relation and embed the form of several children of another
|
||||
* layer.
|
||||
*/
|
||||
|
||||
class CORE_EXPORT QgsAttributeEditorElement SIP_ABSTRACT
|
||||
{
|
||||
|
||||
#ifdef SIP_RUN
|
||||
SIP_CONVERT_TO_SUBCLASS_CODE
|
||||
switch ( sipCpp->type() )
|
||||
{
|
||||
case QgsAttributeEditorElement::AeTypeContainer:
|
||||
sipType = sipType_QgsAttributeEditorContainer;
|
||||
break;
|
||||
case QgsAttributeEditorElement::AeTypeField:
|
||||
sipType = sipType_QgsAttributeEditorField;
|
||||
break;
|
||||
case QgsAttributeEditorElement::AeTypeRelation:
|
||||
sipType = sipType_QgsAttributeEditorRelation;
|
||||
break;
|
||||
default:
|
||||
sipType = nullptr;
|
||||
break;
|
||||
}
|
||||
SIP_END
|
||||
#endif
|
||||
public:
|
||||
enum AttributeEditorType
|
||||
{
|
||||
AeTypeContainer, //!< A container
|
||||
AeTypeField, //!< A field
|
||||
AeTypeRelation, //!< A relation
|
||||
AeTypeInvalid, //!< Invalid
|
||||
AeTypeQmlElement, //!< A QML element
|
||||
AeTypeHtmlElement //!< A HTML element
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param type The type of the new element.
|
||||
* \param name
|
||||
* \param parent
|
||||
*/
|
||||
QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = nullptr )
|
||||
: mType( type )
|
||||
, mName( name )
|
||||
, mParent( parent )
|
||||
, mShowLabel( true )
|
||||
{}
|
||||
|
||||
virtual ~QgsAttributeEditorElement() = default;
|
||||
|
||||
/**
|
||||
* Constructs the editor element from the given element
|
||||
*
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
static QgsAttributeEditorElement *create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = nullptr ) SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Returns the name of this element
|
||||
*
|
||||
* \returns The name for this element
|
||||
*/
|
||||
QString name() const { return mName; }
|
||||
|
||||
/**
|
||||
* The type of this element
|
||||
*
|
||||
* \returns The type
|
||||
*/
|
||||
AttributeEditorType type() const { return mType; }
|
||||
|
||||
/**
|
||||
* Gets the parent of this element.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QgsAttributeEditorElement *parent() const { return mParent; }
|
||||
|
||||
/**
|
||||
* Gets the XML Dom element to save this element.
|
||||
*
|
||||
* \param doc The QDomDocument which is used to create new XML elements
|
||||
*
|
||||
* \returns A DOM element to serialize this element
|
||||
*/
|
||||
QDomElement toDomElement( QDomDocument &doc ) const;
|
||||
|
||||
/**
|
||||
* Returns a clone of this element. To be implemented by subclasses.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const = 0 SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Controls if this element should be labeled with a title (field, relation or groupname).
|
||||
*
|
||||
* \since QGIS 2.18
|
||||
*/
|
||||
bool showLabel() const;
|
||||
|
||||
/**
|
||||
* Controls if this element should be labeled with a title (field, relation or groupname).
|
||||
* \since QGIS 2.18
|
||||
*/
|
||||
void setShowLabel( bool showLabel );
|
||||
|
||||
protected:
|
||||
#ifndef SIP_RUN
|
||||
AttributeEditorType mType;
|
||||
QString mName;
|
||||
QgsAttributeEditorElement *mParent = nullptr;
|
||||
bool mShowLabel;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Should be implemented by subclasses to save type specific configuration.
|
||||
*
|
||||
* \since QGIS 2.18
|
||||
*/
|
||||
virtual void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const = 0;
|
||||
|
||||
/**
|
||||
* Should be implemented by subclasses to read specific configuration
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
virtual void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) = 0;
|
||||
|
||||
/**
|
||||
* All subclasses need to overwrite this method and return a type specific identifier.
|
||||
* Needs to be XML key compatible.
|
||||
*
|
||||
* \since QGIS 2.18
|
||||
*/
|
||||
virtual QString typeIdentifier() const = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSATTRIBUTEEDITORELEMENT_H
|
42
src/core/editform/qgsattributeeditorfield.cpp
Normal file
42
src/core/editform/qgsattributeeditorfield.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorfield.cpp - QgsAttributeEditorField
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgsattributeeditorfield.h"
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorField::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorField *element = new QgsAttributeEditorField( name(), mIdx, parent );
|
||||
return element;
|
||||
}
|
||||
|
||||
|
||||
void QgsAttributeEditorField::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
elem.setAttribute( QStringLiteral( "index" ), mIdx );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorField::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
Q_UNUSED( element )
|
||||
Q_UNUSED( layerId )
|
||||
Q_UNUSED( context )
|
||||
Q_UNUSED( fields )
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorField::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorField" );
|
||||
}
|
59
src/core/editform/qgsattributeeditorfield.h
Normal file
59
src/core/editform/qgsattributeeditorfield.h
Normal file
@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorfield.h - QgsAttributeEditorElement
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSATTRIBUTEEDITORFIELD_H
|
||||
#define QGSATTRIBUTEEDITORFIELD_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgsattributeeditorelement.h"
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* This element will load a field's widget onto the form.
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorField : public QgsAttributeEditorElement
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new attribute editor element which represents a field
|
||||
*
|
||||
* \param name The name of the element
|
||||
* \param idx The index of the field which should be embedded
|
||||
* \param parent The parent of this widget (used as container)
|
||||
*/
|
||||
QgsAttributeEditorField( const QString &name, int idx, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeField, name, parent )
|
||||
, mIdx( idx )
|
||||
{}
|
||||
|
||||
/**
|
||||
* Returns the index of the field.
|
||||
*/
|
||||
int idx() const { return mIdx; }
|
||||
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
int mIdx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // QGSATTRIBUTEEDITORFIELD_H
|
55
src/core/editform/qgsattributeeditorhtmlelement.cpp
Normal file
55
src/core/editform/qgsattributeeditorhtmlelement.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorhtmlelement.cpp - QgsAttributeEditorHtmlelement
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgsattributeeditorhtmlelement.h"
|
||||
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorHtmlElement::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorHtmlElement *element = new QgsAttributeEditorHtmlElement( name(), parent );
|
||||
element->setHtmlCode( mHtmlCode );
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorHtmlElement::htmlCode() const
|
||||
{
|
||||
return mHtmlCode;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorHtmlElement::setHtmlCode( const QString &htmlCode )
|
||||
{
|
||||
mHtmlCode = htmlCode;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorHtmlElement::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
QDomText codeElem = doc.createTextNode( mHtmlCode );
|
||||
elem.appendChild( codeElem );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorHtmlElement::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
Q_UNUSED( layerId )
|
||||
Q_UNUSED( context )
|
||||
Q_UNUSED( fields )
|
||||
setHtmlCode( element.text() );
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorHtmlElement::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorHtmlElement" );
|
||||
}
|
||||
|
66
src/core/editform/qgsattributeeditorhtmlelement.h
Normal file
66
src/core/editform/qgsattributeeditorhtmlelement.h
Normal file
@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorhtmlelement.h - QgsAttributeEditorElement
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSATTRIBUTEEDITORHTMLELEMENT_H
|
||||
#define QGSATTRIBUTEEDITORHTMLELEMENT_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgsattributeeditorelement.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* An attribute editor widget that will represent arbitrary HTML code.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorHtmlElement : public QgsAttributeEditorElement
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new element which can display HTML
|
||||
*
|
||||
* \param name The name of the widget
|
||||
* \param parent The parent (used as container)
|
||||
*/
|
||||
QgsAttributeEditorHtmlElement( const QString &name, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeHtmlElement, name, parent )
|
||||
{}
|
||||
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* The Html code that will be represented within this widget.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
QString htmlCode() const;
|
||||
|
||||
/**
|
||||
* Sets the HTML code that will be represented within this widget to \a htmlCode.
|
||||
*/
|
||||
void setHtmlCode( const QString &htmlCode );
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
QString mHtmlCode;
|
||||
};
|
||||
|
||||
|
||||
#endif // QGSATTRIBUTEEDITORHTMLELEMENT_H
|
56
src/core/editform/qgsattributeeditorqmlelement.cpp
Normal file
56
src/core/editform/qgsattributeeditorqmlelement.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorqmlelement.cpp - QgsAttributeEditorQmlelement
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgsattributeeditorqmlelement.h"
|
||||
|
||||
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorQmlElement::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorQmlElement *element = new QgsAttributeEditorQmlElement( name(), parent );
|
||||
element->setQmlCode( mQmlCode );
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorQmlElement::qmlCode() const
|
||||
{
|
||||
return mQmlCode;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorQmlElement::setQmlCode( const QString &qmlCode )
|
||||
{
|
||||
mQmlCode = qmlCode;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorQmlElement::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
QDomText codeElem = doc.createTextNode( mQmlCode );
|
||||
elem.appendChild( codeElem );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorQmlElement::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
Q_UNUSED( layerId )
|
||||
Q_UNUSED( context )
|
||||
Q_UNUSED( fields )
|
||||
setQmlCode( element.text() );
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorQmlElement::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorQmlElement" );
|
||||
}
|
||||
|
63
src/core/editform/qgsattributeeditorqmlelement.h
Normal file
63
src/core/editform/qgsattributeeditorqmlelement.h
Normal file
@ -0,0 +1,63 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorqmlelement.h - QgsAttributeEditorElement
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSATTRIBUTEEDITORQMLELEMENT_H
|
||||
#define QGSATTRIBUTEEDITORQMLELEMENT_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgsattributeeditorelement.h"
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* An attribute editor widget that will represent arbitrary QML code.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorQmlElement : public QgsAttributeEditorElement
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new element which can display QML
|
||||
*
|
||||
* \param name The name of the widget
|
||||
* \param parent The parent (used as container)
|
||||
*/
|
||||
QgsAttributeEditorQmlElement( const QString &name, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeQmlElement, name, parent )
|
||||
{}
|
||||
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* The QML code that will be represented within this widget.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
QString qmlCode() const;
|
||||
|
||||
/**
|
||||
* Sets the QML code that will be represented within this widget to \a qmlCode.
|
||||
*/
|
||||
void setQmlCode( const QString &qmlCode );
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
QString mQmlCode;
|
||||
};
|
||||
|
||||
#endif // QGSATTRIBUTEEDITORQMLELEMENT_H
|
157
src/core/editform/qgsattributeeditorrelation.cpp
Normal file
157
src/core/editform/qgsattributeeditorrelation.cpp
Normal file
@ -0,0 +1,157 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorrelation.cpp - QgsAttributeEditorRelation
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgsattributeeditorrelation.h"
|
||||
#include "qgsrelationmanager.h"
|
||||
#include "qgsxmlutils.h"
|
||||
|
||||
bool QgsAttributeEditorRelation::init( QgsRelationManager *relationManager )
|
||||
{
|
||||
mRelation = relationManager->relation( mRelationId );
|
||||
return mRelation.isValid();
|
||||
}
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorRelation::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorRelation *element = new QgsAttributeEditorRelation( mRelationId, parent );
|
||||
element->mRelation = mRelation;
|
||||
element->mButtons = mButtons;
|
||||
element->mForceSuppressFormPopup = mForceSuppressFormPopup;
|
||||
element->mNmRelationId = mNmRelationId;
|
||||
element->mLabel = mLabel;
|
||||
element->mRelationEditorConfig = mRelationEditorConfig;
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
elem.setAttribute( QStringLiteral( "relation" ), mRelation.id() );
|
||||
elem.setAttribute( QStringLiteral( "forceSuppressFormPopup" ), mForceSuppressFormPopup );
|
||||
elem.setAttribute( QStringLiteral( "nmRelationId" ), mNmRelationId.toString() );
|
||||
elem.setAttribute( QStringLiteral( "label" ), mLabel );
|
||||
elem.setAttribute( QStringLiteral( "relationWidgetTypeId" ), mRelationWidgetTypeId );
|
||||
|
||||
QDomElement elemConfig = QgsXmlUtils::writeVariant( mRelationEditorConfig, doc );
|
||||
elemConfig.setTagName( QStringLiteral( "editor_configuration" ) );
|
||||
elem.appendChild( elemConfig );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
Q_UNUSED( layerId )
|
||||
Q_UNUSED( context )
|
||||
Q_UNUSED( fields )
|
||||
|
||||
QVariantMap config = QgsXmlUtils::readVariant( element.firstChildElement( "editor_configuration" ) ).toMap();
|
||||
|
||||
// load defaults
|
||||
if ( config.isEmpty() )
|
||||
config = relationEditorConfiguration();
|
||||
|
||||
// pre QGIS 3.18 compatibility
|
||||
if ( ! config.contains( QStringLiteral( "buttons" ) ) )
|
||||
{
|
||||
if ( element.hasAttribute( "buttons" ) )
|
||||
{
|
||||
QString buttonString = element.attribute( QStringLiteral( "buttons" ), qgsFlagValueToKeys( QgsAttributeEditorRelation::Button::AllButtons ) );
|
||||
config.insert( "buttons", qgsFlagValueToKeys( qgsFlagKeysToValue( buttonString, QgsAttributeEditorRelation::Button::AllButtons ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// pre QGIS 3.16 compatibility
|
||||
QgsAttributeEditorRelation::Buttons buttons = QgsAttributeEditorRelation::Button::AllButtons;
|
||||
buttons.setFlag( QgsAttributeEditorRelation::Button::Link, element.attribute( QStringLiteral( "showLinkButton" ), QStringLiteral( "1" ) ).toInt() );
|
||||
buttons.setFlag( QgsAttributeEditorRelation::Button::Unlink, element.attribute( QStringLiteral( "showUnlinkButton" ), QStringLiteral( "1" ) ).toInt() );
|
||||
buttons.setFlag( QgsAttributeEditorRelation::Button::SaveChildEdits, element.attribute( QStringLiteral( "showSaveChildEditsButton" ), QStringLiteral( "1" ) ).toInt() );
|
||||
config.insert( "buttons", qgsFlagValueToKeys( buttons ) );
|
||||
}
|
||||
}
|
||||
|
||||
setRelationEditorConfiguration( config );
|
||||
|
||||
setForceSuppressFormPopup( element.attribute( QStringLiteral( "forceSuppressFormPopup" ), 0 ).toInt() );
|
||||
|
||||
if ( element.hasAttribute( QStringLiteral( "nmRelationId" ) ) )
|
||||
{
|
||||
setNmRelationId( element.attribute( QStringLiteral( "nmRelationId" ) ) );
|
||||
}
|
||||
|
||||
if ( element.hasAttribute( "label" ) )
|
||||
{
|
||||
QString label = element.attribute( QStringLiteral( "label" ) );
|
||||
setLabel( label );
|
||||
}
|
||||
if ( element.hasAttribute( "relationWidgetTypeId" ) )
|
||||
{
|
||||
QString relationWidgetTypeId = element.attribute( QStringLiteral( "relationWidgetTypeId" ) );
|
||||
setRelationWidgetTypeId( relationWidgetTypeId );
|
||||
}
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorRelation::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorRelation" );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setForceSuppressFormPopup( bool forceSuppressFormPopup )
|
||||
{
|
||||
mForceSuppressFormPopup = forceSuppressFormPopup;
|
||||
}
|
||||
|
||||
bool QgsAttributeEditorRelation::forceSuppressFormPopup() const
|
||||
{
|
||||
return mForceSuppressFormPopup;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setNmRelationId( const QVariant &nmRelationId )
|
||||
{
|
||||
mNmRelationId = nmRelationId;
|
||||
}
|
||||
|
||||
QVariant QgsAttributeEditorRelation::nmRelationId() const
|
||||
{
|
||||
return mNmRelationId;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setLabel( const QString &label )
|
||||
{
|
||||
mLabel = label;
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorRelation::label() const
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorRelation::relationWidgetTypeId() const
|
||||
{
|
||||
return mRelationWidgetTypeId;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setRelationWidgetTypeId( const QString &relationWidgetTypeId )
|
||||
{
|
||||
mRelationWidgetTypeId = relationWidgetTypeId;
|
||||
}
|
||||
|
||||
QVariantMap QgsAttributeEditorRelation::relationEditorConfiguration() const
|
||||
{
|
||||
return mRelationEditorConfig;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setRelationEditorConfiguration( const QVariantMap &config )
|
||||
{
|
||||
mRelationEditorConfig = config;
|
||||
}
|
195
src/core/editform/qgsattributeeditorrelation.h
Normal file
195
src/core/editform/qgsattributeeditorrelation.h
Normal file
@ -0,0 +1,195 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorrelation.h - QgsAttributeEditorElement
|
||||
|
||||
---------------------
|
||||
begin : 12.01.2021
|
||||
copyright : (C) 2021 by Denis Rouzaud
|
||||
email : denis@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSATTRIBUTEEDITORRELATION_H
|
||||
#define QGSATTRIBUTEEDITORRELATION_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgsattributeeditorelement.h"
|
||||
#include "qgsrelation.h"
|
||||
#include "qgsoptionalexpression.h"
|
||||
#include "qgspropertycollection.h"
|
||||
#include <QColor>
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* This element will load a relation editor onto the form.
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorRelation : public QgsAttributeEditorElement
|
||||
{
|
||||
Q_GADGET
|
||||
public:
|
||||
|
||||
/**
|
||||
* Possible buttons shown in the relation editor
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
enum Button
|
||||
{
|
||||
Link = 1 << 1, //!< Link button
|
||||
Unlink = 1 << 2, //!< Unlink button
|
||||
SaveChildEdits = 1 << 3, //!< Save child edits button
|
||||
AddChildFeature = 1 << 4, //!< Add child feature (as in some projects we only want to allow linking/unlinking existing features)
|
||||
DuplicateChildFeature = 1 << 5, //!< Duplicate child feature
|
||||
DeleteChildFeature = 1 << 6, //!< Delete child feature button
|
||||
ZoomToChildFeature = 1 << 7, //!< Zoom to child feature
|
||||
AllButtons = Link | Unlink | SaveChildEdits | AddChildFeature | DuplicateChildFeature | DeleteChildFeature | ZoomToChildFeature //!< All buttons
|
||||
};
|
||||
Q_ENUM( Button )
|
||||
Q_DECLARE_FLAGS( Buttons, Button )
|
||||
Q_FLAG( Buttons )
|
||||
|
||||
/**
|
||||
* \deprecated since QGIS 3.0.2. The name parameter is not used for anything and overwritten by the relationId internally.
|
||||
*/
|
||||
Q_DECL_DEPRECATED QgsAttributeEditorRelation( const QString &name, const QString &relationId, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeRelation, name, parent )
|
||||
, mRelationId( relationId )
|
||||
{}
|
||||
|
||||
/**
|
||||
* \deprecated since QGIS 3.0.2. The name parameter is not used for anything and overwritten by the relationId internally.
|
||||
*/
|
||||
Q_DECL_DEPRECATED QgsAttributeEditorRelation( const QString &name, const QgsRelation &relation, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeRelation, name, parent )
|
||||
, mRelationId( relation.id() )
|
||||
, mRelation( relation )
|
||||
{}
|
||||
|
||||
/**
|
||||
* Creates a new element which embeds a relation.
|
||||
*
|
||||
* \param relationId The id of the relation to embed
|
||||
* \param parent The parent (used as container)
|
||||
*/
|
||||
QgsAttributeEditorRelation( const QString &relationId, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeRelation, relationId, parent )
|
||||
, mRelationId( relationId )
|
||||
{}
|
||||
|
||||
/**
|
||||
* Creates a new element which embeds a relation.
|
||||
*
|
||||
* \param relation The relation to embed
|
||||
* \param parent The parent (used as container)
|
||||
*/
|
||||
QgsAttributeEditorRelation( const QgsRelation &relation, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeRelation, relation.id(), parent )
|
||||
, mRelationId( relation.id() )
|
||||
, mRelation( relation )
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the id of the relation which shall be embedded
|
||||
*
|
||||
* \returns the id
|
||||
*/
|
||||
const QgsRelation &relation() const { return mRelation; }
|
||||
|
||||
/**
|
||||
* Initializes the relation from the id
|
||||
*
|
||||
* \param relManager The relation manager to use for the initialization
|
||||
* \returns TRUE if the relation was found in the relationmanager
|
||||
*/
|
||||
bool init( QgsRelationManager *relManager );
|
||||
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Determines the force suppress form popup status.
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
bool forceSuppressFormPopup() const;
|
||||
|
||||
/**
|
||||
* Sets force suppress form popup status to \a forceSuppressFormPopup.
|
||||
* This flag is to override the layer and general settings regarding the automatic
|
||||
* opening of the attribute form dialog when digitizing is completed.
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void setForceSuppressFormPopup( bool forceSuppressFormPopup );
|
||||
|
||||
/**
|
||||
* Determines the relation id of the second relation involved in an N:M relation.
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
QVariant nmRelationId() const;
|
||||
|
||||
/**
|
||||
* Sets \a nmRelationId for the relation id of the second relation involved in an N:M relation.
|
||||
* If it's empty, then it's considered as a 1:M relationship.
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void setNmRelationId( const QVariant &nmRelationId = QVariant() );
|
||||
|
||||
/**
|
||||
* Determines the label of this element
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
QString label() const;
|
||||
|
||||
/**
|
||||
* Sets \a label for this element
|
||||
* If it's empty it takes the relation id as label
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void setLabel( const QString &label = QString() );
|
||||
|
||||
/**
|
||||
* Returns the current relation widget type id
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
QString relationWidgetTypeId() const;
|
||||
|
||||
/**
|
||||
* Sets the relation widget type
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
void setRelationWidgetTypeId( const QString &relationWidgetTypeId );
|
||||
|
||||
/**
|
||||
* Returns the relation editor widget configuration
|
||||
*
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
QVariantMap relationEditorConfiguration() const;
|
||||
|
||||
/**
|
||||
* Sets the relation editor configuration
|
||||
*
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
void setRelationEditorConfiguration( const QVariantMap &config );
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
QString mRelationId;
|
||||
QgsRelation mRelation;
|
||||
Buttons mButtons = Buttons( Button::AllButtons );
|
||||
bool mForceSuppressFormPopup = false;
|
||||
QVariant mNmRelationId;
|
||||
QString mLabel;
|
||||
QString mRelationWidgetTypeId;
|
||||
QVariantMap mRelationEditorConfig;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAttributeEditorRelation::Buttons )
|
||||
|
||||
|
||||
#endif // QGSATTRIBUTEEDITORRELATION_H
|
@ -1,469 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorelement.cpp - QgsAttributeEditorElement
|
||||
|
||||
---------------------
|
||||
begin : 18.8.2016
|
||||
copyright : (C) 2016 by Matthias Kuhn
|
||||
email : matthias@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgsattributeeditorelement.h"
|
||||
#include "qgsrelationmanager.h"
|
||||
#include "qgsxmlutils.h"
|
||||
|
||||
|
||||
void QgsAttributeEditorContainer::addChildElement( QgsAttributeEditorElement *widget )
|
||||
{
|
||||
mChildren.append( widget );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::setName( const QString &name )
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
QgsOptionalExpression QgsAttributeEditorContainer::visibilityExpression() const
|
||||
{
|
||||
return mVisibilityExpression;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::setVisibilityExpression( const QgsOptionalExpression &visibilityExpression )
|
||||
{
|
||||
if ( visibilityExpression == mVisibilityExpression )
|
||||
return;
|
||||
|
||||
mVisibilityExpression = visibilityExpression;
|
||||
}
|
||||
|
||||
QColor QgsAttributeEditorContainer::backgroundColor() const
|
||||
{
|
||||
return mBackgroundColor;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::setBackgroundColor( const QColor &backgroundColor )
|
||||
{
|
||||
mBackgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
QList<QgsAttributeEditorElement *> QgsAttributeEditorContainer::findElements( QgsAttributeEditorElement::AttributeEditorType type ) const
|
||||
{
|
||||
QList<QgsAttributeEditorElement *> results;
|
||||
|
||||
const auto constMChildren = mChildren;
|
||||
for ( QgsAttributeEditorElement *elem : constMChildren )
|
||||
{
|
||||
if ( elem->type() == type )
|
||||
{
|
||||
results.append( elem );
|
||||
}
|
||||
|
||||
if ( elem->type() == AeTypeContainer )
|
||||
{
|
||||
QgsAttributeEditorContainer *cont = dynamic_cast<QgsAttributeEditorContainer *>( elem );
|
||||
if ( cont )
|
||||
results += cont->findElements( type );
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::clear()
|
||||
{
|
||||
qDeleteAll( mChildren );
|
||||
mChildren.clear();
|
||||
}
|
||||
|
||||
int QgsAttributeEditorContainer::columnCount() const
|
||||
{
|
||||
return mColumnCount;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::setColumnCount( int columnCount )
|
||||
{
|
||||
mColumnCount = columnCount;
|
||||
}
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorContainer::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorContainer *element = new QgsAttributeEditorContainer( name(), parent );
|
||||
|
||||
const auto childElements = children();
|
||||
|
||||
for ( QgsAttributeEditorElement *child : childElements )
|
||||
{
|
||||
element->addChildElement( child->clone( element ) );
|
||||
}
|
||||
element->mIsGroupBox = mIsGroupBox;
|
||||
element->mColumnCount = mColumnCount;
|
||||
element->mVisibilityExpression = mVisibilityExpression;
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
elem.setAttribute( QStringLiteral( "columnCount" ), mColumnCount );
|
||||
elem.setAttribute( QStringLiteral( "groupBox" ), mIsGroupBox ? 1 : 0 );
|
||||
elem.setAttribute( QStringLiteral( "visibilityExpressionEnabled" ), mVisibilityExpression.enabled() ? 1 : 0 );
|
||||
elem.setAttribute( QStringLiteral( "visibilityExpression" ), mVisibilityExpression->expression() );
|
||||
if ( mBackgroundColor.isValid() )
|
||||
elem.setAttribute( QStringLiteral( "backgroundColor" ), mBackgroundColor.name( ) );
|
||||
const auto constMChildren = mChildren;
|
||||
for ( QgsAttributeEditorElement *child : constMChildren )
|
||||
{
|
||||
QDomDocument doc = elem.ownerDocument();
|
||||
elem.appendChild( child->toDomElement( doc ) );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAttributeEditorContainer::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
mBackgroundColor = element.attribute( QStringLiteral( "backgroundColor" ), QString() );
|
||||
bool ok;
|
||||
int cc = element.attribute( QStringLiteral( "columnCount" ) ).toInt( &ok );
|
||||
if ( !ok )
|
||||
cc = 0;
|
||||
setColumnCount( cc );
|
||||
|
||||
bool isGroupBox = element.attribute( QStringLiteral( "groupBox" ) ).toInt( &ok );
|
||||
if ( ok )
|
||||
setIsGroupBox( isGroupBox );
|
||||
else
|
||||
setIsGroupBox( mParent );
|
||||
|
||||
bool visibilityExpressionEnabled = element.attribute( QStringLiteral( "visibilityExpressionEnabled" ) ).toInt( &ok );
|
||||
QgsOptionalExpression visibilityExpression;
|
||||
if ( ok )
|
||||
{
|
||||
visibilityExpression.setEnabled( visibilityExpressionEnabled );
|
||||
visibilityExpression.setData( QgsExpression( element.attribute( QStringLiteral( "visibilityExpression" ) ) ) );
|
||||
}
|
||||
setVisibilityExpression( visibilityExpression );
|
||||
|
||||
QDomNodeList childNodeList = element.childNodes();
|
||||
|
||||
for ( int i = 0; i < childNodeList.size(); i++ )
|
||||
{
|
||||
QDomElement childElem = childNodeList.at( i ).toElement();
|
||||
|
||||
QgsAttributeEditorElement *myElem = create( childElem, layerId, fields, context, this );
|
||||
if ( myElem )
|
||||
addChildElement( myElem );
|
||||
}
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorContainer::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorContainer" );
|
||||
}
|
||||
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorField::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorField *element = new QgsAttributeEditorField( name(), mIdx, parent );
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
bool QgsAttributeEditorRelation::init( QgsRelationManager *relationManager )
|
||||
{
|
||||
mRelation = relationManager->relation( mRelationId );
|
||||
return mRelation.isValid();
|
||||
}
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorRelation::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorRelation *element = new QgsAttributeEditorRelation( mRelationId, parent );
|
||||
element->mRelation = mRelation;
|
||||
element->mButtons = mButtons;
|
||||
element->mForceSuppressFormPopup = mForceSuppressFormPopup;
|
||||
element->mNmRelationId = mNmRelationId;
|
||||
element->mLabel = mLabel;
|
||||
element->mRelationEditorConfig = mRelationEditorConfig;
|
||||
|
||||
return element;
|
||||
}
|
||||
void QgsAttributeEditorField::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
elem.setAttribute( QStringLiteral( "index" ), mIdx );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorField::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
Q_UNUSED( element )
|
||||
Q_UNUSED( layerId )
|
||||
Q_UNUSED( context )
|
||||
Q_UNUSED( fields )
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorField::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorField" );
|
||||
}
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorElement::create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent )
|
||||
{
|
||||
QgsAttributeEditorElement *newElement = nullptr;
|
||||
|
||||
QString name = element.attribute( QStringLiteral( "name" ) );
|
||||
|
||||
if ( element.tagName() == QLatin1String( "attributeEditorContainer" ) )
|
||||
{
|
||||
newElement = new QgsAttributeEditorContainer( context.projectTranslator()->translate( QStringLiteral( "project:layers:%1:formcontainers" ).arg( layerId ),
|
||||
name ), parent );
|
||||
}
|
||||
else if ( element.tagName() == QLatin1String( "attributeEditorField" ) )
|
||||
{
|
||||
int idx = fields.lookupField( name );
|
||||
newElement = new QgsAttributeEditorField( name, idx, parent );
|
||||
}
|
||||
else if ( element.tagName() == QLatin1String( "attributeEditorRelation" ) )
|
||||
{
|
||||
// At this time, the relations are not loaded
|
||||
// So we only grab the id and delegate the rest to onRelationsLoaded()
|
||||
newElement = new QgsAttributeEditorRelation( element.attribute( QStringLiteral( "relation" ), QStringLiteral( "[None]" ) ), parent );
|
||||
}
|
||||
else if ( element.tagName() == QLatin1String( "attributeEditorQmlElement" ) )
|
||||
{
|
||||
newElement = new QgsAttributeEditorQmlElement( element.attribute( QStringLiteral( "name" ) ), parent );
|
||||
}
|
||||
else if ( element.tagName() == QLatin1String( "attributeEditorHtmlElement" ) )
|
||||
{
|
||||
newElement = new QgsAttributeEditorHtmlElement( element.attribute( QStringLiteral( "name" ) ), parent );
|
||||
}
|
||||
|
||||
if ( newElement )
|
||||
{
|
||||
if ( element.hasAttribute( QStringLiteral( "showLabel" ) ) )
|
||||
newElement->setShowLabel( element.attribute( QStringLiteral( "showLabel" ) ).toInt() );
|
||||
else
|
||||
newElement->setShowLabel( true );
|
||||
|
||||
newElement->loadConfiguration( element, layerId, context, fields );
|
||||
}
|
||||
|
||||
return newElement;
|
||||
}
|
||||
|
||||
QDomElement QgsAttributeEditorElement::toDomElement( QDomDocument &doc ) const
|
||||
{
|
||||
QDomElement elem = doc.createElement( typeIdentifier() );
|
||||
elem.setAttribute( QStringLiteral( "name" ), mName );
|
||||
elem.setAttribute( QStringLiteral( "showLabel" ), mShowLabel );
|
||||
saveConfiguration( elem, doc );
|
||||
return elem;
|
||||
}
|
||||
|
||||
bool QgsAttributeEditorElement::showLabel() const
|
||||
{
|
||||
return mShowLabel;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorElement::setShowLabel( bool showLabel )
|
||||
{
|
||||
mShowLabel = showLabel;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
elem.setAttribute( QStringLiteral( "relation" ), mRelation.id() );
|
||||
elem.setAttribute( QStringLiteral( "forceSuppressFormPopup" ), mForceSuppressFormPopup );
|
||||
elem.setAttribute( QStringLiteral( "nmRelationId" ), mNmRelationId.toString() );
|
||||
elem.setAttribute( QStringLiteral( "label" ), mLabel );
|
||||
elem.setAttribute( QStringLiteral( "relationWidgetTypeId" ), mRelationWidgetTypeId );
|
||||
|
||||
QDomElement elemConfig = QgsXmlUtils::writeVariant( mRelationEditorConfig, doc );
|
||||
elemConfig.setTagName( QStringLiteral( "editor_configuration" ) );
|
||||
elem.appendChild( elemConfig );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
Q_UNUSED( layerId )
|
||||
Q_UNUSED( context )
|
||||
Q_UNUSED( fields )
|
||||
|
||||
QVariantMap config = QgsXmlUtils::readVariant( element.firstChildElement( "editor_configuration" ) ).toMap();
|
||||
|
||||
// load defaults
|
||||
if ( config.isEmpty() )
|
||||
config = relationEditorConfiguration();
|
||||
|
||||
// pre QGIS 3.18 compatibility
|
||||
if ( ! config.contains( QStringLiteral( "buttons" ) ) )
|
||||
{
|
||||
if ( element.hasAttribute( "buttons" ) )
|
||||
{
|
||||
QString buttonString = element.attribute( QStringLiteral( "buttons" ), qgsFlagValueToKeys( QgsAttributeEditorRelation::Button::AllButtons ) );
|
||||
config.insert( "buttons", qgsFlagValueToKeys( qgsFlagKeysToValue( buttonString, QgsAttributeEditorRelation::Button::AllButtons ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// pre QGIS 3.16 compatibility
|
||||
QgsAttributeEditorRelation::Buttons buttons = QgsAttributeEditorRelation::Button::AllButtons;
|
||||
buttons.setFlag( QgsAttributeEditorRelation::Button::Link, element.attribute( QStringLiteral( "showLinkButton" ), QStringLiteral( "1" ) ).toInt() );
|
||||
buttons.setFlag( QgsAttributeEditorRelation::Button::Unlink, element.attribute( QStringLiteral( "showUnlinkButton" ), QStringLiteral( "1" ) ).toInt() );
|
||||
buttons.setFlag( QgsAttributeEditorRelation::Button::SaveChildEdits, element.attribute( QStringLiteral( "showSaveChildEditsButton" ), QStringLiteral( "1" ) ).toInt() );
|
||||
config.insert( "buttons", qgsFlagValueToKeys( buttons ) );
|
||||
}
|
||||
}
|
||||
|
||||
setRelationEditorConfiguration( config );
|
||||
|
||||
setForceSuppressFormPopup( element.attribute( QStringLiteral( "forceSuppressFormPopup" ), 0 ).toInt() );
|
||||
|
||||
if ( element.hasAttribute( QStringLiteral( "nmRelationId" ) ) )
|
||||
{
|
||||
setNmRelationId( element.attribute( QStringLiteral( "nmRelationId" ) ) );
|
||||
}
|
||||
|
||||
if ( element.hasAttribute( "label" ) )
|
||||
{
|
||||
QString label = element.attribute( QStringLiteral( "label" ) );
|
||||
setLabel( label );
|
||||
}
|
||||
if ( element.hasAttribute( "relationWidgetTypeId" ) )
|
||||
{
|
||||
QString relationWidgetTypeId = element.attribute( QStringLiteral( "relationWidgetTypeId" ) );
|
||||
setRelationWidgetTypeId( relationWidgetTypeId );
|
||||
}
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorRelation::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorRelation" );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setForceSuppressFormPopup( bool forceSuppressFormPopup )
|
||||
{
|
||||
mForceSuppressFormPopup = forceSuppressFormPopup;
|
||||
}
|
||||
|
||||
bool QgsAttributeEditorRelation::forceSuppressFormPopup() const
|
||||
{
|
||||
return mForceSuppressFormPopup;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setNmRelationId( const QVariant &nmRelationId )
|
||||
{
|
||||
mNmRelationId = nmRelationId;
|
||||
}
|
||||
|
||||
QVariant QgsAttributeEditorRelation::nmRelationId() const
|
||||
{
|
||||
return mNmRelationId;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setLabel( const QString &label )
|
||||
{
|
||||
mLabel = label;
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorRelation::label() const
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorRelation::relationWidgetTypeId() const
|
||||
{
|
||||
return mRelationWidgetTypeId;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setRelationWidgetTypeId( const QString &relationWidgetTypeId )
|
||||
{
|
||||
mRelationWidgetTypeId = relationWidgetTypeId;
|
||||
}
|
||||
|
||||
QVariantMap QgsAttributeEditorRelation::relationEditorConfiguration() const
|
||||
{
|
||||
return mRelationEditorConfig;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorRelation::setRelationEditorConfiguration( const QVariantMap &config )
|
||||
{
|
||||
mRelationEditorConfig = config;
|
||||
}
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorQmlElement::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorQmlElement *element = new QgsAttributeEditorQmlElement( name(), parent );
|
||||
element->setQmlCode( mQmlCode );
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorQmlElement::qmlCode() const
|
||||
{
|
||||
return mQmlCode;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorQmlElement::setQmlCode( const QString &qmlCode )
|
||||
{
|
||||
mQmlCode = qmlCode;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorQmlElement::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
QDomText codeElem = doc.createTextNode( mQmlCode );
|
||||
elem.appendChild( codeElem );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorQmlElement::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
Q_UNUSED( layerId )
|
||||
Q_UNUSED( context )
|
||||
Q_UNUSED( fields )
|
||||
setQmlCode( element.text() );
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorQmlElement::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorQmlElement" );
|
||||
}
|
||||
|
||||
QgsAttributeEditorElement *QgsAttributeEditorHtmlElement::clone( QgsAttributeEditorElement *parent ) const
|
||||
{
|
||||
QgsAttributeEditorHtmlElement *element = new QgsAttributeEditorHtmlElement( name(), parent );
|
||||
element->setHtmlCode( mHtmlCode );
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorHtmlElement::htmlCode() const
|
||||
{
|
||||
return mHtmlCode;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorHtmlElement::setHtmlCode( const QString &htmlCode )
|
||||
{
|
||||
mHtmlCode = htmlCode;
|
||||
}
|
||||
|
||||
void QgsAttributeEditorHtmlElement::saveConfiguration( QDomElement &elem, QDomDocument &doc ) const
|
||||
{
|
||||
QDomText codeElem = doc.createTextNode( mHtmlCode );
|
||||
elem.appendChild( codeElem );
|
||||
}
|
||||
|
||||
void QgsAttributeEditorHtmlElement::loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields )
|
||||
{
|
||||
Q_UNUSED( layerId )
|
||||
Q_UNUSED( context )
|
||||
Q_UNUSED( fields )
|
||||
setHtmlCode( element.text() );
|
||||
}
|
||||
|
||||
QString QgsAttributeEditorHtmlElement::typeIdentifier() const
|
||||
{
|
||||
return QStringLiteral( "attributeEditorHtmlElement" );
|
||||
}
|
||||
|
@ -1,598 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsattributeeditorelement.h - QgsAttributeEditorElement
|
||||
|
||||
---------------------
|
||||
begin : 18.8.2016
|
||||
copyright : (C) 2016 by Matthias Kuhn
|
||||
email : matthias@opengis.ch
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSATTRIBUTEEDITORELEMENT_H
|
||||
#define QGSATTRIBUTEEDITORELEMENT_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgsrelation.h"
|
||||
#include "qgsoptionalexpression.h"
|
||||
#include "qgspropertycollection.h"
|
||||
#include <QColor>
|
||||
|
||||
|
||||
class QgsRelationManager;
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* This is an abstract base class for any elements of a drag and drop form.
|
||||
*
|
||||
* This can either be a container which will be represented on the screen
|
||||
* as a tab widget or a collapsible group box. Or it can be a field which will
|
||||
* then be represented based on the QgsEditorWidget type and configuration.
|
||||
* Or it can be a relation and embed the form of several children of another
|
||||
* layer.
|
||||
*/
|
||||
|
||||
class CORE_EXPORT QgsAttributeEditorElement SIP_ABSTRACT
|
||||
{
|
||||
|
||||
#ifdef SIP_RUN
|
||||
SIP_CONVERT_TO_SUBCLASS_CODE
|
||||
switch ( sipCpp->type() )
|
||||
{
|
||||
case QgsAttributeEditorElement::AeTypeContainer:
|
||||
sipType = sipType_QgsAttributeEditorContainer;
|
||||
break;
|
||||
case QgsAttributeEditorElement::AeTypeField:
|
||||
sipType = sipType_QgsAttributeEditorField;
|
||||
break;
|
||||
case QgsAttributeEditorElement::AeTypeRelation:
|
||||
sipType = sipType_QgsAttributeEditorRelation;
|
||||
break;
|
||||
default:
|
||||
sipType = nullptr;
|
||||
break;
|
||||
}
|
||||
SIP_END
|
||||
#endif
|
||||
public:
|
||||
enum AttributeEditorType
|
||||
{
|
||||
AeTypeContainer, //!< A container
|
||||
AeTypeField, //!< A field
|
||||
AeTypeRelation, //!< A relation
|
||||
AeTypeInvalid, //!< Invalid
|
||||
AeTypeQmlElement, //!< A QML element
|
||||
AeTypeHtmlElement //!< A HTML element
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param type The type of the new element.
|
||||
* \param name
|
||||
* \param parent
|
||||
*/
|
||||
QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = nullptr )
|
||||
: mType( type )
|
||||
, mName( name )
|
||||
, mParent( parent )
|
||||
, mShowLabel( true )
|
||||
{}
|
||||
|
||||
virtual ~QgsAttributeEditorElement() = default;
|
||||
|
||||
/**
|
||||
* Constructs the editor element from the given element
|
||||
*
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
static QgsAttributeEditorElement *create( const QDomElement &element, const QString &layerId, const QgsFields &fields, const QgsReadWriteContext &context, QgsAttributeEditorElement *parent = nullptr ) SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Returns the name of this element
|
||||
*
|
||||
* \returns The name for this element
|
||||
*/
|
||||
QString name() const { return mName; }
|
||||
|
||||
/**
|
||||
* The type of this element
|
||||
*
|
||||
* \returns The type
|
||||
*/
|
||||
AttributeEditorType type() const { return mType; }
|
||||
|
||||
/**
|
||||
* Gets the parent of this element.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QgsAttributeEditorElement *parent() const { return mParent; }
|
||||
|
||||
/**
|
||||
* Gets the XML Dom element to save this element.
|
||||
*
|
||||
* \param doc The QDomDocument which is used to create new XML elements
|
||||
*
|
||||
* \returns A DOM element to serialize this element
|
||||
*/
|
||||
QDomElement toDomElement( QDomDocument &doc ) const;
|
||||
|
||||
/**
|
||||
* Returns a clone of this element. To be implemented by subclasses.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const = 0 SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Controls if this element should be labeled with a title (field, relation or groupname).
|
||||
*
|
||||
* \since QGIS 2.18
|
||||
*/
|
||||
bool showLabel() const;
|
||||
|
||||
/**
|
||||
* Controls if this element should be labeled with a title (field, relation or groupname).
|
||||
* \since QGIS 2.18
|
||||
*/
|
||||
void setShowLabel( bool showLabel );
|
||||
|
||||
protected:
|
||||
#ifndef SIP_RUN
|
||||
AttributeEditorType mType;
|
||||
QString mName;
|
||||
QgsAttributeEditorElement *mParent = nullptr;
|
||||
bool mShowLabel;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Should be implemented by subclasses to save type specific configuration.
|
||||
*
|
||||
* \since QGIS 2.18
|
||||
*/
|
||||
virtual void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const = 0;
|
||||
|
||||
/**
|
||||
* Should be implemented by subclasses to read specific configuration
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
virtual void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) = 0;
|
||||
|
||||
/**
|
||||
* All subclasses need to overwrite this method and return a type specific identifier.
|
||||
* Needs to be XML key compatible.
|
||||
*
|
||||
* \since QGIS 2.18
|
||||
*/
|
||||
virtual QString typeIdentifier() const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* This is a container for attribute editors, used to group them visually in the
|
||||
* attribute form if it is set to the drag and drop designer.
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorContainer : public QgsAttributeEditorElement
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new attribute editor container
|
||||
*
|
||||
* \param name The name to show as title
|
||||
* \param parent The parent. May be another container.
|
||||
* \param backgroundColor The optional background color of the container.
|
||||
*/
|
||||
QgsAttributeEditorContainer( const QString &name, QgsAttributeEditorElement *parent, const QColor &backgroundColor = QColor() )
|
||||
: QgsAttributeEditorElement( AeTypeContainer, name, parent )
|
||||
, mIsGroupBox( true )
|
||||
, mColumnCount( 1 )
|
||||
, mBackgroundColor( backgroundColor )
|
||||
{}
|
||||
|
||||
|
||||
~QgsAttributeEditorContainer() override;
|
||||
|
||||
/**
|
||||
* Add a child element to this container. This may be another container, a field or a relation.
|
||||
*
|
||||
* \param element The element to add as child
|
||||
*/
|
||||
virtual void addChildElement( QgsAttributeEditorElement *element SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Determines if this container is rendered as collapsible group box or tab in a tabwidget
|
||||
*
|
||||
* \param isGroupBox If TRUE, this will be a group box
|
||||
*/
|
||||
virtual void setIsGroupBox( bool isGroupBox ) { mIsGroupBox = isGroupBox; }
|
||||
|
||||
/**
|
||||
* Returns if this container is going to be rendered as a group box
|
||||
*
|
||||
* \returns TRUE if it will be a group box, FALSE if it will be a tab
|
||||
*/
|
||||
virtual bool isGroupBox() const { return mIsGroupBox; }
|
||||
|
||||
/**
|
||||
* Gets a list of the children elements of this container
|
||||
*
|
||||
* \returns A list of elements
|
||||
*/
|
||||
QList<QgsAttributeEditorElement *> children() const { return mChildren; }
|
||||
|
||||
/**
|
||||
* Traverses the element tree to find any element of the specified type
|
||||
*
|
||||
* \param type The type which should be searched
|
||||
*
|
||||
* \returns A list of elements of the type which has been searched for
|
||||
*/
|
||||
virtual QList<QgsAttributeEditorElement *> findElements( AttributeEditorType type ) const;
|
||||
|
||||
/**
|
||||
* Clear all children from this container.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Change the name of this container
|
||||
*/
|
||||
void setName( const QString &name );
|
||||
|
||||
/**
|
||||
* Gets the number of columns in this group
|
||||
*/
|
||||
int columnCount() const;
|
||||
|
||||
/**
|
||||
* Set the number of columns in this group
|
||||
*/
|
||||
void setColumnCount( int columnCount );
|
||||
|
||||
/**
|
||||
* Creates a deep copy of this element. To be implemented by subclasses.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* The visibility expression is used in the attribute form to
|
||||
* show or hide this container based on an expression incorporating
|
||||
* the field value controlled by editor widgets.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
QgsOptionalExpression visibilityExpression() const;
|
||||
|
||||
/**
|
||||
* The visibility expression is used in the attribute form to
|
||||
* show or hide this container based on an expression incorporating
|
||||
* the field value controlled by editor widgets.
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
void setVisibilityExpression( const QgsOptionalExpression &visibilityExpression );
|
||||
|
||||
/**
|
||||
* \brief backgroundColor
|
||||
* \return background color of the container
|
||||
* \since QGIS 3.8
|
||||
*/
|
||||
QColor backgroundColor() const;
|
||||
|
||||
/**
|
||||
* Sets the background color to \a backgroundColor
|
||||
*/
|
||||
void setBackgroundColor( const QColor &backgroundColor );
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
|
||||
bool mIsGroupBox;
|
||||
QList<QgsAttributeEditorElement *> mChildren;
|
||||
int mColumnCount;
|
||||
QgsOptionalExpression mVisibilityExpression;
|
||||
QColor mBackgroundColor;
|
||||
};
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* This element will load a field's widget onto the form.
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorField : public QgsAttributeEditorElement
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new attribute editor element which represents a field
|
||||
*
|
||||
* \param name The name of the element
|
||||
* \param idx The index of the field which should be embedded
|
||||
* \param parent The parent of this widget (used as container)
|
||||
*/
|
||||
QgsAttributeEditorField( const QString &name, int idx, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeField, name, parent )
|
||||
, mIdx( idx )
|
||||
{}
|
||||
|
||||
/**
|
||||
* Returns the index of the field.
|
||||
*/
|
||||
int idx() const { return mIdx; }
|
||||
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
int mIdx;
|
||||
};
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* This element will load a relation editor onto the form.
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorRelation : public QgsAttributeEditorElement
|
||||
{
|
||||
Q_GADGET
|
||||
public:
|
||||
|
||||
/**
|
||||
* Possible buttons shown in the relation editor
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
enum Button
|
||||
{
|
||||
Link = 1 << 1, //!< Link button
|
||||
Unlink = 1 << 2, //!< Unlink button
|
||||
SaveChildEdits = 1 << 3, //!< Save child edits button
|
||||
AddChildFeature = 1 << 4, //!< Add child feature (as in some projects we only want to allow linking/unlinking existing features)
|
||||
DuplicateChildFeature = 1 << 5, //!< Duplicate child feature
|
||||
DeleteChildFeature = 1 << 6, //!< Delete child feature button
|
||||
ZoomToChildFeature = 1 << 7, //!< Zoom to child feature
|
||||
AllButtons = Link | Unlink | SaveChildEdits | AddChildFeature | DuplicateChildFeature | DeleteChildFeature | ZoomToChildFeature //!< All buttons
|
||||
};
|
||||
Q_ENUM( Button )
|
||||
Q_DECLARE_FLAGS( Buttons, Button )
|
||||
Q_FLAG( Buttons )
|
||||
|
||||
/**
|
||||
* \deprecated since QGIS 3.0.2. The name parameter is not used for anything and overwritten by the relationId internally.
|
||||
*/
|
||||
Q_DECL_DEPRECATED QgsAttributeEditorRelation( const QString &name, const QString &relationId, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeRelation, name, parent )
|
||||
, mRelationId( relationId )
|
||||
{}
|
||||
|
||||
/**
|
||||
* \deprecated since QGIS 3.0.2. The name parameter is not used for anything and overwritten by the relationId internally.
|
||||
*/
|
||||
Q_DECL_DEPRECATED QgsAttributeEditorRelation( const QString &name, const QgsRelation &relation, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeRelation, name, parent )
|
||||
, mRelationId( relation.id() )
|
||||
, mRelation( relation )
|
||||
{}
|
||||
|
||||
/**
|
||||
* Creates a new element which embeds a relation.
|
||||
*
|
||||
* \param relationId The id of the relation to embed
|
||||
* \param parent The parent (used as container)
|
||||
*/
|
||||
QgsAttributeEditorRelation( const QString &relationId, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeRelation, relationId, parent )
|
||||
, mRelationId( relationId )
|
||||
{}
|
||||
|
||||
/**
|
||||
* Creates a new element which embeds a relation.
|
||||
*
|
||||
* \param relation The relation to embed
|
||||
* \param parent The parent (used as container)
|
||||
*/
|
||||
QgsAttributeEditorRelation( const QgsRelation &relation, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeRelation, relation.id(), parent )
|
||||
, mRelationId( relation.id() )
|
||||
, mRelation( relation )
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the id of the relation which shall be embedded
|
||||
*
|
||||
* \returns the id
|
||||
*/
|
||||
const QgsRelation &relation() const { return mRelation; }
|
||||
|
||||
/**
|
||||
* Initializes the relation from the id
|
||||
*
|
||||
* \param relManager The relation manager to use for the initialization
|
||||
* \returns TRUE if the relation was found in the relationmanager
|
||||
*/
|
||||
bool init( QgsRelationManager *relManager );
|
||||
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Determines the force suppress form popup status.
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
bool forceSuppressFormPopup() const;
|
||||
|
||||
/**
|
||||
* Sets force suppress form popup status to \a forceSuppressFormPopup.
|
||||
* This flag is to override the layer and general settings regarding the automatic
|
||||
* opening of the attribute form dialog when digitizing is completed.
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void setForceSuppressFormPopup( bool forceSuppressFormPopup );
|
||||
|
||||
/**
|
||||
* Determines the relation id of the second relation involved in an N:M relation.
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
QVariant nmRelationId() const;
|
||||
|
||||
/**
|
||||
* Sets \a nmRelationId for the relation id of the second relation involved in an N:M relation.
|
||||
* If it's empty, then it's considered as a 1:M relationship.
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void setNmRelationId( const QVariant &nmRelationId = QVariant() );
|
||||
|
||||
/**
|
||||
* Determines the label of this element
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
QString label() const;
|
||||
|
||||
/**
|
||||
* Sets \a label for this element
|
||||
* If it's empty it takes the relation id as label
|
||||
* \since QGIS 3.16
|
||||
*/
|
||||
void setLabel( const QString &label = QString() );
|
||||
|
||||
/**
|
||||
* Returns the current relation widget type id
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
QString relationWidgetTypeId() const;
|
||||
|
||||
/**
|
||||
* Sets the relation widget type
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
void setRelationWidgetTypeId( const QString &relationWidgetTypeId );
|
||||
|
||||
/**
|
||||
* Returns the relation editor widget configuration
|
||||
*
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
QVariantMap relationEditorConfiguration() const;
|
||||
|
||||
/**
|
||||
* Sets the relation editor configuration
|
||||
*
|
||||
* \since QGIS 3.18
|
||||
*/
|
||||
void setRelationEditorConfiguration( const QVariantMap &config );
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
QString mRelationId;
|
||||
QgsRelation mRelation;
|
||||
Buttons mButtons = Buttons( Button::AllButtons );
|
||||
bool mForceSuppressFormPopup = false;
|
||||
QVariant mNmRelationId;
|
||||
QString mLabel;
|
||||
QString mRelationWidgetTypeId;
|
||||
QVariantMap mRelationEditorConfig;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAttributeEditorRelation::Buttons )
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* An attribute editor widget that will represent arbitrary QML code.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorQmlElement : public QgsAttributeEditorElement
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new element which can display QML
|
||||
*
|
||||
* \param name The name of the widget
|
||||
* \param parent The parent (used as container)
|
||||
*/
|
||||
QgsAttributeEditorQmlElement( const QString &name, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeQmlElement, name, parent )
|
||||
{}
|
||||
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* The QML code that will be represented within this widget.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
QString qmlCode() const;
|
||||
|
||||
/**
|
||||
* Sets the QML code that will be represented within this widget to \a qmlCode.
|
||||
*/
|
||||
void setQmlCode( const QString &qmlCode );
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
QString mQmlCode;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* An attribute editor widget that will represent arbitrary HTML code.
|
||||
*
|
||||
* \since QGIS 3.8
|
||||
*/
|
||||
class CORE_EXPORT QgsAttributeEditorHtmlElement : public QgsAttributeEditorElement
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new element which can display HTML
|
||||
*
|
||||
* \param name The name of the widget
|
||||
* \param parent The parent (used as container)
|
||||
*/
|
||||
QgsAttributeEditorHtmlElement( const QString &name, QgsAttributeEditorElement *parent )
|
||||
: QgsAttributeEditorElement( AeTypeHtmlElement, name, parent )
|
||||
{}
|
||||
|
||||
QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* The QML code that will be represented within this widget.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
QString htmlCode() const;
|
||||
|
||||
/**
|
||||
* Sets the HTML code that will be represented within this widget to \a htmlCode.
|
||||
*/
|
||||
void setHtmlCode( const QString &htmlCode );
|
||||
|
||||
private:
|
||||
void saveConfiguration( QDomElement &elem, QDomDocument &doc ) const override;
|
||||
void loadConfiguration( const QDomElement &element, const QString &layerId, const QgsReadWriteContext &context, const QgsFields &fields ) override;
|
||||
QString typeIdentifier() const override;
|
||||
QString mHtmlCode;
|
||||
};
|
||||
|
||||
|
||||
#endif // QGSATTRIBUTEEDITORELEMENT_H
|
Loading…
x
Reference in New Issue
Block a user