Repository: spyder-ide/spyder

Issue:
Unify behavior to trigger elements edition (Variable Explorer)
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

## Problem Description

> Not for me on Linux. @dalthviz, what happens on Windows?

@ccordoba12  Yep now the edition of an element triggers with single selection. I think that's because I changed the flags for the edition trigger when implementing the Variable Explorer filter [here](https://github.com/spyder-ide/spyder/blob/f63309f66fbb602539864e82247a98a8ed6df0d8/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1120). Also, there are two different behaviors when trying to trigger the edition depending on the column you click (if is the `name` one you need to double click but if it's over the value column it triggers with a single click)

_Originally posted by @dalthviz in https://github.com/spyder-ide/spyder/issues/9942#issuecomment-517367491_

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 4.0.0.dev0 [6df0d8](https://github.com/spyder-ide/spyder/commit/f63309f66fbb602539864e82247a98a8ed6df0d8)
* Operating System name/version: Windows



Discussion:

Resolving patch:
diff --git a/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py b/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py
--- a/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py
+++ b/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py
@@ -15,7 +15,7 @@
 from qtpy.compat import to_qvariant
 from qtpy.QtCore import QDateTime, Qt, Signal, Slot
 from qtpy.QtWidgets import (QAbstractItemDelegate, QDateEdit, QDateTimeEdit,
-                            QItemDelegate, QLineEdit, QMessageBox)
+                            QItemDelegate, QLineEdit, QMessageBox, QTableView)
 
 # Local imports
 from spyder.config.base import _
@@ -336,6 +336,29 @@ def setModelData(self, editor, model, index):
             raise RuntimeError("Unsupported editor widget")
         self.set_value(index, value)
 
+    def updateEditorGeometry(self, editor, option, index):
+        """
+        Overriding method updateEditorGeometry.
+
+        This is necessary to set the correct position of the QLineEdit
+        editor since option.rect doesn't have values -> QRect() and
+        makes the editor to be invisible (i.e. it has 0 as x, y, width
+        and height) when doing double click over a cell.
+        See spyder-ide/spyder#9945
+        """
+        table_view = editor.parent().parent()
+        if isinstance(table_view, QTableView):
+            row = index.row()
+            column = index.column()
+            y0 = table_view.rowViewportPosition(row)
+            x0 = table_view.columnViewportPosition(column)
+            width = table_view.columnWidth(column)
+            height = table_view.rowHeight(row)
+            editor.setGeometry(x0, y0, width, height)
+        else:
+            super(CollectionsDelegate, self).updateEditorGeometry(
+                editor, option, index)
+
 
 class ToggleColumnDelegate(CollectionsDelegate):
     """ToggleColumn Item Delegate"""
diff --git a/spyder/plugins/variableexplorer/widgets/collectionseditor.py b/spyder/plugins/variableexplorer/widgets/collectionseditor.py
--- a/spyder/plugins/variableexplorer/widgets/collectionseditor.py
+++ b/spyder/plugins/variableexplorer/widgets/collectionseditor.py
@@ -1115,10 +1115,6 @@ def __init__(self, parent, data, readonly=False, title="",
 
         self.delegate = CollectionsDelegate(self)
         self.setItemDelegate(self.delegate)
-        self.setSelectionBehavior(QAbstractItemView.SelectItems)
-        self.setSelectionMode(QAbstractItemView.SingleSelection)
-        self.setEditTriggers(QAbstractItemView.AllEditTriggers)
-        self.setSortingEnabled(True)
 
         self.setup_table()
         self.menu = self.setup_menu(minmax)
@@ -1422,10 +1418,6 @@ def __init__(self, parent, data, minmax=False, shellwidget=None,
         self.delegate = RemoteCollectionsDelegate(self)
         self.delegate.sig_free_memory.connect(self.sig_free_memory.emit)
         self.setItemDelegate(self.delegate)
-        self.setSelectionBehavior(QAbstractItemView.SelectItems)
-        self.setSelectionMode(QAbstractItemView.SingleSelection)
-        self.setEditTriggers(QAbstractItemView.AllEditTriggers)
-        self.setSortingEnabled(True)
 
         self.setup_table()
         self.menu = self.setup_menu(minmax)


Test patch: