QGIS API Documentation  2.99.0-Master (314842d)
qgslayertreeviewdefaultactions.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayertreeviewdefaultactions.h
3  --------------------------------------
4  Date : May 2014
5  Copyright : (C) 2014 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSLAYERTREEVIEWDEFAULTACTIONS_H
17 #define QGSLAYERTREEVIEWDEFAULTACTIONS_H
18 
19 #include <QObject>
20 #include "qgis_gui.h"
21 
22 class QAction;
23 
24 class QgsLayerTreeGroup;
25 class QgsLayerTreeView;
26 class QgsMapCanvas;
27 class QgsMapLayer;
28 
29 
38 class GUI_EXPORT QgsLayerTreeViewDefaultActions : public QObject
39 {
40  Q_OBJECT
41  public:
43 
44  QAction *actionAddGroup( QObject *parent = nullptr );
45  QAction *actionRemoveGroupOrLayer( QObject *parent = nullptr );
46  QAction *actionShowInOverview( QObject *parent = nullptr );
47  QAction *actionRenameGroupOrLayer( QObject *parent = nullptr );
48  QAction *actionShowFeatureCount( QObject *parent = nullptr );
49 
51  QAction *actionCheckAndAllChildren( QObject *parent = nullptr );
52 
54  QAction *actionUncheckAndAllChildren( QObject *parent = nullptr );
55 
57  QAction *actionCheckAndAllParents( QObject *parent = nullptr );
58 
59  QAction *actionZoomToLayer( QgsMapCanvas *canvas, QObject *parent = nullptr );
60  QAction *actionZoomToGroup( QgsMapCanvas *canvas, QObject *parent = nullptr );
61  // TODO: zoom to selected
62 
63  QAction *actionMakeTopLevel( QObject *parent = nullptr );
64  QAction *actionGroupSelected( QObject *parent = nullptr );
67  QAction *actionMutuallyExclusiveGroup( QObject *parent = nullptr );
68 
69  void zoomToLayer( QgsMapCanvas *canvas );
70  void zoomToGroup( QgsMapCanvas *canvas );
71 
72  public slots:
73  void showInOverview();
74  void addGroup();
75 
76  protected slots:
77  void removeGroupOrLayer();
78  void renameGroupOrLayer();
79  void showFeatureCount();
80  void zoomToLayer();
81  void zoomToGroup();
82  void makeTopLevel();
83  void groupSelected();
86  void mutuallyExclusiveGroup();
87 
88  private slots:
89  void checkAndAllChildren();
90  void uncheckAndAllChildren();
91  void checkAndAllParents();
92 
93  protected:
94  void zoomToLayers( QgsMapCanvas *canvas, const QList<QgsMapLayer *> &layers );
95 
96  QString uniqueGroupName( QgsLayerTreeGroup *parentGroup );
97 
98  protected:
99  QgsLayerTreeView *mView = nullptr;
100 };
101 
102 
103 #endif // QGSLAYERTREEVIEWDEFAULTACTIONS_H
Layer tree group node serves as a container for layers and further groups.
Base class for all map layer types.
Definition: qgsmaplayer.h:52
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:72
The QgsLayerTreeViewDefaultActions class serves as a factory of actions that can be used together wit...