5
5
#include " qgslayertreenode.h"
6
6
#include " qgslayertreeview.h"
7
7
#include " qgsmapcanvas.h"
8
+ #include " qgsmaplayerregistry.h"
8
9
#include " qgsvectorlayer.h"
9
10
10
11
#include < QAction>
@@ -24,7 +25,7 @@ QAction* QgsLayerTreeViewDefaultActions::actionAddGroup(QObject* parent)
24
25
25
26
QAction* QgsLayerTreeViewDefaultActions::actionRemoveGroupOrLayer (QObject* parent)
26
27
{
27
- QAction* a = new QAction (tr (" Remove" ), parent);
28
+ QAction* a = new QAction (QgsApplication::getThemeIcon ( " /mActionRemoveLayer.svg " ), tr (" & Remove" ), parent);
28
29
connect (a, SIGNAL (triggered ()), this , SLOT (removeGroupOrLayer ()));
29
30
return a;
30
31
}
@@ -35,7 +36,7 @@ QAction* QgsLayerTreeViewDefaultActions::actionShowInOverview(QObject* parent)
35
36
if (!node)
36
37
return 0 ;
37
38
38
- QAction* a = new QAction (tr (" Show in overview" ), parent);
39
+ QAction* a = new QAction (tr (" & Show in overview" ), parent);
39
40
connect (a, SIGNAL (triggered ()), this , SLOT (showInOverview ()));
40
41
a->setCheckable (true );
41
42
a->setChecked (node->customProperty (" overview" , 0 ).toInt ());
@@ -52,12 +53,21 @@ QAction* QgsLayerTreeViewDefaultActions::actionRenameGroupOrLayer(QObject* paren
52
53
QAction* QgsLayerTreeViewDefaultActions::actionZoomToLayer (QgsMapCanvas* canvas, QObject* parent)
53
54
{
54
55
QAction* a = new QAction (QgsApplication::getThemeIcon ( " /mActionZoomToLayer.svg" ),
55
- tr (" &Zoom to Layer Extent " ), parent);
56
+ tr (" &Zoom to Layer" ), parent);
56
57
a->setData (QVariant::fromValue (reinterpret_cast <void *>(canvas)));
57
58
connect (a, SIGNAL (triggered ()), this , SLOT (zoomToLayer ()));
58
59
return a;
59
60
}
60
61
62
+ QAction* QgsLayerTreeViewDefaultActions::actionZoomToGroup (QgsMapCanvas* canvas, QObject* parent)
63
+ {
64
+ QAction* a = new QAction (QgsApplication::getThemeIcon ( " /mActionZoomToLayer.svg" ),
65
+ tr (" &Zoom to Group" ), parent);
66
+ a->setData (QVariant::fromValue (reinterpret_cast <void *>(canvas)));
67
+ connect (a, SIGNAL (triggered ()), this , SLOT (zoomToGroup ()));
68
+ return a;
69
+ }
70
+
61
71
void QgsLayerTreeViewDefaultActions::addGroup ()
62
72
{
63
73
QgsLayerTreeGroup* group = mView ->currentGroupNode ();
@@ -82,10 +92,6 @@ void QgsLayerTreeViewDefaultActions::removeGroupOrLayer()
82
92
83
93
void QgsLayerTreeViewDefaultActions::renameGroupOrLayer ()
84
94
{
85
- /* QgsLayerTreeNode* node = mView->currentNode();
86
- if (!node)
87
- return;*/
88
-
89
95
mView ->edit (mView ->currentIndex ());
90
96
}
91
97
@@ -112,6 +118,18 @@ void QgsLayerTreeViewDefaultActions::zoomToLayer()
112
118
zoomToLayers (canvas, layers);
113
119
}
114
120
121
+ void QgsLayerTreeViewDefaultActions::zoomToGroup ()
122
+ {
123
+ QAction* s = qobject_cast<QAction*>(sender ());
124
+ QgsMapCanvas* canvas = reinterpret_cast <QgsMapCanvas*>(s->data ().value <void *>());
125
+
126
+ QList<QgsMapLayer*> layers;
127
+ foreach (QString layerId, mView ->currentGroupNode ()->childLayerIds ())
128
+ layers << QgsMapLayerRegistry::instance ()->mapLayer (layerId);
129
+
130
+ zoomToLayers (canvas, layers);
131
+ }
132
+
115
133
116
134
void QgsLayerTreeViewDefaultActions::zoomToLayers (QgsMapCanvas* canvas, const QList<QgsMapLayer*>& layers)
117
135
{
@@ -148,4 +166,5 @@ void QgsLayerTreeViewDefaultActions::zoomToLayers(QgsMapCanvas* canvas, const QL
148
166
149
167
// zoom to bounding box
150
168
canvas->setExtent ( extent );
169
+ canvas->refresh ();
151
170
}
0 commit comments