Skip to content

Commit

Permalink
made regular table not editable by default
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhroom committed Nov 4, 2024
1 parent 67bb7a4 commit 3a27de2
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions rascal2/widgets/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,6 @@ def __init__(self, classlist: RATapi.ClassList, parent: QtWidgets.QWidget):
self.headers = list(self.item_type.model_fields)
self.edit_mode = False

def flags(self, index):
flags = super().flags(index)
# allow editing of everything except name by default, and never allow name editing for protected parameters
if self.index_header(index) != "name" or (self.edit_mode):
flags |= QtCore.Qt.ItemFlag.ItemIsEditable

return flags

def rowCount(self, parent=None) -> int:
return len(self.classlist)

Expand Down Expand Up @@ -350,9 +342,9 @@ def flags(self, index):
# disable mu, sigma if prior type is not Gaussian
if self.classlist[index.row()].prior_type != "gaussian" and header in ["mu", "sigma"]:
return QtCore.Qt.ItemFlag.NoItemFlags
# never allow name editing for protected parameters
if header == "name" and index.row() in self.protected_indices:
flags &= ~QtCore.Qt.ItemFlag.ItemIsEditable
# never allow name editing for protected parameters, allow everything else to be edited by default
if header != "name" or (self.edit_mode and index.row() not in self.protected_indices):
flags |= QtCore.Qt.ItemFlag.ItemIsEditable

return flags

Expand Down

0 comments on commit 3a27de2

Please sign in to comment.