Skip to content

Commit

Permalink
Got it working and refreshing on panel change. Trying to fix tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-eq committed Dec 20, 2024
1 parent 869f845 commit cfd7dcb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/ert/gui/ertnotifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@ def set_current_ensemble(self, ensemble: Ensemble | None = None) -> None:
@Slot(bool)
def set_is_simulation_running(self, is_running: bool) -> None:
self._is_simulation_running = is_running

def refresh(self):

Check failure on line 68 in src/ert/gui/ertnotifier.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

Function is missing a return type annotation
print("FORCED REFRESH")
if self._storage is None:
return
self._storage.refresh()
self.storage_changed.emit(self._storage)
1 change: 1 addition & 0 deletions src/ert/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def right_clicked(self) -> None:
def select_central_widget(self) -> None:
actor = self.sender()
if actor:
self.notifier.refresh()

Check failure on line 156 in src/ert/gui/main_window.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

Call to untyped function "refresh" in typed context
index_name = actor.property("index")

for widget in self.central_panels_map.values():
Expand Down
17 changes: 15 additions & 2 deletions src/ert/gui/tools/manage_experiments/storage_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def __init__(self, experiment: Experiment, parent: "StorageModel"):
self._id = experiment.id
self._name = experiment.name
self._is_valid = experiment.is_valid()
self._error = experiment.error_message
print(f"{self._is_valid=}")
self._experiment_type = experiment.metadata.get("ensemble_type")
self._children: list[EnsembleModel] = []
Expand Down Expand Up @@ -132,6 +133,11 @@ def data(
qapp = QApplication.instance()
assert isinstance(qapp, QApplication)
return qapp.palette().mid()
if role == Qt.ItemDataRole.ToolTipRole:
print("TRYING TO GET TOOLTIP")
if self._error:
print("FOUND ERROR TOOLTIP")
return self._error
return None


Expand All @@ -143,6 +149,7 @@ def __init__(self, storage: Storage):

@Slot(Storage)
def reloadStorage(self, storage: Storage) -> None:
print("RELOADED STORAGE")
self.beginResetModel()
self._load_storage(storage)
self.endResetModel()
Expand Down Expand Up @@ -214,7 +221,14 @@ def headerData(
def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) -> Any:
if not index.isValid():
return None
print("CALLED DATA")
if role == Qt.ItemDataRole.ToolTipRole:
print("TRYING TO GET TOOLTIP")
error = index.internalPointer().data(index, role)._error
if error:
print("FOUND ERROR TOOLTIP")
return self._error

Check failure on line 229 in src/ert/gui/tools/manage_experiments/storage_model.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

"StorageModel" has no attribute "_error"
else:
return "NO PROBLEM :)"
return index.internalPointer().data(index, role)

@override
Expand All @@ -223,7 +237,6 @@ def flags(self, index: QModelIndex) -> Qt.ItemFlag:
if not index.isValid():
return default_flags
item = index.internalPointer()
print("CALLED FLAGS")
if isinstance(item, ExperimentModel) and not item._is_valid:
return default_flags & ~Qt.ItemFlag.ItemIsEnabled

Check failure on line 241 in src/ert/gui/tools/manage_experiments/storage_model.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

Incompatible return value type (got "int", expected "ItemFlag")
return default_flags
Expand Down

0 comments on commit cfd7dcb

Please sign in to comment.