void QgsAtlasComposition::readXmlMapSettings( const QDomElement &elem, const QDomDocument &doc ) { Q_UNUSED( doc ); //look for stored composer map, to upgrade pre 2.1 projects int composerMapNo = elem.attribute( QStringLiteral( "composerMap" ), QStringLiteral( "-1" ) ).toInt(); QgsComposerMap * composerMap = nullptr; if ( composerMapNo != -1 ) { QList<QgsComposerMap*> maps; mComposition->composerItems( maps ); for ( QList<QgsComposerMap*>::iterator it = maps.begin(); it != maps.end(); ++it ) { if (( *it )->id() == composerMapNo ) { composerMap = ( *it ); composerMap->setAtlasDriven( true ); break; } } } //upgrade pre 2.1 projects double margin = elem.attribute( QStringLiteral( "margin" ), QStringLiteral( "0.0" ) ).toDouble(); if ( composerMap && !qgsDoubleNear( margin, 0.0 ) ) { composerMap->setAtlasMargin( margin ); } bool fixedScale = elem.attribute( QStringLiteral( "fixedScale" ), QStringLiteral( "false" ) ) == QLatin1String( "true" ) ? true : false; if ( composerMap && fixedScale ) { composerMap->setAtlasScalingMode( QgsComposerMap::Fixed ); } }
void QgsAtlasComposition::readXML( const QDomElement& atlasElem, const QDomDocument& ) { mEnabled = atlasElem.attribute( "enabled", "false" ) == "true" ? true : false; emit toggled( mEnabled ); if ( !mEnabled ) { emit parameterChanged(); return; } // look for stored layer name mCoverageLayer = 0; QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers(); for ( QMap<QString, QgsMapLayer*>::const_iterator it = layers.begin(); it != layers.end(); ++it ) { if ( it.key() == atlasElem.attribute( "coverageLayer" ) ) { mCoverageLayer = dynamic_cast<QgsVectorLayer*>( it.value() ); break; } } //look for stored composer map, to upgrade pre 2.1 projects int composerMapNo = atlasElem.attribute( "composerMap", "-1" ).toInt(); QgsComposerMap * composerMap = 0; if ( composerMapNo != -1 ) { QList<QgsComposerMap*> maps; mComposition->composerItems( maps ); for ( QList<QgsComposerMap*>::iterator it = maps.begin(); it != maps.end(); ++it ) { if (( *it )->id() == composerMapNo ) { composerMap = ( *it ); composerMap->setAtlasDriven( true ); break; } } } mHideCoverage = atlasElem.attribute( "hideCoverage", "false" ) == "true" ? true : false; //upgrade pre 2.1 projects double margin = atlasElem.attribute( "margin", "0.0" ).toDouble(); if ( composerMap && margin != 0 ) { composerMap->setAtlasMargin( margin ); } bool fixedScale = atlasElem.attribute( "fixedScale", "false" ) == "true" ? true : false; if ( composerMap && fixedScale ) { composerMap->setAtlasFixedScale( true ); } mSingleFile = atlasElem.attribute( "singleFile", "false" ) == "true" ? true : false; mFilenamePattern = atlasElem.attribute( "filenamePattern", "" ); mSortFeatures = atlasElem.attribute( "sortFeatures", "false" ) == "true" ? true : false; if ( mSortFeatures ) { mSortKeyAttributeIdx = atlasElem.attribute( "sortKey", "0" ).toInt(); mSortAscending = atlasElem.attribute( "sortAscending", "true" ) == "true" ? true : false; } mFilterFeatures = atlasElem.attribute( "filterFeatures", "false" ) == "true" ? true : false; if ( mFilterFeatures ) { mFeatureFilter = atlasElem.attribute( "featureFilter", "" ); } emit parameterChanged(); }
void QgsAtlasComposition::readXML( const QDomElement& atlasElem, const QDomDocument& ) { mEnabled = atlasElem.attribute( "enabled", "false" ) == "true" ? true : false; emit toggled( mEnabled ); if ( !mEnabled ) { emit parameterChanged(); return; } // look for stored layer name mCoverageLayer = 0; QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers(); for ( QMap<QString, QgsMapLayer*>::const_iterator it = layers.begin(); it != layers.end(); ++it ) { if ( it.key() == atlasElem.attribute( "coverageLayer" ) ) { mCoverageLayer = dynamic_cast<QgsVectorLayer*>( it.value() ); break; } } //look for stored composer map, to upgrade pre 2.1 projects int composerMapNo = atlasElem.attribute( "composerMap", "-1" ).toInt(); QgsComposerMap * composerMap = 0; if ( composerMapNo != -1 ) { QList<QgsComposerMap*> maps; mComposition->composerItems( maps ); for ( QList<QgsComposerMap*>::iterator it = maps.begin(); it != maps.end(); ++it ) { if (( *it )->id() == composerMapNo ) { composerMap = ( *it ); composerMap->setAtlasDriven( true ); break; } } } mHideCoverage = atlasElem.attribute( "hideCoverage", "false" ) == "true" ? true : false; //upgrade pre 2.1 projects double margin = atlasElem.attribute( "margin", "0.0" ).toDouble(); if ( composerMap && margin != 0 ) { composerMap->setAtlasMargin( margin ); } bool fixedScale = atlasElem.attribute( "fixedScale", "false" ) == "true" ? true : false; if ( composerMap && fixedScale ) { composerMap->setAtlasScalingMode( QgsComposerMap::Fixed ); } mSingleFile = atlasElem.attribute( "singleFile", "false" ) == "true" ? true : false; mFilenamePattern = atlasElem.attribute( "filenamePattern", "" ); mSortFeatures = atlasElem.attribute( "sortFeatures", "false" ) == "true" ? true : false; if ( mSortFeatures ) { mSortKeyAttributeName = atlasElem.attribute( "sortKey", "" ); // since 2.3, the field name is saved instead of the field index // following code keeps compatibility with version 2.2 projects // to be removed in QGIS 3.0 bool isIndex; int idx = mSortKeyAttributeName.toInt( &isIndex ); if ( isIndex && mCoverageLayer ) { const QgsFields fields = mCoverageLayer->pendingFields(); if ( idx >= 0 && idx < fields.count() ) { mSortKeyAttributeName = fields[idx].name(); } } mSortAscending = atlasElem.attribute( "sortAscending", "true" ) == "true" ? true : false; } mFilterFeatures = atlasElem.attribute( "filterFeatures", "false" ) == "true" ? true : false; if ( mFilterFeatures ) { mFeatureFilter = atlasElem.attribute( "featureFilter", "" ); } emit parameterChanged(); }