Skip to content

Commit 12eb44e

Browse files
committed
[composer] Refresh main map canvas when atlas preview feature changes, allows for easier customisation of maps styled using $atlasfeatureid expressions
1 parent 8a11be8 commit 12eb44e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/app/composer/qgscomposer.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
507507
mActionExportAtlasAsImage->setEnabled( false );
508508
mActionExportAtlasAsSVG->setEnabled( false );
509509
mActionExportAtlasAsPDF->setEnabled( false );
510+
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
511+
connect( atlasMap, SIGNAL( toggled( bool ) ), this, SLOT( toggleAtlasControls( bool ) ) );
510512

511513
// Create size grip (needed by Mac OS X for QMainWindow if QStatusBar is not visible)
512514
//should not be needed now that composer has a status bar?
@@ -857,6 +859,7 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
857859
if ( checked )
858860
{
859861
atlasMap->firstFeature();
862+
emit( atlasPreviewFeatureChanged() );
860863
}
861864
else
862865
{
@@ -875,7 +878,7 @@ void QgsComposer::on_mActionAtlasNext_triggered()
875878
}
876879

877880
atlasMap->nextFeature();
878-
881+
emit( atlasPreviewFeatureChanged() );
879882
}
880883

881884
void QgsComposer::on_mActionAtlasPrev_triggered()
@@ -887,7 +890,7 @@ void QgsComposer::on_mActionAtlasPrev_triggered()
887890
}
888891

889892
atlasMap->prevFeature();
890-
893+
emit( atlasPreviewFeatureChanged() );
891894
}
892895

893896
void QgsComposer::on_mActionAtlasFirst_triggered()
@@ -899,6 +902,7 @@ void QgsComposer::on_mActionAtlasFirst_triggered()
899902
}
900903

901904
atlasMap->firstFeature();
905+
emit( atlasPreviewFeatureChanged() );
902906
}
903907

904908
void QgsComposer::on_mActionAtlasLast_triggered()
@@ -910,6 +914,7 @@ void QgsComposer::on_mActionAtlasLast_triggered()
910914
}
911915

912916
atlasMap->lastFeature();
917+
emit( atlasPreviewFeatureChanged() );
913918
}
914919

915920
QgsMapCanvas *QgsComposer::mapCanvas( void )

src/app/composer/qgscomposer.h

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
123123
//!Composer deletes the old composerview when loading a template
124124
void composerWillBeRemoved( QgsComposerView* v );
125125

126+
//! Is emitted when the atlas preview feature changes
127+
void atlasPreviewFeatureChanged();
128+
126129
public slots:
127130
//! Zoom to full extent of the paper
128131
void on_mActionZoomAll_triggered();

src/app/qgisapp.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -5048,6 +5048,7 @@ QgsComposer* QgisApp::createNewComposer( QString title )
50485048
emit composerAdded( newComposerObject->view() );
50495049
connect( newComposerObject, SIGNAL( composerAdded( QgsComposerView* ) ), this, SIGNAL( composerAdded( QgsComposerView* ) ) );
50505050
connect( newComposerObject, SIGNAL( composerWillBeRemoved( QgsComposerView* ) ), this, SIGNAL( composerWillBeRemoved( QgsComposerView* ) ) );
5051+
connect( newComposerObject, SIGNAL( atlasPreviewFeatureChanged() ), this, SLOT( refreshMapCanvas() ) );
50515052
markDirty();
50525053
return newComposerObject;
50535054
}
@@ -5137,6 +5138,7 @@ bool QgisApp::loadComposersFromProject( const QDomDocument& doc )
51375138
emit composerAdded( composer->view() );
51385139
connect( composer, SIGNAL( composerAdded( QgsComposerView* ) ), this, SIGNAL( composerAdded( QgsComposerView* ) ) );
51395140
connect( composer, SIGNAL( composerWillBeRemoved( QgsComposerView* ) ), this, SIGNAL( composerWillBeRemoved( QgsComposerView* ) ) );
5141+
connect( composer, SIGNAL( atlasPreviewFeatureChanged() ), this, SLOT( refreshMapCanvas() ) );
51405142
}
51415143
return true;
51425144
}

0 commit comments

Comments
 (0)