From c5652a52e252d97a77ffd66caca5a0ed58ccf58f Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Thu, 2 Oct 2014 17:38:18 +0200 Subject: [PATCH] [fix #11300] make edit form non modal on feature creation too --- src/app/qgsfeatureaction.cpp | 12 ++++++++++-- src/app/qgsfeatureaction.h | 4 ++-- src/app/qgsmaptooladdfeature.cpp | 10 +++++----- src/app/qgsmaptooladdfeature.h | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/app/qgsfeatureaction.cpp b/src/app/qgsfeatureaction.cpp index b8fb17af38a..2968189b28a 100644 --- a/src/app/qgsfeatureaction.cpp +++ b/src/app/qgsfeatureaction.cpp @@ -128,7 +128,7 @@ bool QgsFeatureAction::editFeature( bool showModal ) return true; } -bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes ) +bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes, bool showModal ) { if ( !mLayer || !mLayer->isEditable() ) return false; @@ -194,7 +194,15 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes ) connect( dialog->attributeForm(), SIGNAL( featureSaved( QgsFeature ) ), this, SLOT( onFeatureSaved( QgsFeature ) ) ); - dialog->exec(); + if ( showModal ) + { + dialog->exec(); + } + else + { + dialog->show(); + return true; + } } // Will be set in the onFeatureSaved SLOT diff --git a/src/app/qgsfeatureaction.h b/src/app/qgsfeatureaction.h index e8363736ad0..348b09b1550 100644 --- a/src/app/qgsfeatureaction.h +++ b/src/app/qgsfeatureaction.h @@ -48,9 +48,9 @@ class APP_EXPORT QgsFeatureAction : public QAction * * @param defaultAttributes Provide some default attributes here if desired. * - * @return true if feature was added + * @return true if feature was added if showModal is true. If showModal is false, returns true in every case */ - bool addFeature( const QgsAttributeMap& defaultAttributes = QgsAttributeMap() ); + bool addFeature(const QgsAttributeMap& defaultAttributes = QgsAttributeMap() , bool showModal = true ); private slots: void onFeatureSaved( const QgsFeature& feature ); diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index c1ad192cef0..bfbbab1a5ca 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -38,10 +38,10 @@ QgsMapToolAddFeature::~QgsMapToolAddFeature() { } -bool QgsMapToolAddFeature::addFeature( QgsVectorLayer *vlayer, QgsFeature *f ) +bool QgsMapToolAddFeature::addFeature(QgsVectorLayer *vlayer, QgsFeature *f, bool showModal ) { QgsFeatureAction action( tr( "add feature" ), *f, vlayer, -1, -1, this ); - return action.addFeature(); + return action.addFeature( QgsAttributeMap(), showModal ); } void QgsMapToolAddFeature::activate() @@ -50,7 +50,7 @@ void QgsMapToolAddFeature::activate() if ( vlayer && vlayer->geometryType() == QGis::NoGeometry ) { QgsFeature f; - addFeature( vlayer, &f ); + addFeature( vlayer, &f, false ); return; } @@ -138,7 +138,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) f.setGeometry( g ); - addFeature( vlayer, &f ); + addFeature( vlayer, &f, false ); mCanvas->refresh(); } @@ -285,7 +285,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) } } - if ( addFeature( vlayer, f ) ) + if ( addFeature( vlayer, f, false ) ) { //add points to other features to keep topology up-to-date int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); diff --git a/src/app/qgsmaptooladdfeature.h b/src/app/qgsmaptooladdfeature.h index cc778c4c1e4..156cec9c49f 100644 --- a/src/app/qgsmaptooladdfeature.h +++ b/src/app/qgsmaptooladdfeature.h @@ -25,6 +25,6 @@ class APP_EXPORT QgsMapToolAddFeature : public QgsMapToolCapture virtual ~QgsMapToolAddFeature(); void canvasReleaseEvent( QMouseEvent * e ); - bool addFeature( QgsVectorLayer *vlayer, QgsFeature *f ); + bool addFeature(QgsVectorLayer *vlayer, QgsFeature *f , bool showModal = true ); void activate(); };