mirror of https://gitlab.com/pamhyr/pamhyr2
BC: Edit: Add table display mode 'time' and 'date'.
parent
31ca9bf70c
commit
7a7e714ea4
|
|
@ -201,6 +201,7 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
for row in rows:
|
||||
win = EditBoundaryConditionWindow(
|
||||
data=self._bcs.get(tab, row),
|
||||
study=self._study,
|
||||
parent=self
|
||||
)
|
||||
win.show()
|
||||
|
|
|
|||
|
|
@ -109,10 +109,11 @@ class ExTimeDelegate(QItemDelegate):
|
|||
|
||||
|
||||
class TableModel(QAbstractTableModel):
|
||||
def __init__(self, data=None, undo=None):
|
||||
def __init__(self, data=None, mode="time", undo=None):
|
||||
super(QAbstractTableModel, self).__init__()
|
||||
self._headers = data.header
|
||||
self._data = data
|
||||
self._mode = mode
|
||||
self._undo = undo
|
||||
|
||||
def flags(self, index):
|
||||
|
|
@ -144,12 +145,13 @@ class TableModel(QAbstractTableModel):
|
|||
if self._data.get_type_column(column) == float:
|
||||
value = f"{v:.4f}"
|
||||
elif self._data.header[column] == "time":
|
||||
t0 = datetime.fromtimestamp(0)
|
||||
t = datetime.fromtimestamp(v)
|
||||
value = str(t - t0)
|
||||
#value = v
|
||||
if self._mode == "time":
|
||||
t0 = datetime.fromtimestamp(0)
|
||||
t = datetime.fromtimestamp(v)
|
||||
value = str(t - t0)
|
||||
else:
|
||||
value = str(datetime.fromtimestamp(v))
|
||||
else:
|
||||
# TODO: Time format
|
||||
value = f"{v}"
|
||||
|
||||
return value
|
||||
|
|
|
|||
|
|
@ -27,12 +27,14 @@ from View.BoundaryCondition.Edit.Plot import Plot
|
|||
_translate = QCoreApplication.translate
|
||||
|
||||
class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Edit BoundaryConditions", data=None, parent=None):
|
||||
def __init__(self, title="Edit BoundaryConditions",
|
||||
data=None, study=None, parent=None):
|
||||
super(EditBoundaryConditionWindow, self).__init__(
|
||||
name=title, ui="EditBoundaryConditions", parent=parent
|
||||
)
|
||||
|
||||
self._data = data
|
||||
self._study = study
|
||||
self._title = title
|
||||
|
||||
self.setup_window()
|
||||
|
|
@ -66,14 +68,15 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
table = self.find(QTableView, "tableView")
|
||||
self._table = TableModel(
|
||||
data = self._data,
|
||||
undo = self._undo_stack
|
||||
undo = self._undo_stack,
|
||||
mode = self._study.time_system
|
||||
)
|
||||
|
||||
if self._data.header[0] == "time":
|
||||
self._delegate_time = ExTimeDelegate(
|
||||
data = self._data,
|
||||
mode = "type",
|
||||
parent=self
|
||||
mode = self._study.time_system,
|
||||
parent = self
|
||||
)
|
||||
|
||||
table.setItemDelegateForColumn(
|
||||
|
|
|
|||
Loading…
Reference in New Issue