[QGIS Commit] r10792 - in trunk/qgis/src: app/attributetable ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu May 14 12:40:07 EDT 2009


Author: wonder
Date: 2009-05-14 12:40:06 -0400 (Thu, 14 May 2009)
New Revision: 10792

Modified:
   trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
   trunk/qgis/src/ui/qgsattributetabledialog.ui
Log:
[FEATURE] Possibility to search in attribute table within selected records only.


Modified: trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2009-05-14 15:58:24 UTC (rev 10791)
+++ trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2009-05-14 16:40:06 UTC (rev 10792)
@@ -424,19 +424,35 @@
   }
 
   QApplication::setOverrideCursor( Qt::WaitCursor );
-
   mSelectedFeatures.clear();
-  mLayer->select( mLayer->pendingAllAttributesList(), QgsRectangle(), false );
+  
+  if ( cbxSearchSelectedOnly->isChecked() )
+  {
+    QgsFeatureList selectedFeatures = mLayer->selectedFeatures();
+    for (QgsFeatureList::ConstIterator it = selectedFeatures.begin(); it != selectedFeatures.end(); ++it)
+    {
+      if ( searchTree->checkAgainst( mLayer->pendingFields(), it->attributeMap() ) )
+        mSelectedFeatures << it->id();
 
-  QgsFeature f;
-  while ( mLayer->nextFeature( f ) )
+      // check if there were errors during evaluating
+      if ( searchTree->hasError() )
+        break;
+    } 
+  }
+  else
   {
-    if ( searchTree->checkAgainst( mLayer->pendingFields(), f.attributeMap() ) )
-      mSelectedFeatures << f.id();
+    mLayer->select( mLayer->pendingAllAttributesList(), QgsRectangle(), false );
+    QgsFeature f;
 
-    // check if there were errors during evaluating
-    if ( searchTree->hasError() )
-      break;
+    while ( mLayer->nextFeature( f ) )
+    {
+      if ( searchTree->checkAgainst( mLayer->pendingFields(), f.attributeMap() ) )
+        mSelectedFeatures << f.id();
+
+      // check if there were errors during evaluating
+      if ( searchTree->hasError() )
+        break;
+    }
   }
 
   QApplication::restoreOverrideCursor();

Modified: trunk/qgis/src/ui/qgsattributetabledialog.ui
===================================================================
--- trunk/qgis/src/ui/qgsattributetabledialog.ui	2009-05-14 15:58:24 UTC (rev 10791)
+++ trunk/qgis/src/ui/qgsattributetabledialog.ui	2009-05-14 16:40:06 UTC (rev 10792)
@@ -220,6 +220,13 @@
       </widget>
      </item>
      <item>
+      <widget class="QCheckBox" name="cbxSearchSelectedOnly" >
+       <property name="text" >
+        <string>Search selected records only</string>
+       </property>
+      </widget>
+     </item>
+     <item>
       <spacer>
        <property name="orientation" >
         <enum>Qt::Horizontal</enum>



More information about the QGIS-commit mailing list