prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Previously selected point deleted when deleting layer
  ## 🐛 Bug
  
  Recently selected points are erroneously removed when deleting new layers with the delete key. (reproduced with points and labels layer)
  
  ## To Reproduce
  
  Steps to reproduce the behaviour:
  
  1. Create a point on a points layer
  2. Create a new points layer
  3. Select the newly created points layer from the layer list (visually deselecting the point)
  4. Delete newly created layer using the delete key, the last selected point will also be deleted
  
  Please note that this issue does not occur when the layer is deleted using the bin icon, leading me to believe it is a keybinding issue (and the point must still be 'selected' in come capacity)
  <!-- If you have a code sample, error messages, stack traces, please provide it here as well -->
  
  
  https://user-images.githubusercontent.com/95660545/156966137-b2a645a6-25ae-42b4-baf7-137e7506e20a.mp4
  
  
  ## Expected behaviour
  It is expected that only the newly created points layer (with no points assigned to it) should be deleted, not the point as well.
  
  <!-- A clear and concise description of what you expected to happen. -->
  
  ## Environment
  
  napari: 0.4.15.dev68+gdd3a2afd
  Platform: Windows-10-10.0.19044-SP0
  Python: 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]
  Qt: 5.15.2
  PyQt5: 5.15.6
  NumPy: 1.21.5
  SciPy: 1.7.3
  Dask: 2022.01.0
  VisPy: 0.9.6
  
  OpenGL:
  - GL version: 4.6.0 - Build 26.20.100.7372
  - MAX_TEXTURE_SIZE: 16384
  
  Screens:
  - screen 1: resolution 1920x1080, scale 1.0
  
  Plugins:
  - console: 0.0.4
  - scikit-image: 0.4.15.dev68+gdd3a2afd
  - svg: 0.1.6
  
  napari contributors (2019). napari: a multi-dimensional image viewer for python. doi:10.5281/zenodo.3555620
  
  
  </issue>
  <code>
  [start of napari/_qt/containers/qt_layer_list.py]
  1 from __future__ import annotations
  2 
  3 from typing import TYPE_CHECKING
  4 
  5 from qtpy.QtCore import QSortFilterProxyModel, Qt
  6 
  7 from ...layers import Layer
  8 from ...utils.translations import trans
  9 from ._base_item_model import SortRole, _BaseEventedItemModel
  10 from ._layer_delegate import LayerDelegate
  11 from .qt_list_view import QtListView
  12 
  13 if TYPE_CHECKING:
  14     from qtpy.QtGui import QKeyEvent
  15     from qtpy.QtWidgets import QWidget
  16 
  17     from ...components.layerlist import LayerList
  18 
  19 
  20 class ReverseProxyModel(QSortFilterProxyModel):
  21     """Proxy Model that reverses the view order of a _BaseEventedItemModel."""
  22 
  23     def __init__(self, model: _BaseEventedItemModel) -> None:
  24         super().__init__()
  25         self.setSourceModel(model)
  26         self.setSortRole(SortRole)
  27         self.sort(0, Qt.DescendingOrder)
  28 
  29     def dropMimeData(self, data, action, destRow, col, parent):
  30         """Handle destination row for dropping with reversed indices."""
  31         row = 0 if destRow == -1 else self.sourceModel().rowCount() - destRow
  32         return self.sourceModel().dropMimeData(data, action, row, col, parent)
  33 
  34 
  35 class QtLayerList(QtListView[Layer]):
  36     """QItemView subclass specialized for the LayerList.
  37 
  38     This is as mostly for targetting with QSS, applying the delegate and
  39     reversing the view with ReverseProxyModel.
  40     """
  41 
  42     def __init__(self, root: LayerList, parent: QWidget = None):
  43         super().__init__(root, parent)
  44         self.setItemDelegate(LayerDelegate())
  45         self.setToolTip(trans._('Layer list'))
  46         font = self.font()
  47         font.setPointSize(12)
  48         self.setFont(font)
  49 
  50         # This reverses the order of the items in the view,
  51         # so items at the end of the list are at the top.
  52         self.setModel(ReverseProxyModel(self.model()))
  53 
  54     def keyPressEvent(self, e: QKeyEvent) -> None:
  55         """Override Qt event to pass events to the viewer."""
  56         if e.key() != Qt.Key_Space:
  57             super().keyPressEvent(e)
  58 
  59         e.ignore()  # pass key events up to viewer
  60
  [end of napari/_qt/containers/qt_layer_list.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/napari/_qt/containers/qt_layer_list.py b/napari/_qt/containers/qt_layer_list.py
  --- a/napari/_qt/containers/qt_layer_list.py
  +++ b/napari/_qt/containers/qt_layer_list.py
  @@ -53,7 +53,7 @@
   
       def keyPressEvent(self, e: QKeyEvent) -> None:
           """Override Qt event to pass events to the viewer."""
  -        if e.key() != Qt.Key_Space:
  +        if e.key() != Qt.Key.Key_Space:
               super().keyPressEvent(e)
  -
  -        e.ignore()  # pass key events up to viewer
  +        if e.key() not in (Qt.Key.Key_Backspace, Qt.Key.Key_Delete):
  +            e.ignore()  # pass key events up to viewer
  
verification_info: {"golden_diff": "diff --git a/napari/_qt/containers/qt_layer_list.py b/napari/_qt/containers/qt_layer_list.py\n--- a/napari/_qt/containers/qt_layer_list.py\n+++ b/napari/_qt/containers/qt_layer_list.py\n@@ -53,7 +53,7 @@\n \n     def keyPressEvent(self, e: QKeyEvent) -> None:\n         \"\"\"Override Qt event to pass events to the viewer.\"\"\"\n-        if e.key() != Qt.Key_Space:\n+        if e.key() != Qt.Key.Key_Space:\n             super().keyPressEvent(e)\n-\n-        e.ignore()  # pass key events up to viewer\n+        if e.key() not in (Qt.Key.Key_Backspace, Qt.Key.Key_Delete):\n+            e.ignore()  # pass key events up to viewer\n", "issue": "Previously selected point deleted when deleting layer\n## \ud83d\udc1b Bug\r\n\r\nRecently selected points are erroneously removed when deleting new layers with the delete key. (reproduced with points and labels layer)\r\n\r\n## To Reproduce\r\n\r\nSteps to reproduce the behaviour:\r\n\r\n1. Create a point on a points layer\r\n2. Create a new points layer\r\n3. Select the newly created points layer from the layer list (visually deselecting the point)\r\n4. Delete newly created layer using the delete key, the last selected point will also be deleted\r\n\r\nPlease note that this issue does not occur when the layer is deleted using the bin icon, leading me to believe it is a keybinding issue (and the point must still be 'selected' in come capacity)\r\n<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->\r\n\r\n\r\nhttps://user-images.githubusercontent.com/95660545/156966137-b2a645a6-25ae-42b4-baf7-137e7506e20a.mp4\r\n\r\n\r\n## Expected behaviour\r\nIt is expected that only the newly created points layer (with no points assigned to it) should be deleted, not the point as well.\r\n\r\n<!-- A clear and concise description of what you expected to happen. -->\r\n\r\n## Environment\r\n\r\nnapari: 0.4.15.dev68+gdd3a2afd\r\nPlatform: Windows-10-10.0.19044-SP0\r\nPython: 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]\r\nQt: 5.15.2\r\nPyQt5: 5.15.6\r\nNumPy: 1.21.5\r\nSciPy: 1.7.3\r\nDask: 2022.01.0\r\nVisPy: 0.9.6\r\n\r\nOpenGL:\r\n- GL version: 4.6.0 - Build 26.20.100.7372\r\n- MAX_TEXTURE_SIZE: 16384\r\n\r\nScreens:\r\n- screen 1: resolution 1920x1080, scale 1.0\r\n\r\nPlugins:\r\n- console: 0.0.4\r\n- scikit-image: 0.4.15.dev68+gdd3a2afd\r\n- svg: 0.1.6\r\n\r\nnapari contributors (2019). napari: a multi-dimensional image viewer for python. doi:10.5281/zenodo.3555620\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nfrom qtpy.QtCore import QSortFilterProxyModel, Qt\n\nfrom ...layers import Layer\nfrom ...utils.translations import trans\nfrom ._base_item_model import SortRole, _BaseEventedItemModel\nfrom ._layer_delegate import LayerDelegate\nfrom .qt_list_view import QtListView\n\nif TYPE_CHECKING:\n    from qtpy.QtGui import QKeyEvent\n    from qtpy.QtWidgets import QWidget\n\n    from ...components.layerlist import LayerList\n\n\nclass ReverseProxyModel(QSortFilterProxyModel):\n    \"\"\"Proxy Model that reverses the view order of a _BaseEventedItemModel.\"\"\"\n\n    def __init__(self, model: _BaseEventedItemModel) -> None:\n        super().__init__()\n        self.setSourceModel(model)\n        self.setSortRole(SortRole)\n        self.sort(0, Qt.DescendingOrder)\n\n    def dropMimeData(self, data, action, destRow, col, parent):\n        \"\"\"Handle destination row for dropping with reversed indices.\"\"\"\n        row = 0 if destRow == -1 else self.sourceModel().rowCount() - destRow\n        return self.sourceModel().dropMimeData(data, action, row, col, parent)\n\n\nclass QtLayerList(QtListView[Layer]):\n    \"\"\"QItemView subclass specialized for the LayerList.\n\n    This is as mostly for targetting with QSS, applying the delegate and\n    reversing the view with ReverseProxyModel.\n    \"\"\"\n\n    def __init__(self, root: LayerList, parent: QWidget = None):\n        super().__init__(root, parent)\n        self.setItemDelegate(LayerDelegate())\n        self.setToolTip(trans._('Layer list'))\n        font = self.font()\n        font.setPointSize(12)\n        self.setFont(font)\n\n        # This reverses the order of the items in the view,\n        # so items at the end of the list are at the top.\n        self.setModel(ReverseProxyModel(self.model()))\n\n    def keyPressEvent(self, e: QKeyEvent) -> None:\n        \"\"\"Override Qt event to pass events to the viewer.\"\"\"\n        if e.key() != Qt.Key_Space:\n            super().keyPressEvent(e)\n\n        e.ignore()  # pass key events up to viewer\n", "path": "napari/_qt/containers/qt_layer_list.py"}]}