Skip to content
Permalink
Browse files

remove shift+c to close line

  • Loading branch information
lbartoletti committed Mar 2, 2020
1 parent 14760f5 commit 0f32dcfbc4cb6d74c84c6c5f5bcb0401117698f2
@@ -92,46 +92,6 @@ void QgsMapToolDigitizeFeature::setCheckGeometryType( bool checkGeometryType )
mCheckGeometryType = checkGeometryType;
}

void QgsMapToolDigitizeFeature::keyPressEvent( QKeyEvent *e )
{
if ( e && e->key() == Qt::Key_C && e->modifiers() == Qt::ShiftModifier )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mLayer );
if ( !vlayer )
//if no given layer take the current from canvas
vlayer = currentVectorLayer();

if ( !vlayer )
{
notifyNotVectorLayer();
return;
}

QgsVectorDataProvider *provider = vlayer->dataProvider();

if ( !( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) )
{
emit messageEmitted( tr( "The data provider for this layer does not support the addition of features." ), Qgis::Warning );
return;
}

if ( !vlayer->isEditable() )
{
notifyNotEditableLayer();
return;
}

if ( ( mode() == CaptureLine && vlayer->geometryType() == QgsWkbTypes::LineGeometry && mCheckGeometryType ) || ( mode() == CapturePolygon && vlayer->geometryType() == QgsWkbTypes::PolygonGeometry && mCheckGeometryType ) )
{
closePolygon();
QgsMapMouseEvent e2( mCanvas, QEvent::MouseButtonRelease, QPoint( ), Qt::RightButton );
cadCanvasReleaseEvent( &e2 );
}
}
else
QgsMapToolCapture::keyPressEvent( e );
}

void QgsMapToolDigitizeFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mLayer );
@@ -42,7 +42,6 @@ class GUI_EXPORT QgsMapToolDigitizeFeature : public QgsMapToolCapture
*/
QgsMapToolDigitizeFeature( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget, CaptureMode mode = QgsMapToolCapture::CaptureNone );

void keyPressEvent( QKeyEvent *e ) override;
void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) override;

/**
@@ -69,7 +69,6 @@ class TestQgsMapToolAddFeatureLine : public QObject
void testZMSnapping();
void testTopologicalEditingZ();
void testCloseLine();
void testCloseLineShiftRigthClick();

private:
QgisApp *mQgisApp = nullptr;
@@ -495,23 +494,6 @@ void TestQgsMapToolAddFeatureLine::testCloseLine()
{
TestQgsMapToolAdvancedDigitizingUtils utils( mCaptureTool );

mCanvas->setCurrentLayer( mLayerCloseLine );
QSet<QgsFeatureId> oldFids = utils.existingFeatureIds();
utils.mouseClick( 1, 1, Qt::LeftButton );
utils.mouseClick( 5, 1, Qt::LeftButton );
utils.mouseClick( 5, 5, Qt::LeftButton );
utils.keyClick( Qt::Key_C, Qt::ShiftModifier );
QgsFeatureId newFid = utils.newFeatureId( oldFids );

QString wkt = "LineString (1 1, 5 1, 5 5, 1 1)";
QCOMPARE( mLayerCloseLine->getFeature( newFid ).geometry(), QgsGeometry::fromWkt( wkt ) );

mLayerCloseLine->undoStack()->undo();
}
void TestQgsMapToolAddFeatureLine::testCloseLineShiftRigthClick()
{
TestQgsMapToolAdvancedDigitizingUtils utils( mCaptureTool );

mCanvas->setCurrentLayer( mLayerCloseLine );
QSet<QgsFeatureId> oldFids = utils.existingFeatureIds();
utils.mouseClick( 1, 1, Qt::LeftButton );

0 comments on commit 0f32dcf

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