int MItem::expandAction( const WString& actionName, WString& command ) { WVList actions; addActions( actions ); for( int i=0; i<actions.count(); i++ ) { MAction* action = (MAction*)actions[i]; if( action->name().match( actionName ) ) { return( expandAction( action, command ) ); } } return( -1 ); }
void QgsAttributeAction::doAction( int index, const QgsAttributeMap &attributes, int defaultValueIndex, void ( *executePython )( const QString & ) ) { if ( index < 0 || index >= size() ) return; const QgsAction &action = at( index ); if ( !action.runable() ) return; // A couple of extra options for running the action may be // useful. For example, // - run the action inside a terminal (on unix) // - capture the stdout from the process and display in a dialog // box // // The capture stdout one is partially implemented. It just needs // the UI and the code in this function to select on the // action.capture() return value. // The QgsRunProcess instance created by this static function // deletes itself when no longer needed. QString expandedAction = expandAction( action.action(), attributes, defaultValueIndex ); if ( action.type() == QgsAction::GenericPython ) { if ( executePython ) { executePython( expandedAction ); } else if ( smPythonExecute ) { smPythonExecute( expandedAction ); } } else { QgsRunProcess::create( expandedAction, action.capture() ); } }