Skip to content

Commit c5652a5

Browse files
committedOct 2, 2014
[fix #11300] make edit form non modal on feature creation too
1 parent 7225913 commit c5652a5

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed
 

‎src/app/qgsfeatureaction.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool QgsFeatureAction::editFeature( bool showModal )
128128
return true;
129129
}
130130

131-
bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes )
131+
bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes, bool showModal )
132132
{
133133
if ( !mLayer || !mLayer->isEditable() )
134134
return false;
@@ -194,7 +194,15 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes )
194194

195195
connect( dialog->attributeForm(), SIGNAL( featureSaved( QgsFeature ) ), this, SLOT( onFeatureSaved( QgsFeature ) ) );
196196

197-
dialog->exec();
197+
if ( showModal )
198+
{
199+
dialog->exec();
200+
}
201+
else
202+
{
203+
dialog->show();
204+
return true;
205+
}
198206
}
199207

200208
// Will be set in the onFeatureSaved SLOT

‎src/app/qgsfeatureaction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class APP_EXPORT QgsFeatureAction : public QAction
4848
*
4949
* @param defaultAttributes Provide some default attributes here if desired.
5050
*
51-
* @return true if feature was added
51+
* @return true if feature was added if showModal is true. If showModal is false, returns true in every case
5252
*/
53-
bool addFeature( const QgsAttributeMap& defaultAttributes = QgsAttributeMap() );
53+
bool addFeature(const QgsAttributeMap& defaultAttributes = QgsAttributeMap() , bool showModal = true );
5454

5555
private slots:
5656
void onFeatureSaved( const QgsFeature& feature );

‎src/app/qgsmaptooladdfeature.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ QgsMapToolAddFeature::~QgsMapToolAddFeature()
3838
{
3939
}
4040

41-
bool QgsMapToolAddFeature::addFeature( QgsVectorLayer *vlayer, QgsFeature *f )
41+
bool QgsMapToolAddFeature::addFeature(QgsVectorLayer *vlayer, QgsFeature *f, bool showModal )
4242
{
4343
QgsFeatureAction action( tr( "add feature" ), *f, vlayer, -1, -1, this );
44-
return action.addFeature();
44+
return action.addFeature( QgsAttributeMap(), showModal );
4545
}
4646

4747
void QgsMapToolAddFeature::activate()
@@ -50,7 +50,7 @@ void QgsMapToolAddFeature::activate()
5050
if ( vlayer && vlayer->geometryType() == QGis::NoGeometry )
5151
{
5252
QgsFeature f;
53-
addFeature( vlayer, &f );
53+
addFeature( vlayer, &f, false );
5454
return;
5555
}
5656

@@ -138,7 +138,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
138138

139139
f.setGeometry( g );
140140

141-
addFeature( vlayer, &f );
141+
addFeature( vlayer, &f, false );
142142

143143
mCanvas->refresh();
144144
}
@@ -285,7 +285,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
285285
}
286286
}
287287

288-
if ( addFeature( vlayer, f ) )
288+
if ( addFeature( vlayer, f, false ) )
289289
{
290290
//add points to other features to keep topology up-to-date
291291
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );

‎src/app/qgsmaptooladdfeature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ class APP_EXPORT QgsMapToolAddFeature : public QgsMapToolCapture
2525
virtual ~QgsMapToolAddFeature();
2626
void canvasReleaseEvent( QMouseEvent * e );
2727

28-
bool addFeature( QgsVectorLayer *vlayer, QgsFeature *f );
28+
bool addFeature(QgsVectorLayer *vlayer, QgsFeature *f , bool showModal = true );
2929
void activate();
3030
};

0 commit comments

Comments
 (0)
Please sign in to comment.