Skip to content
Permalink
Browse files

Merge pull request #3410 from m-kuhn/editformconfig-refactor

Refactor edit form config
  • Loading branch information
m-kuhn committed Aug 19, 2016
2 parents 72cbff9 + fd4fe83 commit c46767106e07d93dd3728bb399023089d86211a9
Showing with 1,408 additions and 1,045 deletions.
  1. +13 −0 doc/api_break.dox
  2. +1 −0 python/core/core.sip
  3. +295 −0 python/core/qgsattributeeditorelement.sip
  4. +16 −251 python/core/qgseditformconfig.sip
  5. +26 −63 python/core/qgsvectorlayer.sip
  6. +4 −4 src/app/ogr/qgsvectorlayersaveasdialog.cpp
  7. +2 −2 src/app/qgisapp.cpp
  8. +5 −5 src/app/qgsattributetabledialog.cpp
  9. +1 −1 src/app/qgsfeatureaction.cpp
  10. +32 −29 src/app/qgsfieldsproperties.cpp
  11. +1 −1 src/app/qgsfieldsproperties.h
  12. +4 −4 src/app/qgsidentifyresultsdialog.cpp
  13. +2 −2 src/app/qgsmergeattributesdialog.cpp
  14. +2 −2 src/app/qgsvectorlayerproperties.cpp
  15. +3 −1 src/core/CMakeLists.txt
  16. +106 −0 src/core/qgsattributeeditorelement.cpp
  17. +311 −0 src/core/qgsattributeeditorelement.h
  18. +262 −97 src/core/qgseditformconfig.cpp
  19. +57 −337 src/core/qgseditformconfig.h
  20. +99 −0 src/core/qgseditformconfig_p.h
  21. +2 −2 src/core/qgsfeature.h
  22. +2 −2 src/core/qgsfield.cpp
  23. +24 −92 src/core/qgsvectorlayer.cpp
  24. +41 −63 src/core/qgsvectorlayer.h
  25. +1 −1 src/core/qgsvectorlayereditpassthrough.cpp
  26. +3 −3 src/core/qgsvectorlayerundocommand.cpp
  27. +3 −3 src/gui/attributetable/qgsattributetabledelegate.cpp
  28. +3 −3 src/gui/attributetable/qgsattributetablemodel.cpp
  29. +1 −1 src/gui/attributetable/qgsdualview.cpp
  30. +14 −14 src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp
  31. +3 −3 src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp
  32. +2 −2 src/gui/qgsattributeeditor.cpp
  33. +31 −31 src/gui/qgsattributeform.cpp
  34. +1 −1 src/gui/qgsattributeformeditorwidget.cpp
  35. +2 −2 src/plugins/grass/qgsgrassplugin.cpp
  36. +2 −2 src/providers/grass/qgsgrassprovider.cpp
  37. +3 −3 src/server/qgsserverprojectparser.cpp
  38. +2 −2 src/server/qgswmsserver.cpp
  39. +1 −1 tests/src/app/testqgsvectorlayersaveasdialog.cpp
  40. +25 −15 tests/src/gui/testqgsattributeform.cpp
@@ -216,6 +216,12 @@ attributeIndexes(), pkAttributeIndexes(), isSaveAndLoadStyleToDBSupported()</li>
</li>
</ul>

\subsection qgis_api_break_3_0_QgsEditFormConfig QgsEditFormConfig

<ul>
<li>Does no longer inherit QObject
</ul>

\subsection qgis_api_break_3_0_Qgis Qgis

<ul>
@@ -867,6 +873,13 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.</li>
<li>applyNamedStyle() replaced by applyNamedStyle()
<li>isReadOnly() use readOnly()
<li>Signal changeAttributeValue()
<li>Deleted GroupData (Use QgsEditFormConfig::GroupData)
<li>Deleted TabData (Use QgsEditFormConfig::TabData)
<li>Deleted EditorLayout (Use QgsEditFormConfig::EditorLayout)
<li>Deleted ValueRelationData (Use QgsEditFormConfig::editorWidgetConfig)
<li>Deleted attributeEditorElementFromDomElement
<li>editFormConfig() returns a copy instead of direct access (Use setEditFormConfig to update)
<li>Removed valueRelation(), replaced with QgsEditFormConfig::editorWidgetConfig
</ul>

\subsection qgis_api_break_3_0_QgsVectorLayerEditBuffer QgsVectorLayerEditBuffer
@@ -24,6 +24,7 @@
%Include qgsactionmanager.sip
%Include qgsaggregatecalculator.sip
%Include qgsattributetableconfig.sip
%Include qgsattributeeditorelement.sip
%Include qgsbrowsermodel.sip
%Include qgsclipper.sip
%Include qgscolorscheme.sip
@@ -0,0 +1,295 @@
/***************************************************************************
qgsattributeeditorelement.sip - 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. *
* *
***************************************************************************/

/** \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 ca 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 QgsAttributeEditorElement
{
%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, //!< A container
AeTypeField, //!< A field
AeTypeRelation, //!< A relation
AeTypeInvalid //!< Invalid
};

/**
* Constructor
*
* @param type The type of the new element. Should never
* @param name
* @param parent
*/
QgsAttributeEditorElement( AttributeEditorType type, const QString& name, QgsAttributeEditorElement* parent = nullptr );

/**
* Return the name of this element
*
* @return The name for this element
*/
QString name() const;

/**
* The type of this element
*
* @return The type
*/
AttributeEditorType type();

/**
* Get the parent of this element.
*
* @note Added in QGIS 3.0
*/
QgsAttributeEditorElement* parent() const;

/**
* Is reimplemented in classes inheriting from this to serialize it.
*
* @param doc The QDomDocument which is used to create new XML elements
*
* @return An DOM element which represents this element
*/
virtual QDomElement toDomElement( QDomDocument& doc ) const = 0;

/**
* Returns a clone of this element. To be implemented by subclasses.
*
* @note Added in QGIS 3.0
*/
virtual QgsAttributeEditorElement* clone( QgsAttributeEditorElement* parent ) const = 0 /Factory/;
};


/** \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 QgsAttributeEditorContainer : QgsAttributeEditorElement
{
%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;
}
%End
public:
/**
* Creates a new attribute editor container
*
* @param name The name to show as title
* @param parent The parent. May be another container.
*/
QgsAttributeEditorContainer( const QString& name, QgsAttributeEditorElement* parent );

/**
* Will serialize this containers information into a QDomElement for saving it in an XML file.
*
* @param doc The QDomDocument used to generate the QDomElement
*
* @return The XML element
*/
virtual QDomElement toDomElement( QDomDocument& doc ) const;

/**
* 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 /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 );

/**
* 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
*/
virtual bool isGroupBox() const;

/**
* Get a list of the children elements of this container
*
* @return A list of elements
*/
QList<QgsAttributeEditorElement*> children() const;

/**
* 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
*/
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 );

/**
* Get 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.
*
* @note Added in QGIS 3.0
*/
virtual QgsAttributeEditorElement* clone(QgsAttributeEditorElement* parent) const /Factory/;
};

/** \ingroup core
* This element will load a field's widget onto the form.
*/
class QgsAttributeEditorField : public QgsAttributeEditorElement
{
%TypeHeaderCode
#include <qgsattributeeditorelement.h>
%End
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 );

/**
* Will serialize this elements information into a QDomElement for saving it in an XML file.
*
* @param doc The QDomDocument used to generate the QDomElement
*
* @return The XML element
*/
virtual QDomElement toDomElement( QDomDocument& doc ) const;

/**
* Return the index of the field
* @return
*/
int idx() const;

virtual QgsAttributeEditorElement* clone( QgsAttributeEditorElement* parent ) const /Factory/;
};

/** \ingroup core
* This element will load a relation editor onto the form.
*/
class QgsAttributeEditorRelation : QgsAttributeEditorElement
{
%TypeHeaderCode
#include <qgsattributeeditorelement.h>
%End
public:
/**
* Creates a new element which embeds a relation.
*
* @param name The name of this element
* @param relationId The id of the relation to embed
* @param parent The parent (used as container)
*/
QgsAttributeEditorRelation( const QString& name, const QString &relationId, QgsAttributeEditorElement* parent );

/**
* Creates a new element which embeds a relation.
*
* @param name The name of this element
* @param relation The relation to embed
* @param parent The parent (used as container)
*/
QgsAttributeEditorRelation( const QString& name, const QgsRelation& relation, QgsAttributeEditorElement* parent );

/**
* Will serialize this elements information into a QDomElement for saving it in an XML file.
*
* @param doc The QDomDocument used to generate the QDomElement
*
* @return The XML element
*/
virtual QDomElement toDomElement( QDomDocument& doc ) const;

/**
* Get the id of the relation which shall be embedded
*
* @return the id
*/
const QgsRelation& relation() const;

/**
* 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
*/
bool init( QgsRelationManager* relManager );

virtual QgsAttributeEditorElement* clone(QgsAttributeEditorElement* parent) const /Factory/;
};

0 comments on commit c467671

Please sign in to comment.
You can’t perform that action at this time.