Skip to content

Commit

Permalink
Merge pull request #5783 from pblottiere/ref_rel_perf_218
Browse files Browse the repository at this point in the history
[2.18] QgsRelationReferenceWidget slowness
  • Loading branch information
pblottiere committed Dec 15, 2017
2 parents 2ef6a82 + fd7fc94 commit f4b007e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/app/qgsoptions.cpp
Expand Up @@ -928,7 +928,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
mVariableEditor->reloadContext();
mVariableEditor->setEditableScopeIndex( 0 );


const QString key = "/QgsRelationReferenceWidget/cacheSize";
mSettings->setValue( key, mSettings->value( key, 200000 ) );

mAdvancedSettingsEditor->setSettingsObject( mSettings );

Expand Down
13 changes: 10 additions & 3 deletions src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Expand Up @@ -479,7 +479,8 @@ void QgsRelationReferenceWidget::init()

QSet<QString> requestedAttrs;

QgsVectorLayerCache* layerCache = new QgsVectorLayerCache( mReferencedLayer, 100000, this );
const int cacheSize = QSettings().value( "/QgsRelationReferenceWidget/cacheSize" ).toInt();
QgsVectorLayerCache* layerCache = new QgsVectorLayerCache( mReferencedLayer, cacheSize, this );

if ( !mFilterFields.isEmpty() )
{
Expand Down Expand Up @@ -583,8 +584,14 @@ void QgsRelationReferenceWidget::init()
}
}

QVariant featId = mFeature.isValid() ? mFeature.id() : QVariant( QVariant::Int );
mComboBox->setCurrentIndex( mComboBox->findData( featId, QgsAttributeTableModel::FeatureIdRole ) );
if ( mFeature.isValid() )
{
mComboBox->setCurrentIndex( mComboBox->findData( mFeature.id(), QgsAttributeTableModel::FeatureIdRole ) );
}
else
{
mComboBox->setCurrentIndex( -1 );
}

// Only connect after iterating, to have only one iterator on the referenced table at once
connect( mComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( comboReferenceChanged( int ) ) );
Expand Down
Expand Up @@ -71,7 +71,7 @@ void QgsRelationReferenceWidgetWrapper::initWidget( QWidget* editor )
if ( ctx->relation().name() == relation.name() )
{
mWidget->setEmbedForm( false );
mWidget->setReadOnlySelector( false );
mWidget->setReadOnlySelector( true );
mWidget->setAllowMapIdentification( false );
}
ctx = ctx->parentContext();
Expand Down

0 comments on commit f4b007e

Please sign in to comment.