Skip to content
Permalink
Browse files
[FEATURE] toggle feature selection from identify results (implements #…
  • Loading branch information
jef-n committed May 20, 2014
1 parent 986ffd6 commit 45cd8953d93062a3b4c331040abf8e521c8e1c53
Showing with 27 additions and 3 deletions.
  1. +23 −0 src/app/qgsidentifyresultsdialog.cpp
  2. +4 −3 src/app/qgsidentifyresultsdialog.h
@@ -944,6 +944,7 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
{
mActionPopup->addAction( tr( "Zoom to feature" ), this, SLOT( zoomToFeature() ) );
mActionPopup->addAction( tr( "Copy feature" ), this, SLOT( copyFeature() ) );
mActionPopup->addAction( tr( "Toggle feature selection" ), this, SLOT( toggleFeatureSelection() ) );
}

mActionPopup->addAction( tr( "Copy attribute value" ), this, SLOT( copyAttributeValue() ) );
@@ -1786,6 +1787,28 @@ void QgsIdentifyResultsDialog::copyFeature()
emit copyToClipboard( featureStore );
}

void QgsIdentifyResultsDialog::toggleFeatureSelection()
{
QgsDebugMsg( "Entered" );

QgsIdentifyResultsFeatureItem *item = dynamic_cast<QgsIdentifyResultsFeatureItem *>( featureItem( lstResults->selectedItems().value( 0 ) ) );

if ( !item ) // should not happen
{
QgsDebugMsg( "Selected item is not feature" );
return;
}

QgsVectorLayer *vl = qobject_cast<QgsVectorLayer*>( layer( item ) );
if ( !vl )
return;

if ( vl->selectedFeaturesIds().contains( item->feature().id() ) )
vl->deselect( item->feature().id() );
else
vl->select( item->feature().id() );
}

void QgsIdentifyResultsDialog::formatChanged( int index )
{
QgsDebugMsg( "Entered" );
@@ -66,9 +66,9 @@ class APP_EXPORT QgsIdentifyResultsFeatureItem: public QTreeWidgetItem
{
public:
QgsIdentifyResultsFeatureItem( const QgsFields &fields, const QgsFeature &feature, const QgsCoordinateReferenceSystem &crs, const QStringList & strings = QStringList() );
QgsFields fields() const { return mFields; }
QgsFeature feature() const { return mFeature; }
QgsCoordinateReferenceSystem crs() { return mCrs; }
const QgsFields &fields() const { return mFields; }
const QgsFeature &feature() const { return mFeature; }
const QgsCoordinateReferenceSystem &crs() { return mCrs; }

private:
QgsFields mFields;
@@ -169,6 +169,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
void zoomToFeature();
void copyAttributeValue();
void copyFeature();
void toggleFeatureSelection();
void copyFeatureAttributes();
void copyGetFeatureInfoUrl();
void highlightAll();

0 comments on commit 45cd895

Please sign in to comment.