@@ -45,7 +45,9 @@ QgsAtlasCompositionWidget::QgsAtlasCompositionWidget( QWidget* parent, QgsCompos
45
45
mAtlasCoverageLayerComboBox ->setFilters ( QgsMapLayerProxyModel::VectorLayer );
46
46
47
47
connect ( mAtlasCoverageLayerComboBox , SIGNAL ( layerChanged ( QgsMapLayer* ) ), mAtlasSortFeatureKeyComboBox , SLOT ( setLayer ( QgsMapLayer* ) ) );
48
- connect ( mAtlasCoverageLayerComboBox , SIGNAL ( layerChanged ( QgsMapLayer* ) ), mPageNameWidget , SLOT ( setLayer ( QgsMapLayer* ) ) );
48
+ connect ( mAtlasCoverageLayerComboBox , SIGNAL ( layerChanged ( QgsMapLayer* ) ), this , SLOT ( changeCoverageLayer ( QgsMapLayer* ) ) );
49
+ connect ( mAtlasSortFeatureKeyComboBox , SIGNAL ( fieldChanged ( QString ) ), this , SLOT ( changesSortFeatureField ( QString ) ) );
50
+ connect ( mPageNameWidget , SIGNAL ( fieldChanged ( QString, bool ) ), this , SLOT ( pageNameExpressionChanged ( QString, bool ) ) );
49
51
50
52
// Sort direction
51
53
mAtlasSortFeatureDirectionButton ->setEnabled ( false );
@@ -80,6 +82,27 @@ void QgsAtlasCompositionWidget::on_mUseAtlasCheckBox_stateChanged( int state )
80
82
}
81
83
}
82
84
85
+ void QgsAtlasCompositionWidget::changeCoverageLayer ( QgsMapLayer *layer )
86
+ {
87
+ QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
88
+ if ( !atlasMap )
89
+ {
90
+ return ;
91
+ }
92
+
93
+ QgsVectorLayer* vl = dynamic_cast <QgsVectorLayer*>( layer );
94
+
95
+ if ( !vl )
96
+ {
97
+ atlasMap->setCoverageLayer ( 0 );
98
+ }
99
+ else
100
+ {
101
+ atlasMap->setCoverageLayer ( vl );
102
+ updateAtlasFeatures ();
103
+ }
104
+ }
105
+
83
106
void QgsAtlasCompositionWidget::on_mAtlasFilenamePatternEdit_editingFinished ()
84
107
{
85
108
QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
@@ -133,6 +156,16 @@ void QgsAtlasCompositionWidget::on_mAtlasFilenameExpressionButton_clicked()
133
156
}
134
157
}
135
158
159
+ void QgsAtlasCompositionWidget::on_mAtlasHideCoverageCheckBox_stateChanged ( int state )
160
+ {
161
+ QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
162
+ if ( !atlasMap )
163
+ {
164
+ return ;
165
+ }
166
+ atlasMap->setHideCoverage ( state == Qt::Checked );
167
+ }
168
+
136
169
void QgsAtlasCompositionWidget::on_mAtlasSingleFileCheckBox_stateChanged ( int state )
137
170
{
138
171
QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
@@ -155,6 +188,12 @@ void QgsAtlasCompositionWidget::on_mAtlasSingleFileCheckBox_stateChanged( int st
155
188
156
189
void QgsAtlasCompositionWidget::on_mAtlasSortFeatureCheckBox_stateChanged ( int state )
157
190
{
191
+ QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
192
+ if ( !atlasMap )
193
+ {
194
+ return ;
195
+ }
196
+
158
197
if ( state == Qt::Checked )
159
198
{
160
199
mAtlasSortFeatureDirectionButton ->setEnabled ( true );
@@ -165,6 +204,8 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureCheckBox_stateChanged( int s
165
204
mAtlasSortFeatureDirectionButton ->setEnabled ( false );
166
205
mAtlasSortFeatureKeyComboBox ->setEnabled ( false );
167
206
}
207
+ atlasMap->setSortFeatures ( state == Qt::Checked );
208
+ updateAtlasFeatures ();
168
209
}
169
210
170
211
void QgsAtlasCompositionWidget::updateAtlasFeatures ()
@@ -190,12 +231,31 @@ void QgsAtlasCompositionWidget::updateAtlasFeatures()
190
231
QMessageBox::Ok,
191
232
QMessageBox::Ok );
192
233
234
+ // Perhaps atlas preview should be disabled now? If so, it may get annoying if user is editing
235
+ // the filter expression and it keeps disabling itself.
236
+ return ;
237
+ }
238
+ }
239
+
240
+ void QgsAtlasCompositionWidget::changesSortFeatureField ( QString fieldName )
241
+ {
242
+ QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
243
+ if ( !atlasMap )
244
+ {
193
245
return ;
194
246
}
247
+ atlasMap->setSortKeyAttributeName ( fieldName );
248
+ updateAtlasFeatures ();
195
249
}
196
250
197
251
void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged ( int state )
198
252
{
253
+ QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
254
+ if ( !atlasMap )
255
+ {
256
+ return ;
257
+ }
258
+
199
259
if ( state == Qt::Checked )
200
260
{
201
261
mAtlasFeatureFilterEdit ->setEnabled ( true );
@@ -206,36 +266,30 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterCheckBox_stateChanged( int
206
266
mAtlasFeatureFilterEdit ->setEnabled ( false );
207
267
mAtlasFeatureFilterButton ->setEnabled ( false );
208
268
}
269
+ atlasMap->setFilterFeatures ( state == Qt::Checked );
270
+ updateAtlasFeatures ();
209
271
}
210
272
211
- void QgsAtlasCompositionWidget::on_mApplyConfigButton_clicked ( )
273
+ void QgsAtlasCompositionWidget::pageNameExpressionChanged ( QString expression, bool valid )
212
274
{
213
275
QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
214
- if ( !atlasMap )
276
+ if ( !atlasMap || ( !valid && !expression. isEmpty () ) )
215
277
{
216
278
return ;
217
279
}
218
280
219
- QgsVectorLayer* vl = dynamic_cast <QgsVectorLayer*>( mAtlasCoverageLayerComboBox ->currentLayer () );
220
- if ( !vl )
221
- {
222
- atlasMap->setCoverageLayer ( 0 );
223
- }
224
- else
281
+ atlasMap->setPageNameExpression ( expression );
282
+ }
283
+
284
+ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterEdit_editingFinished ()
285
+ {
286
+ QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
287
+ if ( !atlasMap )
225
288
{
226
- atlasMap-> setCoverageLayer ( vl ) ;
289
+ return ;
227
290
}
228
291
229
- atlasMap->setSortFeatures ( mAtlasSortFeatureCheckBox ->isChecked () );
230
- atlasMap->setSortKeyAttributeName ( mAtlasSortFeatureKeyComboBox ->currentField () );
231
- Qt::ArrowType at = mAtlasSortFeatureDirectionButton ->arrowType ();
232
- at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
233
- atlasMap->setSortAscending ( at == Qt::UpArrow );
234
- atlasMap->setFilterFeatures ( mAtlasFeatureFilterCheckBox ->isChecked () );
235
292
atlasMap->setFeatureFilter ( mAtlasFeatureFilterEdit ->text () );
236
- atlasMap->setPageNameExpression ( mPageNameWidget ->currentField () );
237
- atlasMap->setHideCoverage ( mAtlasHideCoverageCheckBox ->isChecked () );
238
-
239
293
updateAtlasFeatures ();
240
294
}
241
295
@@ -259,6 +313,8 @@ void QgsAtlasCompositionWidget::on_mAtlasFeatureFilterButton_clicked()
259
313
if ( !expression.isEmpty () )
260
314
{
261
315
mAtlasFeatureFilterEdit ->setText ( expression );
316
+ atlasMap->setFeatureFilter ( mAtlasFeatureFilterEdit ->text () );
317
+ updateAtlasFeatures ();
262
318
}
263
319
}
264
320
}
@@ -268,6 +324,15 @@ void QgsAtlasCompositionWidget::on_mAtlasSortFeatureDirectionButton_clicked()
268
324
Qt::ArrowType at = mAtlasSortFeatureDirectionButton ->arrowType ();
269
325
at = ( at == Qt::UpArrow ) ? Qt::DownArrow : Qt::UpArrow;
270
326
mAtlasSortFeatureDirectionButton ->setArrowType ( at );
327
+
328
+ QgsAtlasComposition* atlasMap = &mComposition ->atlasComposition ();
329
+ if ( !atlasMap )
330
+ {
331
+ return ;
332
+ }
333
+
334
+ atlasMap->setSortAscending ( at == Qt::UpArrow );
335
+ updateAtlasFeatures ();
271
336
}
272
337
273
338
void QgsAtlasCompositionWidget::updateGuiElements ()
0 commit comments