Skip to content

Commit

Permalink
Remove remove button from Manage Cases
Browse files Browse the repository at this point in the history
We want to support this but needs design
  • Loading branch information
dafeda committed Feb 7, 2024
1 parent 7522112 commit 0ebf21c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
40 changes: 13 additions & 27 deletions src/ert/gui/ertwidgets/caselist.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Callable

from qtpy.QtCore import QSize, Qt
from qtpy.QtGui import QIcon
from qtpy.QtWidgets import (
Expand All @@ -6,7 +8,6 @@
QLabel,
QListWidget,
QListWidgetItem,
QMessageBox,
QToolButton,
QVBoxLayout,
QWidget,
Expand All @@ -18,43 +19,33 @@
from ert.storage import StorageAccessor


class AddRemoveWidget(QWidget):
class AddWidget(QWidget):
"""
A simple class that provides to vertically positioned buttons for adding and
removing something. The addFunction and removeFunction functions must be
provided.
A widget with an add button.
Parameters
----------
addFunction: Callable to be connected to the add button.
"""

def __init__(self, addFunction=None, removeFunction=None):
QWidget.__init__(self)
def __init__(self, addFunction: Callable):
super().__init__()

self.addButton = QToolButton(self)
self.addButton.setIcon(QIcon("img:add_circle_outlined.svg"))
self.addButton.setIconSize(QSize(16, 16))
self.addButton.clicked.connect(addFunction)

self.removeButton = QToolButton(self)
self.removeButton.setIcon(QIcon("img:remove_outlined.svg"))
self.removeButton.setIconSize(QSize(16, 16))
self.removeButton.clicked.connect(removeFunction)
self.removeButton = None

self.buttonLayout = QHBoxLayout()

self.buttonLayout.setContentsMargins(0, 0, 0, 0)

self.buttonLayout.addStretch(1)

self.buttonLayout.addWidget(self.addButton)
self.buttonLayout.addWidget(self.removeButton)

self.buttonLayout.addSpacing(2)

self.setLayout(self.buttonLayout)

def enableRemoveButton(self, state):
"""Enable or disable the remove button"""
self.removeButton.setEnabled(state)


class CaseList(QWidget):
def __init__(self, config: ErtConfig, notifier: ErtNotifier, ensemble_size: int):
Expand All @@ -72,9 +63,8 @@ def __init__(self, config: ErtConfig, notifier: ErtNotifier, ensemble_size: int)
layout.addWidget(QLabel("Available cases:"))
layout.addWidget(self._list, stretch=1)

self._addRemoveWidget = AddRemoveWidget(self.addItem, self.removeItem)
self._addRemoveWidget.enableRemoveButton(False)
layout.addWidget(self._addRemoveWidget)
self._addWidget = AddWidget(self.addItem)
layout.addWidget(self._addWidget)

self._title = "New keyword"
self._description = "Enter name of keyword:"
Expand Down Expand Up @@ -108,10 +98,6 @@ def addItem(self):
self.notifier.set_current_case(ensemble)
self.notifier.ertChanged.emit()

def removeItem(self):
message = "Support for removal of items has not been implemented!"
QMessageBox.information(self, "Not implemented!", message)

def updateList(self):
"""Retrieves data from the model and inserts it into the list"""
case_list = sorted(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/gui/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
REALIZATION_STATE_UNKNOWN,
)
from ert.gui.ertwidgets import ClosableDialog
from ert.gui.ertwidgets.caselist import AddRemoveWidget
from ert.gui.ertwidgets.caselist import AddWidget
from ert.gui.ertwidgets.caseselector import CaseSelector
from ert.gui.ertwidgets.validateddialog import ValidatedDialog
from ert.gui.main import ErtMainWindow, GUILogHandler, _setup_main_window
Expand Down Expand Up @@ -412,7 +412,7 @@ def handle_dialog(dialog, cases_panel):
cases_panel.setCurrentIndex(0)
current_tab = cases_panel.currentWidget()
assert current_tab.objectName() == "create_new_case_tab"
create_widget = get_child(current_tab, AddRemoveWidget)
create_widget = get_child(current_tab, AddWidget)

# Click add case and name it "iter-0"
def handle_add_dialog():
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/gui/test_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ert.config import ErtConfig
from ert.enkf_main import EnKFMain
from ert.gui.ertwidgets.analysismodulevariablespanel import AnalysisModuleVariablesPanel
from ert.gui.ertwidgets.caselist import AddRemoveWidget, CaseList
from ert.gui.ertwidgets.caselist import AddWidget, CaseList
from ert.gui.ertwidgets.caseselector import CaseSelector
from ert.gui.ertwidgets.customdialog import CustomDialog
from ert.gui.ertwidgets.listeditbox import ListEditBox
Expand Down Expand Up @@ -508,7 +508,7 @@ def handle_dialog(dialog, cases_panel):
cases_panel.setCurrentIndex(0)
current_tab = cases_panel.currentWidget()
assert current_tab.objectName() == "create_new_case_tab"
create_widget = get_child(current_tab, AddRemoveWidget)
create_widget = get_child(current_tab, AddWidget)
case_list = get_child(current_tab, CaseList)

# The case list should contain the expected cases
Expand Down Expand Up @@ -648,7 +648,7 @@ def handle_dialog(dialog, cases_panel):
cases_panel.setCurrentIndex(0)
current_tab = cases_panel.currentWidget()
assert current_tab.objectName() == "create_new_case_tab"
create_widget = get_child(current_tab, AddRemoveWidget)
create_widget = get_child(current_tab, AddWidget)
case_list = get_child(current_tab, CaseList)

assert case_list._list.count() == 0
Expand Down

0 comments on commit 0ebf21c

Please sign in to comment.