Skip to content

Commit

Permalink
multi layer identify:
Browse files Browse the repository at this point in the history
- restore editing, if one feature is identified on a editable vector layer
- expand just the first feature on the first layer



git-svn-id: http://svn.osgeo.org/qgis/trunk@11626 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Sep 11, 2009
1 parent 558ea8d commit c77d2ec
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
37 changes: 29 additions & 8 deletions src/app/qgsidentifyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class QgsIdentifyResultsDock : public QDockWidget
deleteLater();
}
};

// Tree hierachy
//
// layer [userrole: QgsMapLayer]
Expand Down Expand Up @@ -124,13 +125,13 @@ void QgsIdentifyResults::addFeature( QgsMapLayer *layer, int fid,
const QMap<QString, QString> &attributes,
const QMap<QString, QString> &derivedAttributes )
{
QTreeWidgetItem *item = layerItem( layer );
QTreeWidgetItem *layItem = layerItem( layer );

if ( item == 0 )
if ( layItem == 0 )
{
item = new QTreeWidgetItem( QStringList() << layer->name() << tr( "Layer" ) );
item->setData( 0, Qt::UserRole, QVariant::fromValue( dynamic_cast<QObject*>( layer ) ) );
lstResults->addTopLevelItem( item );
layItem = new QTreeWidgetItem( QStringList() << layer->name() << tr( "Layer" ) );
layItem->setData( 0, Qt::UserRole, QVariant::fromValue( dynamic_cast<QObject*>( layer ) ) );
lstResults->addTopLevelItem( layItem );

connect( layer, SIGNAL( destroyed() ), this, SLOT( layerDestroyed() ) );

Expand Down Expand Up @@ -158,9 +159,7 @@ void QgsIdentifyResults::addFeature( QgsMapLayer *layer, int fid,
}
}

item->addChild( featItem );
item->setExpanded( true );
featItem->setExpanded( true );
layItem->addChild( featItem );
}

// Call to show the dialog box.
Expand All @@ -170,6 +169,28 @@ void QgsIdentifyResults::show()
lstResults->sortItems( 0, Qt::AscendingOrder );
expandColumnsToFit();

if ( lstResults->topLevelItemCount() > 0 )
{
QTreeWidgetItem *layItem = lstResults->topLevelItem( 0 );
QTreeWidgetItem *featItem = layItem->child( 0 );

if ( layItem->childCount() == 1 )
{
QgsVectorLayer *layer = dynamic_cast<QgsVectorLayer *>( layItem->data( 0, Qt::UserRole ).value<QObject *>() );
if ( layer && layer->isEditable() )
{
// if this is the only feature, it's on a vector layer and that layer is editable:
// don't show the edit dialog instead of the results window
editFeature( featItem );
return;
}
}

// expand first layer and feature
featItem->setExpanded( true );
layItem->setExpanded( true );
}

QDialog::show();
}
// Slot called when user clicks the Close button
Expand Down
4 changes: 3 additions & 1 deletion src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<string>QGIS Options</string>
</property>
<property name="windowIcon" >
<iconset/>
<iconset>
<normaloff/>
</iconset>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>
Expand Down

0 comments on commit c77d2ec

Please sign in to comment.