Skip to content
Permalink
Browse files

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/qgis@11626 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Sep 11, 2009
1 parent 2f4441c commit 7e24f68d842abaca9c028a1aef6568444b577895
Showing with 32 additions and 9 deletions.
  1. +29 −8 src/app/qgsidentifyresults.cpp
  2. +3 −1 src/ui/qgsoptionsbase.ui
@@ -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
@@ -13,7 +13,9 @@
<string>QGIS Options</string>
</property>
<property name="windowIcon" >
<iconset/>
<iconset>
<normaloff/>
</iconset>
</property>
<property name="sizeGripEnabled" >
<bool>true</bool>

0 comments on commit 7e24f68

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