Ver código fonte

wxGUI/lmgr: add layer menu items for check/uncheck selected layers (#1905)

Tomas Zigo 3 anos atrás
pai
commit
5e861620da
1 arquivos alterados com 35 adições e 0 exclusões
  1. 35 0
      gui/wxpython/lmgr/layertree.py

+ 35 - 0
gui/wxpython/lmgr/layertree.py

@@ -459,6 +459,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                 "export-pg",
                 "export-attr",
                 "pack",
+                "check",
+                "uncheck",
             ):
                 self.popupID[key] = NewId()
 
@@ -478,6 +480,30 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
             self.popupMenu.Append(self.popupID["rename"], _("Rename"))
             self.Bind(wx.EVT_MENU, self.OnRenameLayer, id=self.popupID["rename"])
 
+        if numSelected > 1:
+            item = wx.MenuItem(
+                self.popupMenu,
+                id=self.popupID["check"],
+                text=_("Check selected layers"),
+            )
+            self.popupMenu.AppendItem(item)
+            self.Bind(
+                wx.EVT_MENU,
+                self.OnCheckUncheckSelectedLayer,
+                id=self.popupID["check"],
+            )
+            item = wx.MenuItem(
+                self.popupMenu,
+                id=self.popupID["uncheck"],
+                text=_("Uncheck selected layers"),
+            )
+            self.popupMenu.AppendItem(item)
+            self.Bind(
+                wx.EVT_MENU,
+                self.OnCheckUncheckSelectedLayer,
+                id=self.popupID["uncheck"],
+            )
+
         # when multiple maps are selected of different types
         # we cannot zoom or change region
         # because g.region can handle only the same type
@@ -1334,6 +1360,15 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                     )
                     self.SetItemText(item, newlabel)
 
+    def OnCheckUncheckSelectedLayer(self, event):
+        """Check/uncheck selected layer(s)"""
+        check = wx.CHK_CHECKED
+        if event.GetId() == self.popupID["uncheck"]:
+            check = wx.CHK_UNCHECKED
+        self.hitCheckbox = True
+        for layer in self.GetSelections():
+            self.CheckItem(layer, checked=check)
+
     def AddLayer(
         self,
         ltype,