@@ -407,6 +407,17 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
407
407
atlasExportToolButton->addAction ( mActionExportAtlasAsPDF );
408
408
atlasExportToolButton->setDefaultAction ( mActionExportAtlasAsImage );
409
409
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 );
410
421
411
422
QMenu *settingsMenu = menuBar ()->addMenu ( tr ( " &Settings" ) );
412
423
settingsMenu->addAction ( mActionOptions );
@@ -613,12 +624,14 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
613
624
mActionAtlasNext ->setEnabled ( false );
614
625
mActionAtlasPrev ->setEnabled ( false );
615
626
mActionPrintAtlas ->setEnabled ( false );
627
+ mAtlasPageComboBox ->setEnabled ( false );
616
628
mActionExportAtlasAsImage ->setEnabled ( false );
617
629
mActionExportAtlasAsSVG ->setEnabled ( false );
618
630
mActionExportAtlasAsPDF ->setEnabled ( false );
619
631
QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
620
632
connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
621
633
connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
634
+ connect ( atlasMap, SIGNAL ( numberFeaturesChanged ( int ) ), this , SLOT ( updateAtlasPageComboBox ( int ) ) );
622
635
623
636
// default printer page setup
624
637
setPrinterPageDefaults ();
@@ -968,6 +981,7 @@ void QgsComposer::toggleAtlasControls( bool atlasEnabled )
968
981
mActionAtlasLast ->setEnabled ( false );
969
982
mActionAtlasNext ->setEnabled ( false );
970
983
mActionAtlasPrev ->setEnabled ( false );
984
+ mAtlasPageComboBox ->setEnabled ( false );
971
985
mActionAtlasPreview ->blockSignals ( false );
972
986
mActionAtlasPreview ->setEnabled ( atlasEnabled );
973
987
mActionPrintAtlas ->setEnabled ( atlasEnabled );
@@ -978,6 +992,20 @@ void QgsComposer::toggleAtlasControls( bool atlasEnabled )
978
992
updateAtlasMapLayerAction ( atlasEnabled );
979
993
}
980
994
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
+
981
1009
void QgsComposer::on_mActionAtlasPreview_triggered ( bool checked )
982
1010
{
983
1011
QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
@@ -1002,6 +1030,7 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
1002
1030
mActionAtlasLast ->setEnabled ( checked );
1003
1031
mActionAtlasNext ->setEnabled ( checked );
1004
1032
mActionAtlasPrev ->setEnabled ( checked );
1033
+ mAtlasPageComboBox ->setEnabled ( checked );
1005
1034
1006
1035
if ( checked )
1007
1036
{
@@ -1022,6 +1051,7 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
1022
1051
mActionAtlasLast ->setEnabled ( false );
1023
1052
mActionAtlasNext ->setEnabled ( false );
1024
1053
mActionAtlasPrev ->setEnabled ( false );
1054
+ mAtlasPageComboBox ->setEnabled ( false );
1025
1055
mActionAtlasPreview ->blockSignals ( false );
1026
1056
mStatusAtlasLabel ->setText ( QString () );
1027
1057
return ;
@@ -1036,10 +1066,8 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
1036
1066
{
1037
1067
mStatusAtlasLabel ->setText ( QString () );
1038
1068
}
1039
-
1040
1069
}
1041
1070
1042
-
1043
1071
void QgsComposer::on_mActionAtlasNext_triggered ()
1044
1072
{
1045
1073
QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
@@ -1100,6 +1128,23 @@ void QgsComposer::on_mActionAtlasLast_triggered()
1100
1128
emit atlasPreviewFeatureChanged ();
1101
1129
}
1102
1130
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
+
1103
1148
QgsMapCanvas *QgsComposer::mapCanvas ( void )
1104
1149
{
1105
1150
return mQgis ->mapCanvas ();
@@ -1415,6 +1460,7 @@ void QgsComposer::setComposition( QgsComposition* composition )
1415
1460
toggleAtlasControls ( atlasMap->enabled () );
1416
1461
connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
1417
1462
connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
1463
+ connect ( atlasMap, SIGNAL ( numberFeaturesChanged ( int ) ), this , SLOT ( updateAtlasPageComboBox ( int ) ) );
1418
1464
1419
1465
// default printer page setup
1420
1466
setPrinterPageDefaults ();
@@ -3233,6 +3279,7 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
3233
3279
toggleAtlasControls ( atlasMap->enabled () );
3234
3280
connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
3235
3281
connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
3282
+ connect ( atlasMap, SIGNAL ( numberFeaturesChanged ( int ) ), this , SLOT ( updateAtlasPageComboBox ( int ) ) );
3236
3283
3237
3284
// default printer page setup
3238
3285
setPrinterPageDefaults ();
@@ -3716,6 +3763,7 @@ void QgsComposer::setAtlasFeature( QgsMapLayer* layer, const QgsFeature& feat )
3716
3763
mActionAtlasLast ->setEnabled ( true );
3717
3764
mActionAtlasNext ->setEnabled ( true );
3718
3765
mActionAtlasPrev ->setEnabled ( true );
3766
+ mAtlasPageComboBox ->setEnabled ( true );
3719
3767
}
3720
3768
3721
3769
// bring composer window to foreground
0 commit comments