Skip to content

Commit 783b8cb

Browse files
author
wonder
committedMay 14, 2009
[FEATURE] Possibility to search in attribute table within selected records only.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10792 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed
 

‎src/app/attributetable/qgsattributetabledialog.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,19 +424,35 @@ void QgsAttributeTableDialog::doSearch( QString searchString )
424424
}
425425

426426
QApplication::setOverrideCursor( Qt::WaitCursor );
427-
428427
mSelectedFeatures.clear();
429-
mLayer->select( mLayer->pendingAllAttributesList(), QgsRectangle(), false );
428+
429+
if ( cbxSearchSelectedOnly->isChecked() )
430+
{
431+
QgsFeatureList selectedFeatures = mLayer->selectedFeatures();
432+
for (QgsFeatureList::ConstIterator it = selectedFeatures.begin(); it != selectedFeatures.end(); ++it)
433+
{
434+
if ( searchTree->checkAgainst( mLayer->pendingFields(), it->attributeMap() ) )
435+
mSelectedFeatures << it->id();
430436

431-
QgsFeature f;
432-
while ( mLayer->nextFeature( f ) )
437+
// check if there were errors during evaluating
438+
if ( searchTree->hasError() )
439+
break;
440+
}
441+
}
442+
else
433443
{
434-
if ( searchTree->checkAgainst( mLayer->pendingFields(), f.attributeMap() ) )
435-
mSelectedFeatures << f.id();
444+
mLayer->select( mLayer->pendingAllAttributesList(), QgsRectangle(), false );
445+
QgsFeature f;
446+
447+
while ( mLayer->nextFeature( f ) )
448+
{
449+
if ( searchTree->checkAgainst( mLayer->pendingFields(), f.attributeMap() ) )
450+
mSelectedFeatures << f.id();
436451

437-
// check if there were errors during evaluating
438-
if ( searchTree->hasError() )
439-
break;
452+
// check if there were errors during evaluating
453+
if ( searchTree->hasError() )
454+
break;
455+
}
440456
}
441457

442458
QApplication::restoreOverrideCursor();

‎src/ui/qgsattributetabledialog.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@
219219
</property>
220220
</widget>
221221
</item>
222+
<item>
223+
<widget class="QCheckBox" name="cbxSearchSelectedOnly" >
224+
<property name="text" >
225+
<string>Search selected records only</string>
226+
</property>
227+
</widget>
228+
</item>
222229
<item>
223230
<spacer>
224231
<property name="orientation" >

0 commit comments

Comments
 (0)
Please sign in to comment.