@@ -633,6 +633,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
633
633
connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
634
634
connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
635
635
connect ( atlasMap, SIGNAL ( numberFeaturesChanged ( int ) ), this , SLOT ( updateAtlasPageComboBox ( int ) ) );
636
+ connect ( atlasMap, SIGNAL ( featureChanged ( QgsFeature* ) ), this , SLOT ( atlasFeatureChanged ( QgsFeature* ) ) );
636
637
637
638
// default printer page setup
638
639
setPrinterPageDefaults ();
@@ -1007,6 +1008,27 @@ void QgsComposer::updateAtlasPageComboBox( int pageCount )
1007
1008
mAtlasPageComboBox ->blockSignals ( false );
1008
1009
}
1009
1010
1011
+ void QgsComposer::atlasFeatureChanged ( QgsFeature *feature )
1012
+ {
1013
+ Q_UNUSED ( feature );
1014
+
1015
+ if ( !mComposition )
1016
+ return ;
1017
+
1018
+ mAtlasPageComboBox ->blockSignals ( true );
1019
+ // prefer to set index of current atlas page, if combo box is showing enough page items
1020
+ if ( mComposition ->atlasComposition ().currentFeatureNumber () < mAtlasPageComboBox ->count () )
1021
+ {
1022
+ mAtlasPageComboBox ->setCurrentIndex ( mComposition ->atlasComposition ().currentFeatureNumber () );
1023
+ }
1024
+ else
1025
+ {
1026
+ // fallback to setting the combo text to the page number
1027
+ mAtlasPageComboBox ->setEditText ( QString::number ( mComposition ->atlasComposition ().currentFeatureNumber () + 1 ) );
1028
+ }
1029
+ mAtlasPageComboBox ->blockSignals ( false );
1030
+ }
1031
+
1010
1032
void QgsComposer::on_mActionAtlasPreview_triggered ( bool checked )
1011
1033
{
1012
1034
QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
@@ -1134,7 +1156,7 @@ void QgsComposer::atlasPageComboEditingFinished()
1134
1156
QString text = mAtlasPageComboBox ->lineEdit ()->text ();
1135
1157
bool ok = false ;
1136
1158
int page = text.toInt ( &ok );
1137
- if ( !ok || page >= mComposition ->atlasComposition ().numFeatures () )
1159
+ if ( !ok || page >= mComposition ->atlasComposition ().numFeatures () || page < 1 )
1138
1160
{
1139
1161
mAtlasPageComboBox ->blockSignals ( true );
1140
1162
mAtlasPageComboBox ->setCurrentIndex ( mComposition ->atlasComposition ().currentFeatureNumber () );
@@ -1462,6 +1484,7 @@ void QgsComposer::setComposition( QgsComposition* composition )
1462
1484
connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
1463
1485
connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
1464
1486
connect ( atlasMap, SIGNAL ( numberFeaturesChanged ( int ) ), this , SLOT ( updateAtlasPageComboBox ( int ) ) );
1487
+ connect ( atlasMap, SIGNAL ( featureChanged ( QgsFeature* ) ), this , SLOT ( atlasFeatureChanged ( QgsFeature* ) ) );
1465
1488
1466
1489
// default printer page setup
1467
1490
setPrinterPageDefaults ();
@@ -3281,6 +3304,7 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
3281
3304
connect ( atlasMap, SIGNAL ( toggled ( bool ) ), this , SLOT ( toggleAtlasControls ( bool ) ) );
3282
3305
connect ( atlasMap, SIGNAL ( coverageLayerChanged ( QgsVectorLayer* ) ), this , SLOT ( updateAtlasMapLayerAction ( QgsVectorLayer * ) ) );
3283
3306
connect ( atlasMap, SIGNAL ( numberFeaturesChanged ( int ) ), this , SLOT ( updateAtlasPageComboBox ( int ) ) );
3307
+ connect ( atlasMap, SIGNAL ( featureChanged ( QgsFeature* ) ), this , SLOT ( atlasFeatureChanged ( QgsFeature* ) ) );
3284
3308
3285
3309
// default printer page setup
3286
3310
setPrinterPageDefaults ();
0 commit comments