Skip to content

Commit

Permalink
DEP: Remove references to deprecated QVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
zdomke committed Dec 17, 2024
1 parent 136ed4a commit d6a5ad7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 38 deletions.
14 changes: 6 additions & 8 deletions pydm/widgets/archiver_time_plot_editor.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 2 additions & 8 deletions pydm/widgets/eventplot_curve_editor.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions pydm/widgets/nt_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ 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()])
except IndexError:
item = ""
return item
else:
return QtCore.QVariant()
return None

def setData(self, index, value, role=QtCore.Qt.EditRole):
if self.edit_method is None:
Expand Down
10 changes: 3 additions & 7 deletions pydm/widgets/scatterplot_curve_editor.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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":
Expand Down
6 changes: 2 additions & 4 deletions pydm/widgets/timeplot_curve_editor.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
10 changes: 3 additions & 7 deletions pydm/widgets/waveformplot_curve_editor.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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":
Expand Down

0 comments on commit d6a5ad7

Please sign in to comment.