MerginMaps / MerginMaps/mobile

Exit early from loop when feature has been found in VR model

Open
#2,379 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement forms
Dominant language
C++
Stars
388
Forks
87
Avg merge
2d 7h
Merged PRs (30d)
20

Description

ValueRelationFeaturesModel::convertFromQgisType converts QGIS VR type {1, 2, 3} to normal list. It supports VR with multiple values.

That function includes a loop that goes over the entire referenced layer and tries to find the features.
We should stop the loop when number of found features equals the number of features from QGIS value.

See ValueRelationFeaturesModel::150 ⬇️

  for ( int ix = 0; ix < FeaturesModel::rowCount(); ++ix )
  {
    QgsFeature f = FeaturesModel::data( index( ix, 0 ), Feature ).value<QgsFeature>();

    if ( keyMap.contains( f.attribute( mKeyField ).toString() ) )
    {
      if ( toRole == FeatureId )
        roleList.append( f.id() );
      else
      {
        QVariant attr = FeaturesModel::convertRoleValue( FeatureId, f.id(), toRole );
        if ( !attr.isNull() )
          roleList.append( attr );
      }
      // <----- TODO: stop the search if the roleList has enough features
    }
  }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ValueRelationFeaturesModel::convertFromQgisType at the loop around line 150 and inspect how the QGIS value count and roleList are established. Update the search so it stops once the required features have been found, then verify conversion for VR types with multiple values.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
mobile-dev
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.