Skip to content

Commit

Permalink
make more buttons configurable in relation editor
Browse files Browse the repository at this point in the history
fixes #37718
  • Loading branch information
3nids committed Jul 13, 2020
1 parent ebd4cd8 commit ccb3b8e
Show file tree
Hide file tree
Showing 17 changed files with 447 additions and 126 deletions.
15 changes: 15 additions & 0 deletions python/core/auto_additions/qgsattributeeditorelement.py
@@ -0,0 +1,15 @@
# The following has been generated automatically from src/core/qgsattributeeditorelement.h
# monkey patching scoped based enum
QgsAttributeEditorRelation.Button.Link.__doc__ = "Show link button"
QgsAttributeEditorRelation.Button.Unlink.__doc__ = "Show unlink button"
QgsAttributeEditorRelation.Button.SaveChildEdits.__doc__ = "Show save child edits button"
QgsAttributeEditorRelation.Button.AddChildFeature.__doc__ = "Show add child feature (as in some projects we only want to allow to link/unlink existing features)"
QgsAttributeEditorRelation.Button.DuplicateChildFeature.__doc__ = "Show duplicate child feature"
QgsAttributeEditorRelation.Button.DeleteChildFeature.__doc__ = "Show delete child feature button"
QgsAttributeEditorRelation.Button.ZoomToChildFeature.__doc__ = "Show zoom to child feature"
QgsAttributeEditorRelation.Button.AllButtons.__doc__ = "Defaults set of buttons shown"
QgsAttributeEditorRelation.Button.__doc__ = 'Possible buttons shown in the relation editor\n\n.. versionadded:: 3.16\n\n' + '* ``Link``: ' + QgsAttributeEditorRelation.Button.Link.__doc__ + '\n' + '* ``Unlink``: ' + QgsAttributeEditorRelation.Button.Unlink.__doc__ + '\n' + '* ``SaveChildEdits``: ' + QgsAttributeEditorRelation.Button.SaveChildEdits.__doc__ + '\n' + '* ``AddChildFeature``: ' + QgsAttributeEditorRelation.Button.AddChildFeature.__doc__ + '\n' + '* ``DuplicateChildFeature``: ' + QgsAttributeEditorRelation.Button.DuplicateChildFeature.__doc__ + '\n' + '* ``DeleteChildFeature``: ' + QgsAttributeEditorRelation.Button.DeleteChildFeature.__doc__ + '\n' + '* ``ZoomToChildFeature``: ' + QgsAttributeEditorRelation.Button.ZoomToChildFeature.__doc__ + '\n' + '* ``AllButtons``: ' + QgsAttributeEditorRelation.Button.AllButtons.__doc__
# --
QgsAttributeEditorRelation.Button.baseClass = QgsAttributeEditorRelation
QgsAttributeEditorRelation.Buttons.baseClass = QgsAttributeEditorRelation
Buttons = QgsAttributeEditorRelation # dirty hack since SIP seems to introduce the flags in module
71 changes: 63 additions & 8 deletions python/core/auto_generated/qgsattributeeditorelement.sip.in
Expand Up @@ -9,6 +9,7 @@




class QgsAttributeEditorElement /Abstract/
{
%Docstring
Expand Down Expand Up @@ -282,6 +283,24 @@ This element will load a relation editor onto the form.
#include "qgsattributeeditorelement.h"
%End
public:
static const QMetaObject staticMetaObject;

public:

enum class Button
{
Link,
Unlink,
SaveChildEdits,
AddChildFeature,
DuplicateChildFeature,
DeleteChildFeature,
ZoomToChildFeature,
AllButtons
};
typedef QFlags<QgsAttributeEditorRelation::Button> Buttons;



QgsAttributeEditorRelation( const QString &name, const QString &relationId, QgsAttributeEditorElement *parent );
%Docstring
Expand Down Expand Up @@ -333,51 +352,87 @@ Initializes the relation from the id
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;


bool showLinkButton() const;
bool showLinkButton() const /Deprecated/;
%Docstring
Determines if the "link feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use shownButtons() instead
%End

void setShowLinkButton( bool showLinkButton );
void setShowLinkButton( bool showLinkButton ) /Deprecated/;
%Docstring
Determines if the "link feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use setShownButtons() instead
%End

bool showUnlinkButton() const;
bool showUnlinkButton() const /Deprecated/;
%Docstring
Determines if the "unlink feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use shownButtons() instead
%End

void setShowUnlinkButton( bool showUnlinkButton );
void setShowUnlinkButton( bool showUnlinkButton ) /Deprecated/;
%Docstring
Determines if the "unlink feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use setShownButtons() instead
%End

void setShowSaveChildEditsButton( bool showSaveChildEditsButton );
void setShowSaveChildEditsButton( bool showChildEdits ) /Deprecated/;
%Docstring
Determines if the "save child layer edits" button should be shown
Determines if the "Save child layer edits" button should be shown

.. versionadded:: 3.14

.. deprecated:: QGIS 3.16
use setShownButtons() instead
%End

bool showSaveChildEditsButton( ) const;
bool showSaveChildEditsButton() const /Deprecated/;
%Docstring
Returns ``True`` if the "save child layer edits" button should be shown.
Determines if the "Save child layer edits" button should be shown

.. versionadded:: 3.14

.. deprecated:: QGIS 3.16
use shownButtons() instead
%End

void setShownButtons( const QgsAttributeEditorRelation::Buttons &buttons );
%Docstring
Defines the buttons which are shown

.. versionadded:: 3.16
%End

QgsAttributeEditorRelation::Buttons shownButtons() const;
%Docstring
Returns the buttons which are shown

.. versionadded:: 3.16
%End


};

QFlags<QgsAttributeEditorRelation::Button> operator|(QgsAttributeEditorRelation::Button f1, QFlags<QgsAttributeEditorRelation::Button> f2);



class QgsAttributeEditorQmlElement : QgsAttributeEditorElement
{
%Docstring
Expand Down
Expand Up @@ -39,46 +39,78 @@ Only has an effect after :py:func:`~QgsRelationWidgetWrapper.widget` has been ca
.. versionadded:: 2.18
%End

bool showLinkButton() const;
bool showLinkButton() const /Deprecated/;
%Docstring
Determines if the "link feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use shownButtons() instead
%End

void setShowLinkButton( bool showLinkButton );
void setShowLinkButton( bool showLinkButton ) /Deprecated/;
%Docstring
Determines if the "link feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use setShownButtons() instead
%End

bool showUnlinkButton() const /Deprecated/;
%Docstring
Determines if the "unlink feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use shownButtons() instead
%End

void setShowUnlinkButton( bool showUnlinkButton ) /Deprecated/;
%Docstring
Determines if the "unlink feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use setShownButtons() instead
%End

bool showSaveChildEditsButton() const;
void setShowSaveChildEditsButton( bool showChildEdits ) /Deprecated/;
%Docstring
Determines if the "save child layer edits" button should be shown
Determines if the "Save child layer edits" button should be shown

.. versionadded:: 3.14

.. deprecated:: QGIS 3.16
use setShownButtons() instead
%End

void setShowSaveChildEditsButton( bool showSaveChildEditsButton );
bool showSaveChildEditsButton() const /Deprecated/;
%Docstring
Determines if the "save child layer edits" button should be shown
Determines if the "Save child layer edits" button should be shown

.. versionadded:: 3.14

.. deprecated:: QGIS 3.16
use shownButtons() instead
%End

bool showUnlinkButton() const;
void setShownButtons( const QgsAttributeEditorRelation::Buttons &buttons );
%Docstring
Determines if the "unlink feature" button should be shown
Defines the buttons which are shown

.. versionadded:: 2.18
.. versionadded:: 3.16
%End

void setShowUnlinkButton( bool showUnlinkButton );
QgsAttributeEditorRelation::Buttons shownButtons() const;
%Docstring
Determines if the "unlink feature" button should be shown
Returns the buttons which are shown

.. versionadded:: 2.18
.. versionadded:: 3.16
%End

QgsRelation relation() const;
Expand Down
46 changes: 40 additions & 6 deletions python/gui/auto_generated/qgsrelationeditorwidget.sip.in
Expand Up @@ -34,6 +34,7 @@ class QgsRelationEditorWidget : QgsCollapsibleGroupBox
%End
public:


QgsRelationEditorWidget( QWidget *parent /TransferThis/ = 0 );
%Docstring

Expand Down Expand Up @@ -108,46 +109,78 @@ Defines if a title label should be shown for this widget.
.. versionadded:: 2.18
%End

bool showLinkButton() const;
bool showLinkButton() const /Deprecated/;
%Docstring
Determines if the "link feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use shownButtons() instead
%End

void setShowLinkButton( bool showLinkButton );
void setShowLinkButton( bool showLinkButton ) /Deprecated/;
%Docstring
Determines if the "link feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use setShownButtons() instead
%End

bool showUnlinkButton() const;
bool showUnlinkButton() const /Deprecated/;
%Docstring
Determines if the "unlink feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use shownButtons() instead
%End

void setShowUnlinkButton( bool showUnlinkButton );
void setShowUnlinkButton( bool showUnlinkButton ) /Deprecated/;
%Docstring
Determines if the "unlink feature" button should be shown

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use setShownButtons() instead
%End

void setShowSaveChildEditsButton( bool showChildEdits );
void setShowSaveChildEditsButton( bool showChildEdits ) /Deprecated/;
%Docstring
Determines if the "Save child layer edits" button should be shown

.. versionadded:: 3.14

.. deprecated:: QGIS 3.16
use setShownButtons() instead
%End

bool showSaveChildEditsButton() const;
bool showSaveChildEditsButton() const /Deprecated/;
%Docstring
Determines if the "Save child layer edits" button should be shown

.. versionadded:: 3.14

.. deprecated:: QGIS 3.16
use shownButtons() instead
%End

void setShownButtons( const QgsAttributeEditorRelation::Buttons &buttons );
%Docstring
Defines the buttons which are shown

.. versionadded:: 3.16
%End

QgsAttributeEditorRelation::Buttons shownButtons() const;
%Docstring
Returns the buttons which are shown

.. versionadded:: 3.16
%End

QgsFeature feature() const;
Expand All @@ -168,6 +201,7 @@ Called when an ``attribute`` value in the parent widget has changed to ``newValu

};


/************************************************************************
* This file has been generated automatically from *
* *
Expand Down

0 comments on commit ccb3b8e

Please sign in to comment.