Skip to content

Commit

Permalink
Remove legacy QgsLegendInterface, move still valid methods to QgisInt…
Browse files Browse the repository at this point in the history
…erface
  • Loading branch information
wonder-sk committed Nov 22, 2016
1 parent 188033a commit e5f62e4
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 820 deletions.
5 changes: 5 additions & 0 deletions doc/api_break.dox
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion python/gui/gui.sip
Expand Up @@ -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
Expand Down
29 changes: 26 additions & 3 deletions python/gui/qgisinterface.sip
Expand Up @@ -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 */
Expand Down
118 changes: 0 additions & 118 deletions python/gui/qgslegendinterface.sip

This file was deleted.

4 changes: 0 additions & 4 deletions src/app/CMakeLists.txt
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

2 comments on commit e5f62e4

@nirvn
Copy link
Contributor

@nirvn nirvn commented on e5f62e4 Nov 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops... I'm on it

Please sign in to comment.