Skip to content

Commit b056f53

Browse files
author
jef
committedNov 22, 2009

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed
 

‎src/app/qgsidentifyresults.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ static void _runPythonString( const QString &expr )
4949

5050
void 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

5758
class QgsIdentifyResultsDock : public QDockWidget
@@ -442,16 +443,17 @@ void QgsIdentifyResults::clearRubberBand()
442443

443444
void 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
{

‎src/app/qgsidentifyresults.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
101101
/* Item in tree was clicked */
102102
void itemClicked( QTreeWidgetItem *lvi, int column );
103103

104-
QTreeWidgetItem *retrieveAttributes( QTreeWidgetItem *item, QList< QPair<QString, QString> > &attributes );
104+
QTreeWidgetItem *retrieveAttributes( QTreeWidgetItem *item, QList< QPair<QString, QString> > &attributes, int &currentIdx );
105105

106106
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
107107

0 commit comments

Comments
 (0)
Please sign in to comment.