|
28 | 28 | #include "qgslogger.h" |
29 | 29 | #include <QMessageBox> |
30 | 30 | #include <QMouseEvent> |
| 31 | +#include <QSettings> |
31 | 32 |
|
32 | 33 | QgsMapToolAddFeature::QgsMapToolAddFeature( QgsMapCanvas* canvas, enum CaptureTool tool ): QgsMapToolCapture( canvas, tool ) |
33 | 34 | { |
@@ -175,18 +176,28 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) |
175 | 176 | } |
176 | 177 |
|
177 | 178 | // show the dialog to enter attribute values |
178 | | - QgsAttributeDialog * mypDialog = new QgsAttributeDialog( vlayer, f ); |
179 | | - if ( mypDialog->exec() ) |
| 179 | + QSettings settings; |
| 180 | + bool isDisabledAttributeValuesDlg = settings.value( "/qgis/digitizing/disable_enter_attribute_values_dialog", false ).toBool(); |
| 181 | + if ( isDisabledAttributeValuesDlg ) |
180 | 182 | { |
181 | 183 | qDebug( "Adding feature to layer" ); |
182 | 184 | vlayer->addFeature( *f ); |
183 | 185 | } |
184 | 186 | else |
185 | 187 | { |
186 | | - qDebug( "Adding feature to layer failed" ); |
187 | | - delete f; |
| 188 | + QgsAttributeDialog * mypDialog = new QgsAttributeDialog( vlayer, f ); |
| 189 | + if ( mypDialog->exec() ) |
| 190 | + { |
| 191 | + qDebug( "Adding feature to layer" ); |
| 192 | + vlayer->addFeature( *f ); |
| 193 | + } |
| 194 | + else |
| 195 | + { |
| 196 | + qDebug( "Adding feature to layer failed" ); |
| 197 | + delete f; |
| 198 | + } |
| 199 | + delete mypDialog; |
188 | 200 | } |
189 | | - delete mypDialog; |
190 | 201 | mCanvas->refresh(); |
191 | 202 | } |
192 | 203 |
|
@@ -444,21 +455,38 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e ) |
444 | 455 | f->addAttribute( it.key(), provider->defaultValue( it.key() ) ); |
445 | 456 | } |
446 | 457 |
|
447 | | - QgsAttributeDialog * mypDialog = new QgsAttributeDialog( vlayer, f ); |
448 | | - if ( mypDialog->exec() ) |
| 458 | + QSettings settings; |
| 459 | + bool isDisabledAttributeValuesDlg = settings.value( "/qgis/digitizing/disable_enter_attribute_values_dialog", false ).toBool(); |
| 460 | + if ( isDisabledAttributeValuesDlg ) |
449 | 461 | { |
450 | 462 | if ( vlayer->addFeature( *f ) ) |
| 463 | + { |
| 464 | + //add points to other features to keep topology up-to-date |
| 465 | + int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); |
| 466 | + if ( topologicalEditing ) |
| 467 | + { |
| 468 | + vlayer->addTopologicalPoints( f->geometry() ); |
| 469 | + } |
| 470 | + } |
| 471 | + } |
| 472 | + else |
| 473 | + { |
| 474 | + QgsAttributeDialog * mypDialog = new QgsAttributeDialog( vlayer, f ); |
| 475 | + if ( mypDialog->exec() ) |
451 | 476 | { |
452 | | - //add points to other features to keep topology up-to-date |
453 | | - int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); |
454 | | - if ( topologicalEditing ) |
| 477 | + if ( vlayer->addFeature( *f ) ) |
455 | 478 | { |
456 | | - vlayer->addTopologicalPoints( f->geometry() ); |
| 479 | + //add points to other features to keep topology up-to-date |
| 480 | + int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); |
| 481 | + if ( topologicalEditing ) |
| 482 | + { |
| 483 | + vlayer->addTopologicalPoints( f->geometry() ); |
| 484 | + } |
457 | 485 | } |
458 | 486 | } |
| 487 | + delete mypDialog; |
459 | 488 | } |
460 | 489 | delete f; |
461 | | - delete mypDialog; |
462 | 490 |
|
463 | 491 | delete mRubberBand; |
464 | 492 | mRubberBand = NULL; |
|
0 commit comments