Skip to content

Commit 3b6d4ef

Browse files
committed
[FEATURE] Add 'Suppress attribute form pop-up after feature creation' option to vector layers; overrides application-wide option
1 parent 9ebf1fe commit 3b6d4ef

6 files changed

+192
-88
lines changed

src/app/qgsfeatureaction.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
qgsfeatureaction.cpp - description
33
-------------------
44
begin : 2010-09-20
5-
copyright : (C) 2010 by Jürgen E. Fischer
5+
copyright : (C) 2010 by Juergen E. Fischer
66
email : jef at norbit dot de
77
***************************************************************************/
88

@@ -171,6 +171,18 @@ bool QgsFeatureAction::addFeature()
171171

172172
// show the dialog to enter attribute values
173173
bool isDisabledAttributeValuesDlg = settings.value( "/qgis/digitizing/disable_enter_attribute_values_dialog", false ).toBool();
174+
// override application-wide setting with any layer setting
175+
switch ( mLayer->featureFormSuppress() )
176+
{
177+
case QgsVectorLayer::SuppressOn:
178+
isDisabledAttributeValuesDlg = true;
179+
break;
180+
case QgsVectorLayer::SuppressOff:
181+
isDisabledAttributeValuesDlg = false;
182+
break;
183+
case QgsVectorLayer::SuppressDefault:
184+
break;
185+
}
174186
if ( isDisabledAttributeValuesDlg )
175187
{
176188
res = mLayer->addFeature( mFeature );

src/app/qgsfieldsproperties.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ void QgsFieldsProperties::init()
219219
loadRows();
220220

221221
mEditorLayoutComboBox->setCurrentIndex( mLayer->editorLayout() );
222+
mFormSuppressCmbBx->setCurrentIndex( mLayer->featureFormSuppress() );
222223

223224
loadAttributeEditorTree();
224225
}
@@ -918,6 +919,7 @@ void QgsFieldsProperties::apply()
918919
mLayer->setEditorLayout(( QgsVectorLayer::EditorLayout )mEditorLayoutComboBox->currentIndex() );
919920
mLayer->setEditForm( leEditForm->text() );
920921
mLayer->setEditFormInit( leEditFormInit->text() );
922+
mLayer->setFeatureFormSuppress(( QgsVectorLayer::FeatureFormSuppress )mFormSuppressCmbBx->currentIndex() );
921923

922924
mLayer->setExcludeAttributesWMS( excludeAttributesWMS );
923925
mLayer->setExcludeAttributesWFS( excludeAttributesWFS );

src/core/qgsvectorlayer.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
125125
, mFeatureBlendMode( QPainter::CompositionMode_SourceOver ) // Default to normal feature blending
126126
, mLayerTransparency( 0 )
127127
, mVertexMarkerOnlyForSelection( false )
128+
, mFeatureFormSuppress( SuppressDefault )
128129
, mCache( new QgsGeometryCache( this ) )
129130
, mEditBuffer( 0 )
130131
, mJoinBuffer( 0 )
@@ -1982,6 +1983,17 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
19821983
mEditFormInit = editFormInitNode.toElement().text();
19831984
}
19841985

1986+
QDomNode fFSuppNode = node.namedItem( "featformsuppress" );
1987+
if ( fFSuppNode.isNull() )
1988+
{
1989+
mFeatureFormSuppress = SuppressDefault;
1990+
}
1991+
else
1992+
{
1993+
QDomElement e = fFSuppNode.toElement();
1994+
mFeatureFormSuppress = ( QgsVectorLayer::FeatureFormSuppress )e.text().toInt();
1995+
}
1996+
19851997
QDomNode annotationFormNode = node.namedItem( "annotationform" );
19861998
if ( !annotationFormNode.isNull() )
19871999
{
@@ -2290,6 +2302,11 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
22902302
efiField.appendChild( efiText );
22912303
node.appendChild( efiField );
22922304

2305+
QDomElement fFSuppElem = doc.createElement( "featformsuppress" );
2306+
QDomText fFSuppText = doc.createTextNode( QString::number( featureFormSuppress() ) );
2307+
fFSuppElem.appendChild( fFSuppText );
2308+
node.appendChild( fFSuppElem );
2309+
22932310
QDomElement afField = doc.createElement( "annotationform" );
22942311
QDomText afText = doc.createTextNode( QgsProject::instance()->writePath( mAnnotationForm ) );
22952312
afField.appendChild( afText );

src/core/qgsvectorlayer.h

+22
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,15 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
446446
Color, /**< color @note added in 1.9 */
447447
};
448448

449+
/** Types of feature form suppression after feature creation
450+
* @note added in 2.1 */
451+
enum FeatureFormSuppress
452+
{
453+
SuppressDefault = 0, // use the application-wide setting
454+
SuppressOn = 1,
455+
SuppressOff = 2
456+
};
457+
449458
struct RangeData
450459
{
451460
RangeData() {}
@@ -1112,6 +1121,14 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
11121121
/** set edit form (added in 1.4) */
11131122
void setEditForm( QString ui );
11141123

1124+
/** Type of feature form pop-up suppression after feature creation (overrides app setting)
1125+
* @note added in 2.1 */
1126+
QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const { return mFeatureFormSuppress; }
1127+
1128+
/** Set type of feature form pop-up suppression after feature creation (overrides app setting)
1129+
* @note added in 2.1 */
1130+
void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) { mFeatureFormSuppress = s; }
1131+
11151132
/** get annotation form (added in 1.5)*/
11161133
QString annotationForm() const { return mAnnotationForm; }
11171134

@@ -1539,6 +1556,11 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
15391556
EditorLayout mEditorLayout;
15401557

15411558
QString mEditForm, mEditFormInit;
1559+
1560+
/** Type of feature form suppression after feature creation
1561+
* @note added in 2.1 */
1562+
QgsVectorLayer::FeatureFormSuppress mFeatureFormSuppress;
1563+
15421564
//annotation form for this layer
15431565
QString mAnnotationForm;
15441566

src/ui/qgsfieldspropertiesbase.ui

+137-86
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,45 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>782</width>
10-
<height>663</height>
9+
<width>871</width>
10+
<height>712</height>
1111
</rect>
1212
</property>
1313
<layout class="QGridLayout" name="gridLayout_6">
14+
<item row="1" column="5">
15+
<widget class="QLabel" name="label_3">
16+
<property name="toolTip">
17+
<string>QGIS forms can have a Python function that is called when the form is opened.
18+
Use this function to add extra logic to your forms.
19+
20+
An example is (in module MyForms.py):
21+
22+
def open(dialog, layer, feature):
23+
geom = feature.geometry()
24+
control = dialog.findChild(QWidget,&quot;MyLineEdit&quot;)
25+
26+
Reference in Python Init Function like so: MyForms.open
27+
28+
MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.</string>
29+
</property>
30+
<property name="text">
31+
<string>Python Init function</string>
32+
</property>
33+
</widget>
34+
</item>
35+
<item row="0" column="4">
36+
<spacer>
37+
<property name="orientation">
38+
<enum>Qt::Horizontal</enum>
39+
</property>
40+
<property name="sizeHint" stdset="0">
41+
<size>
42+
<width>100</width>
43+
<height>19</height>
44+
</size>
45+
</property>
46+
</spacer>
47+
</item>
1448
<item row="0" column="0">
1549
<widget class="QToolButton" name="mAddAttributeButton">
1650
<property name="sizePolicy">
@@ -34,52 +68,32 @@
3468
</property>
3569
</widget>
3670
</item>
37-
<item row="0" column="3">
38-
<widget class="QToolButton" name="mCalculateFieldButton">
39-
<property name="toolTip">
40-
<string>Field calculator</string>
41-
</property>
42-
<property name="whatsThis">
43-
<string>Click to toggle table editing</string>
44-
</property>
71+
<item row="1" column="6">
72+
<widget class="QLineEdit" name="leEditFormInit"/>
73+
</item>
74+
<item row="0" column="5">
75+
<widget class="QLabel" name="label_2">
4576
<property name="text">
46-
<string/>
47-
</property>
48-
<property name="checkable">
49-
<bool>false</bool>
77+
<string>Attribute editor layout:</string>
5078
</property>
5179
</widget>
5280
</item>
53-
<item row="0" column="1">
54-
<widget class="QToolButton" name="mDeleteAttributeButton">
81+
<item row="0" column="2">
82+
<widget class="QToolButton" name="mToggleEditingButton">
5583
<property name="toolTip">
56-
<string>Delete column</string>
84+
<string>Toggle editing mode</string>
85+
</property>
86+
<property name="whatsThis">
87+
<string>Click to toggle table editing</string>
5788
</property>
5889
<property name="text">
5990
<string/>
6091
</property>
61-
<property name="icon">
62-
<iconset>
63-
<normaloff>.designer/xpm/delete_attribute.png</normaloff>.designer/xpm/delete_attribute.png</iconset>
64-
</property>
65-
<property name="shortcut">
66-
<string>Ctrl+X</string>
92+
<property name="checkable">
93+
<bool>true</bool>
6794
</property>
6895
</widget>
6996
</item>
70-
<item row="0" column="4">
71-
<spacer>
72-
<property name="orientation">
73-
<enum>Qt::Horizontal</enum>
74-
</property>
75-
<property name="sizeHint" stdset="0">
76-
<size>
77-
<width>100</width>
78-
<height>19</height>
79-
</size>
80-
</property>
81-
</spacer>
82-
</item>
8397
<item row="0" column="6">
8498
<widget class="QComboBox" name="mEditorLayoutComboBox">
8599
<property name="sizePolicy">
@@ -105,53 +119,6 @@
105119
</item>
106120
</widget>
107121
</item>
108-
<item row="1" column="5">
109-
<widget class="QLabel" name="label_3">
110-
<property name="toolTip">
111-
<string>QGIS forms can have a Python function that is called when the form is opened.
112-
Use this function to add extra logic to your forms.
113-
114-
An example is (in module MyForms.py):
115-
116-
def open(dialog, layer, feature):
117-
geom = feature.geometry()
118-
control = dialog.findChild(QWidget,&quot;MyLineEdit&quot;)
119-
120-
Reference in Python Init Function like so: MyForms.open
121-
122-
MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.</string>
123-
</property>
124-
<property name="text">
125-
<string>Python Init function</string>
126-
</property>
127-
</widget>
128-
</item>
129-
<item row="0" column="2">
130-
<widget class="QToolButton" name="mToggleEditingButton">
131-
<property name="toolTip">
132-
<string>Toggle editing mode</string>
133-
</property>
134-
<property name="whatsThis">
135-
<string>Click to toggle table editing</string>
136-
</property>
137-
<property name="text">
138-
<string/>
139-
</property>
140-
<property name="checkable">
141-
<bool>true</bool>
142-
</property>
143-
</widget>
144-
</item>
145-
<item row="1" column="6">
146-
<widget class="QLineEdit" name="leEditFormInit"/>
147-
</item>
148-
<item row="0" column="5">
149-
<widget class="QLabel" name="label_2">
150-
<property name="text">
151-
<string>Attribute editor layout:</string>
152-
</property>
153-
</widget>
154-
</item>
155122
<item row="2" column="0" colspan="7">
156123
<widget class="QSplitter" name="mSplitter">
157124
<property name="orientation">
@@ -230,9 +197,6 @@ MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.<
230197
</size>
231198
</property>
232199
<layout class="QVBoxLayout" name="verticalLayout">
233-
<property name="spacing">
234-
<number>6</number>
235-
</property>
236200
<property name="margin">
237201
<number>0</number>
238202
</property>
@@ -342,6 +306,93 @@ MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.<
342306
</widget>
343307
</widget>
344308
</item>
309+
<item row="0" column="3">
310+
<widget class="QToolButton" name="mCalculateFieldButton">
311+
<property name="toolTip">
312+
<string>Field calculator</string>
313+
</property>
314+
<property name="whatsThis">
315+
<string>Click to toggle table editing</string>
316+
</property>
317+
<property name="text">
318+
<string/>
319+
</property>
320+
<property name="checkable">
321+
<bool>false</bool>
322+
</property>
323+
</widget>
324+
</item>
325+
<item row="0" column="1">
326+
<widget class="QToolButton" name="mDeleteAttributeButton">
327+
<property name="toolTip">
328+
<string>Delete column</string>
329+
</property>
330+
<property name="text">
331+
<string/>
332+
</property>
333+
<property name="icon">
334+
<iconset>
335+
<normaloff>.designer/xpm/delete_attribute.png</normaloff>.designer/xpm/delete_attribute.png</iconset>
336+
</property>
337+
<property name="shortcut">
338+
<string>Ctrl+X</string>
339+
</property>
340+
</widget>
341+
</item>
342+
<item row="3" column="0" colspan="7">
343+
<layout class="QHBoxLayout" name="horizontalLayout">
344+
<item>
345+
<widget class="QLabel" name="mFormSuppressLabel">
346+
<property name="sizePolicy">
347+
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
348+
<horstretch>0</horstretch>
349+
<verstretch>0</verstretch>
350+
</sizepolicy>
351+
</property>
352+
<property name="minimumSize">
353+
<size>
354+
<width>150</width>
355+
<height>0</height>
356+
</size>
357+
</property>
358+
<property name="text">
359+
<string>Suppress attribute form pop-up after feature creation</string>
360+
</property>
361+
<property name="alignment">
362+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
363+
</property>
364+
<property name="wordWrap">
365+
<bool>true</bool>
366+
</property>
367+
</widget>
368+
</item>
369+
<item>
370+
<widget class="QComboBox" name="mFormSuppressCmbBx">
371+
<property name="sizePolicy">
372+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
373+
<horstretch>0</horstretch>
374+
<verstretch>0</verstretch>
375+
</sizepolicy>
376+
</property>
377+
<item>
378+
<property name="text">
379+
<string>Default</string>
380+
</property>
381+
</item>
382+
<item>
383+
<property name="text">
384+
<string>On</string>
385+
</property>
386+
</item>
387+
<item>
388+
<property name="text">
389+
<string>Off</string>
390+
</property>
391+
</item>
392+
</widget>
393+
</item>
394+
</layout>
395+
</item>
345396
</layout>
346397
</widget>
347398
<resources>

0 commit comments

Comments
 (0)