[QGIS Commit] r14010 - in trunk/qgis: python/core src/app
src/app/attributetable src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Aug 4 12:57:52 EDT 2010
Author: jef
Date: 2010-08-04 16:57:52 +0000 (Wed, 04 Aug 2010)
New Revision: 14010
Modified:
trunk/qgis/python/core/qgsattributeaction.sip
trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
trunk/qgis/src/app/qgisapp.cpp
trunk/qgis/src/app/qgsidentifyresults.cpp
trunk/qgis/src/core/qgsattributeaction.cpp
trunk/qgis/src/core/qgsattributeaction.h
Log:
add QgsAttributeAction::doAction to python bindings
Modified: trunk/qgis/python/core/qgsattributeaction.sip
===================================================================
--- trunk/qgis/python/core/qgsattributeaction.sip 2010-08-04 15:45:39 UTC (rev 14009)
+++ trunk/qgis/python/core/qgsattributeaction.sip 2010-08-04 16:57:52 UTC (rev 14010)
@@ -49,13 +49,12 @@
// 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<QString, QString> > &values,
- int defaultValueIndex = 0, void *executePython = 0 );
- */
+ int defaultValueIndex = 0 );
//! Removes all actions
void clearActions();
Modified: trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp 2010-08-04 15:45:39 UTC (rev 14009)
+++ trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp 2010-08-04 16:57:52 UTC (rev 14010)
@@ -497,11 +497,6 @@
emit layoutAboutToBeChanged();
}
-static void _runPythonString( const QString &expr )
-{
- QgisApp::instance()->runPythonString( expr );
-}
-
void QgsAttributeTableModel::executeAction( int action, const QModelIndex &idx ) const
{
QList< QPair<QString, QString> > attributes;
@@ -514,5 +509,5 @@
);
}
- mLayer->actions()->doAction( action, attributes, fieldIdx( idx.column() ), _runPythonString );
+ mLayer->actions()->doAction( action, attributes, fieldIdx( idx.column() ) );
}
Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp 2010-08-04 15:45:39 UTC (rev 14009)
+++ trunk/qgis/src/app/qgisapp.cpp 2010-08-04 16:57:52 UTC (rev 14010)
@@ -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 @@
}
}
+static void _runPythonString( const QString &expr )
+{
+ QgisApp::instance()->runPythonString( expr );
+}
+
void QgisApp::loadPythonSupport()
{
QString pythonlibName( "qgispython" );
@@ -4983,6 +4989,7 @@
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
QgsPluginRegistry::instance()->setPythonUtils( mPythonUtils );
+ QgsAttributeAction::setPythonExecute( _runPythonString );
mActionShowPythonDialog = new QAction( tr( "Python Console" ), this );
QgsShortcutsManager::instance()->registerAction( mActionShowPythonDialog );
Modified: trunk/qgis/src/app/qgsidentifyresults.cpp
===================================================================
--- trunk/qgis/src/app/qgsidentifyresults.cpp 2010-08-04 15:45:39 UTC (rev 14009)
+++ trunk/qgis/src/app/qgsidentifyresults.cpp 2010-08-04 16:57:52 UTC (rev 14010)
@@ -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 @@
void QgsFeatureAction::execute()
{
- mLayer->actions()->doAction( mAction, mAttributes, mIdx, _runPythonString );
+ mLayer->actions()->doAction( mAction, mAttributes, mIdx );
}
class QgsIdentifyResultsDock : public QDockWidget
Modified: trunk/qgis/src/core/qgsattributeaction.cpp
===================================================================
--- trunk/qgis/src/core/qgsattributeaction.cpp 2010-08-04 15:45:39 UTC (rev 14009)
+++ trunk/qgis/src/core/qgsattributeaction.cpp 2010-08-04 16:57:52 UTC (rev 14010)
@@ -68,6 +68,10 @@
{
executePython( expandedAction );
}
+ else if ( smPythonExecute )
+ {
+ smPythonExecute( expandedAction );
+ }
}
else
{
@@ -151,3 +155,9 @@
return true;
}
+void ( *QgsAttributeAction::smPythonExecute )( const QString & ) = 0;
+
+void QgsAttributeAction::setPythonExecute( void ( *runPython )( const QString & ) )
+{
+ smPythonExecute = runPython;
+}
Modified: trunk/qgis/src/core/qgsattributeaction.h
===================================================================
--- trunk/qgis/src/core/qgsattributeaction.h 2010-08-04 15:45:39 UTC (rev 14009)
+++ trunk/qgis/src/core/qgsattributeaction.h 2010-08-04 16:57:52 UTC (rev 14010)
@@ -32,6 +32,7 @@
class QDomNode;
class QDomDocument;
+class QgsPythonUtils;
/** \ingroup core
* Utility class that encapsulates an action based on vector attributes.
@@ -109,6 +110,7 @@
//! 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 parameter executePython deprecated (and missing in python binding)
void doAction( int index, const QList< QPair<QString, QString> > &values,
int defaultValueIndex = 0, void ( *executePython )( const QString & ) = 0 );
@@ -130,8 +132,11 @@
QgsAction &at( int idx ) { return mActions[idx]; }
QgsAction &operator[]( int idx ) { return mActions[idx]; }
+ static void setPythonExecute( void ( * )( const QString & ) );
+
private:
QList<QgsAction> mActions;
+ static void ( *smPythonExecute )( const QString & );
};
#endif
More information about the QGIS-commit
mailing list