@@ -407,6 +407,17 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
407407 atlasExportToolButton->addAction ( mActionExportAtlasAsPDF );
408408 atlasExportToolButton->setDefaultAction ( mActionExportAtlasAsImage );
409409 mAtlasToolbar ->insertWidget ( mActionAtlasSettings , atlasExportToolButton );
410+ mAtlasPageComboBox = new QComboBox ();
411+ mAtlasPageComboBox ->setEditable ( true );
412+ mAtlasPageComboBox ->addItem ( QString::number ( 1 ) );
413+ mAtlasPageComboBox ->setCurrentIndex ( 0 );
414+ mAtlasPageComboBox ->setMinimumHeight ( mAtlasToolbar ->height () );
415+ mAtlasPageComboBox ->setMinimumContentsLength ( 6 );
416+ mAtlasPageComboBox ->setMaxVisibleItems ( 20 );
417+ mAtlasPageComboBox ->setInsertPolicy ( QComboBox::NoInsert );
418+ connect ( mAtlasPageComboBox ->lineEdit (), SIGNAL ( editingFinished () ), this , SLOT ( atlasPageComboEditingFinished () ) );
419+ connect ( mAtlasPageComboBox , SIGNAL ( currentIndexChanged ( QString ) ), this , SLOT ( atlasPageComboEditingFinished () ) );
420+ mAtlasToolbar ->insertWidget ( mActionAtlasNext , mAtlasPageComboBox );
410421
411422 QMenu *settingsMenu = menuBar ()->addMenu ( tr ( " &Settings" ) );
412423 settingsMenu->addAction ( mActionOptions );
@@ -613,12 +624,14 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
613624 mActionAtlasNext ->setEnabled ( false );
614625 mActionAtlasPrev ->setEnabled ( false );
615626 mActionPrintAtlas ->setEnabled ( false );
627+ mAtlasPageComboBox ->setEnabled ( false );
616628 mActionExportAtlasAsImage ->setEnabled ( false );
617629 mActionExportAtlasAsSVG ->setEnabled ( false );
618630 mActionExportAtlasAsPDF ->setEnabled ( false );
619631 QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
620632 connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
621633 connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
634+ connect ( atlasMap, SIGNAL ( numberFeaturesChanged ( int ) ), this , SLOT ( updateAtlasPageComboBox ( int ) ) );
622635
623636 // default printer page setup
624637 setPrinterPageDefaults ();
@@ -968,6 +981,7 @@ void QgsComposer::toggleAtlasControls( bool atlasEnabled )
968981 mActionAtlasLast ->setEnabled ( false );
969982 mActionAtlasNext ->setEnabled ( false );
970983 mActionAtlasPrev ->setEnabled ( false );
984+ mAtlasPageComboBox ->setEnabled ( false );
971985 mActionAtlasPreview ->blockSignals ( false );
972986 mActionAtlasPreview ->setEnabled ( atlasEnabled );
973987 mActionPrintAtlas ->setEnabled ( atlasEnabled );
@@ -978,6 +992,20 @@ void QgsComposer::toggleAtlasControls( bool atlasEnabled )
978992 updateAtlasMapLayerAction ( atlasEnabled );
979993}
980994
995+ void QgsComposer::updateAtlasPageComboBox ( int pageCount )
996+ {
997+ if ( pageCount == mAtlasPageComboBox ->count () )
998+ return ;
999+
1000+ mAtlasPageComboBox ->blockSignals ( true );
1001+ mAtlasPageComboBox ->clear ();
1002+ for ( int i = 1 ; i <= pageCount && i < 500 ; ++i )
1003+ {
1004+ mAtlasPageComboBox ->addItem ( QString::number ( i ), i );
1005+ }
1006+ mAtlasPageComboBox ->blockSignals ( false );
1007+ }
1008+
9811009void QgsComposer::on_mActionAtlasPreview_triggered ( bool checked )
9821010{
9831011 QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
@@ -1002,6 +1030,7 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
10021030 mActionAtlasLast ->setEnabled ( checked );
10031031 mActionAtlasNext ->setEnabled ( checked );
10041032 mActionAtlasPrev ->setEnabled ( checked );
1033+ mAtlasPageComboBox ->setEnabled ( checked );
10051034
10061035 if ( checked )
10071036 {
@@ -1022,6 +1051,7 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
10221051 mActionAtlasLast ->setEnabled ( false );
10231052 mActionAtlasNext ->setEnabled ( false );
10241053 mActionAtlasPrev ->setEnabled ( false );
1054+ mAtlasPageComboBox ->setEnabled ( false );
10251055 mActionAtlasPreview ->blockSignals ( false );
10261056 mStatusAtlasLabel ->setText ( QString () );
10271057 return ;
@@ -1036,10 +1066,8 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
10361066 {
10371067 mStatusAtlasLabel ->setText ( QString () );
10381068 }
1039-
10401069}
10411070
1042-
10431071void QgsComposer::on_mActionAtlasNext_triggered ()
10441072{
10451073 QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
@@ -1100,6 +1128,23 @@ void QgsComposer::on_mActionAtlasLast_triggered()
11001128 emit atlasPreviewFeatureChanged ();
11011129}
11021130
1131+ void QgsComposer::atlasPageComboEditingFinished ()
1132+ {
1133+ QString text = mAtlasPageComboBox ->lineEdit ()->text ();
1134+ bool ok = false ;
1135+ int page = text.toInt ( &ok );
1136+ if ( !ok || page >= mComposition ->atlasComposition ().numFeatures () )
1137+ {
1138+ mAtlasPageComboBox ->blockSignals ( true );
1139+ mAtlasPageComboBox ->setCurrentIndex ( mComposition ->atlasComposition ().currentFeatureNumber () );
1140+ mAtlasPageComboBox ->blockSignals ( false );
1141+ }
1142+ else if ( page != mComposition ->atlasComposition ().currentFeatureNumber () + 1 )
1143+ {
1144+ mComposition ->atlasComposition ().prepareForFeature ( page - 1 );
1145+ }
1146+ }
1147+
11031148QgsMapCanvas *QgsComposer::mapCanvas ( void )
11041149{
11051150 return mQgis ->mapCanvas ();
@@ -1415,6 +1460,7 @@ void QgsComposer::setComposition( QgsComposition* composition )
14151460 toggleAtlasControls ( atlasMap->enabled () );
14161461 connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
14171462 connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
1463+ connect ( atlasMap, SIGNAL ( numberFeaturesChanged ( int ) ), this , SLOT ( updateAtlasPageComboBox ( int ) ) );
14181464
14191465 // default printer page setup
14201466 setPrinterPageDefaults ();
@@ -3233,6 +3279,7 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
32333279 toggleAtlasControls ( atlasMap->enabled () );
32343280 connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
32353281 connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
3282+ connect ( atlasMap, SIGNAL ( numberFeaturesChanged ( int ) ), this , SLOT ( updateAtlasPageComboBox ( int ) ) );
32363283
32373284 // default printer page setup
32383285 setPrinterPageDefaults ();
@@ -3716,6 +3763,7 @@ void QgsComposer::setAtlasFeature( QgsMapLayer* layer, const QgsFeature& feat )
37163763 mActionAtlasLast ->setEnabled ( true );
37173764 mActionAtlasNext ->setEnabled ( true );
37183765 mActionAtlasPrev ->setEnabled ( true );
3766+ mAtlasPageComboBox ->setEnabled ( true );
37193767 }
37203768
37213769 // bring composer window to foreground
0 commit comments