@@ -315,7 +315,7 @@ void QgsVectorLayerAndAttributeModel::applyVisibilityPreset( const QString &name
315
315
316
316
void QgsVectorLayerAndAttributeModel::applyVisibility ( QSet<QString> &visibleLayers, QgsLayerTreeNode *node )
317
317
{
318
- QgsLayerTreeGroup *group = QgsLayerTree::toGroup ( node );
318
+ QgsLayerTreeGroup *group = QgsLayerTree::isGroup ( node ) ? QgsLayerTree:: toGroup ( node ) : 0 ;
319
319
if ( !group )
320
320
return ;
321
321
@@ -336,6 +336,41 @@ void QgsVectorLayerAndAttributeModel::applyVisibility( QSet<QString> &visibleLay
336
336
}
337
337
}
338
338
339
+ void QgsVectorLayerAndAttributeModel::retrieveAllLayers ( QgsLayerTreeNode *node, QSet<QString> &set )
340
+ {
341
+ if ( QgsLayerTree::isLayer ( node ) )
342
+ {
343
+ set << QgsLayerTree::toLayer ( node )->layer ()->id ();
344
+ }
345
+ else if ( QgsLayerTree::isGroup ( node ) )
346
+ {
347
+ foreach ( QgsLayerTreeNode *child, QgsLayerTree::toGroup ( node )->children () )
348
+ {
349
+ retrieveAllLayers ( child, set );
350
+ }
351
+ }
352
+ }
353
+
354
+ void QgsVectorLayerAndAttributeModel::selectAll ()
355
+ {
356
+ mCheckedLeafs .clear ();
357
+
358
+ QSet<QString> allLayers;
359
+ retrieveAllLayers ( rootGroup (), allLayers );
360
+ applyVisibility ( allLayers, rootGroup () );
361
+
362
+ emit dataChanged ( QModelIndex (), QModelIndex () );
363
+ }
364
+
365
+ void QgsVectorLayerAndAttributeModel::unSelectAll ()
366
+ {
367
+ mCheckedLeafs .clear ();
368
+
369
+ applyVisibility ( QSet<QString>(), rootGroup () );
370
+
371
+ emit dataChanged ( QModelIndex (), QModelIndex () );
372
+ }
373
+
339
374
QgsDxfExportDialog::QgsDxfExportDialog ( QWidget *parent, Qt::WindowFlags f )
340
375
: QDialog( parent, f )
341
376
{
@@ -392,7 +427,7 @@ void QgsDxfExportDialog::on_mVisibilityPresets_currentIndexChanged( int index )
392
427
393
428
void QgsDxfExportDialog::cleanGroup ( QgsLayerTreeNode *node )
394
429
{
395
- QgsLayerTreeGroup *group = QgsLayerTree::toGroup ( node );
430
+ QgsLayerTreeGroup *group = QgsLayerTree::isGroup ( node ) ? QgsLayerTree:: toGroup ( node ) : 0 ;
396
431
if ( !group )
397
432
return ;
398
433
@@ -418,13 +453,16 @@ void QgsDxfExportDialog::cleanGroup( QgsLayerTreeNode *node )
418
453
419
454
void QgsDxfExportDialog::selectAll ()
420
455
{
421
- mTreeView ->selectAll ();
456
+ QgsVectorLayerAndAttributeModel *model = dynamic_cast < QgsVectorLayerAndAttributeModel *>( mTreeView ->model () );
457
+ Q_ASSERT ( model );
458
+ model->selectAll ();
422
459
}
423
460
424
-
425
461
void QgsDxfExportDialog::unSelectAll ()
426
462
{
427
- mTreeView ->clearSelection ();
463
+ QgsVectorLayerAndAttributeModel *model = dynamic_cast < QgsVectorLayerAndAttributeModel *>( mTreeView ->model () );
464
+ Q_ASSERT ( model );
465
+ model->unSelectAll ();
428
466
}
429
467
430
468
@@ -438,7 +476,7 @@ QList< QPair<QgsVectorLayer *, int> > QgsDxfExportDialog::layers() const
438
476
439
477
double QgsDxfExportDialog::symbologyScale () const
440
478
{
441
- double scale = 1 / mScaleWidget ->scale ();
479
+ double scale = 1 / mScaleWidget ->scale ();
442
480
if ( qgsDoubleNear ( scale, 0.0 ) )
443
481
{
444
482
return 1.0 ;
0 commit comments