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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Dec 2 12:57:20 EST 2009


Author: jef
Date: 2009-12-02 12:57:20 -0500 (Wed, 02 Dec 2009)
New Revision: 12309

Modified:
   trunk/qgis/src/app/qgsidentifyresults.cpp
   trunk/qgis/src/app/qgsidentifyresults.h
Log:
[FEATURE] more identify changes:
- down hide highlights when the identify tool is deactivated
- add context menu entries to clear results and highlights

[fix]
- remove QSharedPointer usage (Qt 4.5 dependency)


Modified: trunk/qgis/src/app/qgsidentifyresults.cpp
===================================================================
--- trunk/qgis/src/app/qgsidentifyresults.cpp	2009-12-02 17:38:32 UTC (rev 12308)
+++ trunk/qgis/src/app/qgsidentifyresults.cpp	2009-12-02 17:57:20 UTC (rev 12309)
@@ -123,6 +123,7 @@
 
 QgsIdentifyResults::~QgsIdentifyResults()
 {
+  clearRubberbands();
   delete mActionPopup;
 }
 
@@ -340,8 +341,11 @@
   mActionPopup->addAction( tr( "Copy attribute value" ), this, SLOT( copyAttributeValue() ) );
   mActionPopup->addAction( tr( "Copy feature attributes" ), this, SLOT( copyFeatureAttributes() ) );
   mActionPopup->addSeparator();
+  mActionPopup->addAction( tr( "Clear results" ), this, SLOT( clear() ) );
+  mActionPopup->addAction( tr( "Clear highlights" ), this, SLOT( clearRubberbands() ) );
   mActionPopup->addAction( tr( "Highlight all" ), this, SLOT( highlightAll() ) );
   mActionPopup->addAction( tr( "Highlight layer" ), this, SLOT( highlightLayer() ) );
+  mActionPopup->addSeparator();
   mActionPopup->addAction( tr( "Expand all" ), this, SLOT( expandAll() ) );
   mActionPopup->addAction( tr( "Collapse all" ), this, SLOT( collapseAll() ) );
 
@@ -398,6 +402,16 @@
   lstResults->resizeColumnToContents( 1 );
 }
 
+void QgsIdentifyResults::clearRubberbands()
+{
+  foreach( QgsRubberBand *rb, mRubberBands )
+  {
+    delete rb;
+  }
+
+  mRubberBands.clear();
+}
+
 void QgsIdentifyResults::clear()
 {
   for ( int i = 0; i < lstResults->topLevelItemCount(); i++ )
@@ -406,15 +420,17 @@
   }
 
   lstResults->clear();
-  mRubberBands.clear();
+  clearRubberbands();
 }
 
 void QgsIdentifyResults::activate()
 {
-  foreach( QSharedPointer<QgsRubberBand> rb, mRubberBands )
+#if 0
+  foreach( QgsRubberBand *rb, mRubberBands )
   {
     rb->show();
   }
+#endif
 
   if ( lstResults->topLevelItemCount() > 0 )
   {
@@ -425,10 +441,12 @@
 
 void QgsIdentifyResults::deactivate()
 {
-  foreach( QSharedPointer<QgsRubberBand> rb, mRubberBands )
+#if 0
+  foreach( QgsRubberBand *rb, mRubberBands )
   {
     rb->hide();
   }
+#endif
 }
 
 void QgsIdentifyResults::doAction( QTreeWidgetItem *item, int action )
@@ -558,7 +576,7 @@
   }
   else
   {
-    mRubberBands.clear();
+    clearRubberbands();
     highlightFeature( current );
   }
 }
@@ -575,7 +593,7 @@
     {
       for ( int j = 0; j < layItem->childCount(); j++ )
       {
-        mRubberBands.remove( layItem->child( i ) );
+        delete mRubberBands.take( layItem->child( i ) );
       }
     }
   }
@@ -621,7 +639,7 @@
 
     if ( featItem && featItem->data( 0, Qt::UserRole ).toInt() == fid )
     {
-      mRubberBands.remove( featItem );
+      delete mRubberBands.take( featItem );
       break;
     }
   }
@@ -670,7 +688,7 @@
     rb->setWidth( 2 );
     rb->setColor( Qt::red );
     rb->show();
-    mRubberBands.insert( featItem, QSharedPointer<QgsRubberBand>( rb ) );
+    mRubberBands.insert( featItem, rb );
   }
 }
 
@@ -805,7 +823,7 @@
   if ( !layItem )
     return;
 
-  mRubberBands.clear();
+  clearRubberbands();
 
   for ( int i = 0; i < layItem->childCount(); i++ )
   {

Modified: trunk/qgis/src/app/qgsidentifyresults.h
===================================================================
--- trunk/qgis/src/app/qgsidentifyresults.h	2009-12-02 17:38:32 UTC (rev 12308)
+++ trunk/qgis/src/app/qgsidentifyresults.h	2009-12-02 17:57:20 UTC (rev 12309)
@@ -25,7 +25,6 @@
 
 #include <QWidget>
 #include <QList>
-#include <QSharedPointer>
 
 class QCloseEvent;
 class QTreeWidgetItem;
@@ -60,9 +59,6 @@
                      const QMap< QString, QString > &attributes,
                      const QMap< QString, QString > &derivedAttributes );
 
-    /** Remove results */
-    void clear();
-
     /** map tool was deactivated */
     void deactivate();
 
@@ -75,6 +71,8 @@
     void selectedFeatureChanged( QgsVectorLayer *, int featureId );
 
   public slots:
+    /** Remove results */
+    void clear();
 
     void show();
 
@@ -91,6 +89,7 @@
     void copyFeatureAttributes();
     void highlightAll();
     void highlightLayer();
+    void clearRubberbands();
     void expandAll();
     void collapseAll();
 
@@ -110,7 +109,7 @@
 
   private:
     QMenu *mActionPopup;
-    QMap<QTreeWidgetItem *, QSharedPointer<QgsRubberBand> > mRubberBands;
+    QMap<QTreeWidgetItem *, QgsRubberBand * > mRubberBands;
     QgsMapCanvas *mCanvas;
 
     QgsVectorLayer *vectorLayer( QTreeWidgetItem *item );



More information about the QGIS-commit mailing list