void QgsExternalResourceWidgetWrapper::setFeature( const QgsFeature &feature )
{
  if ( mQgsWidget && mPropertyCollection.hasActiveProperties() )
  {
    QgsExpressionContext expressionContext( QgsExpressionContextUtils::globalProjectLayerScopes( layer() ) );
    expressionContext.setFeature( feature );
    bool ok = false;

    if ( mPropertyCollection.isActive( QgsEditorWidgetWrapper::RootPath ) )
    {
      QString path = mPropertyCollection.valueAsString( QgsEditorWidgetWrapper::RootPath, expressionContext, QString(), &ok );
      if ( ok )
      {
        mQgsWidget->setDefaultRoot( path );
      }
    }
    if ( mPropertyCollection.isActive( QgsEditorWidgetWrapper::DocumentViewerContent ) )
    {
      QString dvcString = mPropertyCollection.valueAsString( QgsEditorWidgetWrapper::DocumentViewerContent, expressionContext, QStringLiteral( "NoContent" ), &ok );
      if ( ok )
      {
        QgsExternalResourceWidget::DocumentViewerContent dvc;
        if ( dvcString.compare( QLatin1String( "image" ), Qt::CaseInsensitive ) == 0 )
        {
          dvc = QgsExternalResourceWidget::Image;
        }
        else if ( dvcString.compare( QLatin1String( "web" ), Qt::CaseInsensitive ) == 0 )
        {
          dvc = QgsExternalResourceWidget::Web;
        }
        else
        {
          dvc = QgsExternalResourceWidget::NoContent;
        }
        mQgsWidget->setDocumentViewerContent( dvc );
      }
    }
  }

  QgsEditorWidgetWrapper::setFeature( feature );
}
示例#2
0
void QgsAbstractFeatureIterator::setupOrderBy( const QList<QgsFeatureRequest::OrderByClause>& orderBys )
{
    // Let the provider try using an efficient order by strategy first
    if ( !orderBys.isEmpty() && !prepareOrderBy( orderBys ) )
    {
        // No success from the provider

        // Prepare the expressions
        QList<QgsFeatureRequest::OrderByClause> preparedOrderBys( orderBys );
        QList<QgsFeatureRequest::OrderByClause>::iterator orderByIt( preparedOrderBys.begin() );

        QgsExpressionContext* expressionContext( mRequest.expressionContext() );
        do
        {
            orderByIt->expression().prepare( expressionContext );
        }
        while ( ++orderByIt != preparedOrderBys.end() );

        // Fetch all features
        QgsIndexedFeature indexedFeature;
        indexedFeature.mIndexes.resize( preparedOrderBys.size() );

        while ( nextFeature( indexedFeature.mFeature ) )
        {
            expressionContext->setFeature( indexedFeature.mFeature );
            int i = 0;
            Q_FOREACH ( const QgsFeatureRequest::OrderByClause& orderBy, preparedOrderBys )
            {
                indexedFeature.mIndexes.replace( i++, orderBy.expression().evaluate( expressionContext ) );
            }

            // We need all features, to ignore the limit for this pre-fetch
            // keep the fetched count at 0.
            mFetchedCount = 0;
            mCachedFeatures.append( indexedFeature );
        }