Skip to content
Permalink
Browse files

Single QgsBasicRelationWidget file

  • Loading branch information
suricactus committed Jan 6, 2021
1 parent 8f4bf3e commit 472698583c903f04a488c3f9154fc812130b22da
@@ -103,6 +103,7 @@ Sets the title of the root groupbox
};



/************************************************************************
* This file has been generated automatically from *
* *
@@ -568,8 +568,6 @@ set(QGIS_GUI_SRCS
qgsrelationeditorwidget.cpp
qgsrelationconfigwidget.cpp
qgsbasicrelationwidget.cpp
qgsbasicrelationconfigwidget.cpp
qgsbasicrelationwidgetfactory.cpp
qgsrelationwidget.cpp
qgsrelationwidgetfactory.cpp
qgsrelationwidgetregistry.cpp
@@ -821,8 +819,6 @@ set(QGIS_GUI_HDRS
qgsrelationeditorwidget.h
qgsrelationconfigwidget.h
qgsbasicrelationwidget.h
qgsbasicrelationconfigwidget.h
qgsbasicrelationwidgetfactory.h
qgsrelationwidget.h
qgsrelationwidgetfactory.h
qgsrelationwidgetregistry.h

This file was deleted.

This file was deleted.

@@ -556,3 +556,77 @@ void QgsBasicRelationWidget::afterSetRelations()

updateButtons();
}


///////////////////////////////////////////////////////////////////////////////


#ifndef SIP_RUN
QgsBasicRelationWidgetFactory::QgsBasicRelationWidgetFactory()
{

}

QString QgsBasicRelationWidgetFactory::type() const
{
return QStringLiteral( "relation_editor" );
}

QString QgsBasicRelationWidgetFactory::name() const
{
return QStringLiteral( "Relation Editor" );
}

QgsRelationWidget *QgsBasicRelationWidgetFactory::create( const QVariantMap &config, QWidget *parent ) const
{
return new QgsBasicRelationWidget( config, parent );
}


QgsRelationConfigWidget *QgsBasicRelationWidgetFactory::configWidget( const QgsRelation &relation, QWidget *parent ) const
{
return static_cast<QgsRelationConfigWidget *>( new QgsBasicRelationConfigWidget( relation, parent ) );
}
#endif


///////////////////////////////////////////////////////////////////////////////


#ifndef SIP_RUN
QgsBasicRelationConfigWidget::QgsBasicRelationConfigWidget( const QgsRelation &relation, QWidget *parent )
: QgsRelationConfigWidget( relation, parent )
{
setupUi( this );
}

QVariantMap QgsBasicRelationConfigWidget::config()
{
QgsBasicRelationWidget::Buttons buttons;
buttons.setFlag( QgsBasicRelationWidget::Button::Link, mRelationShowLinkCheckBox->isChecked() );
buttons.setFlag( QgsBasicRelationWidget::Button::Unlink, mRelationShowUnlinkCheckBox->isChecked() );
buttons.setFlag( QgsBasicRelationWidget::Button::AddChildFeature, mRelationShowAddChildCheckBox->isChecked() );
buttons.setFlag( QgsBasicRelationWidget::Button::DuplicateChildFeature, mRelationShowDuplicateChildFeatureCheckBox->isChecked() );
buttons.setFlag( QgsBasicRelationWidget::Button::ZoomToChildFeature, mRelationShowZoomToFeatureCheckBox->isChecked() );
buttons.setFlag( QgsBasicRelationWidget::Button::DeleteChildFeature, mRelationDeleteChildFeatureCheckBox->isChecked() );
buttons.setFlag( QgsBasicRelationWidget::Button::SaveChildEdits, mRelationShowSaveChildEditsCheckBox->isChecked() );

return QVariantMap(
{
{"buttons", qgsFlagValueToKeys( buttons )},
} );
}

void QgsBasicRelationConfigWidget::setConfig( const QVariantMap &config )
{
const QgsBasicRelationWidget::Buttons buttons = qgsFlagKeysToValue( config.value( QStringLiteral( "buttons" ) ).toString(), QgsBasicRelationWidget::Button::AllButtons );

mRelationShowLinkCheckBox->setChecked( buttons.testFlag( QgsBasicRelationWidget::Button::Link ) );
mRelationShowUnlinkCheckBox->setChecked( buttons.testFlag( QgsBasicRelationWidget::Button::Unlink ) );
mRelationShowAddChildCheckBox->setChecked( buttons.testFlag( QgsBasicRelationWidget::Button::AddChildFeature ) );
mRelationShowDuplicateChildFeatureCheckBox->setChecked( buttons.testFlag( QgsBasicRelationWidget::Button::DuplicateChildFeature ) );
mRelationShowZoomToFeatureCheckBox->setChecked( buttons.testFlag( QgsBasicRelationWidget::Button::ZoomToChildFeature ) );
mRelationDeleteChildFeatureCheckBox->setChecked( buttons.testFlag( QgsBasicRelationWidget::Button::DeleteChildFeature ) );
mRelationShowSaveChildEditsCheckBox->setChecked( buttons.testFlag( QgsBasicRelationWidget::Button::SaveChildEdits ) );
}
#endif
@@ -24,8 +24,12 @@
#include <QGridLayout>
#include "qobjectuniqueptr.h"

#include "qgsrelationeditorwidget.h"
#include "ui_qgsrelationeditorconfigwidgetbase.h"

#include "qgsrelationwidget.h"
#include "qgsrelationconfigwidget.h"
#include "qgsrelationwidgetfactory.h"
#include "qgsrelationeditorwidget.h"
#include "qobjectuniqueptr.h"
#include "qgsattributeeditorcontext.h"
#include "qgscollapsiblegroupbox.h"
@@ -40,6 +44,7 @@ class QgsVectorLayerTools;
class QgsMapTool;
class QgsMapToolDigitizeFeature;


/**
* The default relation widget in QGIS. Successor of the now deprecated {\see QgsRelationEditorWidget}.
* \ingroup gui
@@ -169,4 +174,63 @@ class GUI_EXPORT QgsBasicRelationWidget : public QgsRelationWidget
};


#ifndef SIP_RUN

/**
* Factory class for creating a basic relation widget and the respective config widget.
* \ingroup gui
* \class QgsBasicRelationWidgetFactory
* \note not available in Python bindings
* \since QGIS 3.18
*/
class GUI_EXPORT QgsBasicRelationWidgetFactory : public QgsRelationWidgetFactory
{
public:
QgsBasicRelationWidgetFactory();

QString type() const override;

QString name() const override;

QgsRelationWidget *create( const QVariantMap &config, QWidget *parent = nullptr ) const override;

QgsRelationConfigWidget *configWidget( const QgsRelation &relation, QWidget *parent ) const override;

};

/**
* \ingroup gui
* \class QgsBasicRelationConfigWidget
* Creates a new configuration widget for the basic relation widget
* \since QGIS 3.18
*/
class QgsBasicRelationConfigWidget : public QgsRelationConfigWidget, private Ui::QgsRelationEditorConfigWidgetBase
{
public:

/**
* Create a new configuration widget
*
* \param relation The relation for which the configuration dialog will be created
* \param parent A parent widget
*/
explicit QgsBasicRelationConfigWidget( const QgsRelation &relation, QWidget *parent SIP_TRANSFERTHIS );

/**
* \brief Create a configuration from the current GUI state
*
* \returns A widget configuration
*/
QVariantMap config();

/**
* \brief Update the configuration widget to represent the given configuration.
*
* \param config The configuration which should be represented by this widget
*/
void setConfig( const QVariantMap &config );

};
#endif

#endif // QGSBASICRELATIONWIDGET_H

This file was deleted.

0 comments on commit 4726985

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