mirror of https://gitlab.com/pamhyr/pamhyr2
HS: Basic: Add question for BHS type change.
parent
c667d94e84
commit
3ef4b40558
|
|
@ -31,7 +31,7 @@ from PyQt5.QtWidgets import (
|
||||||
QDialogButtonBox, QPushButton, QLineEdit,
|
QDialogButtonBox, QPushButton, QLineEdit,
|
||||||
QFileDialog, QTableView, QAbstractItemView,
|
QFileDialog, QTableView, QAbstractItemView,
|
||||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||||
QComboBox,
|
QComboBox, QMessageBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
from View.Tools.PamhyrTable import PamhyrTableModel
|
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||||
|
|
@ -137,13 +137,17 @@ class TableModel(PamhyrTableModel):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif self._headers[column] == "type":
|
elif self._headers[column] == "type":
|
||||||
key = next(k for k, v in self._long_types.items()
|
if self._question_set_type():
|
||||||
if v == value)
|
key = next(
|
||||||
self._undo.push(
|
k for k, v in self._long_types.items()
|
||||||
SetTypeCommand(
|
if v == value
|
||||||
self._data, row, BHS_types[key]
|
)
|
||||||
|
|
||||||
|
self._undo.push(
|
||||||
|
SetTypeCommand(
|
||||||
|
self._data, row, BHS_types[key]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
|
|
@ -151,6 +155,17 @@ class TableModel(PamhyrTableModel):
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _question_set_type(self):
|
||||||
|
question = QMessageBox(self._parent)
|
||||||
|
|
||||||
|
question.setWindowTitle(self._trad['msg_type_change_title'])
|
||||||
|
question.setText(self._trad['msg_type_change_msg'])
|
||||||
|
question.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok )
|
||||||
|
question.setIcon(QMessageBox.Question)
|
||||||
|
|
||||||
|
res = question.exec()
|
||||||
|
return res == QMessageBox.Ok
|
||||||
|
|
||||||
def add(self, row, parent=QModelIndex()):
|
def add(self, row, parent=QModelIndex()):
|
||||||
self.beginInsertRows(parent, row, row - 1)
|
self.beginInsertRows(parent, row, row - 1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,17 @@ class BasicHydraulicStructuresTranslate(PamhyrTranslate):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(BasicHydraulicStructuresTranslate, self).__init__()
|
super(BasicHydraulicStructuresTranslate, self).__init__()
|
||||||
|
|
||||||
|
self._dict['msg_type_change_title'] = _translate(
|
||||||
|
"BasicHydraulicStructures",
|
||||||
|
"Change hydraulic structure type"
|
||||||
|
)
|
||||||
|
|
||||||
|
self._dict['msg_type_change_msg'] = _translate(
|
||||||
|
"BasicHydraulicStructures",
|
||||||
|
"Do you want to change the hydraulic structure type and reset \
|
||||||
|
hydraulic structure values?"
|
||||||
|
)
|
||||||
|
|
||||||
self._sub_dict["long_types"] = {
|
self._sub_dict["long_types"] = {
|
||||||
"ND": _translate("BasicHydraulicStructures", "Not defined"),
|
"ND": _translate("BasicHydraulicStructures", "Not defined"),
|
||||||
"DU": _translate("BasicHydraulicStructures", "Dummy"),
|
"DU": _translate("BasicHydraulicStructures", "Dummy"),
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ class BasicHydraulicStructuresWindow(PamhyrWindow):
|
||||||
trad=self._trad,
|
trad=self._trad,
|
||||||
data=self._hs,
|
data=self._hs,
|
||||||
undo=self._undo_stack,
|
undo=self._undo_stack,
|
||||||
|
parent=self,
|
||||||
)
|
)
|
||||||
|
|
||||||
selectionModel = table.selectionModel()
|
selectionModel = table.selectionModel()
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,8 @@ class PamhyrTableModel(QAbstractTableModel):
|
||||||
trad=None,
|
trad=None,
|
||||||
data=None,
|
data=None,
|
||||||
undo=None,
|
undo=None,
|
||||||
opt_data=None):
|
opt_data=None,
|
||||||
|
parent=None):
|
||||||
super(PamhyrTableModel, self).__init__()
|
super(PamhyrTableModel, self).__init__()
|
||||||
|
|
||||||
self._table_view = table_view
|
self._table_view = table_view
|
||||||
|
|
@ -93,6 +94,7 @@ class PamhyrTableModel(QAbstractTableModel):
|
||||||
self._editable_headers = editable_headers
|
self._editable_headers = editable_headers
|
||||||
self._delegates = delegates
|
self._delegates = delegates
|
||||||
self._trad = trad
|
self._trad = trad
|
||||||
|
self._parent = parent
|
||||||
|
|
||||||
self._data = data
|
self._data = data
|
||||||
self._opt_data = opt_data
|
self._opt_data = opt_data
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue