From 02f996b70594a9af4debda386efae8f8735cc54e Mon Sep 17 00:00:00 2001 From: Andreas Eknes Lie <114403625+andreas-el@users.noreply.github.com> Date: Tue, 20 Aug 2024 08:27:36 +0200 Subject: [PATCH] Fix job label not updating when selecting same index * Fix job label not updating when same index * Place job_label with job_overview * Update tests accordingly --- src/ert/gui/simulation/run_dialog.py | 12 +++++++++--- src/ert/gui/simulation/view/realization.py | 12 ++++++------ tests/unit_tests/gui/simulation/test_run_dialog.py | 4 ++-- .../gui/simulation/view/test_realization.py | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/ert/gui/simulation/run_dialog.py b/src/ert/gui/simulation/run_dialog.py index 78b021e519c..bb989ecc591 100644 --- a/src/ert/gui/simulation/run_dialog.py +++ b/src/ert/gui/simulation/run_dialog.py @@ -18,6 +18,7 @@ QAbstractItemView, QDialog, QDialogButtonBox, + QFrame, QHBoxLayout, QHeaderView, QLabel, @@ -264,13 +265,18 @@ def __init__( layout.addWidget(self._total_progress_bar) layout.addWidget(self._iteration_progress_label) layout.addWidget(self._progress_widget) - layout.addWidget(self._job_label) adjustable_splitter_layout = QSplitter() adjustable_splitter_layout.setOrientation(Qt.Orientation.Vertical) adjustable_splitter_layout.addWidget(self._tab_widget) - adjustable_splitter_layout.addWidget(self._job_overview) + self.job_frame = QFrame(self) + job_frame_layout = QVBoxLayout(self.job_frame) + job_frame_layout.setContentsMargins(0, 0, 0, 0) + job_frame_layout.addWidget(self._job_label) + job_frame_layout.addWidget(self._job_overview) + + adjustable_splitter_layout.addWidget(self.job_frame) layout.addWidget(adjustable_splitter_layout) layout.addWidget(button_widget_container) @@ -307,7 +313,7 @@ def on_snapshot_new_iteration( widget = RealizationWidget(iter_row) widget.setSnapshotModel(self._snapshot_model) - widget.currentChanged.connect(self._select_real) + widget.itemClicked.connect(self._select_real) tab_index = self._tab_widget.addTab( widget, f"Realizations for iteration {index.internalPointer().id_}" diff --git a/src/ert/gui/simulation/view/realization.py b/src/ert/gui/simulation/view/realization.py index 4a556851df1..3d81ba0e973 100644 --- a/src/ert/gui/simulation/view/realization.py +++ b/src/ert/gui/simulation/view/realization.py @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Optional from qtpy.QtCore import ( QAbstractItemModel, @@ -54,10 +54,7 @@ def __init__(self, _it: int, parent: Optional[QWidget] = None) -> None: f"QListView {{ background-color: {self.palette().color(QPalette.Window).name()}; }}" ) - def _emit_change(current: QModelIndex, previous: Any) -> None: - self.currentChanged.emit(current) - - self._real_view.currentChanged = _emit_change # type: ignore + self._real_view.clicked.connect(self._item_clicked) layout = QVBoxLayout() layout.addWidget(self._real_view) @@ -65,7 +62,10 @@ def _emit_change(current: QModelIndex, previous: Any) -> None: self.setLayout(layout) # Signal when the user selects another real - currentChanged = Signal(QModelIndex) + itemClicked = Signal(QModelIndex) + + def _item_clicked(self, item: QModelIndex) -> None: + self.itemClicked.emit(item) def setSnapshotModel(self, model: QAbstractItemModel) -> None: self._real_list_model = RealListModel(self, self._iter) diff --git a/tests/unit_tests/gui/simulation/test_run_dialog.py b/tests/unit_tests/gui/simulation/test_run_dialog.py index e0ed0a4bccb..83059b9cd24 100644 --- a/tests/unit_tests/gui/simulation/test_run_dialog.py +++ b/tests/unit_tests/gui/simulation/test_run_dialog.py @@ -401,7 +401,7 @@ def test_that_run_dialog_can_be_closed_while_file_plot_is_open( realization_widget._real_list_model.index(0, 0) ).center() - with qtbot.waitSignal(realization_widget.currentChanged, timeout=30000): + with qtbot.waitSignal(realization_widget.itemClicked, timeout=30000): qtbot.mouseClick( realization_widget._real_view.viewport(), Qt.LeftButton, @@ -594,7 +594,7 @@ def test_that_stdout_and_stderr_buttons_react_to_file_content( realization_widget._real_list_model.index(0, 0) ).center() - with qtbot.waitSignal(realization_widget.currentChanged, timeout=30000): + with qtbot.waitSignal(realization_widget.itemClicked, timeout=30000): qtbot.mouseClick( realization_widget._real_view.viewport(), Qt.LeftButton, diff --git a/tests/unit_tests/gui/simulation/view/test_realization.py b/tests/unit_tests/gui/simulation/view/test_realization.py index d7dbebaab1f..44ce864ae9a 100644 --- a/tests/unit_tests/gui/simulation/view/test_realization.py +++ b/tests/unit_tests/gui/simulation/view/test_realization.py @@ -75,7 +75,7 @@ def check_selection_cb(index): return isinstance(node, _Node) and str(node.id_) == str(selection_id) with qtbot.waitSignal( - widget.currentChanged, timeout=30000, check_params_cb=check_selection_cb + widget.itemClicked, timeout=30000, check_params_cb=check_selection_cb ): qtbot.mouseClick( widget._real_view.viewport(),