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

Commit

Permalink
Merge pull request #1043 from ess-dmsc/ecdc-3632-removing-unused-fields
Browse files Browse the repository at this point in the history
Ecdc-3632-removing-unused-fields
  • Loading branch information
ggoneiESS authored Oct 26, 2023
2 parents 1f17028 + 1820921 commit 8650323
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 183 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
4 changes: 2 additions & 2 deletions nexus_constructor/model/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def add_rotation(
),
target_pos: int = -1,
offset_vector: Optional[QVector3D] = None,
offset_units: str = ""
offset_units: str = "",
) -> Transformation:
"""
Note, currently assumes angle is in degrees
Expand All @@ -266,7 +266,7 @@ def add_rotation(
values,
target_pos,
offset_vector if offset_vector is not None else QVector3D(0.0, 0.0, 0.0),
offset_units
offset_units,
)

def _create_and_add_transform(
Expand Down
14 changes: 0 additions & 14 deletions nexus_constructor/model/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
get_absolute_path,
)
from nexus_constructor.model.module import Dataset, StreamModules
from nexus_constructor.model.value_type import ValueTypes

if TYPE_CHECKING:
from nexus_constructor.model.module import FileWriterModule
Expand Down Expand Up @@ -87,19 +86,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.

2 changes: 1 addition & 1 deletion nx-class-documentation/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ <h1>User Manual and Reference Documentation<a class="headerlink" href="#user-man
</div>
<hr class="docutils" />
<p class="rubric">Publishing Information</p>
<p>This manual built Oct 25, 2023.</p>
<p>This manual built Oct 26, 2023.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>This document is available in these formats online:</p>
Expand Down
2 changes: 1 addition & 1 deletion nx-class-documentation/html/searchindex.js

Large diffs are not rendered by default.

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
115 changes: 0 additions & 115 deletions ui/parameters_widget.py

This file was deleted.

4 changes: 0 additions & 4 deletions ui/treeview_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
expand_transformation_list,
set_button_states,
)
from ui.parameters_widget import ParametersView


class QNexusTreeView(QTreeView):
Expand All @@ -37,8 +36,6 @@ def __init__(self, scene_widget: InstrumentView, parent=None):
self.setParent(parent)
self.componentsTabLayout = QVBoxLayout()
self.component_tree_view = QNexusTreeView()
self.parameters_widget = ParametersView(parent)
self.componentsTabLayout.addWidget(self.parameters_widget)
self.componentsTabLayout.addWidget(self.component_tree_view)

self.layout().addLayout(self.componentsTabLayout)
Expand Down Expand Up @@ -131,7 +128,6 @@ def set_up_model(self, model: Model):
)
self.component_tree_view.setItemDelegate(self.component_delegate)
self.component_tree_view.setModel(self.component_model)
self.parameters_widget.set_up_model(model)

def reset_model(self):
self.set_up_model(self.component_model.model)
Expand Down
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 8650323

Please sign in to comment.