Skip to content

Commit

Permalink
Fix job label not updating when selecting same index
Browse files Browse the repository at this point in the history
* Fix job label not updating when same index
* Place job_label with job_overview
* Update tests accordingly
  • Loading branch information
andreas-el authored Aug 20, 2024
1 parent cd8d5c9 commit 02f996b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
12 changes: 9 additions & 3 deletions src/ert/gui/simulation/run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
QAbstractItemView,
QDialog,
QDialogButtonBox,
QFrame,
QHBoxLayout,
QHeaderView,
QLabel,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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_}"
Expand Down
12 changes: 6 additions & 6 deletions src/ert/gui/simulation/view/realization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Optional

from qtpy.QtCore import (
QAbstractItemModel,
Expand Down Expand Up @@ -54,18 +54,18 @@ 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)

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)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/gui/simulation/test_run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/gui/simulation/view/test_realization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 02f996b

Please sign in to comment.