Skip to content

Commit

Permalink
fix #2138
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12225 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 22, 2009
1 parent 7f287d8 commit b056f53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/app/qgsidentifyresults.cpp
Expand Up @@ -49,9 +49,10 @@ static void _runPythonString( const QString &expr )

void QgsFeatureAction::execute()
{
int idx;
QList< QPair<QString, QString> > attributes;
mResults->retrieveAttributes( mFeatItem, attributes );
mLayer->actions()->doAction( mAction, attributes, 0, _runPythonString );
mResults->retrieveAttributes( mFeatItem, attributes, idx );
mLayer->actions()->doAction( mAction, attributes, idx, _runPythonString );
}

class QgsIdentifyResultsDock : public QDockWidget
Expand Down Expand Up @@ -442,16 +443,17 @@ void QgsIdentifyResults::clearRubberBand()

void QgsIdentifyResults::doAction( QTreeWidgetItem *item, int action )
{
int idx;
QList< QPair<QString, QString> > attributes;
QTreeWidgetItem *featItem = retrieveAttributes( item, attributes );
QTreeWidgetItem *featItem = retrieveAttributes( item, attributes, idx );
if ( !featItem )
return;

QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( featItem->parent()->data( 0, Qt::UserRole ).value<QObject *>() );
if ( !layer )
return;

int idx = -1;
idx = -1;
if ( item->parent() == featItem )
{
QString fieldName = item->data( 0, Qt::DisplayRole ).toString();
Expand Down Expand Up @@ -516,16 +518,20 @@ QgsVectorLayer *QgsIdentifyResults::vectorLayer( QTreeWidgetItem *item )
}


QTreeWidgetItem *QgsIdentifyResults::retrieveAttributes( QTreeWidgetItem *item, QList< QPair<QString, QString> > &attributes )
QTreeWidgetItem *QgsIdentifyResults::retrieveAttributes( QTreeWidgetItem *item, QList< QPair<QString, QString> > &attributes, int &idx )
{
QTreeWidgetItem *featItem = featureItem( item );

idx = -1;

attributes.clear();
for ( int i = 0; i < featItem->childCount(); i++ )
{
QTreeWidgetItem *item = featItem->child( i );
if ( item->childCount() > 0 )
continue;
if( item==lstResults->currentItem() )
idx = attributes.size();
attributes << QPair<QString, QString>( item->data( 0, Qt::DisplayRole ).toString(), item->data( 1, Qt::DisplayRole ).toString() );
}

Expand Down Expand Up @@ -785,8 +791,9 @@ void QgsIdentifyResults::copyFeatureAttributes()
QClipboard *clipboard = QApplication::clipboard();
QString text;

int idx;
QList< QPair<QString, QString> > attributes;
retrieveAttributes( lstResults->currentItem(), attributes );
retrieveAttributes( lstResults->currentItem(), attributes, idx );

for ( QList< QPair<QString, QString> >::iterator it = attributes.begin(); it != attributes.end(); it++ )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsidentifyresults.h
Expand Up @@ -101,7 +101,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
/* Item in tree was clicked */
void itemClicked( QTreeWidgetItem *lvi, int column );

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

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

Expand Down

0 comments on commit b056f53

Please sign in to comment.