Skip to content
Permalink
Browse files

Add iface.layerTreeCanvasBridge()

  • Loading branch information
m-kuhn committed Jul 26, 2015
1 parent 4984cae commit 70fe622661852db61f66f8b973d1991259338af2
Showing with 31 additions and 8 deletions.
  1. +3 −0 python/gui/qgisinterface.sip
  2. +5 −0 src/app/qgisappinterface.cpp
  3. +10 −3 src/app/qgisappinterface.h
  4. +13 −5 src/gui/qgisinterface.h
@@ -159,6 +159,9 @@ class QgisInterface : QObject
/** Return a pointer to the map canvas */
virtual QgsMapCanvas * mapCanvas() = 0;

/** Returns a pointer to the layer tree canvas bridge */
virtual QgsLayerTreeMapCanvasBridge* layerTreeCanvasBridge() = 0;

/** Return a pointer to the main window (instance of QgisApp in case of QGIS) */
virtual QWidget * mainWindow() = 0;

@@ -311,6 +311,11 @@ QgsMapCanvas * QgisAppInterface::mapCanvas()
return qgis->mapCanvas();
}

QgsLayerTreeMapCanvasBridge* QgisAppInterface::layerTreeCanvasBridge()
{
return qgis->layerTreeCanvasBridge();
}

QWidget * QgisAppInterface::mainWindow()
{
return qgis;
@@ -168,6 +168,13 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
/** Return a pointer to the map canvas used by qgisapp */
QgsMapCanvas * mapCanvas() override;

/**
* Returns a pointer to the layer tree canvas bridge
*
* @note added in 2.12
*/
QgsLayerTreeMapCanvasBridge* layerTreeCanvasBridge() override;

/** Gives access to main QgisApp object
Plugins don't need to know about QgisApp, as we pass it as QWidget,
@@ -243,7 +250,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface

/** Add "add layer" action to the layer menu */
void insertAddLayerAction( QAction *action ) override;
/** remove "add layer" action from the layer menu */
/** Remove "add layer" action from the layer menu */
void removeAddLayerAction( QAction *action ) override;

/** Add a dock widget to the main window */
@@ -252,12 +259,12 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
/** Remove specified dock widget from main window (doesn't delete it). */
void removeDockWidget( QDockWidget * dockwidget ) override;

/** show layer properties dialog for layer
/** Show layer properties dialog for layer
* @param l layer to show properties table for
*/
virtual void showLayerProperties( QgsMapLayer *l ) override;

/** show layer attribute dialog for layer
/** Show layer attribute dialog for layer
* @param l layer to show attribute table for
*/
virtual void showAttributeTable( QgsVectorLayer *l ) override;
@@ -28,6 +28,7 @@ class QWidget;
class QgsAttributeDialog;
class QgsComposerView;
class QgsFeature;
class QgsLayerTreeMapCanvasBridge;
class QgsLayerTreeView;
class QgsLegendInterface;
class QgsMapCanvas;
@@ -205,6 +206,13 @@ class GUI_EXPORT QgisInterface : public QObject
/** Return a pointer to the map canvas */
virtual QgsMapCanvas * mapCanvas() = 0;

/**
* Returns a pointer to the layer tree canvas bridge
*
* @note added in 2.12
*/
virtual QgsLayerTreeMapCanvasBridge* layerTreeCanvasBridge() = 0;

/** Return a pointer to the main window (instance of QgisApp in case of QGIS) */
virtual QWidget * mainWindow() = 0;

@@ -291,10 +299,10 @@ class GUI_EXPORT QgisInterface : public QObject
/** Remove specified dock widget from main window (doesn't delete it). */
virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;

/** open layer properties dialog */
/** Open layer properties dialog */
virtual void showLayerProperties( QgsMapLayer *l ) = 0;

/** open attribute table dialog */
/** Open attribute table dialog */
virtual void showAttributeTable( QgsVectorLayer *l ) = 0;

/** Add window to Window menu. The action title is the window title
@@ -568,14 +576,14 @@ class GUI_EXPORT QgisInterface : public QObject
* This signal is emitted when the initialization is complete
*/
void initializationCompleted();
/** emitted when a project file is successfully read
/** Emitted when a project file is successfully read
@note
This is useful for plug-ins that store properties with project files. A
plug-in can connect to this signal. When it is emitted, the plug-in
knows to then check the project properties for any relevant state.
*/
void projectRead();
/** emitted when starting an entirely new project
/** Emitted when starting an entirely new project
@note
This is similar to projectRead(); plug-ins might want to be notified
that they're in a new project. Yes, projectRead() could have been
@@ -585,7 +593,7 @@ class GUI_EXPORT QgisInterface : public QObject
*/
void newProjectCreated();

/**This signal is emitted when a layer has been saved using save as
/** This signal is emitted when a layer has been saved using save as
@note
added in version 2.7
*/

5 comments on commit 70fe622

@elpaso

This comment has been minimized.

Copy link
Contributor

@elpaso elpaso replied Jul 28, 2015

@m-kuhn can you please check that the manual example using the bridge is still valid? https://github.com/qgis/QGIS-Documentation/blob/master/source/docs/pyqgis_developer_cookbook/loadproject.rst#id21

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jul 28, 2015

@elpaso

This comment has been minimized.

Copy link
Contributor

@elpaso elpaso replied Jul 28, 2015

That part of the cookbook is not specific to standalone (look at the bridge example at the end of the page), anyway maybe worth adding that new iface method to the cookbook (possibly with a short example).

Generally speaking, I believe that when something is added to iface or to the bindings, it should be documented in the cookbook.

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jul 28, 2015

I checked and the bridge example at the end of the page looks a bit odd to me.
A simple QgsProject.instance().read('test.qgs') works perfectly. fine, I don't see a reason why the bridge is required. (I left a comment there)

From my point of view:
The only reason for using an own bridge I have come across so far is for a standalone applicaiton.
Within the Qgis app it makes sense to use the one bridge which is created by Qgis itself (e.g. to synchronize the state between the layer rendering order widget and the map canvas layer rendering order).

@elpaso

This comment has been minimized.

Copy link
Contributor

@elpaso elpaso replied Jul 28, 2015

@m-kuhn , you are right, in master it's not needed, I don't remember if I added it while testing on an older version or if I messed up something while testing a long chain of commands.

Since you know very well how that part of the code works (or is supposed to work) It would be awesome if you could fix that part of the cookbook and add a short example/use case for the new iface.layerTreeCanvasBridge

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