From c8c2f1422b7e7f87fc85a2234f00cb6c356e9f31 Mon Sep 17 00:00:00 2001 From: Gustaw Gawrysiak Date: Thu, 5 Aug 2021 11:51:49 +0000 Subject: [PATCH] Wms wmts ponowne dodanie warstw --- OrtoTools.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/OrtoTools.py b/OrtoTools.py index 6acbb5b..1d3fba6 100644 --- a/OrtoTools.py +++ b/OrtoTools.py @@ -102,10 +102,9 @@ def add_to_map(self, name): CustomMessageBox( None, tr('Can\'t add layer') + name).button_ok() else: - CustomMessageBox( - None, tr('Layer already exists ') + name).button_ok() lyr = QgsProject.instance().mapLayersByName(name)[0] - QgsProject.instance().layerTreeRoot().findLayer(lyr.id()).setItemVisibilityChecked(True) + lyrontree = QgsProject.instance().layerTreeRoot().findLayer(lyr.id()) + lyrontree.setItemVisibilityChecked(not lyrontree.isItemVisibilityCheckedRecursive()) def create_menu(self): layers_names = [] @@ -150,13 +149,9 @@ def create_menu(self): self.ortomenu = menu def ortocheck(self): - lyrs = [layer.name() for layer in QgsProject.instance().mapLayers().values()] - ortos = self.ortomenu - for orto in ortos.actions(): - if orto.text() in lyrs: - orto.setChecked(True) - else: - orto.setChecked(False) + checked = [layer.name() for layer in QgsProject.instance().layerTreeRoot().checkedLayers()] + for orto in self.ortomenu.actions(): + orto.setChecked(orto.text() in checked) class OrtoActionService(QObject): orto_added = pyqtSignal()