本文整理汇总了C++中QScopedPointer::evalErrorString方法的典型用法代码示例。如果您正苦于以下问题:C++ QScopedPointer::evalErrorString方法的具体用法?C++ QScopedPointer::evalErrorString怎么用?C++ QScopedPointer::evalErrorString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScopedPointer
的用法示例。
在下文中一共展示了QScopedPointer::evalErrorString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateFeatures
int QgsAtlasComposition::updateFeatures()
{
//needs to be called when layer, filter, sort changes
if ( !mCoverageLayer )
{
return 0;
}
QgsExpressionContext expressionContext = createExpressionContext();
updateFilenameExpression();
// select all features with all attributes
QgsFeatureRequest req;
QScopedPointer<QgsExpression> filterExpression;
if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
{
filterExpression.reset( new QgsExpression( mFeatureFilter ) );
if ( filterExpression->hasParserError() )
{
mFilterParserError = filterExpression->parserErrorString();
return 0;
}
//filter good to go
req.setFilterExpression( mFeatureFilter );
}
mFilterParserError = QString();
QgsFeatureIterator fit = mCoverageLayer->getFeatures( req );
QScopedPointer<QgsExpression> nameExpression;
if ( !mPageNameExpression.isEmpty() )
{
nameExpression.reset( new QgsExpression( mPageNameExpression ) );
if ( nameExpression->hasParserError() )
{
nameExpression.reset( nullptr );
}
else
{
nameExpression->prepare( &expressionContext );
}
}
// We cannot use nextFeature() directly since the feature pointer is rewinded by the rendering process
// We thus store the feature ids for future extraction
QgsFeature feat;
mFeatureIds.clear();
mFeatureKeys.clear();
int sortIdx = mCoverageLayer->fields().lookupField( mSortKeyAttributeName );
while ( fit.nextFeature( feat ) )
{
expressionContext.setFeature( feat );
QString pageName;
if ( !nameExpression.isNull() )
{
QVariant result = nameExpression->evaluate( &expressionContext );
if ( nameExpression->hasEvalError() )
{
QgsMessageLog::logMessage( tr( "Atlas name eval error: %1" ).arg( nameExpression->evalErrorString() ), tr( "Composer" ) );
}
pageName = result.toString();
}
mFeatureIds.push_back( qMakePair( feat.id(), pageName ) );
if ( mSortFeatures && sortIdx != -1 )
{
mFeatureKeys.insert( feat.id(), feat.attributes().at( sortIdx ) );
}
}
// sort features, if asked for
if ( !mFeatureKeys.isEmpty() )
{
FieldSorter sorter( mFeatureKeys, mSortAscending );
qSort( mFeatureIds.begin(), mFeatureIds.end(), sorter );
}
emit numberFeaturesChanged( mFeatureIds.size() );
//jump to first feature if currently using an atlas preview
//need to do this in case filtering/layer change has altered matching features
if ( mComposition->atlasMode() == QgsComposition::PreviewAtlas )
{
firstFeature();
}
return mFeatureIds.size();
}