Skip to content
Permalink
Browse files

Merge pull request #37763 from 3nids/fix37718

 make more buttons configurable in relation editor
  • Loading branch information
3nids committed Jul 13, 2020
2 parents ebd4cd8 + 1c9211a commit 384962b6c062b751d63a289fe13653716dd481f9
@@ -0,0 +1,4 @@
# The following has been generated automatically from src/core/qgsattributeeditorelement.h
QgsAttributeEditorRelation.Button.baseClass = QgsAttributeEditorRelation
QgsAttributeEditorRelation.Buttons.baseClass = QgsAttributeEditorRelation
Buttons = QgsAttributeEditorRelation # dirty hack since SIP seems to introduce the flags in module
@@ -9,6 +9,7 @@




class QgsAttributeEditorElement /Abstract/
{
%Docstring
@@ -282,6 +283,23 @@ This element will load a relation editor onto the form.
#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
@@ -333,51 +351,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 visibleButtons() 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 setVisibleButtons() 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 visibleButtons() 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 setVisibleButtons() 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 setVisibleButtons() 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 visibleButtons() instead
%End

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

.. versionadded:: 3.16
%End

QgsAttributeEditorRelation::Buttons visibleButtons() 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
@@ -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 visibleButtons() 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 setVisibleButtons() instead
%End

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

.. versionadded:: 2.18

.. deprecated:: QGIS 3.16
use visibleButtons() 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 setVisibleButtons() 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 setVisibleButtons() 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 visibleButtons() instead
%End

bool showUnlinkButton() const;
void setVisibleButtons( 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 visibleButtons() 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;
@@ -34,6 +34,7 @@ class QgsRelationEditorWidget : QgsCollapsibleGroupBox
%End
public:


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

@@ -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 visibleButtons() 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 setVisibleButtons() 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 visibleButtons() 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 setVisibleButtons() 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 setVisibleButtons() 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 visibleButtons() instead
%End

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

.. versionadded:: 3.16
%End

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

.. versionadded:: 3.16
%End

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

};


/************************************************************************
* This file has been generated automatically from *
* *
@@ -96,8 +96,7 @@ QgsAttributeEditorElement *QgsAttributeEditorRelation::clone( QgsAttributeEditor
{
QgsAttributeEditorRelation *element = new QgsAttributeEditorRelation( mRelationId, parent );
element->mRelation = mRelation;
element->mShowLinkButton = mShowLinkButton;
element->mShowUnlinkButton = mShowUnlinkButton;
element->mButtons = mButtons;

return element;
}
@@ -133,9 +132,7 @@ void QgsAttributeEditorElement::setShowLabel( bool showLabel )
void QgsAttributeEditorRelation::saveConfiguration( QDomElement &elem ) const
{
elem.setAttribute( QStringLiteral( "relation" ), mRelation.id() );
elem.setAttribute( QStringLiteral( "showLinkButton" ), mShowLinkButton );
elem.setAttribute( QStringLiteral( "showUnlinkButton" ), mShowUnlinkButton );
elem.setAttribute( QStringLiteral( "showSaveChildEditsButton" ), mShowSaveChildEditsButton );
elem.setAttribute( QStringLiteral( "buttons" ), qgsFlagValueToKeys( mButtons ) );
}

QString QgsAttributeEditorRelation::typeIdentifier() const
@@ -145,32 +142,37 @@ QString QgsAttributeEditorRelation::typeIdentifier() const

bool QgsAttributeEditorRelation::showLinkButton() const
{
return mShowLinkButton;
return mButtons.testFlag( Button::Link );
}

void QgsAttributeEditorRelation::setShowLinkButton( bool showLinkButton )
{
mShowLinkButton = showLinkButton;
mButtons.setFlag( Button::Link, showLinkButton );
}

bool QgsAttributeEditorRelation::showUnlinkButton() const
{
return mShowUnlinkButton;
return mButtons.testFlag( Button::Unlink );
}

void QgsAttributeEditorRelation::setShowUnlinkButton( bool showUnlinkButton )
{
mShowUnlinkButton = showUnlinkButton;
mButtons.setFlag( Button::Unlink, showUnlinkButton );
}

void QgsAttributeEditorRelation::setShowSaveChildEditsButton( bool showSaveChildEdits )
{
mShowSaveChildEditsButton = showSaveChildEdits;
mButtons.setFlag( Button::SaveChildEdits, showSaveChildEdits );
}

bool QgsAttributeEditorRelation::showSaveChildEditsButton() const
{
return mShowSaveChildEditsButton;
return mButtons.testFlag( Button::SaveChildEdits );
}

void QgsAttributeEditorRelation::setVisibleButtons( const QgsAttributeEditorRelation::Buttons &buttons )
{
mButtons = buttons;
}

QgsAttributeEditorElement *QgsAttributeEditorQmlElement::clone( QgsAttributeEditorElement *parent ) const

0 comments on commit 384962b

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