From 50b09e79af08f30406f8b39cce0c9cdb1393c321 Mon Sep 17 00:00:00 2001 From: George O'Neill Date: Wed, 25 Oct 2023 18:11:55 +0200 Subject: [PATCH] removal of description fields --- nexus_constructor/add_component_window.py | 7 ------- nexus_constructor/component_tree_model.py | 3 +++ nexus_constructor/model/group.py | 13 ------------ nexus_constructor/widgets/__init__.py | 1 - nexus_constructor/widgets/description_edit.py | 14 ------------- tests/test_component_tree_model.py | 9 ++++---- ui/add_component.py | 21 ++----------------- ui/parameters_widget.py | 3 --- ui_tests/test_ui_add_component_window.py | 1 - 9 files changed, 10 insertions(+), 62 deletions(-) delete mode 100644 nexus_constructor/widgets/description_edit.py diff --git a/nexus_constructor/add_component_window.py b/nexus_constructor/add_component_window.py index 1496d8b6c..d13dabd6f 100644 --- a/nexus_constructor/add_component_window.py +++ b/nexus_constructor/add_component_window.py @@ -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) @@ -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) @@ -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 ): diff --git a/nexus_constructor/component_tree_model.py b/nexus_constructor/component_tree_model.py index 588221826..470c68039 100644 --- a/nexus_constructor/component_tree_model.py +++ b/nexus_constructor/component_tree_model.py @@ -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) diff --git a/nexus_constructor/model/group.py b/nexus_constructor/model/group.py index f14731208..58c85ef72 100644 --- a/nexus_constructor/model/group.py +++ b/nexus_constructor/model/group.py @@ -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) diff --git a/nexus_constructor/widgets/__init__.py b/nexus_constructor/widgets/__init__.py index 6f386d81e..7c5cf8e88 100644 --- a/nexus_constructor/widgets/__init__.py +++ b/nexus_constructor/widgets/__init__.py @@ -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, diff --git a/nexus_constructor/widgets/description_edit.py b/nexus_constructor/widgets/description_edit.py deleted file mode 100644 index a780a5468..000000000 --- a/nexus_constructor/widgets/description_edit.py +++ /dev/null @@ -1,14 +0,0 @@ -from PySide6 import QtWidgets - -from nexus_constructor.model import GroupContainer - - -class DescriptionEdit(QtWidgets.QLineEdit): - def __init__(self, parent: QtWidgets.QWidget, container: GroupContainer): - super().__init__(parent) - self._container = container - self.textEdited.connect(self._set_new_description) - self.setText(self._container.group.description) - - def _set_new_description(self, new_description: str): - self._container.group.description = new_description diff --git a/tests/test_component_tree_model.py b/tests/test_component_tree_model.py index e8a33e732..5d156ec8d 100644 --- a/tests/test_component_tree_model.py +++ b/tests/test_component_tree_model.py @@ -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(): @@ -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(): @@ -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 diff --git a/ui/add_component.py b/ui/add_component.py index 3344e78c7..e10d1594c 100644 --- a/ui/add_component.py +++ b/ui/add_component.py @@ -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): @@ -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") @@ -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): @@ -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 diff --git a/ui/parameters_widget.py b/ui/parameters_widget.py index 365d4b2b0..00d92bae6 100644 --- a/ui/parameters_widget.py +++ b/ui/parameters_widget.py @@ -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 diff --git a/ui_tests/test_ui_add_component_window.py b/ui_tests/test_ui_add_component_window.py index 273604dff..80c84abc8 100644 --- a/ui_tests/test_ui_add_component_window.py +++ b/ui_tests/test_ui_add_component_window.py @@ -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