Skip to content
Permalink
Browse files

[fix #11300] make edit form non modal on feature creation too

  • Loading branch information
3nids committed Oct 2, 2014
1 parent 7225913 commit c5652a52e252d97a77ffd66caca5a0ed58ccf58f
Showing with 18 additions and 10 deletions.
  1. +10 −2 src/app/qgsfeatureaction.cpp
  2. +2 −2 src/app/qgsfeatureaction.h
  3. +5 −5 src/app/qgsmaptooladdfeature.cpp
  4. +1 −1 src/app/qgsmaptooladdfeature.h
@@ -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
@@ -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 );
@@ -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 );
@@ -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();
};

0 comments on commit c5652a5

Please sign in to comment.
You can’t perform that action at this time.