Repository: pyqtgraph/pyqtgraph

Issue:
Bug: ActionParameter.hide() causes rename to empty string
Calling hide() on an ActionParameter causes it to be renamed to an empty string. Thus, it's no longer accessible in code by it's original name, and if you access it by indexing there is no text on the button (consistent with the name becoming an empty string).

### Code to reproduce
```import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui

app = QtGui.QApplication([])
import pyqtgraph.parametertree.parameterTypes as pTypes
from pyqtgraph.parametertree import Parameter, ParameterTree, ParameterItem, registerParameterType

params = [
    {'name':'action_test', 'type':'action'},
    {'name':'checkbox', 'type':'bool'},
    {'name':'subgroup', 'type':'group', 'children':[
        {'name':'action2', 'type':'action'},
        {'name':'string', 'type':'str', 'readonly':True, 'value':'A string?'}
        ]}
    ]
p = Parameter.create(name='params', type='group', children=params)

t = ParameterTree()
t.addParameters(p)

win = QtGui.QWidget()
layout = QtGui.QGridLayout()
win.setLayout(layout)
layout.addWidget(t)
win.show()

### trigger the bug:
p.child('action_test').hide()
p.child('action_test').show()
```

In commits where the bug exists the above script raises an Exception:

```Traceback (most recent call last):
  File "action_test.py", line 28, in <module>
    p.child('action_test').show()
  File "/Users/meganbkratz/Code/ai/opto/pyqtgraph/pyqtgraph/parametertree/Parameter.py", line 674, in child
    raise KeyError("Parameter %s has no child named %s" % (self.name(), names[0]))
KeyError: 'Parameter params has no child named action_test'
```

It should simply show the ParameterTree without raising an exception.

### Tested environment(s)

 * PyQtGraph version: 0.11.0
 * Qt Python binding: PyQt5 5.9.2 Qt 5.9.6
 * Python version: Python 3.6.9 |Anaconda
 * NumPy version: 1.17.3
 * Operating system: OSX 10.13.6
 * Installation method: git repository

### Additional context
I used git bisect to trace the introduction of this bug to commit 7672b5b72596687295488fd1b1164ece113c71db  


Discussion:
This bug is fixed by PR #1350 

Resolving patch:
diff --git a/pyqtgraph/parametertree/Parameter.py b/pyqtgraph/parametertree/Parameter.py
--- a/pyqtgraph/parametertree/Parameter.py
+++ b/pyqtgraph/parametertree/Parameter.py
@@ -213,6 +213,16 @@ def name(self):
         """Return the name of this Parameter."""
         return self.opts['name']
 
+    def title(self):
+        """Return the title of this Parameter.
+        
+        By default, the title is the same as the name unless it has been explicitly specified
+        otherwise."""
+        title = self.opts.get('title', None)
+        if title is None:
+            title = self.name()
+        return title
+
     def contextMenu(self, name):
         """"A context menu entry was clicked"""
         self.sigContextMenu.emit(self, name)
diff --git a/pyqtgraph/parametertree/ParameterItem.py b/pyqtgraph/parametertree/ParameterItem.py
--- a/pyqtgraph/parametertree/ParameterItem.py
+++ b/pyqtgraph/parametertree/ParameterItem.py
@@ -16,10 +16,7 @@ class ParameterItem(QtGui.QTreeWidgetItem):
     """
     
     def __init__(self, param, depth=0):
-        title = param.opts.get('title', None)
-        if title is None:
-            title = param.name()
-        QtGui.QTreeWidgetItem.__init__(self, [title, ''])
+        QtGui.QTreeWidgetItem.__init__(self, [param.title(), ''])
 
         self.param = param
         self.param.registerItem(self)  ## let parameter know this item is connected to it (for debugging)
@@ -157,8 +154,12 @@ def expandedChangedEvent(self, expanded):
     def nameChanged(self, param, name):
         ## called when the parameter's name has changed.
         if self.param.opts.get('title', None) is None:
-            self.setText(0, name)
-    
+            self.titleChanged()
+
+    def titleChanged(self):
+        # called when the user-visble title has changed (either opts['title'], or name if title is None)
+        self.setText(0, self.param.title())
+
     def limitsChanged(self, param, limits):
         """Called when the parameter's limits have changed"""
         pass
@@ -183,8 +184,10 @@ def optsChanged(self, param, opts):
                 if self.isExpanded() != self.param.opts['expanded']:
                     self.setExpanded(self.param.opts['expanded'])
 
-        self.updateFlags()
+        if 'title' in opts:
+            self.titleChanged()
 
+        self.updateFlags()
 
     def contextMenuTriggered(self, name):
         def trigger():
diff --git a/pyqtgraph/parametertree/parameterTypes.py b/pyqtgraph/parametertree/parameterTypes.py
--- a/pyqtgraph/parametertree/parameterTypes.py
+++ b/pyqtgraph/parametertree/parameterTypes.py
@@ -597,16 +597,11 @@ def __init__(self, param, depth):
         self.layout = QtGui.QHBoxLayout()
         self.layout.setContentsMargins(0, 0, 0, 0)
         self.layoutWidget.setLayout(self.layout)
-        title = param.opts.get('title', None)
-        if title is None:
-            title = param.name()
-        self.button = QtGui.QPushButton(title)
+        self.button = QtGui.QPushButton(param.title())
         #self.layout.addSpacing(100)
         self.layout.addWidget(self.button)
         self.layout.addStretch()
         self.button.clicked.connect(self.buttonClicked)
-        param.sigNameChanged.connect(self.paramRenamed)
-        self.setText(0, '')
         
     def treeWidgetChanged(self):
         ParameterItem.treeWidgetChanged(self)
@@ -616,9 +611,10 @@ def treeWidgetChanged(self):
         
         tree.setFirstItemColumnSpanned(self, True)
         tree.setItemWidget(self, 0, self.layoutWidget)
-        
-    def paramRenamed(self, param, name):
-        self.button.setText(name)
+
+    def titleChanged(self):
+        self.button.setText(self.param.title())
+        ParameterItem.titleChanged(self)
         
     def buttonClicked(self):
         self.param.activate()


Test patch: