@@ -44,6 +44,8 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
44
44
connect ( mAvailableWidgetsTree , &QTreeWidget::itemSelectionChanged, this , &QgsAttributesFormProperties::onAttributeSelectionChanged );
45
45
connect ( mAddTabOrGroupButton , &QAbstractButton::clicked, this , &QgsAttributesFormProperties::addTabOrGroupButton );
46
46
connect ( mRemoveTabOrGroupButton , &QAbstractButton::clicked, this , &QgsAttributesFormProperties::removeTabOrGroupButton );
47
+ connect ( mEditorLayoutComboBox , static_cast <void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this , &QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged );
48
+ connect ( pbnSelectEditForm, &QToolButton::clicked, this , &QgsAttributesFormProperties::pbnSelectEditForm_clicked );
47
49
}
48
50
49
51
@@ -57,6 +59,12 @@ void QgsAttributesFormProperties::init()
57
59
initAvailableWidgetsTree ();
58
60
initFormLayoutTree ();
59
61
62
+ mEditorLayoutComboBox ->setCurrentIndex ( mLayer ->editFormConfig ().layout () );
63
+ mEditorLayoutComboBox_currentIndexChanged ( mEditorLayoutComboBox ->currentIndex () );
64
+
65
+ QgsEditFormConfig cfg = mLayer ->editFormConfig ();
66
+ mEditFormLineEdit ->setText ( cfg.uiForm () );
67
+
60
68
mAttributeTypeDialog ->setEnabled ( false );
61
69
mAttributeRelationEdit ->setEnabled ( false );
62
70
}
@@ -118,7 +126,8 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
118
126
}
119
127
120
128
121
- void QgsAttributesFormProperties::storeAttributeTypeDialog (){
129
+ void QgsAttributesFormProperties::storeAttributeTypeDialog ()
130
+ {
122
131
FieldConfig cfg;
123
132
124
133
cfg.mEditable = mAttributeTypeDialog ->fieldEditable ();
@@ -201,7 +210,7 @@ void QgsAttributesFormProperties::loadAttributeRelationEdit()
201
210
Q_FOREACH ( const QgsRelation &nmrel, QgsProject::instance ()->relationManager ()->referencingRelations ( relation.referencingLayer () ) )
202
211
{
203
212
if ( nmrel.fieldPairs ().at ( 0 ).referencingField () != relation.fieldPairs ().at ( 0 ).referencingField () )
204
- mAttributeRelationEdit ->setCardinalityCombo ( QStringLiteral ( " %1 (%2)" ).arg ( nmrel.referencedLayer ()->name (), nmrel.fieldPairs ().at ( 0 ).referencedField () ), nmrel.id () );
213
+ mAttributeRelationEdit ->setCardinalityCombo ( QStringLiteral ( " %1 (%2)" ).arg ( nmrel.referencedLayer ()->name (), nmrel.fieldPairs ().at ( 0 ).referencedField () ), nmrel.id () );
205
214
}
206
215
207
216
mAttributeRelationEdit ->setCardinality ( cfg.mCardinality );
@@ -353,13 +362,13 @@ void QgsAttributesFormProperties::onAttributeSelectionChanged()
353
362
{
354
363
case DnDTreeItemData::Relation:
355
364
{
356
- mAttributeTypeDialog ->setEnabled ( false );
365
+ mAttributeTypeDialog ->setVisible ( false );
357
366
loadAttributeRelationEdit ();
358
367
break ;
359
368
}
360
369
case DnDTreeItemData::Field:
361
370
{
362
- mAttributeRelationEdit ->setEnabled ( false );
371
+ mAttributeRelationEdit ->setVisible ( false );
363
372
loadAttributeTypeDialog ();
364
373
break ;
365
374
}
@@ -506,6 +515,40 @@ QgsAttributeEditorElement *QgsAttributesFormProperties::createAttributeEditorWid
506
515
return widgetDef;
507
516
}
508
517
518
+ void QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged ( int index )
519
+ {
520
+ switch ( index )
521
+ {
522
+ case 0 :
523
+ mFormLayoutWidget ->setVisible ( false );
524
+ mUiFileFrame ->setVisible ( false );
525
+ break ;
526
+
527
+ case 1 :
528
+ mFormLayoutWidget ->setVisible ( true );
529
+ mUiFileFrame ->setVisible ( false );
530
+ break ;
531
+
532
+ case 2 :
533
+ mFormLayoutWidget ->setVisible ( false );
534
+ mUiFileFrame ->setVisible ( true );
535
+ break ;
536
+ }
537
+ }
538
+
539
+ void QgsAttributesFormProperties::pbnSelectEditForm_clicked ()
540
+ {
541
+ QgsSettings myQSettings;
542
+ QString lastUsedDir = myQSettings.value ( QStringLiteral ( " style/lastUIDir" ), QDir::homePath () ).toString ();
543
+ QString uifilename = QFileDialog::getOpenFileName ( this , tr ( " Select edit form" ), lastUsedDir, tr ( " UI file" ) + " (*.ui)" );
544
+
545
+ if ( uifilename.isNull () )
546
+ return ;
547
+
548
+ QFileInfo fi ( uifilename );
549
+ myQSettings.setValue ( QStringLiteral ( " style/lastUIDir" ), fi.path () );
550
+ mEditFormLineEdit ->setText ( uifilename );
551
+ }
509
552
510
553
void QgsAttributesFormProperties::apply ()
511
554
{
@@ -570,10 +613,11 @@ void QgsAttributesFormProperties::apply()
570
613
editFormConfig.addTab ( createAttributeEditorWidget ( tabItem, nullptr , false ) );
571
614
}
572
615
573
- /*
574
616
editFormConfig.setUiForm ( mEditFormLineEdit ->text () );
617
+
575
618
editFormConfig.setLayout ( ( QgsEditFormConfig::EditorLayout ) mEditorLayoutComboBox ->currentIndex () );
576
619
620
+ /*
577
621
// Init function configuration
578
622
editFormConfig.setInitFunction( mInitFunctionLineEdit->text() );
579
623
editFormConfig.setInitCode( mInitCodeEditorPython->text() );
0 commit comments