mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
LC: Update with functional window LC and Edit.
This commit is contained in:
1 parent
115d84d436
commit
f1d82b2f86
10 files changed
+183
-48
No files matched your search
@@ -49,13 +49,13 @@ class DelCommand(QUndoCommand):
|
||||
self._data = data
|
||||
self._rows = rows
|
||||
|
||||
self._bc = []
|
||||
self._lc = []
|
||||
for row in rows:
|
||||
self._bc.append((row, self._data.get_i(row)))
|
||||
self._bc.sort()
|
||||
self._lc.append((row, self._data.get_i(row)))
|
||||
self._lc.sort()
|
||||
|
||||
def undo(self):
|
||||
for row, el in self._bc:
|
||||
for row, el in self._lc:
|
||||
self._data.insert(row, el)
|
||||
|
||||
def redo(self):
|
||||
@@ -114,19 +114,19 @@ class MoveCommand(QUndoCommand):
|
||||
|
||||
|
||||
class PasteCommand(QUndoCommand):
|
||||
def __init__(self, data, row, bcs):
|
||||
def __init__(self, data, row, lcs):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._data = data
|
||||
self._row = row
|
||||
self._bcs = bcs
|
||||
self._bcs.reverse()
|
||||
self._lcs = lcs
|
||||
self._lcs.reverse()
|
||||
|
||||
def undo(self):
|
||||
self._data.delete(self._bcs)
|
||||
self._data.delete(self._lcs)
|
||||
|
||||
def redo(self):
|
||||
for bc in self._bcs:
|
||||
for bc in self._lcs:
|
||||
self._data.insert(self._row, bc)
|
||||
|
||||
|
||||
@@ -136,12 +136,12 @@ class DuplicateCommand(QUndoCommand):
|
||||
|
||||
self._data = data
|
||||
self._rows = rows
|
||||
self._bc = deepcopy(bc)
|
||||
self._bc.reverse()
|
||||
self._lc = deepcopy(bc)
|
||||
self._lc.reverse()
|
||||
|
||||
def undo(self):
|
||||
self._data.delete(self._bc)
|
||||
self._data.delete(self._lc)
|
||||
|
||||
def redo(self):
|
||||
for bc in self._bcs:
|
||||
for bc in self._lcs:
|
||||
self._data.insert(self._rows[0], bc)
|
||||
@@ -38,7 +38,7 @@ class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.compute_title()
|
||||
|
||||
super(EditLateralContributionWindow, self).__init__(
|
||||
name=self._title, ui="EditLateralContributions", parent=parent
|
||||
name=self._title, ui="EditLateralContribution", parent=parent
|
||||
)
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
@@ -50,13 +50,13 @@ class EditLateralContributionWindow(ASubMainWindow, ListedSubWindow):
|
||||
|
||||
def compute_title(self):
|
||||
if self._data is not None:
|
||||
node_name = (self._data.node.name if self._data.node is not None
|
||||
edge_name = (self._data.edge.name if self._data.edge is not None
|
||||
else _translate("LateralContribution", "Not associate"))
|
||||
self._title = (
|
||||
_translate("Edit boundary condition", self._title) +
|
||||
_translate("Edit Lateral contribution", self._title) +
|
||||
f" - {self._study.name} " +
|
||||
f" - {self._data.name} " +
|
||||
f"({long_types[self._data.bctype]} - {node_name})"
|
||||
f"({long_types[self._data.lctype]} - {edge_name})"
|
||||
)
|
||||
|
||||
def setup_sc(self):
|
||||
|
||||
@@ -16,7 +16,7 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from View.LateralContribution.UndoCommand import (
|
||||
SetNameCommand, SetNodeCommand, SetTypeCommand,
|
||||
SetNameCommand, SetEdgeCommand, SetTypeCommand,
|
||||
AddCommand, DelCommand, SortCommand,
|
||||
MoveCommand, PasteCommand, DuplicateCommand,
|
||||
)
|
||||
@@ -45,8 +45,8 @@ class ComboBoxDelegate(QItemDelegate):
|
||||
map(
|
||||
lambda k: long_types[k],
|
||||
filter(
|
||||
lambda k: self._tab in BC_types[k].compatibility(),
|
||||
BC_types.keys()
|
||||
lambda k: self._tab in LC_types[k].compatibility(),
|
||||
LC_types.keys()
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -56,7 +56,7 @@ class ComboBoxDelegate(QItemDelegate):
|
||||
else:
|
||||
self.editor.addItems(
|
||||
[_translate("LateralContribution", "Not associate")] +
|
||||
self._data.nodes_names()
|
||||
self._data.edges_names()
|
||||
)
|
||||
|
||||
self.editor.setCurrentText(index.data(Qt.DisplayRole))
|
||||
@@ -90,7 +90,7 @@ class TableModel(QAbstractTableModel):
|
||||
self._data = data
|
||||
self._undo = undo
|
||||
self._tab = tab
|
||||
self._lcs = self._data.boundary_condition
|
||||
self._lcs = self._data.lateral_contribution
|
||||
|
||||
def flags(self, index):
|
||||
options = Qt.ItemIsEnabled | Qt.ItemIsSelectable
|
||||
@@ -114,10 +114,10 @@ class TableModel(QAbstractTableModel):
|
||||
if self._headers[column] == "name":
|
||||
return self._lcs.get(self._tab, row).name
|
||||
elif self._headers[column] == "type":
|
||||
t = self._lcs.get(self._tab, row).bctype
|
||||
t = self._lcs.get(self._tab, row).lctype
|
||||
return long_types[t]
|
||||
elif self._headers[column] == "node":
|
||||
n = self._lcs.get(self._tab, row).node
|
||||
elif self._headers[column] == "edge":
|
||||
n = self._lcs.get(self._tab, row).edge
|
||||
if n is None:
|
||||
return _translate("LateralContribution", "Not associate")
|
||||
return n.name
|
||||
@@ -147,13 +147,13 @@ class TableModel(QAbstractTableModel):
|
||||
key = next(k for k, v in long_types.items() if v == value)
|
||||
self._undo.push(
|
||||
SetTypeCommand(
|
||||
self._lcs, self._tab,row, BC_types[key]
|
||||
self._lcs, self._tab,row, LC_types[key]
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "node":
|
||||
elif self._headers[column] == "edge":
|
||||
self._undo.push(
|
||||
SetNodeCommand(
|
||||
self._lcs, self._tab,row, self._data.node(value)
|
||||
SetEdgeCommand(
|
||||
self._lcs, self._tab,row, self._data.edge(value)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -26,21 +26,21 @@ class SetNameCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._lcs.get(self._tab, self._index).name = self._new
|
||||
|
||||
class SetNodeCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, node):
|
||||
class SetEdgeCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, edge):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._lcs = lcs
|
||||
self._tab = tab
|
||||
self._index = index
|
||||
self._old = self._lcs.get(self._tab, self._index).node
|
||||
self._new = node
|
||||
self._old = self._lcs.get(self._tab, self._index).edge
|
||||
self._new = edge
|
||||
|
||||
def undo(self):
|
||||
self._lcs.get(self._tab, self._index).node = self._old
|
||||
self._lcs.get(self._tab, self._index).edge = self._old
|
||||
|
||||
def redo(self):
|
||||
self._lcs.get(self._tab, self._index).node = self._new
|
||||
self._lcs.get(self._tab, self._index).edge = self._new
|
||||
|
||||
class SetTypeCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, _type):
|
||||
|
||||
@@ -23,7 +23,7 @@ from PyQt5.QtWidgets import (
|
||||
)
|
||||
|
||||
from View.LateralContribution.UndoCommand import (
|
||||
SetNameCommand, SetNodeCommand, SetTypeCommand,
|
||||
SetNameCommand, SetEdgeCommand, SetTypeCommand,
|
||||
AddCommand, DelCommand, SortCommand,
|
||||
MoveCommand, PasteCommand, DuplicateCommand,
|
||||
)
|
||||
@@ -88,9 +88,9 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
|
||||
tab = t,
|
||||
parent=self
|
||||
)
|
||||
self._delegate_node = ComboBoxDelegate(
|
||||
self._delegate_edge = ComboBoxDelegate(
|
||||
data = self._study.river,
|
||||
mode = "node",
|
||||
mode = "edge",
|
||||
tab = t,
|
||||
parent=self
|
||||
)
|
||||
@@ -99,7 +99,7 @@ class LateralContributionWindow(ASubMainWindow, ListedSubWindow):
|
||||
1, self._delegate_type
|
||||
)
|
||||
table.setItemDelegateForColumn(
|
||||
2, self._delegate_node
|
||||
2, self._delegate_edge
|
||||
)
|
||||
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
|
||||
@@ -20,10 +20,10 @@ long_types = {
|
||||
table_headers = {
|
||||
"name": _translate("LateralContribution", "Name"),
|
||||
"type": _translate("LateralContribution", "Type"),
|
||||
"node": _translate("LateralContribution", "Node")
|
||||
"edge": _translate("LateralContribution", "Edge")
|
||||
}
|
||||
|
||||
BC_types = {
|
||||
LC_types = {
|
||||
"ND": NotDefined,
|
||||
"PC": PonctualContribution,
|
||||
"TZ": TimeOverZ,
|
||||
|
||||
Reference in new issue
Block a user