Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds contrast tab to the project widget #63

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ extend-ignore-names = ['allKeys',
'showEvent',
'sizeHint',
'stepBy',
'supportedDropActions',
'textFromValue',
'valueFromText',]
'valueFromText',]
15 changes: 11 additions & 4 deletions rascal2/widgets/delegates.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,27 @@ def setModelData(self, editor, model, index):
model.setData(index, data, QtCore.Qt.ItemDataRole.EditRole)


class ParametersDelegate(QtWidgets.QStyledItemDelegate):
class ProjectFieldDelegate(QtWidgets.QStyledItemDelegate):
"""Item delegate to choose from existing draft project parameters."""

def __init__(self, project_widget, parent):
def __init__(self, project_widget, field, parent):
super().__init__(parent)
self.field = field
self.project_widget = project_widget

def createEditor(self, parent, option, index):
widget = QtWidgets.QComboBox(parent)
parameters = self.project_widget.draft_project["parameters"]
names = [p.name for p in parameters]
items = self.project_widget.draft_project[self.field]
names = [item.name for item in items]
widget.addItems(names)
widget.setCurrentText(index.data(QtCore.Qt.ItemDataRole.DisplayRole))

# make combobox searchable
widget.setEditable(True)
widget.setInsertPolicy(widget.InsertPolicy.NoInsert)
widget.setFrame(False)
widget.completer().setCompletionMode(QtWidgets.QCompleter.CompletionMode.PopupCompletion)

return widget

def setEditorData(self, editor: QtWidgets.QWidget, index):
Expand Down
Loading
Loading