Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model selection dialog: fixed order bug when sorting. #1039

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
------------------

- Watershed tool: 2D flowlines intersecting obstacles are no longer shown as 1D flowlines (#1034)
- Model selection dialog: fixed order bug when sorting.


3.9.3 (2024-08-14)
Expand Down
32 changes: 22 additions & 10 deletions gui/threedi_plugin_grid_result_dialog.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
from functools import wraps
from pathlib import Path
from qgis.core import QgsSettings
from qgis.PyQt import QtWidgets
from qgis.PyQt import uic
from qgis.PyQt.QtCore import pyqtSignal
from qgis.PyQt.QtCore import pyqtSlot
from qgis.PyQt.QtCore import QModelIndex
from qgis.PyQt.QtCore import QSortFilterProxyModel
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtGui import QStandardItem
from qgis.PyQt.QtGui import QStandardItemModel
from qgis.PyQt.QtWidgets import QAbstractItemView
from threedi_mi_utils import list_local_schematisations
from threedi_results_analysis.utils.constants import TOOLBOX_QGIS_SETTINGS_GROUP

import logging
import os

from threedi_results_analysis.utils.constants import TOOLBOX_QGIS_SETTINGS_GROUP
from qgis.PyQt import QtWidgets, uic
from qgis.PyQt.QtCore import pyqtSignal, pyqtSlot, QModelIndex, Qt, QSortFilterProxyModel
from qgis.PyQt.QtWidgets import QAbstractItemView
from qgis.core import QgsSettings
from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem
from threedi_mi_utils import list_local_schematisations

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -168,14 +175,16 @@ def _retrieve_selected_grid_folder(self, index: QModelIndex) -> str:
@pyqtSlot()
@disable_dialog
def _add_grid_from_table(self) -> None:
grid_file = os.path.join(self._retrieve_selected_grid_folder(self.tableView.currentIndex()), "gridadmin.h5")
index = self.proxy_model.mapToSource(self.tableView.currentIndex())
grid_file = os.path.join(self._retrieve_selected_grid_folder(index), "gridadmin.h5")
self.grid_file_selected.emit(grid_file)

@pyqtSlot()
@disable_dialog
def _add_result_from_table(self) -> None:
result_file = os.path.join(self._retrieve_selected_result_folder(self.tableView.currentIndex()), "results_3di.nc")
grid_file = os.path.join(self._retrieve_selected_grid_folder(self.tableView.currentIndex()), "gridadmin.h5")
index = self.proxy_model.mapToSource(self.tableView.currentIndex())
result_file = os.path.join(self._retrieve_selected_result_folder(index), "results_3di.nc")
grid_file = os.path.join(self._retrieve_selected_grid_folder(index), "gridadmin.h5")

# Also emit corresponding grid file, if existst
if not os.path.isfile(grid_file):
Expand All @@ -184,6 +193,7 @@ def _add_result_from_table(self) -> None:
self.result_grid_file_selected.emit(result_file, grid_file)

def _item_selected(self, index: QModelIndex):
index = self.proxy_model.mapToSource(index)
self.loadGridPushButton.setEnabled(True)
# Only activate result button when revision contain results
if self.model.item(index.row(), 2):
Expand All @@ -193,6 +203,8 @@ def _item_selected(self, index: QModelIndex):

@disable_dialog
def _item_double_clicked(self, index: QModelIndex):
index = self.proxy_model.mapToSource(index)

# The selection contains a result
if self.model.item(index.row(), 2):
result_file = os.path.join(self._retrieve_selected_result_folder(index), "results_3di.nc")
Expand Down
Loading