|
From: Carlos P. <cpa...@ce...> - 2015-11-09 08:47:44
|
Hi, I have some comments regarding this patch:
1) I do not understand the logic of the setModel implementation. It does
a validation, but it sets the model regardless of its result (??).
2) Why it calls self.setModelCheck instead of TaurusBaseWidget.setModel?
3) in the __main__, it should use a taurusapplication, and the args
should be obtained with a parser, and, even if not,
args = str(sys.argv[1:][0])
could be written as
model = sys.argv[1]
Please address this issues and resubmit
Carlos
On Thu 29 October 2015 18:00:39 cfalcon wrote:
> setModel of taurus.qt.qtgui.table.TaurusPropTable does not work.
>
> TaurusPropTable uses the inherit setModel method of TaurusBaseWidget
> class that does not cover the funcionality of this widget.
>
> Implement a setModel method acording the specifications provided
> by S.Rubio.
> ---
> .../qt/qtgui/table/taurusdevicepropertytable.py | 22
> +++++++++++++++++----- 1 file changed, 17 insertions(+), 5
> deletions(-)
>
> diff --git a/lib/taurus/qt/qtgui/table/taurusdevicepropertytable.py
> b/lib/taurus/qt/qtgui/table/taurusdevicepropertytable.py index
> 9901ec3..b01ded5 100644
> --- a/lib/taurus/qt/qtgui/table/taurusdevicepropertytable.py
> +++ b/lib/taurus/qt/qtgui/table/taurusdevicepropertytable.py
> @@ -33,12 +33,14 @@ from taurus.external.qt import Qt, QtCore, QtGui
> from taurus.qt.qtgui.base import TaurusBaseWidget
> import taurus.core
> import PyTango
> +from taurus.core.taurusdevice import TaurusDevice
>
> class TaurusPropTable(QtGui.QTableWidget, TaurusBaseWidget):
> '''
> This widget will show a list of properties of device and the list
> of values. @todo add a frame for Add, Delete and Refresh buttons!
> '''
> + # TODO This widget is Tango-centric
> __pyqtSignals__ = ("modelChanged(const QString &)",)
>
> def __init__(self, parent=None, designMode = False):
> @@ -59,6 +61,16 @@ class TaurusPropTable(QtGui.QTableWidget,
> TaurusBaseWidget):
> #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> -~-~-~- # TaurusBaseWidget over writing methods
>
> #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> -~-~-~- + def setModel(self, model):
> + name_validator = TaurusDevice.getNameValidator()
> + self.setModelCheck(model)
> + try:
> + _, normal_name, _ = name_validator.getNames(model)
> + except ValueError:
> + self.debug('Wrong model!! %s' %(model))
> + normal_name = ''
> + self.setTable(normal_name)
> +
>
> def sizeHint(self):
> return QtGui.QTableWidget.sizeHint(self)
> @@ -82,7 +94,7 @@ class TaurusPropTable(QtGui.QTableWidget,
> TaurusBaseWidget):
> #-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
> -~-~-~-
>
> model = QtCore.pyqtProperty("QString", TaurusBaseWidget.getModel,
> - TaurusBaseWidget.setModel,
> + setModel,
> TaurusBaseWidget.resetModel)
>
> useParentModel = QtCore.pyqtProperty("bool",
> @@ -375,9 +387,9 @@ if __name__ == '__main__':
> import sys,os
> app = QtGui.QApplication([])
> widget = TaurusPropTable()
> - args = sys.argv[1:]
> - if not args: args =
> ['tango/admin/%s'%(os.environ['TANGO_HOST'].split(':')[0])] -
> widget.setTable(sys.args)
> + args = str(sys.argv[1:][0])
> + if not args:
> + args = 'sys/tg_test/1'
> + widget.setModel(args)
> widget.show()
> app.exec_()
> -
--
+----------------------------------------------------+
Carlos Pascual Izarra
Scientific Software Coordinator
Computing Division
ALBA Synchrotron [http://www.albasynchrotron.es]
Carrer de la Llum 2-26
E-08290 Cerdanyola del Valles (Barcelona), Spain
E-mail: cpa...@ce...
Phone: +34 93 592 4428
+----------------------------------------------------+
|