@@ -49,9 +49,10 @@ static void _runPythonString( const QString &expr )
4949
5050void QgsFeatureAction::execute ()
5151{
52+ int idx;
5253 QList< QPair<QString, QString> > attributes;
53- mResults ->retrieveAttributes ( mFeatItem , attributes );
54- mLayer ->actions ()->doAction ( mAction , attributes, 0 , _runPythonString );
54+ mResults ->retrieveAttributes ( mFeatItem , attributes, idx );
55+ mLayer ->actions ()->doAction ( mAction , attributes, idx , _runPythonString );
5556}
5657
5758class QgsIdentifyResultsDock : public QDockWidget
@@ -442,16 +443,17 @@ void QgsIdentifyResults::clearRubberBand()
442443
443444void QgsIdentifyResults::doAction ( QTreeWidgetItem *item, int action )
444445{
446+ int idx;
445447 QList< QPair<QString, QString> > attributes;
446- QTreeWidgetItem *featItem = retrieveAttributes ( item, attributes );
448+ QTreeWidgetItem *featItem = retrieveAttributes ( item, attributes, idx );
447449 if ( !featItem )
448450 return ;
449451
450452 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( featItem->parent ()->data ( 0 , Qt::UserRole ).value <QObject *>() );
451453 if ( !layer )
452454 return ;
453455
454- int idx = -1 ;
456+ idx = -1 ;
455457 if ( item->parent () == featItem )
456458 {
457459 QString fieldName = item->data ( 0 , Qt::DisplayRole ).toString ();
@@ -516,16 +518,20 @@ QgsVectorLayer *QgsIdentifyResults::vectorLayer( QTreeWidgetItem *item )
516518}
517519
518520
519- QTreeWidgetItem *QgsIdentifyResults::retrieveAttributes ( QTreeWidgetItem *item, QList< QPair<QString, QString> > &attributes )
521+ QTreeWidgetItem *QgsIdentifyResults::retrieveAttributes ( QTreeWidgetItem *item, QList< QPair<QString, QString> > &attributes, int &idx )
520522{
521523 QTreeWidgetItem *featItem = featureItem ( item );
522524
525+ idx = -1 ;
526+
523527 attributes.clear ();
524528 for ( int i = 0 ; i < featItem->childCount (); i++ )
525529 {
526530 QTreeWidgetItem *item = featItem->child ( i );
527531 if ( item->childCount () > 0 )
528532 continue ;
533+ if ( item==lstResults->currentItem () )
534+ idx = attributes.size ();
529535 attributes << QPair<QString, QString>( item->data ( 0 , Qt::DisplayRole ).toString (), item->data ( 1 , Qt::DisplayRole ).toString () );
530536 }
531537
@@ -785,8 +791,9 @@ void QgsIdentifyResults::copyFeatureAttributes()
785791 QClipboard *clipboard = QApplication::clipboard ();
786792 QString text;
787793
794+ int idx;
788795 QList< QPair<QString, QString> > attributes;
789- retrieveAttributes ( lstResults->currentItem (), attributes );
796+ retrieveAttributes ( lstResults->currentItem (), attributes, idx );
790797
791798 for ( QList< QPair<QString, QString> >::iterator it = attributes.begin (); it != attributes.end (); it++ )
792799 {
0 commit comments