mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
[FEATURE] allow multiline feature actions
This commit is contained in:
parent
f9ed6d4dd0
commit
dfd8b81857
@ -4838,7 +4838,7 @@ class QgsPythonRunnerImpl : public QgsPythonRunner
|
||||
{
|
||||
if ( mPythonUtils && mPythonUtils->isEnabled() )
|
||||
{
|
||||
return mPythonUtils->runString( command, messageOnError );
|
||||
return mPythonUtils->runString( command, messageOnError, false );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ QgsAttributeActionDialog::QgsAttributeActionDialog( QgsAttributeAction* actions,
|
||||
connect( attributeActionTable, SIGNAL( itemSelectionChanged() ),
|
||||
this, SLOT( itemSelectionChanged() ) );
|
||||
connect( actionName, SIGNAL( textChanged( QString ) ), this, SLOT( updateButtons() ) );
|
||||
connect( actionAction, SIGNAL( textChanged( QString ) ), this, SLOT( updateButtons() ) );
|
||||
connect( actionAction, SIGNAL( textChanged() ), this, SLOT( updateButtons() ) );
|
||||
|
||||
connect( moveUpButton, SIGNAL( clicked() ), this, SLOT( moveUp() ) );
|
||||
connect( moveDownButton, SIGNAL( clicked() ), this, SLOT( moveDown() ) );
|
||||
@ -159,16 +159,16 @@ void QgsAttributeActionDialog::browse()
|
||||
this, tr( "Select an action", "File dialog window title" ) );
|
||||
|
||||
if ( !action.isNull() )
|
||||
actionAction->insert( action );
|
||||
actionAction->insertPlainText( action );
|
||||
}
|
||||
|
||||
void QgsAttributeActionDialog::insertExpression()
|
||||
{
|
||||
QString selText = actionAction->selectedText();
|
||||
QString selText = actionAction->textCursor().selectedText();
|
||||
|
||||
// edit the selected expression if there's one
|
||||
if ( selText.startsWith( "[%" ) && selText.endsWith( "%]" ) )
|
||||
selText = selText.mid( 2, selText.size() - 3 );
|
||||
selText = selText.mid( 2, selText.size() - 4 );
|
||||
|
||||
// display the expression builder
|
||||
QgsExpressionBuilderDialog dlg( mActions->layer(), selText, this );
|
||||
@ -179,7 +179,7 @@ void QgsAttributeActionDialog::insertExpression()
|
||||
//Only add the expression if the user has entered some text.
|
||||
if ( !expression.isEmpty() )
|
||||
{
|
||||
actionAction->insert( "[%" + expression + "%]" );
|
||||
actionAction->insertPlainText( "[%" + expression + "%]" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,7 +214,7 @@ void QgsAttributeActionDialog::insert( int pos )
|
||||
// Check to see if the action name and the action have been specified
|
||||
// before proceeding
|
||||
|
||||
if ( actionName->text().isEmpty() || actionAction->text().isEmpty() )
|
||||
if ( actionName->text().isEmpty() || actionAction->toPlainText().isEmpty() )
|
||||
{
|
||||
QMessageBox::warning( this, tr( "Missing Information" ),
|
||||
tr( "To create an attribute action, you must provide both a name and the action to perform." ) );
|
||||
@ -240,14 +240,14 @@ void QgsAttributeActionDialog::insert( int pos )
|
||||
if ( pos >= numRows )
|
||||
{
|
||||
// Expand the table to have a row with index pos
|
||||
insertRow( pos, ( QgsAction::ActionType ) actionType->currentIndex(), name, actionAction->text(), captureCB->isChecked() );
|
||||
insertRow( pos, ( QgsAction::ActionType ) actionType->currentIndex(), name, actionAction->toPlainText(), captureCB->isChecked() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update existing row
|
||||
attributeActionTable->item( pos, 0 )->setText( actionType->currentText() );
|
||||
attributeActionTable->item( pos, 1 )->setText( name );
|
||||
attributeActionTable->item( pos, 2 )->setText( actionAction->text() );
|
||||
attributeActionTable->item( pos, 2 )->setText( actionAction->toPlainText() );
|
||||
attributeActionTable->item( pos, 3 )->setCheckState( captureCB->isChecked() ? Qt::Checked : Qt::Unchecked );
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@ void QgsAttributeActionDialog::update()
|
||||
|
||||
void QgsAttributeActionDialog::updateButtons()
|
||||
{
|
||||
bool validNewAction = !actionName->text().isEmpty() && !actionAction->text().isEmpty();
|
||||
bool validNewAction = !actionName->text().isEmpty() && !actionAction->toPlainText().isEmpty();
|
||||
|
||||
QList<QTableWidgetItem *> selection = attributeActionTable->selectedItems();
|
||||
bool hasSelection = !selection.isEmpty();
|
||||
@ -299,7 +299,7 @@ void QgsAttributeActionDialog::insertField()
|
||||
QString field = "[% \"";
|
||||
field += fieldComboBox->currentText();
|
||||
field += "\" %]";
|
||||
actionAction->insert( field );
|
||||
actionAction->insertPlainText( field );
|
||||
}
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ void QgsAttributeActionDialog::rowSelected( int row )
|
||||
// Only if a populated row was selected
|
||||
actionType->setCurrentIndex( actionType->findText( attributeActionTable->item( row, 0 )->text() ) );
|
||||
actionName->setText( attributeActionTable->item( row, 1 )->text() );
|
||||
actionAction->setText( attributeActionTable->item( row, 2 )->text() );
|
||||
actionAction->setPlainText( attributeActionTable->item( row, 2 )->text() );
|
||||
captureCB->setChecked( attributeActionTable->item( row, 3 )->checkState() == Qt::Checked );
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ void QgsAttributeAction::runAction( const QgsAction &action, void ( *executePyth
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: capture output from QgsPythonRunner
|
||||
// TODO: capture output from QgsPythonRunner (like QgsRunProcess does)
|
||||
QgsPythonRunner::run( action.action() );
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class PYTHON_EXPORT QgsPythonUtils
|
||||
|
||||
//! run a statement, show an error message on error
|
||||
//! @return true if no error occured
|
||||
virtual bool runString( const QString& command, QString msgOnError = QString() ) = 0;
|
||||
virtual bool runString( const QString& command, QString msgOnError = QString(), bool single = true ) = 0;
|
||||
|
||||
//! run a statement, error reporting is not done
|
||||
//! @return true if no error occured
|
||||
|
@ -172,9 +172,9 @@ bool QgsPythonUtilsImpl::runStringUnsafe( const QString& command, bool single )
|
||||
return res;
|
||||
}
|
||||
|
||||
bool QgsPythonUtilsImpl::runString( const QString& command, QString msgOnError )
|
||||
bool QgsPythonUtilsImpl::runString( const QString& command, QString msgOnError, bool single )
|
||||
{
|
||||
bool res = runStringUnsafe( command );
|
||||
bool res = runStringUnsafe( command, single );
|
||||
if ( res )
|
||||
return true;
|
||||
|
||||
|
@ -52,7 +52,7 @@ class QgsPythonUtilsImpl : public QgsPythonUtils
|
||||
//! this command is more advanced as enables error checking etc.
|
||||
//! when an exception is raised, it shows dialog with exception details
|
||||
//! @return true if no error occured
|
||||
bool runString( const QString& command, QString msgOnError = QString() );
|
||||
bool runString( const QString& command, QString msgOnError = QString(), bool single = true );
|
||||
|
||||
//! run a statement, error reporting is not done
|
||||
//! @return true if no error occured
|
||||
|
@ -236,12 +236,18 @@
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="actionAction">
|
||||
<widget class="QPlainTextEdit" name="actionAction">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enter the action command here</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Enter the action here. This can be any program, script or command that is available on your system. When the action is invoked any set of characters that start with a % and then have the name of a field will be replaced by the value of that field. The special characters %% will be replaced by the value of the field that was selected. Double quote marks group text into single arguments to the program, script or command. Double quotes will be ignored if prefixed with a backslash</string>
|
||||
<string>Enter the action here. This can be any program, script or command that is available on your system. When the action is invoked any set of characters within [% and %] will be evaluated as expression and replaced by its result. Double quote marks group text into single arguments to the program, script or command. Double quotes will be ignored if prefixed with a backslash</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -380,14 +386,19 @@
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<tabstops>
|
||||
<tabstop>attributeActionTable</tabstop>
|
||||
<tabstop>moveUpButton</tabstop>
|
||||
<tabstop>moveDownButton</tabstop>
|
||||
<tabstop>removeButton</tabstop>
|
||||
<tabstop>actionType</tabstop>
|
||||
<tabstop>captureCB</tabstop>
|
||||
<tabstop>actionName</tabstop>
|
||||
<tabstop>actionAction</tabstop>
|
||||
<tabstop>browseButton</tabstop>
|
||||
<tabstop>captureCB</tabstop>
|
||||
<tabstop>insertExpressionButton</tabstop>
|
||||
<tabstop>fieldComboBox</tabstop>
|
||||
<tabstop>insertFieldButton</tabstop>
|
||||
<tabstop>insertButton</tabstop>
|
||||
<tabstop>updateButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user