Skip to content
Permalink
Browse files
Merge pull request #43195 from domi4484/relationEditorWidgetLabelTitle
Relation editor widget label implementation moved to attribute form
  • Loading branch information
3nids committed May 13, 2021
2 parents 5586d4c + 7a4f2e8 commit ef14092f2a0ba753fd98e0658e2ed49b698b9761
@@ -40,20 +40,26 @@ Constructor for QgsRelationWidgetWrapper
Constructor for QgsRelationWidgetWrapper
%End

bool showLabel() const;
bool showLabel() const /Deprecated/;
%Docstring
Defines if a title label should be shown for this widget.
Only has an effect after :py:func:`~QgsRelationWidgetWrapper.widget` has been called at least once.

.. versionadded:: 2.18

.. deprecated:: QGIS 3.20
label is handled directly in :py:class:`QgsAttributeForm`.
%End

void setShowLabel( bool showLabel );
void setShowLabel( bool showLabel ) /Deprecated/;
%Docstring
Defines if a title label should be shown for this widget.
Only has an effect after :py:func:`~QgsRelationWidgetWrapper.widget` has been called at least once.

.. versionadded:: 2.18

.. deprecated:: QGIS 3.20
label is handled directly in :py:class:`QgsAttributeForm`.
%End

bool showLinkButton() const /Deprecated/;
@@ -185,19 +191,25 @@ If it's empty, then it's considered as a 1:M relationship.
.. versionadded:: 3.16
%End

QString label() const;
QString label() const /Deprecated/;
%Docstring
Determines the label of this element

.. versionadded:: 3.16

.. deprecated:: QGIS 3.20
label is handled directly in :py:class:`QgsAttributeForm`.
%End

void setLabel( const QString &label = QString() );
void setLabel( const QString &label = QString() ) /Deprecated/;
%Docstring
Sets ``label`` for this element
If it's empty it takes the relation id as label

.. versionadded:: 3.16

.. deprecated:: QGIS 3.20
label is handled directly in :py:class:`QgsAttributeForm`.
%End

QgsRelation relation() const;
@@ -91,14 +91,20 @@ Sets the editor ``context``
Returns the attribute editor context.
%End

bool showLabel() const;
bool showLabel() const /Deprecated/;
%Docstring
Defines if a title label should be shown for this widget.

.. deprecated:: QGIS 3.20
label is handled directly in :py:class:`QgsAttributeForm`.
%End

void setShowLabel( bool showLabel );
void setShowLabel( bool showLabel ) /Deprecated/;
%Docstring
Defines if a title label should be shown for this widget.

.. deprecated:: QGIS 3.20
label is handled directly in :py:class:`QgsAttributeForm`.
%End

QVariant nmRelationId() const;
@@ -112,9 +118,12 @@ Sets ``nmRelationId`` for the relation id of the second relation involved in an
If it's empty, then it's considered as a 1:M relationship.
%End

QString label() const;
QString label() const /Deprecated/;
%Docstring
Determines the label of this element

.. deprecated:: QGIS 3.20
label is handled directly in :py:class:`QgsAttributeForm`.
%End

void setLabel( const QString &label = QString() );
@@ -208,9 +217,12 @@ Duplicates features



void updateTitle();
void updateTitle() /Deprecated/;
%Docstring
Updates the title contents to reflect the current state of the widget

.. deprecated:: QGIS 3.20
label is handled directly in :py:class:`QgsAttributeForm`.
%End

void deleteFeatures( const QgsFeatureIds &fids );
@@ -232,10 +244,12 @@ Should be used to refresh the UI regarding the new data.
Check :py:class:`QgsRealationEditorWidget` as an example.
%End

virtual void setTitle( const QString &title );
virtual void setTitle( const QString &title ) /Deprecated/;
%Docstring
Sets the title of the widget, if it is wrapped within a :py:class:`QgsCollapsibleGroupBox`
Check :py:class:`QgsRealationEditorWidget` as an example.

.. deprecated:: QGIS 3.20
label is handled directly in :py:class:`QgsAttributeForm`.
%End

virtual void beforeSetRelationFeature( const QgsRelation &newRelation, const QgsFeature &newFeature );
@@ -133,12 +133,6 @@ Returns the current configuration

%Docstring
Defines the current configuration
%End

virtual void setTitle( const QString &title );

%Docstring
Sets the title of the root groupbox
%End

public slots:
@@ -138,17 +138,12 @@ void QgsRelationWidgetWrapper::setShowSaveChildEditsButton( bool showSaveChildEd

bool QgsRelationWidgetWrapper::showLabel() const
{
if ( mWidget )
{
return mWidget->showLabel();
}
return false;
}

void QgsRelationWidgetWrapper::setShowLabel( bool showLabel )
{
if ( mWidget )
mWidget->setShowLabel( showLabel );
Q_UNUSED( showLabel )
}

void QgsRelationWidgetWrapper::initWidget( QWidget *editor )
@@ -297,14 +292,11 @@ QVariant QgsRelationWidgetWrapper::nmRelationId() const

void QgsRelationWidgetWrapper::setLabel( const QString &label )
{
if ( mWidget )
mWidget->setLabel( label );
Q_UNUSED( label )
}

QString QgsRelationWidgetWrapper::label() const
{
if ( mWidget )
return mWidget->label();
return QString();
}

@@ -57,16 +57,18 @@ class GUI_EXPORT QgsRelationWidgetWrapper : public QgsWidgetWrapper
* Only has an effect after widget() has been called at least once.
*
* \since QGIS 2.18
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
*/
bool showLabel() const;
Q_DECL_DEPRECATED bool showLabel() const SIP_DEPRECATED;

/**
* Defines if a title label should be shown for this widget.
* Only has an effect after widget() has been called at least once.
*
* \since QGIS 2.18
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
*/
void setShowLabel( bool showLabel );
Q_DECL_DEPRECATED void setShowLabel( bool showLabel ) SIP_DEPRECATED;

/**
* Determines if the "link feature" button should be shown
@@ -170,15 +172,17 @@ class GUI_EXPORT QgsRelationWidgetWrapper : public QgsWidgetWrapper
/**
* Determines the label of this element
* \since QGIS 3.16
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
*/
QString label() const;
Q_DECL_DEPRECATED QString label() const SIP_DEPRECATED;

/**
* Sets \a label for this element
* If it's empty it takes the relation id as label
* \since QGIS 3.16
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
*/
void setLabel( const QString &label = QString() );
Q_DECL_DEPRECATED void setLabel( const QString &label = QString() ) SIP_DEPRECATED;

/**
* The relation for which this wrapper is created.
@@ -32,7 +32,6 @@
#include <QMessageBox>
#include <QPushButton>


QgsAbstractRelationEditorWidget::QgsAbstractRelationEditorWidget( const QVariantMap &config, QWidget *parent )
: QWidget( parent )
{
@@ -48,7 +47,6 @@ void QgsAbstractRelationEditorWidget::setRelationFeature( const QgsRelation &rel

setObjectName( QStringLiteral( "referenced/" ) + mRelation.name() );

updateTitle();
afterSetRelationFeature();
updateUi();
}
@@ -87,8 +85,6 @@ void QgsAbstractRelationEditorWidget::setRelations( const QgsRelation &relation,
}
}

updateTitle();

setObjectName( QStringLiteral( "referenced/" ) + mRelation.name() );

afterSetRelations();
@@ -131,26 +127,22 @@ QVariant QgsAbstractRelationEditorWidget::nmRelationId() const

QString QgsAbstractRelationEditorWidget::label() const
{
return mLabel;
return QString();
}

void QgsAbstractRelationEditorWidget::setLabel( const QString &label )
{
mLabel = label;

updateTitle();
Q_UNUSED( label )
}

bool QgsAbstractRelationEditorWidget::showLabel() const
{
return mShowLabel;
return false;
}

void QgsAbstractRelationEditorWidget::setShowLabel( bool showLabel )
{
mShowLabel = showLabel;

updateTitle();
Q_UNUSED( showLabel )
}

void QgsAbstractRelationEditorWidget::setForceSuppressFormPopup( bool forceSuppressFormPopup )
@@ -165,18 +157,6 @@ bool QgsAbstractRelationEditorWidget::forceSuppressFormPopup() const

void QgsAbstractRelationEditorWidget::updateTitle()
{
if ( mShowLabel && !mLabel.isEmpty() )
{
setTitle( mLabel );
}
else if ( mShowLabel && mRelation.isValid() )
{
setTitle( mRelation.name() );
}
else
{
setTitle( QString() );
}
}

QgsFeature QgsAbstractRelationEditorWidget::feature() const
@@ -111,13 +111,15 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget

/**
* Defines if a title label should be shown for this widget.
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
*/
bool showLabel() const;
Q_DECL_DEPRECATED bool showLabel() const SIP_DEPRECATED;

/**
* Defines if a title label should be shown for this widget.
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
*/
void setShowLabel( bool showLabel );
Q_DECL_DEPRECATED void setShowLabel( bool showLabel ) SIP_DEPRECATED;

/**
* Determines the relation id of the second relation involved in an N:M relation.
@@ -132,8 +134,9 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget

/**
* Determines the label of this element
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
*/
QString label() const;
Q_DECL_DEPRECATED QString label() const SIP_DEPRECATED;

/**
* Sets \a label for this element
@@ -228,16 +231,15 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget
QgsRelation mNmRelation;
QgsFeature mFeature;

bool mShowLabel = true;
bool mLayerInSameTransactionGroup = false;

bool mForceSuppressFormPopup = false;
QString mLabel;

/**
* Updates the title contents to reflect the current state of the widget
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
*/
void updateTitle();
Q_DECL_DEPRECATED void updateTitle() SIP_DEPRECATED;

/**
* Deletes the features with \a fids
@@ -261,9 +263,9 @@ class GUI_EXPORT QgsAbstractRelationEditorWidget : public QWidget

/**
* Sets the title of the widget, if it is wrapped within a QgsCollapsibleGroupBox
* Check QgsRealationEditorWidget as an example.
* \deprecated since QGIS 3.20 label is handled directly in QgsAttributeForm.
*/
virtual void setTitle( const QString &title );
Q_DECL_DEPRECATED virtual void setTitle( const QString &title ) SIP_DEPRECATED;

/**
* A hook called right before setRelationFeature() is executed. Used to update the UI once setting the relation feature is done.

0 comments on commit ef14092

Please sign in to comment.