Skip to content

Commit e5f62e4

Browse files
committed
Remove legacy QgsLegendInterface, move still valid methods to QgisInterface
1 parent 188033a commit e5f62e4

16 files changed

+96
-820
lines changed

doc/api_break.dox

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ so there is no longer a need for the separate cache class. Code which previously
240240
should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinateTransformCache::instance()->invalidateCrs( authid ).
241241
- QgsHttpTransaction. This class was outdated and code should be ported to native Qt or Python implementations.
242242
- QgsLabel and QgsLabelAttributes. Replaced by labeling based on PAL library, see QgsLabelingEngineV2.
243+
- QgsLegendInterface was removed. It was replaced by layer tree API (QgsLayerTreeNode class and others).
244+
Methods that deal with custom actions in main window's layer tree context menu were moved to QgisInterface:
245+
- addLegendLayerAction() moved to QgisInterface::addCustomActionForLayerType()
246+
- addLegendLayerActionForLayer() moved to QgisInterface::addCustomActionForLayer()
247+
- removeLegendLayerAction() moved to QgisInterface::removeCustomActionForLayerType()
243248
- QgsLegendModel was removed.
244249
- QgsMapCanvasMap. It is an internal class used by map canvas.
245250
- QgsMapRenderer. It has been replaced by QgsMapRendererJob with subclasses and QgsMapSettings.

python/gui/gui.sip

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
%Include qgskeyvaluewidget.sip
9494
%Include qgslistwidget.sip
9595
%Include qgslegendfilterbutton.sip
96-
%Include qgslegendinterface.sip
9796
%Include qgslimitedrandomcolorrampdialog.sip
9897
%Include qgslonglongvalidator.sip
9998
%Include qgsludialog.sip

python/gui/qgisinterface.sip

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,36 @@ class QgisInterface : QObject
2424
/** Virtual destructor */
2525
virtual ~QgisInterface();
2626

27-
/** Get pointer to legend interface */
28-
virtual QgsLegendInterface* legendInterface() = 0;
29-
3027
virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;
3128

3229
virtual QgsLayerTreeView* layerTreeView() = 0;
3330

31+
/** Add action to context menu for layers in the layer tree.
32+
* If allLayers is true, then the action will be available for all layers of given type,
33+
* otherwise the action will be available only for specific layers added with addCustomActionForLayer()
34+
* after this call.
35+
*
36+
* If menu argument is not empty, the action will be also added to a menu within the main window,
37+
* creating menu with the given name if it does not exist yet.
38+
*
39+
* @see removeCustomActionForLayerType()
40+
* @see addCustomActionForLayer()
41+
*/
42+
virtual void addCustomActionForLayerType( QAction* action, QString menu,
43+
QgsMapLayer::LayerType type, bool allLayers ) = 0;
44+
45+
/** Add action to context menu for a specific layer in the layer tree.
46+
* It is necessary to first call addCustomActionForLayerType() with allLayers=false
47+
* in order for this method to have any effect.
48+
* @see addCustomActionForLayerType()
49+
*/
50+
virtual void addCustomActionForLayer( QAction* action, QgsMapLayer* layer ) = 0;
51+
52+
/** Remove action for layers in the layer tree previously added with addCustomActionForLayerType()
53+
* @see addCustomActionForLayerType()
54+
*/
55+
virtual bool removeCustomActionForLayerType( QAction* action ) = 0;
56+
3457
public slots: // TODO: do these functions really need to be slots?
3558

3659
/* Exposed functions */

python/gui/qgslegendinterface.sip

Lines changed: 0 additions & 118 deletions
This file was deleted.

src/app/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ SET(QGIS_APP_SRCS
151151
composer/qgscompositionwidget.cpp
152152
composer/qgsatlascompositionwidget.cpp
153153

154-
legend/qgsapplegendinterface.cpp
155-
156154
ogr/qgsogrhelperfunctions.cpp
157155
ogr/qgsopenvectorlayerdialog.cpp
158156
ogr/qgsnewogrconnection.cpp
@@ -324,8 +322,6 @@ SET (QGIS_APP_MOC_HDRS
324322
composer/qgscompositionwidget.h
325323
composer/qgsatlascompositionwidget.h
326324

327-
legend/qgsapplegendinterface.h
328-
329325
ogr/qgsopenvectorlayerdialog.h
330326
ogr/qgsnewogrconnection.h
331327
ogr/qgsvectorlayersaveasdialog.h

0 commit comments

Comments
 (0)