@@ -11,22 +11,22 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
11
11
if ( !layer )
12
12
return ;
13
13
14
- setupUi (this );
14
+ setupUi ( this );
15
15
16
16
// drag tree (not mixup with drag queen)
17
17
QGridLayout *mDragListWidgetLayout = new QGridLayout;
18
18
mDragTree = new DnDTree ( mLayer , mDragListWidget );
19
19
mDragListWidgetLayout ->addWidget ( mDragTree );
20
- mDragListWidget ->setLayout (mDragListWidgetLayout );
20
+ mDragListWidget ->setLayout ( mDragListWidgetLayout );
21
21
mDragTree ->setHeaderLabels ( QStringList () << tr ( " Label" ) );
22
22
mDragTree ->type = DnDTree::Type::Drag;
23
23
24
24
// drop tree
25
25
QGridLayout *mDropListWidgetLayout = new QGridLayout;
26
26
mDropTree = new DnDTree ( mLayer , mDropListWidget );
27
27
mDropListWidgetLayout ->addWidget ( mDropTree );
28
- mDropListWidgetLayout ->setMargin (0 );
29
- mDropListWidget ->setLayout (mDropListWidgetLayout );
28
+ mDropListWidgetLayout ->setMargin ( 0 );
29
+ mDropListWidget ->setLayout ( mDropListWidgetLayout );
30
30
mDropTree ->setHeaderLabels ( QStringList () << tr ( " Label" ) );
31
31
mDropTree ->type = DnDTree::Type::Drop;
32
32
@@ -51,8 +51,8 @@ QgsAttributesFormProperties::~QgsAttributesFormProperties()
51
51
52
52
void QgsAttributesFormProperties::init ()
53
53
{
54
- loadAttributeEditorTree (mDragTree );
55
- loadAttributeEditorTree (mDropTree );
54
+ loadAttributeEditorTree ( mDragTree );
55
+ loadAttributeEditorTree ( mDropTree );
56
56
loadAttributeTypeDialog ();
57
57
}
58
58
@@ -63,27 +63,27 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
63
63
64
64
FieldConfig cfg;
65
65
66
- int index = mDragTree ->mIndexedWidgets .indexOf (mDragTree ->currentItem ());
66
+ int index = mDragTree ->mIndexedWidgets .indexOf ( mDragTree ->currentItem () );
67
67
68
- if ( index < 0 ) index = 0 ;
68
+ if ( index < 0 ) index = 0 ;
69
69
70
70
Q_FOREACH ( QTreeWidgetItem *wdg, mDragTree ->mIndexedWidgets )
71
71
{
72
- if ( mDragTree ->invisibleRootItem ()->indexOfChild (wdg) == index )
72
+ if ( mDragTree ->invisibleRootItem ()->indexOfChild ( wdg ) == index )
73
73
{
74
- cfg = wdg->data (0 , FieldConfigRole ).value <FieldConfig>();
74
+ cfg = wdg->data ( 0 , FieldConfigRole ).value <FieldConfig>();
75
75
}
76
76
}
77
77
78
78
// AttributeTypeDialog
79
79
80
- mAttributeTypeFrame ->layout ()->removeWidget (mAttributeTypeDialog );
80
+ mAttributeTypeFrame ->layout ()->removeWidget ( mAttributeTypeDialog );
81
81
delete mAttributeTypeDialog ;
82
82
83
83
//
84
84
mAttributeTypeDialog = new QgsAttributeTypeDialog ( mLayer , index , mAttributeTypeFrame );
85
85
86
- mAttributeTypeDialog ->setFieldEditable ( cfg.mEditable );
86
+ mAttributeTypeDialog ->setFieldEditable ( cfg.mEditable );
87
87
mAttributeTypeDialog ->setLabelOnTop ( cfg.mLabelOnTop );
88
88
mAttributeTypeDialog ->setNotNull ( cfg.mConstraints & QgsFieldConstraints::ConstraintNotNull );
89
89
mAttributeTypeDialog ->setNotNullEnforced ( cfg.mConstraintStrength .value ( QgsFieldConstraints::ConstraintNotNull, QgsFieldConstraints::ConstraintStrengthHard ) == QgsFieldConstraints::ConstraintStrengthHard );
@@ -112,7 +112,7 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
112
112
mAttributeTypeFrame ->setLayout ( new QVBoxLayout ( mAttributeTypeFrame ) );
113
113
mAttributeTypeFrame ->layout ()->setMargin ( 0 );
114
114
115
- mAttributeTypeFrame ->layout ()->addWidget (mAttributeTypeDialog );
115
+ mAttributeTypeFrame ->layout ()->addWidget ( mAttributeTypeDialog );
116
116
}
117
117
118
118
@@ -148,7 +148,7 @@ void QgsAttributesFormProperties::storeAttributeTypeDialog()
148
148
149
149
cfg.mConstraintDescription = mAttributeTypeDialog ->constraintExpressionDescription ();
150
150
cfg.mConstraint = mAttributeTypeDialog ->constraintExpression ();
151
- mLayer ->setDefaultValueExpression ( mAttributeTypeDialog ->fieldIdx () , mAttributeTypeDialog ->defaultValueExpression () );
151
+ mLayer ->setDefaultValueExpression ( mAttributeTypeDialog ->fieldIdx (), mAttributeTypeDialog ->defaultValueExpression () );
152
152
153
153
cfg.mEditorWidgetType = mAttributeTypeDialog ->editorWidgetType ();
154
154
cfg.mEditorWidgetConfig = mAttributeTypeDialog ->editorWidgetConfig ();
@@ -162,9 +162,9 @@ void QgsAttributesFormProperties::storeAttributeTypeDialog()
162
162
163
163
Q_FOREACH ( QTreeWidgetItem *wdg, mDragTree ->mIndexedWidgets )
164
164
{
165
- if ( mDragTree ->invisibleRootItem ()->indexOfChild (wdg) == mAttributeTypeDialog ->fieldIdx () )
165
+ if ( mDragTree ->invisibleRootItem ()->indexOfChild ( wdg ) == mAttributeTypeDialog ->fieldIdx () )
166
166
{
167
- wdg->setData (0 , FieldConfigRole, QVariant::fromValue<FieldConfig>( cfg ) );
167
+ wdg->setData ( 0 , FieldConfigRole, QVariant::fromValue<FieldConfig>( cfg ) );
168
168
}
169
169
}
170
170
}
@@ -173,7 +173,7 @@ QgsAttributesFormProperties::FieldConfig QgsAttributesFormProperties::configForC
173
173
{
174
174
Q_FOREACH ( QTreeWidgetItem *wdg, mDragTree ->mIndexedWidgets )
175
175
{
176
- if ( mDragTree ->invisibleRootItem ()->indexOfChild (wdg) == index )
176
+ if ( mDragTree ->invisibleRootItem ()->indexOfChild ( wdg ) == index )
177
177
{
178
178
return wdg->data ( 0 , FieldConfigRole ).value <FieldConfig>();
179
179
}
@@ -185,7 +185,7 @@ QgsAttributesFormProperties::FieldConfig QgsAttributesFormProperties::configForC
185
185
}
186
186
187
187
188
- QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem ( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree* mTree )
188
+ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem ( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree * mTree )
189
189
{
190
190
QTreeWidgetItem *newWidget = nullptr ;
191
191
switch ( widgetDef->type () )
@@ -242,9 +242,10 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
242
242
243
243
244
244
245
- void QgsAttributesFormProperties::loadAttributeEditorTree (DnDTree* mTree )
245
+ void QgsAttributesFormProperties::loadAttributeEditorTree ( DnDTree * mTree )
246
246
{
247
- if ( mTree ->type ==DnDTree::Type::Drop ){
247
+ if ( mTree ->type == DnDTree::Type::Drop )
248
+ {
248
249
// tabs and groups info
249
250
mTree ->clear ();
250
251
mTree ->setSortingEnabled ( false );
@@ -255,10 +256,12 @@ void QgsAttributesFormProperties::loadAttributeEditorTree(DnDTree* mTree)
255
256
256
257
Q_FOREACH ( QgsAttributeEditorElement *wdg, mLayer ->editFormConfig ().tabs () )
257
258
{
258
- loadAttributeEditorTreeItem ( wdg, mTree ->invisibleRootItem (), mTree );
259
+ loadAttributeEditorTreeItem ( wdg, mTree ->invisibleRootItem (), mTree );
259
260
}
260
261
261
- }else {
262
+ }
263
+ else
264
+ {
262
265
mTree ->clear ();
263
266
mTree ->setSortingEnabled ( false );
264
267
mTree ->setSelectionBehavior ( QAbstractItemView::SelectRows );
@@ -269,14 +272,16 @@ void QgsAttributesFormProperties::loadAttributeEditorTree(DnDTree* mTree)
269
272
mTree ->mIndexedWidgets .clear ();
270
273
271
274
const QgsFields &fields = mLayer ->fields ();
272
- for ( int i = 0 ; i < fields.count (); ++i ){
273
- DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Field, fields.at ( i ).name ());
275
+ for ( int i = 0 ; i < fields.size (); ++i )
276
+ {
277
+ DnDTreeItemData itemData = DnDTreeItemData ( DnDTreeItemData::Field, fields.at ( i ).name () );
274
278
itemData.setShowLabel ( true );
275
279
276
280
FieldConfig cfg ( mLayer , i );
277
281
QgsGui::editorWidgetRegistry ()->name ( cfg.mEditorWidgetType );
278
282
279
- itemData.setData (0 , FieldConfigRole, QVariant::fromValue<FieldConfig>( cfg ) );
283
+
284
+ itemData.setData ( 0 , FieldConfigRole, QVariant::fromValue<FieldConfig>( cfg ) );
280
285
281
286
mTree ->mIndexedWidgets .insert ( i, mTree ->addItem ( mTree ->invisibleRootItem (), itemData ) );
282
287
}
@@ -401,7 +406,7 @@ void QgsAttributesFormProperties::apply()
401
406
402
407
for ( QTreeWidgetItemIterator it ( mDragTree ); *it; ++it )
403
408
{
404
- int idx = mDragTree ->invisibleRootItem ()->indexOfChild (( *it) );
409
+ int idx = mDragTree ->invisibleRootItem ()->indexOfChild ( ( *it ) );
405
410
QString name = mLayer ->fields ().at ( idx ).name ();
406
411
FieldConfig cfg = configForChild ( idx );
407
412
0 commit comments