@@ -141,7 +141,7 @@ void QgsAttributeActionDialog::insertRow( int row, const QgsAction &action )
141
141
142
142
// Icon
143
143
QIcon icon = action.icon ();
144
- QTableWidgetItem *headerItem = new QTableWidgetItem ( icon, QLatin1String ( " " ) );
144
+ QTableWidgetItem *headerItem = new QTableWidgetItem ( icon, QString ( ) );
145
145
headerItem->setData ( Qt::UserRole, action.iconPath () );
146
146
mAttributeActionTable ->setVerticalHeaderItem ( row, headerItem );
147
147
@@ -312,15 +312,15 @@ void QgsAttributeActionDialog::updateButtons()
312
312
void QgsAttributeActionDialog::addDefaultActions ()
313
313
{
314
314
int pos = 0 ;
315
- insertRow ( pos++, QgsAction::Generic, tr ( " Echo attribute's value" ), QStringLiteral ( " echo \" [% \" MY_FIELD\" %]\" " ), QLatin1String ( " " ), true , tr ( " Attribute Value" ), QSet<QString>() << QStringLiteral ( " Field" ), QString () );
316
- insertRow ( pos++, QgsAction::Generic, tr ( " Run an application" ), QStringLiteral ( " ogr2ogr -f \" GPKG\" \" [% \" OUTPUT_PATH\" %]\" \" [% \" INPUT_FILE\" %]\" " ), QLatin1String ( " " ), true , tr ( " Run application" ), QSet<QString>() << QStringLiteral ( " Feature" ) << QStringLiteral ( " Canvas" ), QString () );
317
- insertRow ( pos++, QgsAction::GenericPython, tr ( " Get feature id" ), QStringLiteral ( " from qgis.PyQt import QtWidgets\n\n QtWidgets.QMessageBox.information(None, \" Feature id\" , \" feature id is [% $id %]\" )" ), QLatin1String ( " " ), false , tr ( " Feature ID" ), QSet<QString>() << QStringLiteral ( " Feature" ) << QStringLiteral ( " Canvas" ), QString () );
318
- insertRow ( pos++, QgsAction::GenericPython, tr ( " Selected field's value (Identify features tool)" ), QStringLiteral ( " from qgis.PyQt import QtWidgets\n\n QtWidgets.QMessageBox.information(None, \" Current field's value\" , \" [% @current_field %]\" )" ), QLatin1String ( " " ), false , tr ( " Field Value" ), QSet<QString>() << QStringLiteral ( " Field" ), QString () );
319
- insertRow ( pos++, QgsAction::GenericPython, tr ( " Clicked coordinates (Run feature actions tool)" ), QStringLiteral ( " from qgis.PyQt import QtWidgets\n\n QtWidgets.QMessageBox.information(None, \" Clicked coords\" , \" layer: [% @layer_id %]\\ ncoords: ([% @click_x %],[% @click_y %])\" )" ), QLatin1String ( " " ), false , tr ( " Clicked Coordinate" ), QSet<QString>() << QStringLiteral ( " Canvas" ), QString () );
320
- insertRow ( pos++, QgsAction::OpenUrl, tr ( " Open file" ), QStringLiteral ( " [% \" PATH\" %]" ), QLatin1String ( " " ), false , tr ( " Open file" ), QSet<QString>() << QStringLiteral ( " Feature" ) << QStringLiteral ( " Canvas" ), QString () );
321
- insertRow ( pos++, QgsAction::OpenUrl, tr ( " Search on web based on attribute's value" ), QStringLiteral ( " http://www.google.com/search?q=[% \" ATTRIBUTE\" %]" ), QLatin1String ( " " ), false , tr ( " Search Web" ), QSet<QString>() << QStringLiteral ( " Field" ), QString () );
322
- insertRow ( pos++, QgsAction::GenericPython, tr ( " List feature ids" ), QStringLiteral ( " from qgis.PyQt import QtWidgets\n\n layer = QgsProject.instance().mapLayer('[% @layer_id %]')\n if layer.selectedFeatureCount():\n ids = layer.selectedFeatureIds()\n else:\n ids = [f.id() for f in layer.getFeatures()]\n\n QtWidgets.QMessageBox.information(None, \" Feature ids\" , ', '.join([str(id) for id in ids]))" ), QLatin1String ( " " ), false , tr ( " List feature ids" ), QSet<QString>() << QStringLiteral ( " Layer" ), QString () );
323
- insertRow( pos++, QgsAction::GenericPython, tr( "Duplicate selected features" ), QStringLiteral( "project = QgsProject.instance()\nlayer = QgsProject.instance().mapLayer('[% @layer_id %]')\nif not layer.isEditable():\n qgis.utils.iface.messageBar().pushMessage( 'Cannot duplicate feature in not editable mode on layer {layer}'.format( layer=layer.name() ) )\nelse:\n features=[]\n if len('[% $id %]')>0:\n features.append( layer.getFeature( [% $id %] ) )\n else:\n for x in layer.selectedFeatures():\n features.append( x )\n feature_count=0\n children_info=''\n featureids=[]\n for f in features:\n result=QgsVectorLayerUtils.duplicateFeature(layer, f, project, 0 )\n featureids.append( result[0].id() )\n feature_count+=1\n for ch_layer in result[1].layers():\n children_info+='{number_of_children} children on layer {children_layer}\\n'.format( number_of_children=str( len( result[1].duplicatedFeatures(ch_layer) ) ), children_layer=ch_layer.name() )\n ch_layer.selectByIds( result[1].duplicatedFeatures(ch_layer) )\n layer.selectByIds( featureids )\n qgis.utils.iface.messageBar().pushMessage( '{number_of_features} features on layer {layer} duplicated with\\n{children_info}'.format( number_of_features=str( feature_count ), layer=layer.name(), children_info=children_info ) )" ), QLatin1String( "" ), false, tr( "Duplicate selected" ), QSet<QString>() << QStringLiteral( "Layer" ), QString(), true );
315
+ insertRow ( pos++, QgsAction::Generic, tr ( " Echo attribute's value" ), QStringLiteral ( " echo \" [% \" MY_FIELD\" %]\" " ), QString ( ), true , tr ( " Attribute Value" ), QSet<QString>() << QStringLiteral ( " Field" ), QString () );
316
+ insertRow ( pos++, QgsAction::Generic, tr ( " Run an application" ), QStringLiteral ( " ogr2ogr -f \" GPKG\" \" [% \" OUTPUT_PATH\" %]\" \" [% \" INPUT_FILE\" %]\" " ), QString ( ), true , tr ( " Run application" ), QSet<QString>() << QStringLiteral ( " Feature" ) << QStringLiteral ( " Canvas" ), QString () );
317
+ insertRow ( pos++, QgsAction::GenericPython, tr ( " Get feature id" ), QStringLiteral ( " from qgis.PyQt import QtWidgets\n\n QtWidgets.QMessageBox.information(None, \" Feature id\" , \" feature id is [% $id %]\" )" ), QString ( ), false , tr ( " Feature ID" ), QSet<QString>() << QStringLiteral ( " Feature" ) << QStringLiteral ( " Canvas" ), QString () );
318
+ insertRow ( pos++, QgsAction::GenericPython, tr ( " Selected field's value (Identify features tool)" ), QStringLiteral ( " from qgis.PyQt import QtWidgets\n\n QtWidgets.QMessageBox.information(None, \" Current field's value\" , \" [% @current_field %]\" )" ), QString ( ), false , tr ( " Field Value" ), QSet<QString>() << QStringLiteral ( " Field" ), QString () );
319
+ insertRow ( pos++, QgsAction::GenericPython, tr ( " Clicked coordinates (Run feature actions tool)" ), QStringLiteral ( " from qgis.PyQt import QtWidgets\n\n QtWidgets.QMessageBox.information(None, \" Clicked coords\" , \" layer: [% @layer_id %]\\ ncoords: ([% @click_x %],[% @click_y %])\" )" ), QString ( ), false , tr ( " Clicked Coordinate" ), QSet<QString>() << QStringLiteral ( " Canvas" ), QString () );
320
+ insertRow ( pos++, QgsAction::OpenUrl, tr ( " Open file" ), QStringLiteral ( " [% \" PATH\" %]" ), QString ( ), false , tr ( " Open file" ), QSet<QString>() << QStringLiteral ( " Feature" ) << QStringLiteral ( " Canvas" ), QString () );
321
+ insertRow ( pos++, QgsAction::OpenUrl, tr ( " Search on web based on attribute's value" ), QStringLiteral ( " http://www.google.com/search?q=[% \" ATTRIBUTE\" %]" ), QString ( ), false , tr ( " Search Web" ), QSet<QString>() << QStringLiteral ( " Field" ), QString () );
322
+ insertRow ( pos++, QgsAction::GenericPython, tr ( " List feature ids" ), QStringLiteral ( " from qgis.PyQt import QtWidgets\n\n layer = QgsProject.instance().mapLayer('[% @layer_id %]')\n if layer.selectedFeatureCount():\n ids = layer.selectedFeatureIds()\n else:\n ids = [f.id() for f in layer.getFeatures()]\n\n QtWidgets.QMessageBox.information(None, \" Feature ids\" , ', '.join([str(id) for id in ids]))" ), QString ( ), false , tr ( " List feature ids" ), QSet<QString>() << QStringLiteral ( " Layer" ), QString () );
323
+ insertRow( pos++, QgsAction::GenericPython, tr( "Duplicate selected features" ), QStringLiteral( "project = QgsProject.instance()\nlayer = QgsProject.instance().mapLayer('[% @layer_id %]')\nif not layer.isEditable():\n qgis.utils.iface.messageBar().pushMessage( 'Cannot duplicate feature in not editable mode on layer {layer}'.format( layer=layer.name() ) )\nelse:\n features=[]\n if len('[% $id %]')>0:\n features.append( layer.getFeature( [% $id %] ) )\n else:\n for x in layer.selectedFeatures():\n features.append( x )\n feature_count=0\n children_info=''\n featureids=[]\n for f in features:\n result=QgsVectorLayerUtils.duplicateFeature(layer, f, project, 0 )\n featureids.append( result[0].id() )\n feature_count+=1\n for ch_layer in result[1].layers():\n children_info+='{number_of_children} children on layer {children_layer}\\n'.format( number_of_children=str( len( result[1].duplicatedFeatures(ch_layer) ) ), children_layer=ch_layer.name() )\n ch_layer.selectByIds( result[1].duplicatedFeatures(ch_layer) )\n layer.selectByIds( featureids )\n qgis.utils.iface.messageBar().pushMessage( '{number_of_features} features on layer {layer} duplicated with\\n{children_info}'.format( number_of_features=str( feature_count ), layer=layer.name(), children_info=children_info ) )" ), QString(), false, tr( "Duplicate selected" ), QSet<QString>() << QStringLiteral( "Layer" ), QString(), true );
324
324
325
325
}
326
326
0 commit comments