Skip to content
Permalink
Browse files

[FEATURE] add option to make layer with identified features active

  • Loading branch information
jef-n committed Oct 23, 2013
1 parent ae39f34 commit b6344dec1dff8c687da8202a2d46b720784117f6
Showing with 23 additions and 2 deletions.
  1. +19 −2 src/app/qgsidentifyresultsdialog.cpp
  2. +4 −0 src/app/qgsidentifyresultsdialog.h
@@ -748,7 +748,10 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
mActionPopup->addAction( tr( "Highlight all" ), this, SLOT( highlightAll() ) );
mActionPopup->addAction( tr( "Highlight layer" ), this, SLOT( highlightLayer() ) );
if ( layer && QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() )
{
mActionPopup->addAction( tr( "Activate layer" ), this, SLOT( activateLayer() ) );
mActionPopup->addAction( tr( "Layer properties..." ), this, SLOT( layerProperties() ) );
}
mActionPopup->addSeparator();
mActionPopup->addAction( tr( "Expand all" ), this, SLOT( expandAll() ) );
mActionPopup->addAction( tr( "Collapse all" ), this, SLOT( collapseAll() ) );
@@ -947,20 +950,27 @@ QTreeWidgetItem *QgsIdentifyResultsDialog::layerItem( QTreeWidgetItem *item )
return item;
}

QgsMapLayer *QgsIdentifyResultsDialog::layer( QTreeWidgetItem *item )
{
item = layerItem( item );
if ( !item )
return 0;
return qobject_cast<QgsMapLayer *>( item->data( 0, Qt::UserRole ).value<QObject *>() );
}

QgsVectorLayer *QgsIdentifyResultsDialog::vectorLayer( QTreeWidgetItem *item )
{
item = layerItem( item );
if ( !item )
return NULL;
return 0;
return qobject_cast<QgsVectorLayer *>( item->data( 0, Qt::UserRole ).value<QObject *>() );
}

QgsRasterLayer *QgsIdentifyResultsDialog::rasterLayer( QTreeWidgetItem *item )
{
item = layerItem( item );
if ( !item )
return NULL;
return 0;
return qobject_cast<QgsRasterLayer *>( item->data( 0, Qt::UserRole ).value<QObject *>() );
}

@@ -1280,6 +1290,13 @@ void QgsIdentifyResultsDialog::layerProperties()
layerProperties( lstResults->currentItem() );
}

void QgsIdentifyResultsDialog::activateLayer()
{
connect( this, SIGNAL( activateLayer( QgsMapLayer * ) ), QgisApp::instance(), SLOT( setActiveLayer( QgsMapLayer * ) ) );
emit activateLayer( layer( lstResults->currentItem() ) );
disconnect( this, SIGNAL( activateLayer( QgsMapLayer * ) ), QgisApp::instance(), SLOT( setActiveLayer( QgsMapLayer * ) ) );
}

void QgsIdentifyResultsDialog::layerProperties( QTreeWidgetItem *item )
{
QgsVectorLayer *vlayer = vectorLayer( item );
@@ -134,6 +134,8 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti

void copyToClipboard( QgsFeatureStore& featureStore );

void activateLayer( QgsMapLayer * );

public slots:
/** Remove results */
void clear();
@@ -156,6 +158,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
void copyGetFeatureInfoUrl();
void highlightAll();
void highlightLayer();
void activateLayer();
void layerProperties();
void clearHighlights();
void expandAll();
@@ -196,6 +199,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
QgsMapCanvas *mCanvas;
QList<QgsFeature> mFeatures;

QgsMapLayer *layer( QTreeWidgetItem *item );
QgsVectorLayer *vectorLayer( QTreeWidgetItem *item );
QgsRasterLayer *rasterLayer( QTreeWidgetItem *item );
QTreeWidgetItem *featureItem( QTreeWidgetItem *item );

0 comments on commit b6344de

Please sign in to comment.
You can’t perform that action at this time.