mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[fix #11300] make edit form non modal on feature creation too
This commit is contained in:
parent
72259135b1
commit
c5652a52e2
@ -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();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user