Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
removal of description fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoneiESS committed Oct 25, 2023
1 parent 3b2dac6 commit 50b09e7
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 62 deletions.
7 changes: 0 additions & 7 deletions nexus_constructor/add_component_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def setupUi(self, pixel_options: PixelOptions = PixelOptions()):

# Disable by default as component name will be missing at the very least.
self.ok_button.setEnabled(False)
self.descriptionPlainTextEdit.setText(self._group_container.group.description)
self.placeholder_checkbox.stateChanged.connect(self._disable_fields_and_buttons)
self.meshRadioButton.clicked.connect(self.show_mesh_fields)
self.boxRadioButton.clicked.connect(self.show_box_fields)
Expand Down Expand Up @@ -644,7 +643,6 @@ def finalise_group(
for child in group_children:
c_group[child.name] = child
add_fields_to_component(c_group, self.fieldsListWidget, self.component_model)
self.write_description_to_group(c_group)
if isinstance(c_group, Component):
# remove the previous object from the qt3d view
self._scene_widget.delete_component(old_group_name)
Expand All @@ -654,11 +652,6 @@ def finalise_group(

return c_group

def write_description_to_group(self, c_group: Group):
description = self.descriptionPlainTextEdit.text()
if description:
c_group.description = description

def write_pixel_data_to_component(
self, component: Component, pixel_data: PixelData
):
Expand Down
3 changes: 3 additions & 0 deletions nexus_constructor/component_tree_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def __init__(self, model: Model, parent=None):
super().__init__(parent)
self.model = model
self.tree_root = self.model.entry
self.model.entry.proposal_id = ("", True)
self.model.entry.title = ("", True)
self.model.entry.users_placeholder = True
self.current_nxs_obj: Optional[
Tuple[Union[Group, FileWriterModule], QModelIndex]
] = (self.model.entry, None)
Expand Down
13 changes: 0 additions & 13 deletions nexus_constructor/model/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,6 @@ def __eq__(self, other):
def has_pixel_shape(self):
return False

@property
def description(self) -> str:
try:
return self.get_field_value(CommonAttrs.DESCRIPTION)
except AttributeError:
return ""

@description.setter
def description(self, new_description: str):
self.set_field_value(
CommonAttrs.DESCRIPTION, new_description, ValueTypes.STRING
)

def number_of_children(self):
return len(self.children)

Expand Down
1 change: 0 additions & 1 deletion nexus_constructor/widgets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from nexus_constructor.widgets.group_name_edit import GroupNameEdit # noqa: F401
from nexus_constructor.widgets.description_edit import DescriptionEdit # noqa: F401
from nexus_constructor.widgets.dropdown_list import DropDownList # noqa: F401
from nexus_constructor.widgets.class_dropdown_list import ( # noqa: F401
ClassDropDownList,
Expand Down
14 changes: 0 additions & 14 deletions nexus_constructor/widgets/description_edit.py

This file was deleted.

9 changes: 5 additions & 4 deletions tests/test_component_tree_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ def create_component_tree_model(
def test_number_of_groups_0():
test_component_tree_model, _ = create_component_tree_model()
test_index = test_component_tree_model.index(0, 0, QModelIndex())
assert test_component_tree_model.rowCount(test_index) == 0
# 2 because we always have the proposal and title holder
assert test_component_tree_model.rowCount(test_index) == 2


def test_number_of_groups_1():
test_component_tree_model, _ = create_component_tree_model([get_component()])
test_index = test_component_tree_model.index(0, 0, QModelIndex())
assert test_component_tree_model.rowCount(test_index) == 1
assert test_component_tree_model.rowCount(test_index) == 3


def test_number_of_groups_2():
Expand All @@ -78,7 +79,7 @@ def test_number_of_groups_2():
)
test_index = test_component_tree_model.index(0, 0, QModelIndex())

assert test_component_tree_model.rowCount(test_index) == 2
assert test_component_tree_model.rowCount(test_index) == 4


def test_component_has_0_rows():
Expand Down Expand Up @@ -273,4 +274,4 @@ def test_add_group():
assert test_component_tree_model.rowCount(QModelIndex()) == 1
test_component_tree_model.add_group(get_component())
index = test_component_tree_model.index(0, 0, QModelIndex())
assert test_component_tree_model.rowCount(index) == 1
assert test_component_tree_model.rowCount(index) == 3
21 changes: 2 additions & 19 deletions ui/add_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PySide6.QtWidgets import QDialog

from nexus_constructor.model import GroupContainer
from nexus_constructor.widgets import ClassDropDownList, DescriptionEdit, GroupNameEdit
from nexus_constructor.widgets import ClassDropDownList, GroupNameEdit


class Ui_AddComponentDialog(QDialog):
Expand Down Expand Up @@ -91,23 +91,11 @@ def setupUi(self):
self.verticalLayout_2.addLayout(self.horizontalLayout_5)
self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.label_2 = QtWidgets.QLabel(self.widget)
self.label_2.setObjectName("label_2")
self.horizontalLayout_6.addWidget(self.label_2)
self.descriptionPlainTextEdit = DescriptionEdit(
self.widget, self._group_container
)
sizePolicy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding
)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.descriptionPlainTextEdit.sizePolicy().hasHeightForWidth()
)
self.descriptionPlainTextEdit.setSizePolicy(sizePolicy)
self.descriptionPlainTextEdit.setObjectName("descriptionPlainTextEdit")
self.horizontalLayout_6.addWidget(self.descriptionPlainTextEdit)
self.verticalLayout_2.addLayout(self.horizontalLayout_6)
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
Expand Down Expand Up @@ -298,7 +286,7 @@ def setupUi(self):
self.gridLayout_3.addWidget(self.widget, 0, 0, 1, 1)
self.set_web_engine_view(sizePolicy)
self.retranslateUi()
self.descriptionPlainTextEdit.setFocus()
self.nameLineEdit.setFocus()
QtCore.QMetaObject.connectSlotsByName(self)

def set_web_engine_view(self, sizePolicy):
Expand All @@ -320,11 +308,6 @@ def retranslateUi(self):
self.label.setText(
QtWidgets.QApplication.translate("AddComponentDialog", "Name:", None, -1)
)
self.label_2.setText(
QtWidgets.QApplication.translate(
"AddComponentDialog", "Description:", None, -1
)
)
self.label_3.setText(
QtWidgets.QApplication.translate(
"AddComponentDialog", "Group type:", None, -1
Expand Down
3 changes: 0 additions & 3 deletions ui/parameters_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ def __init__(self, parent=None):
self.model = None
self.setLayout(QVBoxLayout())
self.setParent(parent)
self.model.entry.proposal_id = ("", True)
self.model.entry.title = ("", True)
self.model.entry.users_placeholder = True
1 change: 0 additions & 1 deletion ui_tests/test_ui_add_component_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,6 @@ def test_UI_GIVEN_component_name_and_description_WHEN_editing_component_THEN_cor
qtbot.addWidget(dialog)

assert dialog.nameLineEdit.text() == name
assert dialog.descriptionPlainTextEdit.text() == desc
assert dialog.componentTypeComboBox.currentText() == nx_class


Expand Down

0 comments on commit 50b09e7

Please sign in to comment.