Skip to content

Commit

Permalink
Merge pull request #278 from Oslandia/atlas
Browse files Browse the repository at this point in the history
Fix atlas parameter loading when loading from a template composer
  • Loading branch information
mhugent committed Oct 8, 2012
2 parents 3f412e4 + 6c652a0 commit 3012794
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/app/composer/qgsatlascompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ QgsAtlasCompositionWidget::QgsAtlasCompositionWidget( QWidget* parent, QgsCompos
// Only consider vector layers
if ( dynamic_cast<QgsVectorLayer*>(it.value()) )
{
mAtlasCoverageLayerComboBox->insertItem( idx++, it.key(), /* userdata */ qVariantFromValue( (void*)it.value() ) );
mAtlasCoverageLayerComboBox->insertItem( idx++, it.value()->name(), /* userdata */ qVariantFromValue( (void*)it.value() ) );
}
}

Expand Down Expand Up @@ -93,7 +93,8 @@ void QgsAtlasCompositionWidget::onLayerRemoved( QString layerName )
// update the atlas coverage layer combo box
for ( int i = 0; i < mAtlasCoverageLayerComboBox->count(); ++i )
{
if ( mAtlasCoverageLayerComboBox->itemText( i ) == layerName )
const QgsMapLayer* layer = reinterpret_cast<const QgsMapLayer*>( mAtlasCoverageLayerComboBox->itemData( i ).value<void*>() );
if ( layer->id() == layerName )
{
mAtlasCoverageLayerComboBox->removeItem( i );
break;
Expand All @@ -112,7 +113,7 @@ void QgsAtlasCompositionWidget::onLayerAdded( QgsMapLayer* map )
QgsVectorLayer* vectorLayer = dynamic_cast<QgsVectorLayer*>( map );
if ( vectorLayer )
{
mAtlasCoverageLayerComboBox->addItem( map->id(), qVariantFromValue( (void*)map ) );
mAtlasCoverageLayerComboBox->addItem( map->name(), qVariantFromValue( (void*)map ) );
}
if ( mAtlasCoverageLayerComboBox->count() == 1 )
{
Expand Down
15 changes: 5 additions & 10 deletions src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ bool QgsComposition::loadFromTemplate( const QDomDocument& doc, QMap<QString, QS

//addItemsFromXML
addItemsFromXML( importDoc.documentElement(), importDoc, 0, addUndoCommands, 0 );

// read atlas parameters
QDomElement atlasElem = importDoc.documentElement().firstChildElement( "Atlas" );
atlasComposition().readXML( atlasElem, importDoc );

return true;
}

Expand Down Expand Up @@ -1629,13 +1634,3 @@ QString QgsComposition::encodeStringForXML( const QString& str )
return modifiedStr;
}

#if 0
void QgsComposition::setAtlasComposerMap( QgsAtlasComposerMap* map )
{
if ( mAtlasComposerMap != 0 )
{
delete mAtlasComposerMap;
}
mAtlasComposerMap = map;
}
#endif

0 comments on commit 3012794

Please sign in to comment.