1
+ /* **************************************************************************
2
+ qgsattributesformproperties.cpp
3
+ ---------------------
4
+ begin : August 2017
5
+ copyright : (C) 2017 by David Signer
6
+ email : david at opengis dot ch
7
+ ***************************************************************************
8
+ * *
9
+ * This program is free software; you can redistribute it and/or modify *
10
+ * it under the terms of the GNU General Public License as published by *
11
+ * the Free Software Foundation; either version 2 of the License, or *
12
+ * (at your option) any later version. *
13
+ * *
14
+ ***************************************************************************/
15
+
1
16
#include " qgsattributesformproperties.h"
2
17
#include " qgsattributetypedialog.h"
3
18
#include " qgsattributerelationedit.h"
@@ -47,7 +62,7 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
47
62
connect ( mRemoveTabOrGroupButton , &QAbstractButton::clicked, this , &QgsAttributesFormProperties::removeTabOrGroupButton );
48
63
connect ( mEditorLayoutComboBox , static_cast <void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this , &QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged );
49
64
connect ( pbnSelectEditForm, &QToolButton::clicked, this , &QgsAttributesFormProperties::pbnSelectEditForm_clicked );
50
- connect ( pBInitCode , &QPushButton::clicked, this , &QgsAttributesFormProperties::pBInitCode_clicked );
65
+ connect ( mTbInitCode , &QPushButton::clicked, this , &QgsAttributesFormProperties::mTbInitCode_clicked );
51
66
}
52
67
53
68
@@ -64,8 +79,8 @@ void QgsAttributesFormProperties::init()
64
79
initLayoutConfig ();
65
80
initInitPython ();
66
81
67
- mAttributeTypeDialog ->setEnabled ( false );
68
- mAttributeRelationEdit ->setEnabled ( false );
82
+ // mAttributeTypeDialog->setEnabled( false );
83
+ // mAttributeRelationEdit->setEnabled( false );
69
84
}
70
85
71
86
void QgsAttributesFormProperties::initAvailableWidgetsTree ()
@@ -97,6 +112,7 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
97
112
item->setData ( 0 , FieldConfigRole, cfg );
98
113
item->setData ( 0 , FieldNameRole, field.name () );
99
114
}
115
+ catitem->setExpanded ( true );
100
116
101
117
/* stuff
102
118
itemData.setIcon(i, mLayer->fields().iconForField( i ));
@@ -119,8 +135,9 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
119
135
120
136
QTreeWidgetItem *item = mAvailableWidgetsTree ->addItem ( catitem, itemData );
121
137
item->setData ( 0 , RelationConfigRole, cfg );
122
- item->setData ( 0 , FieldNameRole, QStringLiteral ( " %1 " ). arg ( relation .id () ) ); // relation.name () );
138
+ item->setData ( 0 , FieldNameRole, relation .id () );
123
139
}
140
+ catitem->setExpanded ( true );
124
141
}
125
142
126
143
void QgsAttributesFormProperties::initFormLayoutTree ()
@@ -138,6 +155,17 @@ void QgsAttributesFormProperties::initFormLayoutTree()
138
155
}
139
156
}
140
157
158
+
159
+ void QgsAttributesFormProperties::initSuppressCombo ()
160
+ {
161
+ // mFormSuppressCmbBx->addItem( tr( "" ) );
162
+ // mFormSuppressCmbBx->addItem( tr( "Load from external file" ) );
163
+ // mFormSuppressCmbBx->addItem( tr( "Provide code in this dialog" ) );
164
+ // mFormSuppressCmbBx->addItem( tr( "Load from the environment" ) );
165
+ mFormSuppressCmbBx ->setCurrentIndex ( mLayer ->editFormConfig ().suppress () );
166
+
167
+
168
+ }
141
169
void QgsAttributesFormProperties::initLayoutConfig ()
142
170
{
143
171
mEditorLayoutComboBox ->setCurrentIndex ( mLayer ->editFormConfig ().layout () );
@@ -194,9 +222,11 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
194
222
mAttributeTypeFrame ->layout ()->removeWidget ( mAttributeTypeDialog );
195
223
delete mAttributeTypeDialog ;
196
224
225
+
197
226
//
198
227
mAttributeTypeDialog = new QgsAttributeTypeDialog ( mLayer , index , mAttributeTypeFrame );
199
228
mAttributeTypeDialog ->setAlias ( cfg.mAlias );
229
+ mAttributeTypeDialog ->setComment ( mLayer ->fields ().at ( index ).comment () );
200
230
mAttributeTypeDialog ->setFieldEditable ( cfg.mEditable );
201
231
mAttributeTypeDialog ->setLabelOnTop ( cfg.mLabelOnTop );
202
232
mAttributeTypeDialog ->setNotNull ( cfg.mConstraints & QgsFieldConstraints::ConstraintNotNull );
@@ -239,7 +269,6 @@ void QgsAttributesFormProperties::storeAttributeTypeDialog()
239
269
cfg.mEditable = mAttributeTypeDialog ->fieldEditable ();
240
270
cfg.mLabelOnTop = mAttributeTypeDialog ->labelOnTop ();
241
271
cfg.mAlias = mAttributeTypeDialog ->alias ();
242
- cfg.mComment = mAttributeTypeDialog ->comment ();
243
272
244
273
// confustion (will be removed): wir laden teilweise sachen einfach beim store anstelle des applys auf die mLayer - eingie Sachen laden wir auch vom layer anstatt über das cfg. wieso
245
274
QgsFieldConstraints constraints = mLayer ->fields ().at ( mAttributeTypeDialog ->fieldIdx () ).constraints ();
@@ -571,7 +600,7 @@ void QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged( int
571
600
}
572
601
}
573
602
574
- void QgsAttributesFormProperties::pBInitCode_clicked ()
603
+ void QgsAttributesFormProperties::mTbInitCode_clicked ()
575
604
{
576
605
QgsAttributesFormInitCode attributesFormInitCode;
577
606
@@ -590,7 +619,6 @@ void QgsAttributesFormProperties::pBInitCode_clicked()
590
619
591
620
}
592
621
593
-
594
622
void QgsAttributesFormProperties::pbnSelectEditForm_clicked ()
595
623
{
596
624
QgsSettings myQSettings;
@@ -677,25 +705,7 @@ void QgsAttributesFormProperties::apply()
677
705
editFormConfig.setInitFilePath ( mInitFilePath );
678
706
editFormConfig.setInitCode ( mInitCode );
679
707
680
- /*
681
- Das heisst wir brauchen von Python-Dialog:
682
- mInitCodeSource
683
- mInitFunction
684
- mInitFilePath
685
- mInitCode
686
- Das heisst, beim init lesen wir die alle...
687
-
688
- // Init function configuration
689
- editFormConfig.setInitCodeSource( ( QgsEditFormConfig::PythonInitCodeSource )mInitCodeSourceComboBox->currentIndex() );
690
- editFormConfig.setInitFunction( mInitFunctionLineEdit->text() );
691
- editFormConfig.setInitFilePath( mInitFilePathLineEdit->text() );
692
- editFormConfig.setInitCode( mInitCodeEditorPython->text() );
693
- */
694
-
695
- /*
696
708
editFormConfig.setSuppress ( ( QgsEditFormConfig::FeatureFormSuppress )mFormSuppressCmbBx ->currentIndex () );
697
- */
698
-
699
709
700
710
// relations
701
711
QTreeWidgetItem *relationContainer = mAvailableWidgetsTree ->invisibleRootItem ()->child ( 1 );
0 commit comments