Skip to content
Permalink
Browse files

Remove legacy QgsLegendInterface, move still valid methods to QgisInt…

…erface
  • Loading branch information
wonder-sk committed Nov 22, 2016
1 parent 188033a commit e5f62e49ce3fd617385a3e4290dd9172c691bf0f
@@ -240,6 +240,11 @@ so there is no longer a need for the separate cache class. Code which previously
should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinateTransformCache::instance()->invalidateCrs( authid ).
- QgsHttpTransaction. This class was outdated and code should be ported to native Qt or Python implementations.
- QgsLabel and QgsLabelAttributes. Replaced by labeling based on PAL library, see QgsLabelingEngineV2.
- QgsLegendInterface was removed. It was replaced by layer tree API (QgsLayerTreeNode class and others).
Methods that deal with custom actions in main window's layer tree context menu were moved to QgisInterface:
- addLegendLayerAction() moved to QgisInterface::addCustomActionForLayerType()
- addLegendLayerActionForLayer() moved to QgisInterface::addCustomActionForLayer()
- removeLegendLayerAction() moved to QgisInterface::removeCustomActionForLayerType()
- QgsLegendModel was removed.
- QgsMapCanvasMap. It is an internal class used by map canvas.
- QgsMapRenderer. It has been replaced by QgsMapRendererJob with subclasses and QgsMapSettings.
@@ -93,7 +93,6 @@
%Include qgskeyvaluewidget.sip
%Include qgslistwidget.sip
%Include qgslegendfilterbutton.sip
%Include qgslegendinterface.sip
%Include qgslimitedrandomcolorrampdialog.sip
%Include qgslonglongvalidator.sip
%Include qgsludialog.sip
@@ -24,13 +24,36 @@ class QgisInterface : QObject
/** Virtual destructor */
virtual ~QgisInterface();

/** Get pointer to legend interface */
virtual QgsLegendInterface* legendInterface() = 0;

virtual QgsPluginManagerInterface* pluginManagerInterface() = 0;

virtual QgsLayerTreeView* layerTreeView() = 0;

/** Add action to context menu for layers in the layer tree.
* If allLayers is true, then the action will be available for all layers of given type,
* otherwise the action will be available only for specific layers added with addCustomActionForLayer()
* after this call.
*
* If menu argument is not empty, the action will be also added to a menu within the main window,
* creating menu with the given name if it does not exist yet.
*
* @see removeCustomActionForLayerType()
* @see addCustomActionForLayer()
*/
virtual void addCustomActionForLayerType( QAction* action, QString menu,
QgsMapLayer::LayerType type, bool allLayers ) = 0;

/** Add action to context menu for a specific layer in the layer tree.
* It is necessary to first call addCustomActionForLayerType() with allLayers=false
* in order for this method to have any effect.
* @see addCustomActionForLayerType()
*/
virtual void addCustomActionForLayer( QAction* action, QgsMapLayer* layer ) = 0;

/** Remove action for layers in the layer tree previously added with addCustomActionForLayerType()
* @see addCustomActionForLayerType()
*/
virtual bool removeCustomActionForLayerType( QAction* action ) = 0;

public slots: // TODO: do these functions really need to be slots?

/* Exposed functions */

This file was deleted.

@@ -151,8 +151,6 @@ SET(QGIS_APP_SRCS
composer/qgscompositionwidget.cpp
composer/qgsatlascompositionwidget.cpp

legend/qgsapplegendinterface.cpp

ogr/qgsogrhelperfunctions.cpp
ogr/qgsopenvectorlayerdialog.cpp
ogr/qgsnewogrconnection.cpp
@@ -324,8 +322,6 @@ SET (QGIS_APP_MOC_HDRS
composer/qgscompositionwidget.h
composer/qgsatlascompositionwidget.h

legend/qgsapplegendinterface.h

ogr/qgsopenvectorlayerdialog.h
ogr/qgsnewogrconnection.h
ogr/qgsvectorlayersaveasdialog.h

2 comments on commit e5f62e4

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Nov 22, 2016

@wonder-sk , nice clean up work. The removal of obsolete QgsLegendInterface broken DB Manager:

Couldn't load plugin db_manager due to an error when calling its initGui() method 

AttributeError: 'QgisInterface' object has no attribute 'legendInterface' 
Traceback (most recent call last):
  File "/home/webmaster/apps/share/qgis/python/qgis/utils.py", line 341, in startPlugin
    plugins[packageName].initGui()
  File "/home/webmaster/apps/share/qgis/python/plugins/db_manager/db_manager_plugin.py", line 59, in initGui
    self.iface.legendInterface().addLegendLayerAction(self.layerAction, "", "dbManagerUpdateSqlLayer", QgsMapLayer.VectorLayer, False)
AttributeError: 'QgisInterface' object has no attribute 'legendInterface'
@wonder-sk

This comment has been minimized.

Copy link
Member Author

@wonder-sk wonder-sk replied Nov 22, 2016

oops... I'm on it

Please sign in to comment.
You can’t perform that action at this time.