@@ -1410,102 +1410,6 @@ void QgsLegend::handleItemChange(QTreeWidgetItem* item, int row)
1410
1410
mStateOfCheckBoxes [item] = item->checkState (0 );
1411
1411
}
1412
1412
}
1413
- #if 0
1414
- QgsLegendGroup* lg = dynamic_cast<QgsLegendGroup*>(item);
1415
- if(lg)
1416
- {
1417
- #ifdef QGISDEBUG
1418
- qWarning("detected legend group in QgsLegend::handleItemChange");
1419
- #endif
1420
- std::map<QTreeWidgetItem*, Qt::CheckState>::iterator it = mStateOfCheckBoxes.find(item);
1421
- if(it != mStateOfCheckBoxes.end())
1422
- {
1423
- if(it->second != item->checkState(0)) //the checkState has changed
1424
- {
1425
- bool checked = (item->checkState(0) == Qt::Checked);
1426
-
1427
- }
1428
- }
1429
- return;
1430
- }
1431
-
1432
- QgsLegendLayerFile* llf = dynamic_cast<QgsLegendLayerFile*>(item);
1433
- if(llf)
1434
- {
1435
- #ifdef QGISDEBUG
1436
- qWarning("item is a QgsLegendLayerFile*");
1437
- #endif
1438
- std::map<QTreeWidgetItem*, Qt::CheckState>::iterator it = mStateOfCheckBoxes.find(item);
1439
- if(it != mStateOfCheckBoxes.end())
1440
- {
1441
- if(it->second != item->checkState(0)) //the checkState has changed
1442
- {
1443
- QgsMapLayer* theLayer = llf->layer();
1444
- if(theLayer)
1445
- {
1446
- bool checked = (item->checkState(0) == Qt::Checked);
1447
- theLayer->setVisible(checked);
1448
- //check, how the checkbox of the legendlayer needs to be updated
1449
- QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(item->parent()->parent());
1450
- std::list<QgsLegendLayerFile*> llfiles = ll->legendLayerFiles();
1451
- std::list<QgsLegendLayerFile*>::iterator iter = llfiles.begin();
1452
- Qt::CheckState theState = (*iter)->checkState(0);
1453
- for(; iter != llfiles.end(); ++iter)
1454
- {
1455
- if(theState != (*iter)->checkState(0))
1456
- {
1457
- theState = Qt::PartiallyChecked;
1458
- break;
1459
- }
1460
- }
1461
- //and update the checkbox of the legendlayer if necessary
1462
- if(theState != ll->checkState(0));
1463
- {
1464
- blockSignals(true);
1465
- ll->setCheckState(0, theState);
1466
- mStateOfCheckBoxes[ll] = theState;
1467
- blockSignals(false);
1468
- }
1469
- }
1470
- mStateOfCheckBoxes[item] = item->checkState(0);
1471
- }
1472
- }
1473
- return;
1474
- }
1475
-
1476
- QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(item);
1477
- if(ll)
1478
- {
1479
- #ifdef QGISDEBUG
1480
- qWarning("item is a QgsLegendLayer");
1481
- #endif
1482
- std::map<QTreeWidgetItem*, Qt::CheckState>::iterator it = mStateOfCheckBoxes.find(item);
1483
- if(it != mStateOfCheckBoxes.end())
1484
- {
1485
- if(it->second != item->checkState(0)) //the checkState has changed
1486
- {
1487
- bool checked = (item->checkState(0) == Qt::Checked);
1488
- std::list<QgsLegendLayerFile*> llflist = ll->legendLayerFiles();
1489
- mMapCanvas->setRenderFlag(false);
1490
- //go through all the legendlayerfiles and set their checkState
1491
- for(std::list<QgsLegendLayerFile*>::iterator it = llflist.begin(); it != llflist.end(); ++it)
1492
- {
1493
- if(checked)
1494
- {
1495
- (*it)->setCheckState(0, Qt::Checked);
1496
- mStateOfCheckBoxes[(*it)] = Qt::Checked;
1497
- }
1498
- else
1499
- {
1500
- (*it)->setCheckState(0, Qt::Unchecked);
1501
- mStateOfCheckBoxes[(*it)] = Qt::Unchecked;
1502
- }
1503
- }
1504
- mMapCanvas->setRenderFlag(true);
1505
- }
1506
- }
1507
- }
1508
- #endif // 0
1509
1413
}
1510
1414
1511
1415
void QgsLegend::openEditor ()
@@ -1536,6 +1440,12 @@ void QgsLegend::showLegendLayerFileGroups()
1536
1440
1537
1441
QgsLegendLayerFileGroup* theFileGroup = 0 ;
1538
1442
QTreeWidgetItem* theItem = firstItem ();
1443
+
1444
+ if (!theItem)
1445
+ {
1446
+ return ;
1447
+ }
1448
+
1539
1449
do
1540
1450
{
1541
1451
theFileGroup = dynamic_cast <QgsLegendLayerFileGroup*>(theItem);
0 commit comments