Skip to content

Commit c8495ea

Browse files
committedSep 20, 2017
work in progress status
1 parent 8f895f6 commit c8495ea

9 files changed

+527
-189
lines changed
 

‎src/app/qgsattributesformproperties.cpp

Lines changed: 358 additions & 135 deletions
Large diffs are not rendered by default.

‎src/app/qgsattributesformproperties.h

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@
4141
#include "qgsfieldcalculator.h"
4242
#include "qgsfieldexpressionwidget.h"
4343
#include "qgsaddtaborgroup.h"
44+
#include "qgsattributetypedialog.h"
45+
#include "qgsgui.h"
46+
#include "qgseditorwidgetfactory.h"
47+
#include "qgseditorwidgetregistry.h"
4448

4549
class DnDTree;
4650

4751
class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAttributesFormProperties
4852
{
4953
Q_OBJECT
54+
5055
public:
56+
5157
enum FieldPropertiesRoles
5258
{
5359
DnDTreeRole = Qt::UserRole,
@@ -64,7 +70,7 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
6470
bool showUnlinkButton;
6571
};
6672

67-
class DnDTreeItemData
73+
class DnDTreeItemData : public QTreeWidgetItem
6874
{
6975
public:
7076
enum Type
@@ -74,6 +80,7 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
7480
Container
7581
};
7682

83+
//dave: do we need that
7784
DnDTreeItemData()
7885
: mType( Field )
7986
, mColumnCount( 1 )
@@ -122,30 +129,68 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
122129
RelationEditorConfiguration mRelationEditorConfiguration;
123130
};
124131

132+
133+
/**
134+
* Holds the configuration for a field
135+
*/
136+
class FieldConfig
137+
{
138+
public:
139+
FieldConfig();
140+
FieldConfig( QgsVectorLayer *layer, int idx );
141+
142+
bool mEditable;
143+
bool mEditableEnabled;
144+
bool mLabelOnTop;
145+
QgsFieldConstraints::Constraints mConstraints;
146+
QHash< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength > mConstraintStrength;
147+
QString mConstraint;
148+
QString mConstraintDescription;
149+
QPushButton *mButton = nullptr;
150+
QString mEditorWidgetType;
151+
QMap<QString, QVariant> mEditorWidgetConfig;
152+
};
153+
125154
public:
126155
explicit QgsAttributesFormProperties( QgsVectorLayer *layer, QWidget *parent = nullptr );
127156
~QgsAttributesFormProperties();
128157

158+
QgsAttributeEditorElement *createAttributeEditorWidget( QTreeWidgetItem *item, QgsAttributeEditorElement *parent, bool forceGroup = true );
159+
129160
void init();
130161
void apply();
162+
131163
void onAttributeSelectionChanged();
132164

165+
void loadRelations();
166+
133167
void loadAttributeEditorTree( DnDTree *mTree );
134168
QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement *const widgetDef, QTreeWidgetItem *parent, DnDTree* mTree);
135169

136170
protected:
171+
void updateButtons();
172+
173+
FieldConfig configForChild( int index );
174+
void setConfigForChild( int index, const FieldConfig &cfg );
175+
176+
//QList<QgsRelation> mRelations;
137177
QgsVectorLayer *mLayer = nullptr;
138178

139179
DnDTree *mDragTree = nullptr;
140180
DnDTree *mDropTree = nullptr;
141181

182+
QgsAttributeTypeDialog *mAttributeTypeDialog = nullptr;
183+
184+
142185
private:
143186

144187
signals:
145188

146189
private slots:
147190
void addTabOrGroupButton();
148191
void removeTabOrGroupButton();
192+
void loadAttributeTypeDialog( );
193+
void storeAttributeTypeDialog( );
149194
};
150195

151196

@@ -179,6 +224,7 @@ class DnDTree : public QTreeWidget
179224

180225
Type type;
181226

227+
QList<QTreeWidgetItem *> mIndexedWidgets;
182228
protected:
183229
virtual void dragMoveEvent( QDragMoveEvent *event ) override;
184230
virtual void dropEvent( QDropEvent *event ) override;
@@ -190,15 +236,16 @@ class DnDTree : public QTreeWidget
190236
virtual QStringList mimeTypes() const override;
191237
virtual QMimeData *mimeData( const QList<QTreeWidgetItem *> items ) const override;
192238

239+
193240
private slots:
194241
void onItemDoubleClicked( QTreeWidgetItem *item, int column );
195-
void attributeTypeDialog();
196242

197243
private:
198244
QgsVectorLayer *mLayer = nullptr;
199245
};
200246

201247

248+
Q_DECLARE_METATYPE( QgsAttributesFormProperties::FieldConfig )
202249
Q_DECLARE_METATYPE( QgsAttributesFormProperties::DnDTreeItemData )
203250

204251
#endif // QGSATTRIBUTESFORMPROPERTIES_H

‎src/app/qgsattributetypedialog.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
#include <climits>
4040
#include <cfloat>
4141

42-
QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx )
43-
: QDialog()
42+
QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx, QWidget *parent )
43+
: QWidget( parent )
4444
, mLayer( vl )
4545
, mFieldIdx( fieldIdx )
4646
{
@@ -295,6 +295,12 @@ void QgsAttributeTypeDialog::setDefaultValueExpression( const QString &expressio
295295
mExpressionWidget->setExpression( expression );
296296
}
297297

298+
int QgsAttributeTypeDialog::fieldIdx() const
299+
{
300+
return mFieldIdx;
301+
}
302+
303+
298304
QgsExpressionContext QgsAttributeTypeDialog::createExpressionContext() const
299305
{
300306
QgsExpressionContext context;

‎src/app/qgsattributetypedialog.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
#include "qgsvectordataprovider.h"
2525
#include "qgis_app.h"
2626

27-
class QDialog;
27+
class QWidget;
2828

29-
class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog, QgsExpressionContextGenerator
29+
class APP_EXPORT QgsAttributeTypeDialog: public QWidget, private Ui::QgsAttributeTypeDialog, QgsExpressionContextGenerator
3030
{
3131
Q_OBJECT
3232

3333
public:
34-
QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx );
34+
QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx, QWidget *parent = nullptr );
3535
~QgsAttributeTypeDialog();
3636

3737
/**
@@ -163,6 +163,11 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut
163163
*/
164164
void setDefaultValueExpression( const QString &expression );
165165

166+
/**
167+
* Returns the field id
168+
*/
169+
int fieldIdx() const;
170+
166171
QgsExpressionContext createExpressionContext() const override;
167172

168173
private slots:

‎src/app/qgsfieldsproperties.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ void QgsFieldsProperties::attributeTypeDialog()
581581
attributeTypeDialog.setEditorWidgetConfig( cfg.mEditorWidgetConfig );
582582
attributeTypeDialog.setEditorWidgetType( cfg.mEditorWidgetType );
583583

584-
if ( !attributeTypeDialog.exec() )
585-
return;
584+
//if ( !attributeTypeDialog.exec() )
585+
// return;
586586

587587
cfg.mEditable = attributeTypeDialog.fieldEditable();
588588
cfg.mLabelOnTop = attributeTypeDialog.labelOnTop();
@@ -1074,6 +1074,7 @@ void QgsFieldsProperties::apply()
10741074
}
10751075

10761076
mLayer->setEditFormConfig( editFormConfig );
1077+
10771078
}
10781079
/*
10791080
* FieldConfig implementation

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
9292
, diagramPropertiesDialog( nullptr )
9393
, mFieldsPropertiesDialog( nullptr )
9494
, mSourceFieldsPropertiesDialog( nullptr )
95+
, mAttributesFormPropertiesDialog( nullptr )
9596
{
9697
setupUi( this );
9798
// QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
@@ -213,7 +214,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
213214
//QgisApp::instance(), [ = ]( QgsMapLayer * layer ) { QgisApp::instance()->toggleEditing( layer ); } );
214215

215216
mAttributesFormPropertiesDialog = new QgsAttributesFormProperties( mLayer, mAttributesFormFrame );
216-
//mAttributesFormPropertiesDialog->layout()->setMargin( 0 );
217+
mAttributesFormPropertiesDialog->layout()->setMargin( 0 );
217218
mAttributesFormFrame->setLayout( new QVBoxLayout( mAttributesFormFrame ) );
218219
mAttributesFormFrame->layout()->setMargin( 0 );
219220
mAttributesFormFrame->layout()->addWidget( mAttributesFormPropertiesDialog );
@@ -572,6 +573,8 @@ void QgsVectorLayerProperties::apply()
572573

573574
// Apply fields settings
574575
mFieldsPropertiesDialog->apply();
576+
// has to be done then mSourceFieldsPropertiesDialog->apply();
577+
mAttributesFormPropertiesDialog->apply();
575578

576579
if ( mLayer->renderer() )
577580
{

‎src/ui/qgsattributesformproperties.ui

Lines changed: 84 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,100 @@
1313
<property name="windowTitle">
1414
<string>Form</string>
1515
</property>
16-
<layout class="QVBoxLayout" name="verticalLayout">
17-
<item>
18-
<widget class="QToolButton" name="mRemoveTabOrGroupButton">
19-
<property name="text">
20-
<string>...</string>
21-
</property>
22-
<property name="icon">
23-
<iconset resource="../../images/images.qrc">
24-
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
25-
</property>
26-
</widget>
27-
</item>
28-
<item>
29-
<widget class="QToolButton" name="mAddTabOrGroupButton">
30-
<property name="text">
31-
<string>...</string>
32-
</property>
33-
<property name="icon">
34-
<iconset resource="../../images/images.qrc">
35-
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
36-
</property>
37-
</widget>
38-
</item>
39-
<item>
16+
<layout class="QGridLayout" name="gridLayout">
17+
<item row="0" column="0">
4018
<widget class="QSplitter" name="splitter">
4119
<property name="orientation">
4220
<enum>Qt::Horizontal</enum>
4321
</property>
4422
<widget class="QWidget" name="mDragListWidget" native="true"/>
45-
<widget class="QWidget" name="mDropListWidget" native="true"/>
46-
<widget class="QWidget" name="mOptionsWidget" native="true">
47-
<layout class="QGridLayout" name="gridLayout_2">
48-
<item row="0" column="0">
49-
<widget class="QLabel" name="Testlable">
50-
<property name="text">
51-
<string>Widget Properties</string>
23+
<widget class="QWidget" name="widget_2" native="true">
24+
<layout class="QVBoxLayout" name="verticalLayout">
25+
<property name="spacing">
26+
<number>0</number>
27+
</property>
28+
<property name="leftMargin">
29+
<number>6</number>
30+
</property>
31+
<property name="topMargin">
32+
<number>6</number>
33+
</property>
34+
<property name="rightMargin">
35+
<number>6</number>
36+
</property>
37+
<property name="bottomMargin">
38+
<number>6</number>
39+
</property>
40+
<item>
41+
<widget class="QWidget" name="widget" native="true">
42+
<property name="maximumSize">
43+
<size>
44+
<width>16777215</width>
45+
<height>40</height>
46+
</size>
5247
</property>
48+
<layout class="QHBoxLayout" name="horizontalLayout">
49+
<property name="spacing">
50+
<number>0</number>
51+
</property>
52+
<property name="leftMargin">
53+
<number>0</number>
54+
</property>
55+
<property name="topMargin">
56+
<number>0</number>
57+
</property>
58+
<property name="rightMargin">
59+
<number>0</number>
60+
</property>
61+
<property name="bottomMargin">
62+
<number>0</number>
63+
</property>
64+
<item>
65+
<widget class="QToolButton" name="mRemoveTabOrGroupButton">
66+
<property name="text">
67+
<string>...</string>
68+
</property>
69+
<property name="icon">
70+
<iconset resource="../../images/images.qrc">
71+
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
72+
</property>
73+
</widget>
74+
</item>
75+
<item>
76+
<widget class="QToolButton" name="mAddTabOrGroupButton">
77+
<property name="text">
78+
<string>...</string>
79+
</property>
80+
<property name="icon">
81+
<iconset resource="../../images/images.qrc">
82+
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
83+
</property>
84+
</widget>
85+
</item>
86+
<item>
87+
<spacer name="horizontalSpacer">
88+
<property name="orientation">
89+
<enum>Qt::Horizontal</enum>
90+
</property>
91+
<property name="sizeHint" stdset="0">
92+
<size>
93+
<width>40</width>
94+
<height>20</height>
95+
</size>
96+
</property>
97+
</spacer>
98+
</item>
99+
</layout>
53100
</widget>
54101
</item>
102+
<item>
103+
<widget class="QWidget" name="mDropListWidget" native="true"/>
104+
</item>
55105
</layout>
56106
</widget>
107+
<widget class="QWidget" name="mAttributeTypeFrame" native="true">
108+
<layout class="QGridLayout" name="gridLayout_2"/>
109+
</widget>
57110
</widget>
58111
</item>
59112
</layout>

‎src/ui/qgsattributetypeedit.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ui version="4.0">
33
<class>QgsAttributeTypeDialog</class>
4-
<widget class="QDialog" name="QgsAttributeTypeDialog">
4+
<widget class="QWidget" name="QgsAttributeTypeDialog">
55
<property name="geometry">
66
<rect>
77
<x>0</x>

‎src/ui/qgsvectorlayerpropertiesbase.ui

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
</sizepolicy>
328328
</property>
329329
<property name="currentIndex">
330-
<number>7</number>
330+
<number>6</number>
331331
</property>
332332
<widget class="QWidget" name="mOptsPage_Information">
333333
<layout class="QVBoxLayout" name="verticalLayout_5">
@@ -854,8 +854,8 @@ border-radius: 2px;</string>
854854
<rect>
855855
<x>0</x>
856856
<y>0</y>
857-
<width>302</width>
858-
<height>372</height>
857+
<width>662</width>
858+
<height>534</height>
859859
</rect>
860860
</property>
861861
<layout class="QVBoxLayout" name="verticalLayout_9">
@@ -1193,8 +1193,8 @@ border-radius: 2px;</string>
11931193
<rect>
11941194
<x>0</x>
11951195
<y>0</y>
1196-
<width>100</width>
1197-
<height>30</height>
1196+
<width>662</width>
1197+
<height>534</height>
11981198
</rect>
11991199
</property>
12001200
<layout class="QVBoxLayout" name="verticalLayout_20">
@@ -1320,7 +1320,7 @@ border-radius: 2px;</string>
13201320
<x>0</x>
13211321
<y>0</y>
13221322
<width>725</width>
1323-
<height>350</height>
1323+
<height>520</height>
13241324
</rect>
13251325
</property>
13261326
<layout class="QVBoxLayout" name="verticalLayout_32">
@@ -2072,18 +2072,18 @@ border-radius: 2px;</string>
20722072
<header>qgscollapsiblegroupbox.h</header>
20732073
<container>1</container>
20742074
</customwidget>
2075-
<customwidget>
2076-
<class>QgsScrollArea</class>
2077-
<extends>QScrollArea</extends>
2078-
<header>qgsscrollarea.h</header>
2079-
<container>1</container>
2080-
</customwidget>
20812075
<customwidget>
20822076
<class>QgsFieldExpressionWidget</class>
20832077
<extends>QWidget</extends>
20842078
<header>qgsfieldexpressionwidget.h</header>
20852079
<container>1</container>
20862080
</customwidget>
2081+
<customwidget>
2082+
<class>QgsScrollArea</class>
2083+
<extends>QScrollArea</extends>
2084+
<header>qgsscrollarea.h</header>
2085+
<container>1</container>
2086+
</customwidget>
20872087
<customwidget>
20882088
<class>QgsLayerTreeView</class>
20892089
<extends>QTreeView</extends>

0 commit comments

Comments
 (0)
Please sign in to comment.