13
13
#include " qgsvectorlayer.h"
14
14
15
15
16
- QgsAppLayerTreeViewMenuProvider::QgsAppLayerTreeViewMenuProvider (QgsLayerTreeView* view, QgsMapCanvas* canvas)
17
- : mView(view)
18
- , mCanvas(canvas)
16
+ QgsAppLayerTreeViewMenuProvider::QgsAppLayerTreeViewMenuProvider ( QgsLayerTreeView* view, QgsMapCanvas* canvas )
17
+ : mView( view )
18
+ , mCanvas( canvas )
19
19
{
20
20
}
21
21
@@ -27,38 +27,38 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
27
27
QgsLayerTreeViewDefaultActions* actions = mView ->defaultActions ();
28
28
29
29
QModelIndex idx = mView ->currentIndex ();
30
- if (!idx.isValid ())
30
+ if ( !idx.isValid () )
31
31
{
32
32
// global menu
33
- menu->addAction ( actions->actionAddGroup (menu) );
33
+ menu->addAction ( actions->actionAddGroup ( menu ) );
34
34
35
35
// TODO: expand all, collapse all
36
36
// TODO: update drawing order
37
37
}
38
- else if (QgsLayerTreeNode* node = mView ->layerTreeModel ()->index2node (idx) )
38
+ else if ( QgsLayerTreeNode* node = mView ->layerTreeModel ()->index2node ( idx ) )
39
39
{
40
40
// layer or group selected
41
- if (QgsLayerTree::isGroup (node) )
41
+ if ( QgsLayerTree::isGroup ( node ) )
42
42
{
43
- menu->addAction ( actions->actionZoomToGroup (mCanvas , menu) );
44
- menu->addAction ( actions->actionRemoveGroupOrLayer (menu) );
43
+ menu->addAction ( actions->actionZoomToGroup ( mCanvas , menu ) );
44
+ menu->addAction ( actions->actionRemoveGroupOrLayer ( menu ) );
45
45
46
46
menu->addAction ( QgsApplication::getThemeIcon ( " /mActionSetCRS.png" ),
47
47
tr ( " &Set Group CRS" ), QgisApp::instance (), SLOT ( legendGroupSetCRS () ) );
48
48
49
- menu->addAction ( actions->actionRenameGroupOrLayer (menu) );
49
+ menu->addAction ( actions->actionRenameGroupOrLayer ( menu ) );
50
50
51
- if (mView ->selectedNodes (true ).count () >= 2 )
52
- menu->addAction ( actions->actionGroupSelected (menu) );
51
+ if ( mView ->selectedNodes ( true ).count () >= 2 )
52
+ menu->addAction ( actions->actionGroupSelected ( menu ) );
53
53
54
- menu->addAction ( actions->actionAddGroup (menu) );
54
+ menu->addAction ( actions->actionAddGroup ( menu ) );
55
55
}
56
- else if (QgsLayerTree::isLayer (node) )
56
+ else if ( QgsLayerTree::isLayer ( node ) )
57
57
{
58
- QgsMapLayer* layer = QgsLayerTree::toLayer (node)->layer ();
58
+ QgsMapLayer* layer = QgsLayerTree::toLayer ( node )->layer ();
59
59
60
- menu->addAction ( actions->actionZoomToLayer (mCanvas , menu) );
61
- menu->addAction ( actions->actionShowInOverview (menu) );
60
+ menu->addAction ( actions->actionZoomToLayer ( mCanvas , menu ) );
61
+ menu->addAction ( actions->actionShowInOverview ( menu ) );
62
62
63
63
if ( layer && layer->type () == QgsMapLayer::RasterLayer )
64
64
{
@@ -69,11 +69,14 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
69
69
menu->addAction ( tr ( " &Stretch Using Current Extent" ), QgisApp::instance (), SLOT ( legendLayerStretchUsingCurrentExtent () ) );
70
70
}
71
71
72
- menu->addAction ( actions->actionRemoveGroupOrLayer (menu) );
72
+ menu->addAction ( actions->actionRemoveGroupOrLayer ( menu ) );
73
73
74
74
// duplicate layer
75
75
QAction* duplicateLayersAction = menu->addAction ( QgsApplication::getThemeIcon ( " /mActionDuplicateLayer.svg" ), tr ( " &Duplicate" ), QgisApp::instance (), SLOT ( duplicateLayers () ) );
76
76
77
+ // set layer scale visibility
78
+ menu->addAction ( tr ( " &Set Layer Scale Visibility" ), QgisApp::instance (), SLOT ( setLayerScaleVisibility () ) );
79
+
77
80
// set layer crs
78
81
menu->addAction ( QgsApplication::getThemeIcon ( " /mActionSetCRS.png" ), tr ( " &Set Layer CRS" ), QgisApp::instance (), SLOT ( setLayerCRS () ) );
79
82
@@ -123,7 +126,7 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
123
126
if ( !vlayer->isEditable () && vlayer->dataProvider ()->supportsSubsetString () && vlayer->vectorJoins ().isEmpty () )
124
127
menu->addAction ( tr ( " &Filter..." ), QgisApp::instance (), SLOT ( layerSubsetString () ) );
125
128
126
- menu->addAction ( actions->actionShowFeatureCount (menu) );
129
+ menu->addAction ( actions->actionShowFeatureCount ( menu ) );
127
130
128
131
menu->addSeparator ();
129
132
}
@@ -140,16 +143,16 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
140
143
141
144
// TODO: custom actions
142
145
143
- if (layer && QgsProject::instance ()->layerIsEmbedded ( layer->id () ).isEmpty () )
146
+ if ( layer && QgsProject::instance ()->layerIsEmbedded ( layer->id () ).isEmpty () )
144
147
menu->addAction ( tr ( " &Properties" ), QgisApp::instance (), SLOT ( layerProperties () ) );
145
148
146
- if (node->parent () != mView ->layerTreeModel ()->rootGroup ())
147
- menu->addAction ( actions->actionMakeTopLevel (menu) );
149
+ if ( node->parent () != mView ->layerTreeModel ()->rootGroup () )
150
+ menu->addAction ( actions->actionMakeTopLevel ( menu ) );
148
151
149
- menu->addAction ( actions->actionRenameGroupOrLayer (menu) );
152
+ menu->addAction ( actions->actionRenameGroupOrLayer ( menu ) );
150
153
151
- if (mView ->selectedNodes (true ).count () >= 2 )
152
- menu->addAction ( actions->actionGroupSelected (menu) );
154
+ if ( mView ->selectedNodes ( true ).count () >= 2 )
155
+ menu->addAction ( actions->actionGroupSelected ( menu ) );
153
156
154
157
if ( mView ->selectedLayerNodes ().count () == 1 )
155
158
{
0 commit comments