Skip to content

Commit

Permalink
fix #2682
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13469 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 12, 2010
1 parent 72d2f43 commit 2e41442
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/app/qgsidentifyresults.cpp
Expand Up @@ -378,7 +378,10 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
QTreeWidgetItem *featItem = featureItem( item );
if ( featItem )
{
mActionPopup->addAction( vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ), this, SLOT( featureForm() ) );
mActionPopup->addAction(
QgisApp::getThemeIcon( vlayer->isEditable() ? "/mIconEditable.png" : "/mIconEditable.png" ),
vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ),
this, SLOT( featureForm() ) );
mActionPopup->addAction( tr( "Zoom to feature" ), this, SLOT( zoomToFeature() ) );
mActionPopup->addAction( tr( "Copy attribute value" ), this, SLOT( copyAttributeValue() ) );
mActionPopup->addAction( tr( "Copy feature attributes" ), this, SLOT( copyFeatureAttributes() ) );
Expand All @@ -393,26 +396,23 @@ void QgsIdentifyResults::contextMenuEvent( QContextMenuEvent* event )
mActionPopup->addAction( tr( "Expand all" ), this, SLOT( expandAll() ) );
mActionPopup->addAction( tr( "Collapse all" ), this, SLOT( collapseAll() ) );

if ( vlayer->actions()->size() > 0 )
if ( featItem && vlayer->actions()->size() > 0 )
{
mActionPopup->addSeparator();

// The assumption is made that an instance of QgsIdentifyResults is
// created for each new Identify Results dialog box, and that the
// contents of the popup menu doesn't change during the time that
// such a dialog box is around.
QAction *a = mActionPopup->addAction( tr( "Run action" ) );
a->setEnabled( false );

for ( int i = 0; i < vlayer->actions()->size(); i++ )
{
const QgsAction &action = vlayer->actions()->at( i );

if ( !action.runable() )
continue;

QgsFeatureAction *a = new QgsFeatureAction( action.name(), this, vlayer, i, featureItem( item ) );
mActionPopup->addAction( action.name(), a, SLOT( execute() ) );
QgsFeatureAction *a = new QgsFeatureAction( action.name(), this, vlayer, i, featItem );
mActionPopup->addAction( QgisApp::getThemeIcon( "/mAction.png" ), action.name(), a, SLOT( execute() ) );
}
}

Expand Down Expand Up @@ -525,6 +525,9 @@ void QgsIdentifyResults::doAction( QTreeWidgetItem *item, int action )

QTreeWidgetItem *QgsIdentifyResults::featureItem( QTreeWidgetItem *item )
{
if ( !item )
return 0;

QTreeWidgetItem *featItem;
if ( item->parent() )
{
Expand Down

0 comments on commit 2e41442

Please sign in to comment.