Skip to content
Permalink
Browse files

add level and duration to message emitted

  • Loading branch information
3nids committed May 6, 2020
1 parent 5f50322 commit c6ee633b7d0d51edc71f70223ea56822a70d293d
@@ -323,7 +323,7 @@ displays.

signals:

void messageEmitted( const QString &message );
void messageEmitted( const QString &message, Qgis::MessageLevel level = Qgis::Info, int duration = 5 );
%Docstring
Emits a message than can be displayed to the user in a GUI class

@@ -292,7 +292,7 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
* Emits a message than can be displayed to the user in a GUI class
* \since QGIS 3.14
*/
void messageEmitted( const QString &message );
void messageEmitted( const QString &message, Qgis::MessageLevel level = Qgis::Info, int duration = 5 );

protected slots:
void nodeWillAddChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
@@ -80,7 +80,10 @@ void QgsLayerTreeView::setModel( QAbstractItemModel *model )
connect( model, &QAbstractItemModel::rowsRemoved, this, &QgsLayerTreeView::modelRowsRemoved );

if ( mMessageBar )
connect( layerTreeModel(), &QgsLayerTreeModel::messageEmitted, [ = ]( const QString & message ) {mMessageBar->pushMessage( message );} );
connect( layerTreeModel(), &QgsLayerTreeModel::messageEmitted,
[ = ]( const QString & message, Qgis::MessageLevel level = Qgis::Info, int duration = 5 )
{mMessageBar->pushMessage( message, level, duration );}
);

QTreeView::setModel( model );

@@ -503,7 +506,10 @@ void QgsLayerTreeView::setMessageBar( QgsMessageBar *messageBar )
mMessageBar = messageBar;

if ( mMessageBar )
connect( layerTreeModel(), &QgsLayerTreeModel::messageEmitted, [ = ]( const QString & message ) {mMessageBar->pushMessage( message );} );
connect( layerTreeModel(), &QgsLayerTreeModel::messageEmitted,
[ = ]( const QString & message, Qgis::MessageLevel level = Qgis::Info, int duration = 5 )
{mMessageBar->pushMessage( message, level, duration );}
);
}

void QgsLayerTreeView::mouseReleaseEvent( QMouseEvent *event )

0 comments on commit c6ee633

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