@@ -966,119 +966,162 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
966
966
QWidget *baseWidget = new QWidget ();
967
967
baseWidget->setLayout ( baseLayout );
968
968
969
- if ( itemData.type () == QgsAttributesFormProperties::DnDTreeItemData::Container )
969
+ switch ( itemData.type () )
970
970
{
971
- QDialog dlg;
972
- dlg.setWindowTitle ( tr ( " Configure Container" ) );
973
- QFormLayout *layout = new QFormLayout () ;
974
- dlg.setLayout ( layout );
975
- layout->addRow ( baseWidget );
976
-
977
- QCheckBox *showAsGroupBox = nullptr ;
978
- QLineEdit *title = new QLineEdit ( itemData.name () );
979
- QSpinBox *columnCount = new QSpinBox ();
980
- QGroupBox *visibilityExpressionGroupBox = new QGroupBox ( tr ( " Control visibility by expression" ) );
981
- visibilityExpressionGroupBox->setCheckable ( true );
982
- visibilityExpressionGroupBox->setChecked ( itemData.visibilityExpression ().enabled () );
983
- visibilityExpressionGroupBox->setLayout ( new QGridLayout );
984
- QgsFieldExpressionWidget *visibilityExpressionWidget = new QgsFieldExpressionWidget;
985
- visibilityExpressionWidget->setLayer ( mLayer );
986
- visibilityExpressionWidget->setExpressionDialogTitle ( tr ( " Visibility Expression" ) );
987
- visibilityExpressionWidget->setExpression ( itemData.visibilityExpression ()->expression () );
988
- visibilityExpressionGroupBox->layout ()->addWidget ( visibilityExpressionWidget );
989
-
990
- columnCount->setRange ( 1 , 5 );
991
- columnCount->setValue ( itemData.columnCount () );
992
-
993
- layout->addRow ( tr ( " Title" ), title );
994
- layout->addRow ( tr ( " Column count" ), columnCount );
995
- layout->addRow ( visibilityExpressionGroupBox );
996
-
997
- if ( !item->parent () )
971
+ case QgsAttributesFormProperties::DnDTreeItemData::Container:
998
972
{
999
- showAsGroupBox = new QCheckBox ( tr ( " Show as group box" ) );
1000
- showAsGroupBox->setChecked ( itemData.showAsGroupBox () );
1001
- layout->addRow ( showAsGroupBox );
1002
- }
973
+ QDialog dlg;
974
+ dlg.setWindowTitle ( tr ( " Configure Container" ) );
975
+ QFormLayout *layout = new QFormLayout () ;
976
+ dlg.setLayout ( layout );
977
+ layout->addRow ( baseWidget );
978
+
979
+ QCheckBox *showAsGroupBox = nullptr ;
980
+ QLineEdit *title = new QLineEdit ( itemData.name () );
981
+ QSpinBox *columnCount = new QSpinBox ();
982
+ QGroupBox *visibilityExpressionGroupBox = new QGroupBox ( tr ( " Control visibility by expression" ) );
983
+ visibilityExpressionGroupBox->setCheckable ( true );
984
+ visibilityExpressionGroupBox->setChecked ( itemData.visibilityExpression ().enabled () );
985
+ visibilityExpressionGroupBox->setLayout ( new QGridLayout );
986
+ QgsFieldExpressionWidget *visibilityExpressionWidget = new QgsFieldExpressionWidget;
987
+ visibilityExpressionWidget->setLayer ( mLayer );
988
+ visibilityExpressionWidget->setExpressionDialogTitle ( tr ( " Visibility Expression" ) );
989
+ visibilityExpressionWidget->setExpression ( itemData.visibilityExpression ()->expression () );
990
+ visibilityExpressionGroupBox->layout ()->addWidget ( visibilityExpressionWidget );
991
+
992
+ columnCount->setRange ( 1 , 5 );
993
+ columnCount->setValue ( itemData.columnCount () );
994
+
995
+ layout->addRow ( tr ( " Title" ), title );
996
+ layout->addRow ( tr ( " Column count" ), columnCount );
997
+ layout->addRow ( visibilityExpressionGroupBox );
998
+
999
+ if ( !item->parent () )
1000
+ {
1001
+ showAsGroupBox = new QCheckBox ( tr ( " Show as group box" ) );
1002
+ showAsGroupBox->setChecked ( itemData.showAsGroupBox () );
1003
+ layout->addRow ( showAsGroupBox );
1004
+ }
1003
1005
1004
- QDialogButtonBox *buttonBox = new QDialogButtonBox ( QDialogButtonBox::Ok
1005
- | QDialogButtonBox::Cancel );
1006
+ QDialogButtonBox *buttonBox = new QDialogButtonBox ( QDialogButtonBox::Ok
1007
+ | QDialogButtonBox::Cancel );
1006
1008
1007
- connect ( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1008
- connect ( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1009
+ connect ( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1010
+ connect ( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1009
1011
1010
- layout->addWidget ( buttonBox );
1012
+ layout->addWidget ( buttonBox );
1011
1013
1012
- if ( dlg.exec () )
1013
- {
1014
- itemData.setColumnCount ( columnCount->value () );
1015
- itemData.setShowAsGroupBox ( showAsGroupBox ? showAsGroupBox->isChecked () : true );
1016
- itemData.setName ( title->text () );
1017
- itemData.setShowLabel ( showLabelCheckbox->isChecked () );
1018
-
1019
- QgsOptionalExpression visibilityExpression;
1020
- visibilityExpression.setData ( QgsExpression ( visibilityExpressionWidget->expression () ) );
1021
- visibilityExpression.setEnabled ( visibilityExpressionGroupBox->isChecked () );
1022
- itemData.setVisibilityExpression ( visibilityExpression );
1023
-
1024
- item->setData ( 0 , QgsAttributesFormProperties::DnDTreeRole, itemData );
1025
- item->setText ( 0 , title->text () );
1014
+ if ( dlg.exec () )
1015
+ {
1016
+ itemData.setColumnCount ( columnCount->value () );
1017
+ itemData.setShowAsGroupBox ( showAsGroupBox ? showAsGroupBox->isChecked () : true );
1018
+ itemData.setName ( title->text () );
1019
+ itemData.setShowLabel ( showLabelCheckbox->isChecked () );
1020
+
1021
+ QgsOptionalExpression visibilityExpression;
1022
+ visibilityExpression.setData ( QgsExpression ( visibilityExpressionWidget->expression () ) );
1023
+ visibilityExpression.setEnabled ( visibilityExpressionGroupBox->isChecked () );
1024
+ itemData.setVisibilityExpression ( visibilityExpression );
1025
+
1026
+ item->setData ( 0 , QgsAttributesFormProperties::DnDTreeRole, itemData );
1027
+ item->setText ( 0 , title->text () );
1028
+ }
1026
1029
}
1027
- }
1028
- else if ( itemData.type () == QgsAttributesFormProperties::DnDTreeItemData::Relation )
1029
- {
1030
- QDialog dlg;
1031
- dlg.setWindowTitle ( tr ( " Configure Relation Editor" ) );
1032
- QFormLayout *layout = new QFormLayout () ;
1033
- dlg.setLayout ( layout );
1034
- layout->addWidget ( baseWidget );
1030
+ break ;
1035
1031
1036
- QCheckBox *showLinkButton = new QCheckBox ( tr ( " Show link button" ) );
1037
- showLinkButton->setChecked ( itemData.relationEditorConfiguration ().showLinkButton );
1038
- QCheckBox *showUnlinkButton = new QCheckBox ( tr ( " Show unlink button" ) );
1039
- showUnlinkButton->setChecked ( itemData.relationEditorConfiguration ().showUnlinkButton );
1040
- layout->addRow ( showLinkButton );
1041
- layout->addRow ( showUnlinkButton );
1032
+ case QgsAttributesFormProperties::DnDTreeItemData::Relation:
1033
+ {
1034
+ QDialog dlg;
1035
+ dlg.setWindowTitle ( tr ( " Configure Relation Editor" ) );
1036
+ QFormLayout *layout = new QFormLayout () ;
1037
+ dlg.setLayout ( layout );
1038
+ layout->addWidget ( baseWidget );
1042
1039
1043
- QDialogButtonBox *buttonBox = new QDialogButtonBox ( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
1040
+ QCheckBox *showLinkButton = new QCheckBox ( tr ( " Show link button" ) );
1041
+ showLinkButton->setChecked ( itemData.relationEditorConfiguration ().showLinkButton );
1042
+ QCheckBox *showUnlinkButton = new QCheckBox ( tr ( " Show unlink button" ) );
1043
+ showUnlinkButton->setChecked ( itemData.relationEditorConfiguration ().showUnlinkButton );
1044
+ layout->addRow ( showLinkButton );
1045
+ layout->addRow ( showUnlinkButton );
1044
1046
1045
- connect ( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1046
- connect ( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1047
+ QDialogButtonBox *buttonBox = new QDialogButtonBox ( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
1047
1048
1048
- dlg.layout ()->addWidget ( buttonBox );
1049
+ connect ( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1050
+ connect ( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1049
1051
1050
- if ( dlg.exec () )
1051
- {
1052
- QgsAttributesFormProperties::RelationEditorConfiguration relEdCfg;
1053
- relEdCfg.showLinkButton = showLinkButton->isChecked ();
1054
- relEdCfg.showUnlinkButton = showUnlinkButton->isChecked ();
1055
- itemData.setShowLabel ( showLabelCheckbox->isChecked () );
1056
- itemData.setRelationEditorConfiguration ( relEdCfg );
1052
+ dlg.layout ()->addWidget ( buttonBox );
1053
+
1054
+ if ( dlg.exec () )
1055
+ {
1056
+ QgsAttributesFormProperties::RelationEditorConfiguration relEdCfg;
1057
+ relEdCfg.showLinkButton = showLinkButton->isChecked ();
1058
+ relEdCfg.showUnlinkButton = showUnlinkButton->isChecked ();
1059
+ itemData.setShowLabel ( showLabelCheckbox->isChecked () );
1060
+ itemData.setRelationEditorConfiguration ( relEdCfg );
1057
1061
1058
- item->setData ( 0 , QgsAttributesFormProperties::DnDTreeRole, itemData );
1062
+ item->setData ( 0 , QgsAttributesFormProperties::DnDTreeRole, itemData );
1063
+ }
1059
1064
}
1060
- }
1061
- else
1062
- {
1063
- QDialog dlg;
1064
- dlg.setWindowTitle ( tr ( " Configure Field" ) );
1065
- dlg.setLayout ( new QGridLayout () );
1066
- dlg.layout ()->addWidget ( baseWidget );
1065
+ break ;
1066
+
1067
+ case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
1068
+ {
1069
+ QDialog dlg;
1070
+ dlg.setWindowTitle ( tr ( " Configure QML Widget" ) );
1071
+ QFormLayout *layout = new QFormLayout () ;
1072
+ dlg.setLayout ( layout );
1073
+ layout->addWidget ( baseWidget );
1067
1074
1068
- QDialogButtonBox *buttonBox = new QDialogButtonBox ( QDialogButtonBox::Ok
1069
- | QDialogButtonBox::Cancel );
1075
+ QCheckBox *showLinkButton = new QCheckBox ( tr ( " Show link button" ) );
1076
+ showLinkButton->setChecked ( itemData.relationEditorConfiguration ().showLinkButton );
1077
+ QCheckBox *showUnlinkButton = new QCheckBox ( tr ( " Show unlink button" ) );
1078
+ showUnlinkButton->setChecked ( itemData.relationEditorConfiguration ().showUnlinkButton );
1079
+ layout->addRow ( showLinkButton );
1080
+ layout->addRow ( showUnlinkButton );
1070
1081
1071
- connect ( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1072
- connect ( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1082
+ QDialogButtonBox *buttonBox = new QDialogButtonBox ( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
1073
1083
1074
- dlg.layout ()->addWidget ( buttonBox );
1084
+ connect ( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1085
+ connect ( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1075
1086
1076
- if ( dlg.exec () )
1087
+ dlg.layout ()->addWidget ( buttonBox );
1088
+
1089
+ if ( dlg.exec () )
1090
+ {
1091
+ QgsAttributesFormProperties::RelationEditorConfiguration relEdCfg;
1092
+ relEdCfg.showLinkButton = showLinkButton->isChecked ();
1093
+ relEdCfg.showUnlinkButton = showUnlinkButton->isChecked ();
1094
+ itemData.setShowLabel ( showLabelCheckbox->isChecked () );
1095
+ itemData.setRelationEditorConfiguration ( relEdCfg );
1096
+
1097
+ item->setData ( 0 , QgsAttributesFormProperties::DnDTreeRole, itemData );
1098
+ }
1099
+ }
1100
+ break ;
1101
+
1102
+ case QgsAttributesFormProperties::DnDTreeItemData::Field:
1077
1103
{
1078
- itemData.setShowLabel ( showLabelCheckbox->isChecked () );
1104
+ QDialog dlg;
1105
+ dlg.setWindowTitle ( tr ( " Configure Field" ) );
1106
+ dlg.setLayout ( new QGridLayout () );
1107
+ dlg.layout ()->addWidget ( baseWidget );
1108
+
1109
+ QDialogButtonBox *buttonBox = new QDialogButtonBox ( QDialogButtonBox::Ok
1110
+ | QDialogButtonBox::Cancel );
1111
+
1112
+ connect ( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
1113
+ connect ( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
1114
+
1115
+ dlg.layout ()->addWidget ( buttonBox );
1079
1116
1080
- item->setData ( 0 , QgsAttributesFormProperties::DnDTreeRole, itemData );
1117
+ if ( dlg.exec () )
1118
+ {
1119
+ itemData.setShowLabel ( showLabelCheckbox->isChecked () );
1120
+
1121
+ item->setData ( 0 , QgsAttributesFormProperties::DnDTreeRole, itemData );
1122
+ }
1081
1123
}
1124
+ break ;
1082
1125
}
1083
1126
}
1084
1127
0 commit comments