Skip to content

Commit

Permalink
ENH: Combine Y-axis name and label columns (TRC-79)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdomke committed Nov 1, 2024
1 parent cec3f2e commit c60912c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions trace/mixins/axis_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def axis_table_init(self) -> None:
self.axis_table_model = ArchiverAxisModel(self.ui.main_plot, self)
self.ui.time_axis_tbl.setModel(self.axis_table_model)

label_col = self.axis_table_model.getColumnIndex("Y-Axis Label")
self.ui.time_axis_tbl.hideColumn(label_col)

hdr = self.ui.time_axis_tbl.horizontalHeader()
hdr.setSectionResizeMode(QHeaderView.Stretch)
del_col = self.axis_table_model.getColumnIndex("")
Expand Down
6 changes: 6 additions & 0 deletions trace/table_models/axis_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def setData(self, index: QModelIndex, value: Any, role=Qt.EditRole) -> bool:
elif role == Qt.CheckStateRole and index.column() in self.checkable_col:
return super().setData(index, value, Qt.EditRole)
elif index.column() not in self.checkable_col:
# Changes to axis' name should change axis' label as well
if self._column_names[index.column()] == "Y-Axis Name":
label_col = self.getColumnIndex("Y-Axis Label")
label_index = self.index(index.row(), label_col)
self.setData(label_index, value, role)

return super().setData(index, value, role)
return None

Expand Down

0 comments on commit c60912c

Please # to comment.