Skip to content
Permalink
Browse files

add logMessage method to locator filter (#7222)

to discourage from using Python print()
  • Loading branch information
3nids committed Jun 13, 2018
1 parent 494f7bc commit 3651df0727670cc51ed3e962d4186c189b152f24
@@ -241,6 +241,19 @@ custom configuration widget.
hasConfigWidget() must return true to indicate that the filter supports configuration.
%End

void logMessage( const QString &message, Qgis::MessageLevel level = Qgis::Info );
%Docstring
Logs a ``message`` to the log panel

.. warning::

in Python, do not use print() method as it might result in crashes
since fetching results does not happen in the main thread.

.. versionadded:: 3.2
%End


signals:

void finished();
@@ -20,6 +20,7 @@
#include "qgslocatorfilter.h"
#include "qgsstringutils.h"
#include "qgsfeedback.h"
#include "qgsmessagelog.h"


QgsLocatorFilter::QgsLocatorFilter( QObject *parent )
@@ -80,3 +81,8 @@ void QgsLocatorFilter::setActivePrefix( const QString &activePrefix )
mActivePrefifx = activePrefix;
}

void QgsLocatorFilter::logMessage( const QString &message, Qgis::MessageLevel level )
{
QgsMessageLog::logMessage( QString( "%1: %2" ).arg( name(), message ), QStringLiteral( "Locator bar" ), level );
}

@@ -271,6 +271,15 @@ class CORE_EXPORT QgsLocatorFilter : public QObject
*/
virtual void openConfigWidget( QWidget *parent = nullptr );

/**
* Logs a \a message to the log panel
* \warning in Python, do not use print() method as it might result in crashes
* since fetching results does not happen in the main thread.
* \since QGIS 3.2
*/
void logMessage( const QString &message, Qgis::MessageLevel level = Qgis::Info );


signals:

/**

0 comments on commit 3651df0

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