|
205 | 205 | #include "qgsmaptooldeletering.h"
|
206 | 206 | #include "qgsmaptooldeletepart.h"
|
207 | 207 | #include "qgsmaptooldeletevertex.h"
|
| 208 | +#include "qgsmaptoolfeatureaction.h" |
208 | 209 | #include "qgsmaptoolformannotation.h"
|
209 | 210 | #include "qgsmaptoolidentify.h"
|
210 | 211 | #include "qgsmaptoolmeasureangle.h"
|
@@ -640,6 +641,7 @@ QgisApp::~QgisApp()
|
640 | 641 | delete mMapTools.mZoomOut;
|
641 | 642 | delete mMapTools.mPan;
|
642 | 643 | delete mMapTools.mIdentify;
|
| 644 | + delete mMapTools.mFeatureAction; |
643 | 645 | delete mMapTools.mMeasureDist;
|
644 | 646 | delete mMapTools.mMeasureArea;
|
645 | 647 | delete mMapTools.mMeasureAngle;
|
@@ -814,6 +816,7 @@ void QgisApp::createActions()
|
814 | 816 | connect( mActionSelectRadius, SIGNAL( triggered() ), this, SLOT( selectByRadius() ) );
|
815 | 817 | connect( mActionDeselectAll, SIGNAL( triggered() ), this, SLOT( deselectAll() ) );
|
816 | 818 | connect( mActionIdentify, SIGNAL( triggered() ), this, SLOT( identify() ) );
|
| 819 | + connect( mActionFeatureAction, SIGNAL( triggered() ), this, SLOT( doFeatureAction() ) ); |
817 | 820 | connect( mActionMeasure, SIGNAL( triggered() ), this, SLOT( measure() ) );
|
818 | 821 | connect( mActionMeasureArea, SIGNAL( triggered() ), this, SLOT( measureArea() ) );
|
819 | 822 | connect( mActionMeasureAngle, SIGNAL( triggered() ), this, SLOT( measureAngle() ) );
|
@@ -989,6 +992,7 @@ void QgisApp::createActionGroups()
|
989 | 992 | mMapToolGroup->addAction( mActionZoomIn );
|
990 | 993 | mMapToolGroup->addAction( mActionZoomOut );
|
991 | 994 | mMapToolGroup->addAction( mActionIdentify );
|
| 995 | + mMapToolGroup->addAction( mActionFeatureAction ); |
992 | 996 | mMapToolGroup->addAction( mActionSelect );
|
993 | 997 | mMapToolGroup->addAction( mActionSelectRectangle );
|
994 | 998 | mMapToolGroup->addAction( mActionSelectPolygon );
|
@@ -1172,6 +1176,18 @@ void QgisApp::createToolBars()
|
1172 | 1176 | selectAction->setObjectName( "ActionSelect" );
|
1173 | 1177 | connect( bt, SIGNAL( triggered( QAction * ) ), this, SLOT( toolButtonActionTriggered( QAction * ) ) );
|
1174 | 1178 |
|
| 1179 | + // feature action tool button |
| 1180 | + |
| 1181 | + bt = new QToolButton( mAttributesToolBar ); |
| 1182 | + bt->setPopupMode( QToolButton::MenuButtonPopup ); |
| 1183 | + bt->setDefaultAction( mActionFeatureAction ); |
| 1184 | + mFeatureActionMenu = new QMenu( bt ); |
| 1185 | + connect( mFeatureActionMenu, SIGNAL( triggered( QAction * ) ), this, SLOT( updateDefaultFeatureAction( QAction * ) ) ); |
| 1186 | + connect( mFeatureActionMenu, SIGNAL( aboutToShow() ), this, SLOT( refreshFeatureActions() ) ); |
| 1187 | + bt->setMenu( mFeatureActionMenu ); |
| 1188 | + QAction* featureActionAction = mAttributesToolBar->insertWidget( selectAction, bt ); |
| 1189 | + featureActionAction->setObjectName( "ActionFeatureAction" ); |
| 1190 | + |
1175 | 1191 | // measure tool button
|
1176 | 1192 |
|
1177 | 1193 | bt = new QToolButton( mAttributesToolBar );
|
@@ -1478,6 +1494,7 @@ void QgisApp::setTheme( QString theThemeName )
|
1478 | 1494 | mActionZoomToLayer->setIcon( getThemeIcon( "/mActionZoomToLayer.png" ) );
|
1479 | 1495 | mActionZoomActualSize->setIcon( getThemeIcon( "/mActionZoomActual.png" ) );
|
1480 | 1496 | mActionIdentify->setIcon( getThemeIcon( "/mActionIdentify.png" ) );
|
| 1497 | + mActionFeatureAction->setIcon( getThemeIcon( "/mAction.png" ) ); |
1481 | 1498 | mActionSelect->setIcon( getThemeIcon( "/mActionSelect.png" ) );
|
1482 | 1499 | mActionSelectRectangle->setIcon( getThemeIcon( "/mActionSelectRectangle.png" ) );
|
1483 | 1500 | mActionSelectPolygon->setIcon( getThemeIcon( "/mActionSelectPolygon.png" ) );
|
@@ -1604,6 +1621,8 @@ void QgisApp::createCanvasTools()
|
1604 | 1621 | mMapTools.mPan->setAction( mActionPan );
|
1605 | 1622 | mMapTools.mIdentify = new QgsMapToolIdentify( mMapCanvas );
|
1606 | 1623 | mMapTools.mIdentify->setAction( mActionIdentify );
|
| 1624 | + mMapTools.mFeatureAction = new QgsMapToolFeatureAction( mMapCanvas ); |
| 1625 | + mMapTools.mFeatureAction->setAction( mActionFeatureAction ); |
1607 | 1626 | mMapTools.mMeasureDist = new QgsMeasureTool( mMapCanvas, false /* area */ );
|
1608 | 1627 | mMapTools.mMeasureDist->setAction( mActionMeasure );
|
1609 | 1628 | mMapTools.mMeasureArea = new QgsMeasureTool( mMapCanvas, true /* area */ );
|
@@ -3274,6 +3293,48 @@ void QgisApp::identify()
|
3274 | 3293 | mMapCanvas->setMapTool( mMapTools.mIdentify );
|
3275 | 3294 | }
|
3276 | 3295 |
|
| 3296 | +void QgisApp::doFeatureAction() |
| 3297 | +{ |
| 3298 | + mMapCanvas->setMapTool( mMapTools.mFeatureAction ); |
| 3299 | +} |
| 3300 | + |
| 3301 | +void QgisApp::updateDefaultFeatureAction( QAction *action ) |
| 3302 | +{ |
| 3303 | + foreach( QAction *a, mFeatureActionMenu->actions() ) |
| 3304 | + { |
| 3305 | + a->setChecked( a == action ); |
| 3306 | + } |
| 3307 | + |
| 3308 | + QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( activeLayer() ); |
| 3309 | + if ( !vlayer ) |
| 3310 | + return; |
| 3311 | + |
| 3312 | + int index = mFeatureActionMenu->actions().indexOf( action ); |
| 3313 | + vlayer->actions()->setDefaultAction( index ); |
| 3314 | + |
| 3315 | + doFeatureAction(); |
| 3316 | +} |
| 3317 | + |
| 3318 | +void QgisApp::refreshFeatureActions() |
| 3319 | +{ |
| 3320 | + mFeatureActionMenu->clear(); |
| 3321 | + |
| 3322 | + QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( activeLayer() ); |
| 3323 | + if ( !vlayer ) |
| 3324 | + return; |
| 3325 | + |
| 3326 | + QgsAttributeAction *actions = vlayer->actions(); |
| 3327 | + for ( int i = 0; i < actions->size(); i++ ) |
| 3328 | + { |
| 3329 | + QAction *action = mFeatureActionMenu->addAction( actions->at( i ).name() ); |
| 3330 | + action->setCheckable( true ); |
| 3331 | + if ( i == actions->defaultAction() ) |
| 3332 | + { |
| 3333 | + action->setChecked( true ); |
| 3334 | + } |
| 3335 | + } |
| 3336 | +} |
| 3337 | + |
3277 | 3338 | void QgisApp::measure()
|
3278 | 3339 | {
|
3279 | 3340 | mMapCanvas->setMapTool( mMapTools.mMeasureDist );
|
@@ -6019,7 +6080,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
|
6019 | 6080 | mActionLayerProperties->setEnabled( false );
|
6020 | 6081 | mActionLayerSubsetString->setEnabled( false );
|
6021 | 6082 | mActionAddToOverview->setEnabled( false );
|
6022 |
| - |
| 6083 | + mActionFeatureAction->setEnabled( false ); |
6023 | 6084 | mActionAddFeature->setEnabled( false );
|
6024 | 6085 | mActionMoveFeature->setEnabled( false );
|
6025 | 6086 | mActionNodeTool->setEnabled( false );
|
@@ -6077,6 +6138,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
|
6077 | 6138 | mActionLayerSaveAs->setEnabled( true );
|
6078 | 6139 | mActionLayerSelectionSaveAs->setEnabled( true );
|
6079 | 6140 | mActionCopyFeatures->setEnabled( layerHasSelection );
|
| 6141 | + mActionFeatureAction->setEnabled( vlayer->actions()->size() > 0 ); |
6080 | 6142 |
|
6081 | 6143 | if ( !vlayer->isEditable() && mMapCanvas->mapTool() && mMapCanvas->mapTool()->isEditTool() )
|
6082 | 6144 | {
|
@@ -6244,6 +6306,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
|
6244 | 6306 | mActionFullHistogramStretch->setEnabled( false );
|
6245 | 6307 | }
|
6246 | 6308 | mActionLayerSubsetString->setEnabled( false );
|
| 6309 | + mActionFeatureAction->setEnabled( false ); |
6247 | 6310 | mActionSelect->setEnabled( false );
|
6248 | 6311 | mActionSelectRectangle->setEnabled( false );
|
6249 | 6312 | mActionSelectPolygon->setEnabled( false );
|
|
0 commit comments