[QGIS Commit] r13212 - trunk/qgis/src/app
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Mar 31 11:53:42 EDT 2010
Author: jef
Date: 2010-03-31 11:53:40 -0400 (Wed, 31 Mar 2010)
New Revision: 13212
Modified:
trunk/qgis/src/app/qgsidentifyresults.cpp
trunk/qgis/src/app/qgsidentifyresults.h
Log:
consider attribute changes in identify results
Modified: trunk/qgis/src/app/qgsidentifyresults.cpp
===================================================================
--- trunk/qgis/src/app/qgsidentifyresults.cpp 2010-03-31 13:51:53 UTC (rev 13211)
+++ trunk/qgis/src/app/qgsidentifyresults.cpp 2010-03-31 15:53:40 UTC (rev 13212)
@@ -161,12 +161,12 @@
layItem->setData( 0, Qt::UserRole, QVariant::fromValue( qobject_cast<QObject *>( layer ) ) );
lstResults->addTopLevelItem( layItem );
- QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( vlayer )
{
connect( vlayer, SIGNAL( layerDeleted() ), this, SLOT( layerDestroyed() ) );
connect( vlayer, SIGNAL( layerCrsChanged() ), this, SLOT( layerDestroyed() ) );
connect( vlayer, SIGNAL( featureDeleted( int ) ), this, SLOT( featureDeleted( int ) ) );
+ connect( vlayer, SIGNAL( attributeValueChanged( int, int, const QVariant & ) ), this, SLOT( attributeValueChanged( int, int, const QVariant & ) ) );
connect( vlayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
connect( vlayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
}
@@ -182,7 +182,12 @@
for ( QMap<QString, QString>::const_iterator it = attributes.begin(); it != attributes.end(); it++ )
{
- featItem->addChild( new QTreeWidgetItem( QStringList() << it.key() << it.value() ) );
+ QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << it.key() << it.value() );
+ if ( vlayer )
+ {
+ attrItem->setData( 0, Qt::UserRole, vlayer->fieldNameIndex( it.key() ) );
+ }
+ featItem->addChild( attrItem );
}
if ( derivedAttributes.size() >= 0 )
@@ -644,6 +649,7 @@
{
disconnect( vlayer, SIGNAL( layerDeleted() ), this, SLOT( layerDestroyed() ) );
disconnect( vlayer, SIGNAL( featureDeleted( int ) ), this, SLOT( featureDeleted( int ) ) );
+ disconnect( vlayer, SIGNAL( attributeValueChanged( int, int, const QVariant & ) ), this, SLOT( attributeValueChanged( int, int, const QVariant & ) ) );
disconnect( vlayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
disconnect( vlayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
}
@@ -683,6 +689,35 @@
}
}
+void QgsIdentifyResults::attributeValueChanged( int fid, int idx, const QVariant &val )
+{
+ QTreeWidgetItem *layItem = layerItem( sender() );
+
+ if ( !layItem )
+ return;
+
+ for ( int i = 0; i < layItem->childCount(); i++ )
+ {
+ QTreeWidgetItem *featItem = layItem->child( i );
+
+ if ( featItem && featItem->data( 0, Qt::UserRole ).toInt() == fid )
+ {
+ for ( int j = 0; j < featItem->childCount(); j++ )
+ {
+ QTreeWidgetItem *item = featItem->child( j );
+ if ( item->childCount() > 0 )
+ continue;
+
+ if ( item->data( 0, Qt::UserRole ).toInt() == idx )
+ {
+ item->setData( 1, Qt::DisplayRole, val );
+ return;
+ }
+ }
+ }
+ }
+}
+
void QgsIdentifyResults::highlightFeature( QTreeWidgetItem *item )
{
QgsVectorLayer *layer = vectorLayer( item );
Modified: trunk/qgis/src/app/qgsidentifyresults.h
===================================================================
--- trunk/qgis/src/app/qgsidentifyresults.h 2010-03-31 13:51:53 UTC (rev 13211)
+++ trunk/qgis/src/app/qgsidentifyresults.h 2010-03-31 15:53:40 UTC (rev 13212)
@@ -82,6 +82,7 @@
void layerDestroyed();
void editingToggled();
void featureDeleted( int fid );
+ void attributeValueChanged( int fid, int idx, const QVariant & );
void featureForm();
void zoomToFeature();
More information about the QGIS-commit
mailing list