[QGIS Commit] r12806 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jan 20 13:33:20 EST 2010


Author: jef
Date: 2010-01-20 13:33:19 -0500 (Wed, 20 Jan 2010)
New Revision: 12806

Modified:
   trunk/qgis/src/app/qgsattributedialog.cpp
   trunk/qgis/src/app/qgsattributedialog.h
   trunk/qgis/src/app/qgsidentifyresults.cpp
Log:
[FEATURE] identify tool update
- attribute form now non-modal in view mode (since r12796)
- highlight disappear when window is deactivate or closed and reappears when
  reactivated.


Modified: trunk/qgis/src/app/qgsattributedialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsattributedialog.cpp	2010-01-20 18:24:59 UTC (rev 12805)
+++ trunk/qgis/src/app/qgsattributedialog.cpp	2010-01-20 18:33:19 UTC (rev 12806)
@@ -24,6 +24,7 @@
 #include "qgsuniquevaluerenderer.h"
 #include "qgssymbol.h"
 #include "qgsattributeeditor.h"
+#include "qgsrubberband.h"
 
 #include "qgisapp.h"
 
@@ -44,7 +45,8 @@
     : mDialog( 0 ),
     mSettingsPath( "/Windows/AttributeDialog/" ),
     mLayer( vl ),
-    mpFeature( thepFeature )
+    mpFeature( thepFeature ),
+    mRubberBand( 0 )
 {
   if ( mpFeature == NULL || vl->dataProvider() == NULL )
     return;
@@ -237,6 +239,17 @@
 
 QgsAttributeDialog::~QgsAttributeDialog()
 {
+  if ( mRubberBand )
+  {
+    mRubberBand->hide();
+    delete mRubberBand;
+  }
+
+  if ( mDialog )
+  {
+    delete mDialog;
+  }
+
   saveGeometry();
 }
 
@@ -275,12 +288,11 @@
 
 void QgsAttributeDialog::show()
 {
-  if ( mDialog )
-  {
-    mDialog->setAttribute( Qt::WA_DeleteOnClose );
-    mDialog->show();
-    mDialog = 0;
-  }
+  mDialog->setAttribute( Qt::WA_DeleteOnClose );
+  mDialog->show();
+  mDialog->raise();
+  mDialog->activateWindow();
+  mDialog->installEventFilter( this );
 }
 
 void QgsAttributeDialog::saveGeometry()
@@ -301,6 +313,17 @@
   }
 }
 
+void QgsAttributeDialog::setHighlight( QgsRubberBand *rb )
+{
+  if ( mRubberBand )
+  {
+    delete mRubberBand;
+  }
+
+  mRubberBand = rb;
+}
+
+
 void QgsAttributeDialog::dialogDestroyed()
 {
 #if 0
@@ -308,5 +331,27 @@
   mLayer->setProperty( "featureForm.id", QVariant() );
 #endif
   QgisApp::instance()->runPythonString( QString( "del _qgis_featureform_%1" ).arg( mLayer->getLayerID() ) );
+
   mDialog = NULL;
+  deleteLater();
 }
+
+bool QgsAttributeDialog::eventFilter( QObject *obj, QEvent *e )
+{
+  if ( mRubberBand && obj == mDialog )
+  {
+    switch ( e->type() )
+    {
+      case QEvent::WindowActivate:
+        mRubberBand->show();
+        break;
+      case QEvent::WindowDeactivate:
+        mRubberBand->hide();
+        break;
+      default:
+        break;
+    }
+  }
+
+  return false;
+}

Modified: trunk/qgis/src/app/qgsattributedialog.h
===================================================================
--- trunk/qgis/src/app/qgsattributedialog.h	2010-01-20 18:24:59 UTC (rev 12805)
+++ trunk/qgis/src/app/qgsattributedialog.h	2010-01-20 18:33:19 UTC (rev 12806)
@@ -25,6 +25,7 @@
 class QLayout;
 class QgsField;
 class QgsVectorLayer;
+class QgsRubberBand;
 
 class QgsAttributeDialog : public QObject
 {
@@ -45,6 +46,8 @@
      */
     void restoreGeometry();
 
+    void setHighlight( QgsRubberBand *rb );
+
     QDialog *dialog() { return mDialog; }
 
   public slots:
@@ -59,6 +62,7 @@
     void dialogDestroyed();
 
   private:
+    bool eventFilter( QObject *obj, QEvent *event );
 
     QDialog *mDialog;
     QString mSettingsPath;
@@ -66,6 +70,7 @@
     QList<int> mpIndizes;
     QgsVectorLayer *mLayer;
     QgsFeature *mpFeature;
+    QgsRubberBand *mRubberBand;
 };
 
 #endif

Modified: trunk/qgis/src/app/qgsidentifyresults.cpp
===================================================================
--- trunk/qgis/src/app/qgsidentifyresults.cpp	2010-01-20 18:24:59 UTC (rev 12805)
+++ trunk/qgis/src/app/qgsidentifyresults.cpp	2010-01-20 18:33:19 UTC (rev 12806)
@@ -268,7 +268,9 @@
     QTreeWidgetItem *layItem = lstResults->topLevelItem( 0 );
     QTreeWidgetItem *featItem = layItem->child( 0 );
 
-    if ( lstResults->topLevelItemCount() == 1 && layItem->childCount() == 1 && QSettings().value( "/Map/identifyAutoFeatureForm", false ).toBool() )
+    if ( lstResults->topLevelItemCount() == 1 &&
+         layItem->childCount() == 1 &&
+         QSettings().value( "/Map/identifyAutoFeatureForm", false ).toBool() )
     {
       QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( layItem->data( 0, Qt::UserRole ).value<QObject *>() );
       if ( layer )
@@ -682,7 +684,7 @@
   int fid = featItem->data( 0, Qt::UserRole ).toInt();
 
   QgsFeature feat;
-  if ( ! layer->featureAtId( fid, feat, true, false ) )
+  if ( !layer->featureAtId( fid, feat, true, false ) )
   {
     return;
   }
@@ -816,6 +818,8 @@
   }
   else
   {
+    QgsRubberBand *rb = mRubberBands.take( featItem );
+    ad->setHighlight( rb );
     ad->show();
   }
 }



More information about the QGIS-commit mailing list