mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
LC: Add begin and end kp and fix the convertion bug.
This commit is contained in:
1 parent
ce1872a90f
commit
1179dd0b92
9 files changed
+112
-10
No files matched your search
@@ -17,6 +17,7 @@ from PyQt5.QtWidgets import (
|
||||
|
||||
from View.LateralContribution.UndoCommand import (
|
||||
SetNameCommand, SetEdgeCommand, SetTypeCommand,
|
||||
SetBeginCommand, SetEndCommand,
|
||||
AddCommand, DelCommand, SortCommand,
|
||||
MoveCommand, PasteCommand, DuplicateCommand,
|
||||
)
|
||||
@@ -120,6 +121,11 @@ class TableModel(QAbstractTableModel):
|
||||
if n is None:
|
||||
return _translate("LateralContribution", "Not associate")
|
||||
return n.name
|
||||
elif self._headers[column] == "begin_kp":
|
||||
return self._lcs.get(self._tab, row).begin_kp
|
||||
elif self._headers[column] == "end_kp":
|
||||
return self._lcs.get(self._tab, row).end_kp
|
||||
|
||||
|
||||
return QVariant()
|
||||
|
||||
@@ -139,20 +145,32 @@ class TableModel(QAbstractTableModel):
|
||||
if self._headers[column] == "name":
|
||||
self._undo.push(
|
||||
SetNameCommand(
|
||||
self._lcs, self._tab,row, value
|
||||
self._lcs, self._tab, row, value
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "type":
|
||||
key = next(k for k, v in long_types.items() if v == value)
|
||||
self._undo.push(
|
||||
SetTypeCommand(
|
||||
self._lcs, self._tab,row, LC_types[key]
|
||||
self._lcs, self._tab, row, LC_types[key]
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "edge":
|
||||
self._undo.push(
|
||||
SetEdgeCommand(
|
||||
self._lcs, self._tab,row, self._data.edge(value)
|
||||
self._lcs, self._tab, row, self._data.edge(value)
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "begin_kp":
|
||||
self._undo.push(
|
||||
SetBeginCommand(
|
||||
self._lcs, self._tab, row, value
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "end_kp":
|
||||
self._undo.push(
|
||||
SetEndCommand(
|
||||
self._lcs, self._tab, row, value
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -26,6 +26,39 @@ class SetNameCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._lcs.get(self._tab, self._index).name = self._new
|
||||
|
||||
class SetBeginCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._lcs = lcs
|
||||
self._tab = tab
|
||||
self._index = index
|
||||
self._old = self._lcs.get(self._tab, self._index).begin_kp
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._lcs.get(self._tab, self._index).begin_kp = float(self._old)
|
||||
|
||||
def redo(self):
|
||||
self._lcs.get(self._tab, self._index).begin_kp = float(self._new)
|
||||
|
||||
class SetEndCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._lcs = lcs
|
||||
self._tab = tab
|
||||
self._index = index
|
||||
self._old = self._lcs.get(self._tab, self._index).end_kp
|
||||
self._new = new_value
|
||||
|
||||
def undo(self):
|
||||
self._lcs.get(self._tab, self._index).end_kp = float(self._old)
|
||||
|
||||
def redo(self):
|
||||
self._lcs.get(self._tab, self._index).end_kp = float(self._new)
|
||||
|
||||
|
||||
class SetEdgeCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, edge):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -18,7 +18,9 @@ long_types = {
|
||||
table_headers = {
|
||||
"name": _translate("LateralContribution", "Name"),
|
||||
"type": _translate("LateralContribution", "Type"),
|
||||
"edge": _translate("LateralContribution", "Edge")
|
||||
"edge": _translate("LateralContribution", "Reach"),
|
||||
"begin_kp": _translate("LateralContribution", "Begin kp (m)"),
|
||||
"end_kp": _translate("LateralContribution", "End kp (m)")
|
||||
}
|
||||
|
||||
LC_types = {
|
||||
|
||||
Reference in new issue
Block a user