From d6a5ad72ba2cb3fc4ad7b0ec40947257a1c7fab9 Mon Sep 17 00:00:00 2001 From: Zach Domke Date: Tue, 17 Dec 2024 15:26:17 -0800 Subject: [PATCH] DEP: Remove references to deprecated QVariant --- pydm/widgets/archiver_time_plot_editor.py | 14 ++++++-------- pydm/widgets/eventplot_curve_editor.py | 10 ++-------- pydm/widgets/nt_table.py | 8 ++++---- pydm/widgets/scatterplot_curve_editor.py | 10 +++------- pydm/widgets/timeplot_curve_editor.py | 6 ++---- pydm/widgets/waveformplot_curve_editor.py | 10 +++------- 6 files changed, 20 insertions(+), 38 deletions(-) diff --git a/pydm/widgets/archiver_time_plot_editor.py b/pydm/widgets/archiver_time_plot_editor.py index d7972a6a1..eb3a8b1a6 100644 --- a/pydm/widgets/archiver_time_plot_editor.py +++ b/pydm/widgets/archiver_time_plot_editor.py @@ -1,7 +1,7 @@ from typing import Any, Optional from qtpy.QtCore import Qt, QModelIndex, QObject from qtpy.QtGui import QColor -from .archiver_time_plot import ArchivePlotCurveItem, FormulaCurveItem +from .archiver_time_plot import ArchivePlotCurveItem from .baseplot import BasePlot, BasePlotCurveItem from .baseplot_table_model import BasePlotCurvesModel from .baseplot_curve_editor import BasePlotCurveEditorDialog, PlotStyleColumnDelegate @@ -39,15 +39,13 @@ def data(self, index, role=Qt.DisplayRole): def get_data(self, column_name: str, curve: BasePlotCurveItem) -> Any: """Get data for the input column name""" if column_name == "Channel": - if isinstance(curve, FormulaCurveItem): - if curve.formula is None: - return "" - return str(curve.formula) + if hasattr(curve, "address"): + return curve.address + elif hasattr(curve, "formula"): + return curve.formula # We are either a Formula or a PV (for now at leasts) else: - if curve.address is None: - return "" - return str(curve.address) + return None elif column_name == "Live Data": return bool(curve.liveData) diff --git a/pydm/widgets/eventplot_curve_editor.py b/pydm/widgets/eventplot_curve_editor.py index 683ace5c6..e2bc14c65 100644 --- a/pydm/widgets/eventplot_curve_editor.py +++ b/pydm/widgets/eventplot_curve_editor.py @@ -1,4 +1,4 @@ -from qtpy.QtCore import QModelIndex, QVariant +from qtpy.QtCore import QModelIndex from .baseplot_table_model import BasePlotCurvesModel from .baseplot_curve_editor import BasePlotCurveEditorDialog, PlotStyleColumnDelegate @@ -16,16 +16,10 @@ def __init__(self, plot, parent=None): def get_data(self, column_name, curve): if column_name == "Channel": - if curve.address is None: - return QVariant() - return str(curve.address) + return curve.address elif column_name == "Y Index": - if curve.y_idx is None: - return QVariant() return curve.y_idx elif column_name == "X Index": - if curve.x_idx is None: - return QVariant() return curve.x_idx elif column_name == "Buffer Size": return curve.getBufferSize() diff --git a/pydm/widgets/nt_table.py b/pydm/widgets/nt_table.py index 15df9286d..8ece071f6 100644 --- a/pydm/widgets/nt_table.py +++ b/pydm/widgets/nt_table.py @@ -53,11 +53,11 @@ def columnCount(self, parent=None): def data(self, index, role=QtCore.Qt.DisplayRole): if not index.isValid(): - return QtCore.QVariant() + return None if index.row() >= self.rowCount(): - return QtCore.QVariant() + return None if index.column() >= self.columnCount(): - return QtCore.QVariant() + return None if role == QtCore.Qt.DisplayRole: try: item = str(self._list[index.row()][index.column()]) @@ -65,7 +65,7 @@ def data(self, index, role=QtCore.Qt.DisplayRole): item = "" return item else: - return QtCore.QVariant() + return None def setData(self, index, value, role=QtCore.Qt.EditRole): if self.edit_method is None: diff --git a/pydm/widgets/scatterplot_curve_editor.py b/pydm/widgets/scatterplot_curve_editor.py index 92ea0030a..1b08d4d1a 100644 --- a/pydm/widgets/scatterplot_curve_editor.py +++ b/pydm/widgets/scatterplot_curve_editor.py @@ -1,4 +1,4 @@ -from qtpy.QtCore import QModelIndex, QVariant +from qtpy.QtCore import QModelIndex from .baseplot_table_model import BasePlotCurvesModel from .baseplot_curve_editor import BasePlotCurveEditorDialog, PlotStyleColumnDelegate, RedrawModeColumnDelegate @@ -16,13 +16,9 @@ def __init__(self, plot, parent=None): def get_data(self, column_name, curve): if column_name == "Y Channel": - if curve.y_address is None: - return QVariant() - return str(curve.y_address) + return curve.y_address elif column_name == "X Channel": - if curve.x_address is None: - return QVariant() - return str(curve.x_address) + return curve.x_address elif column_name == "Redraw Mode": return curve.redraw_mode elif column_name == "Buffer Size": diff --git a/pydm/widgets/timeplot_curve_editor.py b/pydm/widgets/timeplot_curve_editor.py index dbe10c39b..cb845c65d 100644 --- a/pydm/widgets/timeplot_curve_editor.py +++ b/pydm/widgets/timeplot_curve_editor.py @@ -1,4 +1,4 @@ -from qtpy.QtCore import QModelIndex, QObject, QVariant +from qtpy.QtCore import QModelIndex, QObject from typing import Optional from .baseplot_table_model import BasePlotCurvesModel from .baseplot_curve_editor import BasePlotCurveEditorDialog, ColorColumnDelegate, PlotStyleColumnDelegate @@ -12,9 +12,7 @@ def __init__(self, plot, parent=None): def get_data(self, column_name, curve): if column_name == "Channel": - if curve.address is None: - return QVariant() - return str(curve.address) + return curve.address elif column_name == "Style": return curve.plot_style return super(PyDMTimePlotCurvesModel, self).get_data(column_name, curve) diff --git a/pydm/widgets/waveformplot_curve_editor.py b/pydm/widgets/waveformplot_curve_editor.py index 6b330a977..30ef1faa1 100644 --- a/pydm/widgets/waveformplot_curve_editor.py +++ b/pydm/widgets/waveformplot_curve_editor.py @@ -1,4 +1,4 @@ -from qtpy.QtCore import QModelIndex, QObject, QVariant +from qtpy.QtCore import QModelIndex, QObject from .baseplot_table_model import BasePlotCurvesModel from .baseplot_curve_editor import ( BasePlotCurveEditorDialog, @@ -22,13 +22,9 @@ def __init__(self, plot, parent=None): def get_data(self, column_name, curve): if column_name == "Y Channel": - if curve.y_address is None: - return QVariant() - return str(curve.y_address) + return curve.y_address elif column_name == "X Channel": - if curve.x_address is None: - return QVariant() - return str(curve.x_address) + return curve.x_address elif column_name == "Style": return curve.plot_style elif column_name == "Redraw Mode":