mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
BC: Edit: Add table display mode 'time' and 'date'.
This commit is contained in:
1 parent
31ca9bf70c
commit
7a7e714ea4
3 files changed
+13
-7
No files matched your search
@@ -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":
|
||||
if self._mode == "time":
|
||||
t0 = datetime.fromtimestamp(0)
|
||||
t = datetime.fromtimestamp(v)
|
||||
value = str(t - t0)
|
||||
#value = v
|
||||
else:
|
||||
# TODO: Time format
|
||||
value = str(datetime.fromtimestamp(v))
|
||||
else:
|
||||
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(
|
||||
|
||||
Reference in new issue
Block a user