Skip to content

Commit

Permalink
Expose application browser model instance to iface
Browse files Browse the repository at this point in the history
Reusing the existing browser model is more efficient then reconstructing
new models, so it's useful for plugins to have access to this instance
too.
  • Loading branch information
nyalldawson committed Oct 16, 2018
1 parent e10736a commit 9050319
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
8 changes: 8 additions & 0 deletions python/gui/auto_generated/qgisinterface.sip.in
Expand Up @@ -1142,6 +1142,14 @@ is chosen. Dialog is shown only if global option is set accordingly.
:return: true if a datum transform has been specifically chosen by user or only one is available.

.. versionadded:: 3.0
%End

virtual QgsBrowserModel *browserModel() = 0;
%Docstring
Returns the application browser model. Using this shared model is more efficient than
creating a new browser model for every use.

.. versionadded:: 3.4
%End

signals:
Expand Down
7 changes: 6 additions & 1 deletion src/app/qgisappinterface.cpp
Expand Up @@ -792,5 +792,10 @@ bool QgisAppInterface::askForDatumTransform( QgsCoordinateReferenceSystem source

void QgisAppInterface::takeAppScreenShots( const QString &saveDirectory, const int categories )
{
return qgis->takeAppScreenShots( saveDirectory, categories );
qgis->takeAppScreenShots( saveDirectory, categories );
}

QgsBrowserModel *QgisAppInterface::browserModel()
{
return qgis->mBrowserModel;
}
1 change: 1 addition & 0 deletions src/app/qgisappinterface.h
Expand Up @@ -553,6 +553,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface

void takeAppScreenShots( const QString &saveDirectory, const int categories = 0 ) override;

QgsBrowserModel *browserModel() override;

private slots:

Expand Down
8 changes: 8 additions & 0 deletions src/gui/qgisinterface.h
Expand Up @@ -48,6 +48,7 @@ class QgsOptionsWidgetFactory;
class QgsLocatorFilter;
class QgsStatusBar;
class QgsMeshLayer;
class QgsBrowserModel;

#include <QObject>
#include <QFont>
Expand Down Expand Up @@ -937,6 +938,13 @@ class GUI_EXPORT QgisInterface : public QObject
*/
virtual bool askForDatumTransform( QgsCoordinateReferenceSystem sourceCrs, QgsCoordinateReferenceSystem destinationCrs ) = 0;

/**
* Returns the application browser model. Using this shared model is more efficient than
* creating a new browser model for every use.
* \since QGIS 3.4
*/
virtual QgsBrowserModel *browserModel() = 0;

signals:

/**
Expand Down

0 comments on commit 9050319

Please sign in to comment.