@@ -136,7 +136,7 @@ void QgsAtlasCompositionWidget::onLayerAdded( QgsMapLayer* map )
136
136
if ( mAtlasCoverageLayerComboBox ->count () == 1 )
137
137
{
138
138
atlasMap->setCoverageLayer ( vectorLayer );
139
- atlasMap-> updateFeatures ();
139
+ updateAtlasFeatures ();
140
140
checkLayerType ( vectorLayer );
141
141
}
142
142
}
@@ -192,7 +192,7 @@ void QgsAtlasCompositionWidget::on_mAtlasCoverageLayerComboBox_currentIndexChang
192
192
{
193
193
checkLayerType ( layer );
194
194
atlasMap->setCoverageLayer ( layer );
195
- atlasMap-> updateFeatures ();
195
+ updateAtlasFeatures ();
196
196
}
197
197
198
198
// update sorting columns
@@ -335,7 +335,36 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureCheckBox_stateChanged( int s
335
335
mAtlasSortFeatureKeyComboBox ->setEnabled ( false );
336
336
}
337
337
atlasMap->setSortFeatures ( state == Qt::Checked );
338
- atlasMap->updateFeatures ();
338
+ updateAtlasFeatures ();
339
+ }
340
+
341
+ void QgsAtlasCompositionWidget::updateAtlasFeatures ()
342
+ {
343
+ // only do this if composer mode is preview
344
+ if ( !mComposition ->atlasPreviewEnabled () )
345
+ {
346
+ return ;
347
+ }
348
+
349
+ // update atlas features
350
+ QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
351
+ if ( !atlasMap )
352
+ {
353
+ return ;
354
+ }
355
+
356
+ bool updated = atlasMap->updateFeatures ();
357
+ if ( !updated )
358
+ {
359
+ QMessageBox::warning ( 0 , tr ( " Atlas preview" ),
360
+ tr ( " No matching atlas features found!" ),
361
+ QMessageBox::Ok,
362
+ QMessageBox::Ok );
363
+
364
+ // Perhaps atlas preview should be disabled now? If so, it may get annoying if user is editing
365
+ // the filter expression and it keeps disabling itself.
366
+ return ;
367
+ }
339
368
}
340
369
341
370
void QgsAtlasCompositionWidget::on_mAtlasSortFeatureKeyComboBox_currentIndexChanged ( int index )
@@ -350,7 +379,7 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureKeyComboBox_currentIndexChan
350
379
{
351
380
atlasMap->setSortKeyAttributeIndex ( index );
352
381
}
353
- atlasMap-> updateFeatures ();
382
+ updateAtlasFeatures ();
354
383
}
355
384
356
385
void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged ( int state )
@@ -372,7 +401,7 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged( int
372
401
mAtlasFeatureFilterButton ->setEnabled ( false );
373
402
}
374
403
atlasMap->setFilterFeatures ( state == Qt::Checked );
375
- atlasMap-> updateFeatures ();
404
+ updateAtlasFeatures ();
376
405
}
377
406
378
407
void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_textChanged ( const QString& text )
@@ -384,7 +413,7 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_textChanged( const QS
384
413
}
385
414
386
415
atlasMap->setFeatureFilter ( text );
387
- atlasMap-> updateFeatures ();
416
+ updateAtlasFeatures ();
388
417
}
389
418
390
419
void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterButton_clicked ()
@@ -421,7 +450,7 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureDirectionButton_clicked()
421
450
}
422
451
423
452
atlasMap->setSortAscending ( at == Qt::UpArrow );
424
- atlasMap-> updateFeatures ();
453
+ updateAtlasFeatures ();
425
454
}
426
455
427
456
void QgsAtlasCompositionWidget::fillSortColumns ()
0 commit comments