multi layer identify:

- 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
This commit is contained in:
jef 2009-09-11 21:56:44 +00:00
parent 558ea8dc24
commit c77d2ecafe
2 changed files with 32 additions and 9 deletions

View File

@ -54,6 +54,7 @@ class QgsIdentifyResultsDock : public QDockWidget
deleteLater();
}
};
// Tree hierachy
//
// layer [userrole: QgsMapLayer]
@ -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() ) );
@ -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.
@ -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

View File

@ -13,7 +13,9 @@
<string>QGIS Options</string>
</property>
<property name="windowIcon" >
<iconset/>
<iconset>
<normaloff/>
</iconset>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>