Skip to content
Permalink
Browse files

Relation Cardinality config

  • Loading branch information
signedav committed Oct 27, 2017
1 parent e251b24 commit 6055e713a3c17605a3d205b76d904fb9c34e5828
@@ -1,16 +1,15 @@
#include "qgsattributerelationedit.h"
#include "ui_qgsattributerelationedit.h"

QgsAttributeRelationEdit::QgsAttributeRelationEdit(QWidget *parent) :
QgsAttributeRelationEdit::QgsAttributeRelationEdit(const QString &relationid, QWidget *parent) :
QWidget(parent),
ui(new Ui::QgsAttributeRelationEdit)
mRelationId( relationid )
{
ui->setupUi(this);
setupUi(this);
}

QgsAttributeRelationEdit::~QgsAttributeRelationEdit()
{
delete ui;
}

void QgsAttributeRelationEdit::setCardinality( const QString &cardinality )
@@ -24,7 +24,7 @@ class APP_EXPORT QgsAttributeRelationEdit: public QWidget, private Ui::QgsAttrib
Q_OBJECT

public:
explicit QgsAttributeRelationEdit(QWidget *parent = 0);
explicit QgsAttributeRelationEdit(const QString &relationid, QWidget *parent = 0);
~QgsAttributeRelationEdit();

/**
@@ -37,8 +37,10 @@ class APP_EXPORT QgsAttributeRelationEdit: public QWidget, private Ui::QgsAttrib
*/
QString cardinality();

QString mRelationId;
private:
Ui::QgsAttributeRelationEdit *ui;

//Ui::QgsAttributeRelationEdit *ui;
};

#endif // QGSATTRIBUTERELATIONEDIT_H
@@ -35,7 +35,8 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
mAttributeTypeFrame->layout()->setMargin( 0 );
mAttributeTypeFrame->layout()->addWidget( mAttributeTypeDialog );

mAttributeRelationEdit = new QgsAttributeRelationEdit( mAttributeTypeFrame );
// AttributeRelationEdit
mAttributeRelationEdit = new QgsAttributeRelationEdit( "", mAttributeTypeFrame );
mAttributeRelationEdit->layout()->setMargin( 0 );
mAttributeTypeFrame->layout()->setMargin( 0 );
mAttributeTypeFrame->layout()->addWidget( mAttributeRelationEdit );
@@ -192,25 +193,38 @@ void QgsAttributesFormProperties::loadAttributeRelationEdit()
delete mAttributeRelationEdit;

//oder mit dem? RelationConfig relCfg = configForRelation( itemData.name() );
RelationConfig cfg = mAvailableWidgetsTree->currentItem()->data( 0, RelationConfigRole).value<RelationConfig>();
RelationConfig cfg = currentItem->data( 0, RelationConfigRole).value<RelationConfig>();

mAttributeRelationEdit = new QgsAttributeRelationEdit( mAttributeTypeFrame );

//testdave mAttributeRelationEdit->setCardinality( cfg.mCardinality );
//testdave mAttributeRelationEdit->setCardinality( "Cardinal Draft" );
mAttributeRelationEdit = new QgsAttributeRelationEdit( currentItem->data( 0, FieldNameRole ).toString(), mAttributeTypeFrame );
mAttributeRelationEdit->setCardinality( cfg.mCardinality );

mAttributeRelationEdit->layout()->setMargin( 0 );
mAttributeTypeFrame->layout()->setMargin( 0 );

mAttributeTypeFrame->layout()->removeWidget( mAttributeTypeDialog );
mAttributeTypeFrame->layout()->addWidget( mAttributeTypeDialog );
mAttributeTypeFrame->layout()->addWidget( mAttributeRelationEdit );
}
}


void QgsAttributesFormProperties::storeAttributeRelationEdit()
{
//store it first
RelationConfig cfg;

cfg.mCardinality = mAttributeRelationEdit->cardinality();

QTreeWidgetItem* relationContainer=mAvailableWidgetsTree->invisibleRootItem()->child(1);

for ( int i = 0; i < relationContainer->childCount(); i++ )
{
QTreeWidgetItem *relationItem = relationContainer->child( i );
DnDTreeItemData itemData= relationItem->data( 0, DnDTreeRole ).value<DnDTreeItemData>();

if( itemData.name()==mAttributeRelationEdit->mRelationId ){
relationItem->setData( 0, RelationConfigRole, QVariant::fromValue<RelationConfig>( cfg ) );
}
}
}

QgsAttributesFormProperties::FieldConfig QgsAttributesFormProperties::configForChild( int index )

0 comments on commit 6055e71

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