@@ -49,9 +49,10 @@ static void _runPythonString( const QString &expr )
49
49
50
50
void QgsFeatureAction::execute ()
51
51
{
52
+ int idx;
52
53
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 );
55
56
}
56
57
57
58
class QgsIdentifyResultsDock : public QDockWidget
@@ -442,16 +443,17 @@ void QgsIdentifyResults::clearRubberBand()
442
443
443
444
void QgsIdentifyResults::doAction ( QTreeWidgetItem *item, int action )
444
445
{
446
+ int idx;
445
447
QList< QPair<QString, QString> > attributes;
446
- QTreeWidgetItem *featItem = retrieveAttributes ( item, attributes );
448
+ QTreeWidgetItem *featItem = retrieveAttributes ( item, attributes, idx );
447
449
if ( !featItem )
448
450
return ;
449
451
450
452
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( featItem->parent ()->data ( 0 , Qt::UserRole ).value <QObject *>() );
451
453
if ( !layer )
452
454
return ;
453
455
454
- int idx = -1 ;
456
+ idx = -1 ;
455
457
if ( item->parent () == featItem )
456
458
{
457
459
QString fieldName = item->data ( 0 , Qt::DisplayRole ).toString ();
@@ -516,16 +518,20 @@ QgsVectorLayer *QgsIdentifyResults::vectorLayer( QTreeWidgetItem *item )
516
518
}
517
519
518
520
519
- QTreeWidgetItem *QgsIdentifyResults::retrieveAttributes ( QTreeWidgetItem *item, QList< QPair<QString, QString> > &attributes )
521
+ QTreeWidgetItem *QgsIdentifyResults::retrieveAttributes ( QTreeWidgetItem *item, QList< QPair<QString, QString> > &attributes, int &idx )
520
522
{
521
523
QTreeWidgetItem *featItem = featureItem ( item );
522
524
525
+ idx = -1 ;
526
+
523
527
attributes.clear ();
524
528
for ( int i = 0 ; i < featItem->childCount (); i++ )
525
529
{
526
530
QTreeWidgetItem *item = featItem->child ( i );
527
531
if ( item->childCount () > 0 )
528
532
continue ;
533
+ if ( item==lstResults->currentItem () )
534
+ idx = attributes.size ();
529
535
attributes << QPair<QString, QString>( item->data ( 0 , Qt::DisplayRole ).toString (), item->data ( 1 , Qt::DisplayRole ).toString () );
530
536
}
531
537
@@ -785,8 +791,9 @@ void QgsIdentifyResults::copyFeatureAttributes()
785
791
QClipboard *clipboard = QApplication::clipboard ();
786
792
QString text;
787
793
794
+ int idx;
788
795
QList< QPair<QString, QString> > attributes;
789
- retrieveAttributes ( lstResults->currentItem (), attributes );
796
+ retrieveAttributes ( lstResults->currentItem (), attributes, idx );
790
797
791
798
for ( QList< QPair<QString, QString> >::iterator it = attributes.begin (); it != attributes.end (); it++ )
792
799
{
0 commit comments