Skip to content

Commit

Permalink
[fix #11300] make edit form non modal on feature creation too
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Oct 2, 2014
1 parent 7225913 commit c5652a5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
12 changes: 10 additions & 2 deletions src/app/qgsfeatureaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsfeatureaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgsmaptooladdfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -50,7 +50,7 @@ void QgsMapToolAddFeature::activate()
if ( vlayer && vlayer->geometryType() == QGis::NoGeometry )
{
QgsFeature f;
addFeature( vlayer, &f );
addFeature( vlayer, &f, false );
return;
}

Expand Down Expand Up @@ -138,7 +138,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )

f.setGeometry( g );

addFeature( vlayer, &f );
addFeature( vlayer, &f, false );

mCanvas->refresh();
}
Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptooladdfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.