Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Speed up listing of field values in search dialog by using QSet
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11711 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Sep 25, 2009
1 parent d278021 commit 35e6048
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/qgssearchquerybuilder.cpp
Expand Up @@ -117,6 +117,9 @@ void QgsSearchQueryBuilder::getFieldValues( int limit )
mModelValues->blockSignals( true );
lstValues->setUpdatesEnabled( false );

/**MH: keep already inserted values in a set. Querying is much faster compared to QStandardItemModel::findItems*/
QSet<QString> insertedValues;

while ( mLayer->nextFeature( feat ) &&
( limit == 0 || mModelValues->rowCount() != limit ) )
{
Expand All @@ -130,12 +133,12 @@ void QgsSearchQueryBuilder::getFieldValues( int limit )
}

// add item only if it's not there already
QList<QStandardItem *> items = mModelValues->findItems( value );
if ( items.isEmpty() )
if ( !insertedValues.contains( value ) )
{
QStandardItem *myItem = new QStandardItem( value );
myItem->setEditable( false );
mModelValues->insertRow( mModelValues->rowCount(), myItem );
insertedValues.insert( value );
}
}
// Unblock for normal use
Expand Down

0 comments on commit 35e6048

Please sign in to comment.