mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "794b06d55a24732d9d5f633b612ade5c7a82ad67" and "40cc18881564f33ad61053417fd7520d596c87f8" have entirely different histories.
794b06d55a
...
40cc188815
|
|
@ -582,9 +582,6 @@ class BoundaryCondition(SQLSubModel):
|
||||||
self._data.index(bc)
|
self._data.index(bc)
|
||||||
|
|
||||||
def get_i(self, index):
|
def get_i(self, index):
|
||||||
if len(self.data) == 0:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return self.data[index]
|
return self.data[index]
|
||||||
|
|
||||||
def get_range(self, _range):
|
def get_range(self, _range):
|
||||||
|
|
|
||||||
|
|
@ -57,19 +57,6 @@ logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class TableModel(PamhyrTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def get_true_data_row(self, row):
|
|
||||||
bc = self._data.get_i(row)
|
|
||||||
|
|
||||||
return next(
|
|
||||||
map(
|
|
||||||
lambda e: e[0],
|
|
||||||
filter(
|
|
||||||
lambda e: e[1] == bc,
|
|
||||||
enumerate(self._data._data)
|
|
||||||
)
|
|
||||||
), 0
|
|
||||||
)
|
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
if role == Qt.TextAlignmentRole:
|
if role == Qt.TextAlignmentRole:
|
||||||
return Qt.AlignHCenter | Qt.AlignVCenter
|
return Qt.AlignHCenter | Qt.AlignVCenter
|
||||||
|
|
@ -121,7 +108,6 @@ class TableModel(PamhyrTableModel):
|
||||||
def add(self, row, parent=QModelIndex()):
|
def add(self, row, parent=QModelIndex()):
|
||||||
self.beginInsertRows(parent, row, row - 1)
|
self.beginInsertRows(parent, row, row - 1)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
AddCommand(
|
AddCommand(
|
||||||
self._data, row
|
self._data, row
|
||||||
|
|
@ -134,9 +120,6 @@ class TableModel(PamhyrTableModel):
|
||||||
def delete(self, rows, parent=QModelIndex()):
|
def delete(self, rows, parent=QModelIndex()):
|
||||||
self.beginRemoveRows(parent, rows[0], rows[-1])
|
self.beginRemoveRows(parent, rows[0], rows[-1])
|
||||||
|
|
||||||
rows = list(map(
|
|
||||||
lambda r: self.get_true_data_row(r), rows))
|
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._data, rows
|
self._data, rows
|
||||||
|
|
@ -162,11 +145,10 @@ class TableModel(PamhyrTableModel):
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
target = row + 1
|
target = row + 2
|
||||||
|
|
||||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
self._undo_stack.push(
|
self._undo_stack.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._data, "up", row
|
self._data, "up", row
|
||||||
|
|
@ -184,7 +166,6 @@ class TableModel(PamhyrTableModel):
|
||||||
|
|
||||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
self._undo_stack.push(
|
self._undo_stack.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._data, "down", row
|
self._data, "down", row
|
||||||
|
|
|
||||||
|
|
@ -115,19 +115,6 @@ class ComboBoxDelegate(QItemDelegate):
|
||||||
|
|
||||||
|
|
||||||
class TableModel(PamhyrTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def get_true_data_row(self, row):
|
|
||||||
bc = self._lst.get(self._tab, row)
|
|
||||||
|
|
||||||
return next(
|
|
||||||
map(
|
|
||||||
lambda e: e[0],
|
|
||||||
filter(
|
|
||||||
lambda e: e[1] == bc,
|
|
||||||
enumerate(self._lst.get_tab(self._tab))
|
|
||||||
)
|
|
||||||
), 0
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, trad=None, **kwargs):
|
def __init__(self, trad=None, **kwargs):
|
||||||
self._trad = trad
|
self._trad = trad
|
||||||
self._long_types = {}
|
self._long_types = {}
|
||||||
|
|
@ -201,8 +188,6 @@ class TableModel(PamhyrTableModel):
|
||||||
def add(self, row, parent=QModelIndex()):
|
def add(self, row, parent=QModelIndex()):
|
||||||
self.beginInsertRows(parent, row, row - 1)
|
self.beginInsertRows(parent, row, row - 1)
|
||||||
|
|
||||||
# row = self.get_true_data_row(row)
|
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
AddCommand(
|
AddCommand(
|
||||||
self._lst, self._tab, row
|
self._lst, self._tab, row
|
||||||
|
|
@ -215,9 +200,6 @@ class TableModel(PamhyrTableModel):
|
||||||
def delete(self, rows, parent=QModelIndex()):
|
def delete(self, rows, parent=QModelIndex()):
|
||||||
self.beginRemoveRows(parent, rows[0], rows[-1])
|
self.beginRemoveRows(parent, rows[0], rows[-1])
|
||||||
|
|
||||||
rows = list(map(
|
|
||||||
lambda r: self.get_true_data_row(r), rows))
|
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._lst, self._tab, rows
|
self._lst, self._tab, rows
|
||||||
|
|
@ -243,11 +225,10 @@ class TableModel(PamhyrTableModel):
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
target = row + 1
|
target = row + 2
|
||||||
|
|
||||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
self._undo_stack.push(
|
self._undo_stack.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._lst, self._tab, "up", row
|
self._lst, self._tab, "up", row
|
||||||
|
|
@ -265,7 +246,6 @@ class TableModel(PamhyrTableModel):
|
||||||
|
|
||||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||||
|
|
||||||
row = self.get_true_data_row(row)
|
|
||||||
self._undo_stack.push(
|
self._undo_stack.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._lst, self._tab, "down", row
|
self._lst, self._tab, "down", row
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,13 @@ class AddCommand(QUndoCommand):
|
||||||
self._bcs = bcs
|
self._bcs = bcs
|
||||||
self._tab = tab
|
self._tab = tab
|
||||||
self._index = index
|
self._index = index
|
||||||
|
self._old = None
|
||||||
|
if len(self._bcs.get_tab(self._tab)) > self._index:
|
||||||
|
self._bcs.get(self._tab, self._index)
|
||||||
self._new = None
|
self._new = None
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._bcs.delete(self._tab, [self._new])
|
self._bcs.delete(self._tab, self._old)
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._new is None:
|
if self._new is None:
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,7 @@ class ScenarioMenu(AbstractMenu):
|
||||||
)
|
)
|
||||||
|
|
||||||
action = self._exec()
|
action = self._exec()
|
||||||
if action == None:
|
if action == select:
|
||||||
return
|
|
||||||
elif action == select:
|
|
||||||
self._parent.select_scenario(item)
|
self._parent.select_scenario(item)
|
||||||
elif action == delete:
|
elif action == delete:
|
||||||
self._parent.delete_scenario(item)
|
self._parent.delete_scenario(item)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue