@@ -115,34 +115,6 @@ QgsFieldsProperties::QgsFieldsProperties( QgsVectorLayer *layer, QWidget* parent
115
115
mRelationsList ->setHorizontalHeaderItem ( RelFieldCol, new QTableWidgetItem ( tr ( " Field" ) ) );
116
116
mRelationsList ->verticalHeader ()->hide ();
117
117
118
- // Python init function and code
119
- leEditForm->setText ( layer->editForm () );
120
- leEditFormInit->setText ( layer->editFormInit () );
121
- leEditFormInitUseCode->setChecked ( layer->editFormInitUseCode () );
122
- QString code ( layer->editFormInitCode () );
123
- if ( code.isEmpty ( ) )
124
- {
125
- code.append ( tr ( " # -*- coding: utf-8 -*-\n\"\"\"\n "
126
- " QGIS forms can have a Python function that is called when the form is\n "
127
- " opened.\n "
128
- " \n "
129
- " Use this function to add extra logic to your forms.\n "
130
- " \n "
131
- " Enter the name of the function in the \" Python Init function\"\n "
132
- " field.\n "
133
- " An example follows:\n "
134
- " \"\"\"\n "
135
- " from PyQt4.QtGui import QWidget\n\n "
136
- " def my_form_open(dialog, layer, feature):\n "
137
- " \t geom = feature.geometry()\n "
138
- " \t control = dialog.findChild(QWidget, \" MyLineEdit\" )\n " ) );
139
-
140
- }
141
- leEditFormInitCode->setText ( code );
142
- // Show or hide as needed
143
- mPythonInitCodeGroupBox ->setVisible ( layer->editFormInitUseCode () );
144
- connect ( leEditFormInitUseCode, SIGNAL ( toggled ( bool ) ), this , SLOT ( on_leEditFormInitUseCodeToggled ( bool ) ) );
145
-
146
118
loadRelations ();
147
119
148
120
updateButtons ();
@@ -213,10 +185,33 @@ QTreeWidgetItem *QgsFieldsProperties::loadAttributeEditorTreeItem( QgsAttributeE
213
185
214
186
void QgsFieldsProperties::setEditFormInit ( const QString &editForm, const QString &editFormInit, const QString &editFormInitCode, const bool editFormInitUseCode )
215
187
{
188
+
189
+ // Python init function and code
190
+ QString code ( editFormInitCode );
191
+ if ( code.isEmpty ( ) )
192
+ {
193
+ code.append ( tr ( " # -*- coding: utf-8 -*-\n\"\"\"\n "
194
+ " QGIS forms can have a Python function that is called when the form is\n "
195
+ " opened.\n "
196
+ " \n "
197
+ " Use this function to add extra logic to your forms.\n "
198
+ " \n "
199
+ " Enter the name of the function in the \" Python Init function\"\n "
200
+ " field.\n "
201
+ " An example follows:\n "
202
+ " \"\"\"\n "
203
+ " from PyQt4.QtGui import QWidget\n\n "
204
+ " def my_form_open(dialog, layer, feature):\n "
205
+ " \t geom = feature.geometry()\n "
206
+ " \t control = dialog.findChild(QWidget, \" MyLineEdit\" )\n " ) );
207
+
208
+ }
216
209
leEditForm->setText ( editForm );
210
+ leEditFormInitCode->setText ( code );
217
211
leEditFormInit->setText ( editFormInit );
218
- leEditFormInitCode->setText ( editFormInitCode );
219
212
leEditFormInitUseCode->setChecked ( editFormInitUseCode );
213
+ // Show or hide as needed
214
+ mPythonInitCodeGroupBox ->setVisible ( editFormInitUseCode );
220
215
}
221
216
222
217
@@ -458,7 +453,7 @@ void QgsFieldsProperties::on_mMoveUpItem_clicked()
458
453
}
459
454
}
460
455
461
- void QgsFieldsProperties::on_leEditFormInitUseCodeToggled ( bool checked )
456
+ void QgsFieldsProperties::on_leEditFormInitUseCode_toggled ( bool checked )
462
457
{
463
458
mPythonInitCodeGroupBox ->setVisible ( checked );
464
459
}
0 commit comments