Skip to content

Commit 299fff7

Browse files
committed
Use lambdas in the connect for tools (and circular tools)
1 parent 5a9278b commit 299fff7

File tree

2 files changed

+22
-133
lines changed

2 files changed

+22
-133
lines changed

src/app/qgisapp.cpp

+19-99
Original file line numberDiff line numberDiff line change
@@ -1787,23 +1787,23 @@ void QgisApp::createActions()
17871787
connect( mActionCopyStyle, &QAction::triggered, this, [ = ] { copyStyle(); } );
17881788
connect( mActionPasteStyle, &QAction::triggered, this, [ = ] { pasteStyle(); } );
17891789
connect( mActionAddFeature, &QAction::triggered, this, &QgisApp::addFeature );
1790-
connect( mActionCircularStringCurvePoint, &QAction::triggered, this, &QgisApp::circularStringCurvePoint );
1791-
connect( mActionCircularStringRadius, &QAction::triggered, this, &QgisApp::circularStringRadius );
1792-
connect( mActionCircle2Points, &QAction::triggered, this, &QgisApp::circle2Points );
1793-
connect( mActionCircle3Points, &QAction::triggered, this, &QgisApp::circle3Points );
1794-
connect( mActionCircle3Tangents, &QAction::triggered, this, &QgisApp::circle3Tangents );
1795-
connect( mActionCircle2TangentsPoint, &QAction::triggered, this, &QgisApp::circle2TangentsPoint );
1796-
connect( mActionCircleCenterPoint, &QAction::triggered, this, &QgisApp::circleCenterPoint );
1797-
connect( mActionEllipseCenter2Points, &QAction::triggered, this, &QgisApp::ellipseCenter2Points );
1798-
connect( mActionEllipseCenterPoint, &QAction::triggered, this, &QgisApp::ellipseCenterPoint );
1799-
connect( mActionEllipseExtent, &QAction::triggered, this, &QgisApp::ellipseExtent );
1800-
connect( mActionEllipseFoci, &QAction::triggered, this, &QgisApp::ellipseFoci );
1801-
connect( mActionRectangleCenterPoint, &QAction::triggered, this, &QgisApp::rectangleCenterPoint );
1802-
connect( mActionRectangleExtent, &QAction::triggered, this, &QgisApp::rectangleExtent );
1803-
connect( mActionRectangle3Points, &QAction::triggered, this, &QgisApp::rectangle3Points );
1804-
connect( mActionRegularPolygon2Points, &QAction::triggered, this, &QgisApp::regularPolygon2Points );
1805-
connect( mActionRegularPolygonCenterPoint, &QAction::triggered, this, &QgisApp::regularPolygonCenterPoint );
1806-
connect( mActionRegularPolygonCenterCorner, &QAction::triggered, this, &QgisApp::regularPolygonCenterCorner );
1790+
connect( mActionCircularStringCurvePoint, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mCircularStringRadius ); } );
1791+
connect( mActionCircularStringRadius, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mCircularStringRadius ); } );
1792+
connect( mActionCircle2Points, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mCircle2Points ); } );
1793+
connect( mActionCircle3Points, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mCircle3Points ); } );
1794+
connect( mActionCircle3Tangents, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mCircle3Tangents ); } );
1795+
connect( mActionCircle2TangentsPoint, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mCircle2TangentsPoint ); } );
1796+
connect( mActionCircleCenterPoint, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mCircleCenterPoint ); } );
1797+
connect( mActionEllipseCenter2Points, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mEllipseCenter2Points ); } );
1798+
connect( mActionEllipseCenterPoint, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mEllipseCenterPoint ); } );
1799+
connect( mActionEllipseExtent, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mEllipseExtent ); } );
1800+
connect( mActionEllipseFoci, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mEllipseFoci ); } );
1801+
connect( mActionRectangleCenterPoint, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRectangleCenterPoint ); } );
1802+
connect( mActionRectangleExtent, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRectangleExtent ); } );
1803+
connect( mActionRectangle3Points, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRectangle3Points ); } );
1804+
connect( mActionRegularPolygon2Points, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRegularPolygon2Points ); } );
1805+
connect( mActionRegularPolygonCenterPoint, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRegularPolygonCenterPoint ); } );
1806+
connect( mActionRegularPolygonCenterCorner, &QAction::triggered, this, [ = ] { setMapTool( mMapTools.mRegularPolygonCenterCorner ); } );
18071807
connect( mActionMoveFeature, &QAction::triggered, this, &QgisApp::moveFeature );
18081808
connect( mActionMoveFeature, &QAction::triggered, this, &QgisApp::moveFeature );
18091809
connect( mActionMoveFeatureCopy, &QAction::triggered, this, &QgisApp::moveFeatureCopy );
@@ -7801,89 +7801,9 @@ void QgisApp::addFeature()
78017801
mMapCanvas->setMapTool( mMapTools.mAddFeature );
78027802
}
78037803

7804-
void QgisApp::circularStringCurvePoint()
7804+
void QgisApp::setMapTool( QgsMapTool *tool )
78057805
{
7806-
mMapCanvas->setMapTool( mMapTools.mCircularStringCurvePoint );
7807-
}
7808-
7809-
void QgisApp::circularStringRadius()
7810-
{
7811-
mMapCanvas->setMapTool( mMapTools.mCircularStringRadius );
7812-
}
7813-
7814-
void QgisApp::circle2Points()
7815-
{
7816-
mMapCanvas->setMapTool( mMapTools.mCircle2Points );
7817-
}
7818-
7819-
void QgisApp::circle3Points()
7820-
{
7821-
mMapCanvas->setMapTool( mMapTools.mCircle3Points );
7822-
}
7823-
7824-
void QgisApp::circle3Tangents()
7825-
{
7826-
mMapCanvas->setMapTool( mMapTools.mCircle3Tangents );
7827-
}
7828-
7829-
void QgisApp::circle2TangentsPoint()
7830-
{
7831-
mMapCanvas->setMapTool( mMapTools.mCircle2TangentsPoint );
7832-
}
7833-
7834-
void QgisApp::circleCenterPoint()
7835-
{
7836-
mMapCanvas->setMapTool( mMapTools.mCircleCenterPoint );
7837-
}
7838-
7839-
void QgisApp::ellipseCenter2Points()
7840-
{
7841-
mMapCanvas->setMapTool( mMapTools.mEllipseCenter2Points );
7842-
}
7843-
7844-
void QgisApp::ellipseCenterPoint()
7845-
{
7846-
mMapCanvas->setMapTool( mMapTools.mEllipseCenterPoint );
7847-
}
7848-
7849-
void QgisApp::ellipseExtent()
7850-
{
7851-
mMapCanvas->setMapTool( mMapTools.mEllipseExtent );
7852-
}
7853-
7854-
void QgisApp::ellipseFoci()
7855-
{
7856-
mMapCanvas->setMapTool( mMapTools.mEllipseFoci );
7857-
}
7858-
7859-
void QgisApp::rectangleCenterPoint()
7860-
{
7861-
mMapCanvas->setMapTool( mMapTools.mRectangleCenterPoint );
7862-
}
7863-
7864-
void QgisApp::rectangleExtent()
7865-
{
7866-
mMapCanvas->setMapTool( mMapTools.mRectangleExtent );
7867-
}
7868-
7869-
void QgisApp::rectangle3Points()
7870-
{
7871-
mMapCanvas->setMapTool( mMapTools.mRectangle3Points );
7872-
}
7873-
7874-
void QgisApp::regularPolygon2Points()
7875-
{
7876-
mMapCanvas->setMapTool( mMapTools.mRegularPolygon2Points );
7877-
}
7878-
7879-
void QgisApp::regularPolygonCenterPoint()
7880-
{
7881-
mMapCanvas->setMapTool( mMapTools.mRegularPolygonCenterPoint );
7882-
}
7883-
7884-
void QgisApp::regularPolygonCenterCorner()
7885-
{
7886-
mMapCanvas->setMapTool( mMapTools.mRegularPolygonCenterCorner );
7806+
mMapCanvas->setMapTool( tool );
78877807
}
78887808

78897809
void QgisApp::selectFeatures()

src/app/qgisapp.h

+3-34
Original file line numberDiff line numberDiff line change
@@ -1221,40 +1221,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
12211221
void newBookmark();
12221222
//! activates the add feature tool
12231223
void addFeature();
1224-
//! activates the add circular string tool
1225-
void circularStringCurvePoint();
1226-
//! activates the circular string radius tool
1227-
void circularStringRadius();
1228-
//! activates the add circle from 2 points tool
1229-
void circle2Points();
1230-
//! activates the add circle from 3 points tool
1231-
void circle3Points();
1232-
//! activates the add circle from 3 tangents tool
1233-
void circle3Tangents();
1234-
//! activates the add circle from 2 tangents and a point tool
1235-
void circle2TangentsPoint();
1236-
//! activates the add circle from center and radius tool
1237-
void circleCenterPoint();
1238-
//! activates the add ellipse from center and 2 points tool
1239-
void ellipseCenter2Points();
1240-
//! activates the add ellipse from center point tool
1241-
void ellipseCenterPoint();
1242-
//! activates the add ellipse from extent tool
1243-
void ellipseExtent();
1244-
//! activates the add ellipse from foci tool
1245-
void ellipseFoci();
1246-
//! activates the add rectangle from center and a point tool
1247-
void rectangleCenterPoint();
1248-
//! activates the add rectangle from extent tool
1249-
void rectangleExtent();
1250-
//! activates the add rectangle from 3 points tool
1251-
void rectangle3Points();
1252-
//! activates the add regular polygon from 2 points tool
1253-
void regularPolygon2Points();
1254-
//! activates the add regular polygon from center and a point tool
1255-
void regularPolygonCenterPoint();
1256-
//! activates the add regular polygon from center and a corner tool
1257-
void regularPolygonCenterCorner();
12581224
//! activates the move feature tool
12591225
void moveFeature();
12601226
//! activates the copy and move feature tool
@@ -1293,6 +1259,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
12931259
void offsetPointSymbol();
12941260
//! shows the snapping Options
12951261
void snappingOptions();
1262+
//! activates the tool
1263+
void setMapTool( QgsMapTool *tool );
1264+
12961265

12971266
//! activates the rectangle selection tool
12981267
void selectFeatures();

0 commit comments

Comments
 (0)