diff --git a/python/core/qgsattributeaction.sip b/python/core/qgsattributeaction.sip index 1198f264851..ccdf03c25cd 100644 --- a/python/core/qgsattributeaction.sip +++ b/python/core/qgsattributeaction.sip @@ -49,13 +49,12 @@ class QgsAttributeAction // dialog box. void addAction( QgsAction::ActionType type, QString name, QString action, bool capture = false ); -/* //! Does the action using the given values. defaultValueIndex is an // index into values which indicates which value in the values vector // is to be used if the action has a default placeholder. + // @note added to python API in 1.6 (without executePython parameter) void doAction( int index, const QList< QPair > &values, - int defaultValueIndex = 0, void *executePython = 0 ); - */ + int defaultValueIndex = 0 ); //! Removes all actions void clearActions(); diff --git a/src/app/attributetable/qgsattributetablemodel.cpp b/src/app/attributetable/qgsattributetablemodel.cpp index 3f157450546..0ff82b089b7 100644 --- a/src/app/attributetable/qgsattributetablemodel.cpp +++ b/src/app/attributetable/qgsattributetablemodel.cpp @@ -497,11 +497,6 @@ void QgsAttributeTableModel::incomingChangeLayout() emit layoutAboutToBeChanged(); } -static void _runPythonString( const QString &expr ) -{ - QgisApp::instance()->runPythonString( expr ); -} - void QgsAttributeTableModel::executeAction( int action, const QModelIndex &idx ) const { QList< QPair > attributes; @@ -514,5 +509,5 @@ void QgsAttributeTableModel::executeAction( int action, const QModelIndex &idx ) ); } - mLayer->actions()->doAction( action, attributes, fieldIdx( idx.column() ), _runPythonString ); + mLayer->actions()->doAction( action, attributes, fieldIdx( idx.column() ) ); } diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 2ecccdf22bd..550ec045b6c 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -159,6 +159,7 @@ #include "qgscredentialdialog.h" #include "qgstilescalewidget.h" #include "qgsquerybuilder.h" +#include "qgsattributeaction.h" #ifdef HAVE_QWT #include "qgsgpsinformationwidget.h" @@ -4939,6 +4940,11 @@ void QgisApp::showPluginManager() } } +static void _runPythonString( const QString &expr ) +{ + QgisApp::instance()->runPythonString( expr ); +} + void QgisApp::loadPythonSupport() { QString pythonlibName( "qgispython" ); @@ -4983,6 +4989,7 @@ void QgisApp::loadPythonSupport() if ( mPythonUtils && mPythonUtils->isEnabled() ) { QgsPluginRegistry::instance()->setPythonUtils( mPythonUtils ); + QgsAttributeAction::setPythonExecute( _runPythonString ); mActionShowPythonDialog = new QAction( tr( "Python Console" ), this ); QgsShortcutsManager::instance()->registerAction( mActionShowPythonDialog ); diff --git a/src/app/qgsidentifyresults.cpp b/src/app/qgsidentifyresults.cpp index 65f5bc6da50..c3de3612849 100644 --- a/src/app/qgsidentifyresults.cpp +++ b/src/app/qgsidentifyresults.cpp @@ -44,11 +44,6 @@ #include "qgslogger.h" -static void _runPythonString( const QString &expr ) -{ - QgisApp::instance()->runPythonString( expr ); -} - QgsFeatureAction::QgsFeatureAction( const QString &name, QgsIdentifyResults *results, QgsVectorLayer *vl, int action, QTreeWidgetItem *featItem ) : QAction( name, results ) , mLayer( vl ) @@ -60,7 +55,7 @@ QgsFeatureAction::QgsFeatureAction( const QString &name, QgsIdentifyResults *res void QgsFeatureAction::execute() { - mLayer->actions()->doAction( mAction, mAttributes, mIdx, _runPythonString ); + mLayer->actions()->doAction( mAction, mAttributes, mIdx ); } class QgsIdentifyResultsDock : public QDockWidget diff --git a/src/core/qgsattributeaction.cpp b/src/core/qgsattributeaction.cpp index eb5ab97fe82..ffaf6223069 100644 --- a/src/core/qgsattributeaction.cpp +++ b/src/core/qgsattributeaction.cpp @@ -68,6 +68,10 @@ void QgsAttributeAction::doAction( int index, const QList< QPair > &values, int defaultValueIndex = 0, void ( *executePython )( const QString & ) = 0 ); @@ -130,8 +132,11 @@ class CORE_EXPORT QgsAttributeAction QgsAction &at( int idx ) { return mActions[idx]; } QgsAction &operator[]( int idx ) { return mActions[idx]; } + static void setPythonExecute( void ( * )( const QString & ) ); + private: QList mActions; + static void ( *smPythonExecute )( const QString & ); }; #endif