Skip to content
Permalink
Browse files

Get access to project from map layer

  • Loading branch information
m-kuhn committed Dec 22, 2020
1 parent 14a60c1 commit 6ddb13ac35e1520eaa8354dac53296f7163c7490
Showing with 19 additions and 0 deletions.
  1. +5 −0 python/core/auto_generated/qgsmaplayer.sip.in
  2. +9 −0 src/core/qgsmaplayer.cpp
  3. +5 −0 src/core/qgsmaplayer.h
@@ -1488,6 +1488,11 @@ Sets the coordinate transform context to ``transformContext``
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

QgsProject *project() const;
%Docstring
Returns the parent project if available.
%End

signals:

void beforeResolveReferences( QgsProject *project );
@@ -1981,6 +1981,15 @@ void QgsMapLayer::setRefreshOnNotifyEnabled( bool enabled )
mIsRefreshOnNofifyEnabled = enabled;
}

QgsProject *QgsMapLayer::project() const
{
if ( QgsMapLayerStore *store = qobject_cast<QgsMapLayerStore *>( parent() ) )
{
return qobject_cast<QgsProject *>( store->parent() );
}
return nullptr;
}

void QgsMapLayer::onNotifiedTriggerRepaint( const QString &message )
{
if ( refreshOnNotifyMessage().isEmpty() || refreshOnNotifyMessage() == message )
@@ -1335,6 +1335,11 @@ class CORE_EXPORT QgsMapLayer : public QObject
% End
#endif

/**
* Returns the parent project if available.
*/
QgsProject *project() const;

signals:

/**

0 comments on commit 6ddb13a

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