mirror of https://gitlab.com/pamhyr/pamhyr2
INISPEC DEL
parent
cd68bebf03
commit
f917dd9284
|
|
@ -37,6 +37,7 @@ from View.Tools.PamhyrTable import PamhyrTableModel
|
||||||
|
|
||||||
from View.InitialConditionsAdisTS.UndoCommand import (
|
from View.InitialConditionsAdisTS.UndoCommand import (
|
||||||
SetCommand, AddCommand, SetCommandSpec,
|
SetCommand, AddCommand, SetCommandSpec,
|
||||||
|
DelCommand,
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
@ -129,7 +130,7 @@ class InitialConditionTableModel(PamhyrTableModel):
|
||||||
|
|
||||||
if self._headers[column] is "name":
|
if self._headers[column] is "name":
|
||||||
n = self._lst[row].name
|
n = self._lst[row].name
|
||||||
if n is None:
|
if n is None or n == "":
|
||||||
return self._trad['not_associated']
|
return self._trad['not_associated']
|
||||||
return n
|
return n
|
||||||
elif self._headers[column] is "reach":
|
elif self._headers[column] is "reach":
|
||||||
|
|
|
||||||
|
|
@ -168,4 +168,22 @@ class AddCommand(QUndoCommand):
|
||||||
self._new = self._data.new(self._index)
|
self._new = self._data.new(self._index)
|
||||||
else:
|
else:
|
||||||
self._ics_spec.insert(self._index, self._new)
|
self._ics_spec.insert(self._index, self._new)
|
||||||
|
class DelCommand(QUndoCommand):
|
||||||
|
def __init__(self, data, ics_spec, rows):
|
||||||
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
|
self._ics_spec = ics_spec
|
||||||
|
self._rows = rows
|
||||||
|
|
||||||
|
self._ic = []
|
||||||
|
for row in rows:
|
||||||
|
self._ic.append((row, self._ics_spec.get(row)))
|
||||||
|
self._ic.sort()
|
||||||
|
|
||||||
|
def undo(self):
|
||||||
|
for row, el in self._ic:
|
||||||
|
self._ics_spec.insert(row, el)
|
||||||
|
|
||||||
|
def redo(self):
|
||||||
|
self._ics_spec.delete_i(self._rows)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ from PyQt5.QtGui import (
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
Qt, QVariant, QAbstractTableModel,
|
Qt, QVariant, QAbstractTableModel,
|
||||||
QCoreApplication, QModelIndex, pyqtSlot,
|
QCoreApplication, QModelIndex, pyqtSlot,
|
||||||
QRect,
|
QRect, QItemSelectionModel,
|
||||||
)
|
)
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
|
|
@ -92,8 +92,6 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
|
|
||||||
self._ics_adists_lst = study.river.initial_conditions_adists
|
self._ics_adists_lst = study.river.initial_conditions_adists
|
||||||
|
|
||||||
print("setup tables")
|
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
|
|
||||||
self.ui.setWindowTitle(self._title)
|
self.ui.setWindowTitle(self._title)
|
||||||
|
|
@ -151,8 +149,6 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
mode="kp"
|
mode="kp"
|
||||||
)
|
)
|
||||||
|
|
||||||
print("hello table", self._study.river)
|
|
||||||
|
|
||||||
self._table_spec = InitialConditionTableModel(
|
self._table_spec = InitialConditionTableModel(
|
||||||
table_view=table_spec,
|
table_view=table_spec,
|
||||||
table_headers=self._trad.get_dict("table_headers_spec"),
|
table_headers=self._trad.get_dict("table_headers_spec"),
|
||||||
|
|
@ -173,6 +169,17 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
table_spec.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
table_spec.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||||
table_spec.setAlternatingRowColors(True)
|
table_spec.setAlternatingRowColors(True)
|
||||||
|
|
||||||
|
selectionModel = table_spec.selectionModel()
|
||||||
|
index = table_spec.model().index(0, 0)
|
||||||
|
|
||||||
|
selectionModel.select(
|
||||||
|
index,
|
||||||
|
QItemSelectionModel.Rows |
|
||||||
|
QItemSelectionModel.ClearAndSelect |
|
||||||
|
QItemSelectionModel.Select
|
||||||
|
)
|
||||||
|
table_spec.scrollTo(index)
|
||||||
|
|
||||||
def index_selected_row(self):
|
def index_selected_row(self):
|
||||||
table = self.find(QTableView, f"tableView")
|
table = self.find(QTableView, f"tableView")
|
||||||
rows = table.selectionModel()\
|
rows = table.selectionModel()\
|
||||||
|
|
@ -260,7 +267,6 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
def add(self):
|
def add(self):
|
||||||
print("Hello")
|
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
if len(self._data[0]._data) == 0 or len(rows) == 0:
|
if len(self._data[0]._data) == 0 or len(rows) == 0:
|
||||||
self._table_spec.add(0)
|
self._table_spec.add(0)
|
||||||
|
|
@ -268,7 +274,9 @@ class InitialConditionsAdisTSWindow(PamhyrWindow):
|
||||||
self._table_spec.add(rows[0])
|
self._table_spec.add(rows[0])
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
|
print("del")
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
if len(rows) == 0:
|
if len(rows) == 0:
|
||||||
|
print("len 0")
|
||||||
return
|
return
|
||||||
self._table_spec.delete(rows)
|
self._table_spec.delete(rows)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue