mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
2 Commits
de180b3635
...
de7f3e63b1
| Author | SHA1 | Date |
|---|---|---|
|
|
de7f3e63b1 | |
|
|
1e6a578890 |
|
|
@ -582,10 +582,10 @@ class BoundaryCondition(SQLSubModel):
|
|||
self._data.index(bc)
|
||||
|
||||
def get_i(self, index):
|
||||
if len(self.data) == 0:
|
||||
if len(self._data) == 0:
|
||||
return None
|
||||
|
||||
return self.data[index]
|
||||
return self._data[index]
|
||||
|
||||
def get_range(self, _range):
|
||||
lst = []
|
||||
|
|
|
|||
|
|
@ -115,8 +115,11 @@ class Results(SQLSubModel):
|
|||
)
|
||||
""")
|
||||
|
||||
if ext != "":
|
||||
return True
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@classmethod
|
||||
def _db_update(cls, execute, version, data=None):
|
||||
major, minor, release = version.strip().split(".")
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ logger = logging.getLogger()
|
|||
|
||||
class TableModel(PamhyrTableModel):
|
||||
def get_true_data_row(self, row):
|
||||
bc = self._data.get_i(row)
|
||||
bc = self._data.data[row]
|
||||
|
||||
return next(
|
||||
map(
|
||||
|
|
@ -83,6 +83,7 @@ class TableModel(PamhyrTableModel):
|
|||
value = QVariant()
|
||||
|
||||
if 0 <= column < 2:
|
||||
row = self.get_true_data_row(row)
|
||||
v = self._data.get_i(row)[column]
|
||||
if self._data.get_type_column(column) == float:
|
||||
if type(v) is str:
|
||||
|
|
@ -106,13 +107,16 @@ class TableModel(PamhyrTableModel):
|
|||
column = index.column()
|
||||
|
||||
try:
|
||||
row = self.get_true_data_row(row)
|
||||
|
||||
self._undo.push(
|
||||
SetDataCommand(
|
||||
self._data, row, column, value
|
||||
self._data, row,
|
||||
column, value
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
logger.info(e)
|
||||
logger.warning(e)
|
||||
logger.debug(traceback.format_exc())
|
||||
|
||||
self.update()
|
||||
|
|
|
|||
|
|
@ -83,13 +83,13 @@ class AddCommand(QUndoCommand):
|
|||
self._new = None
|
||||
|
||||
def undo(self):
|
||||
self._data.delete_i([self._index])
|
||||
self._new.set_as_deleted()
|
||||
|
||||
def redo(self):
|
||||
if self._new is None:
|
||||
self._new = self._data.add(self._index)
|
||||
else:
|
||||
self._data.insert(self._index, self._new)
|
||||
self._new.set_as_not_deleted()
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
|
|
@ -101,15 +101,16 @@ class DelCommand(QUndoCommand):
|
|||
|
||||
self._bc = []
|
||||
for row in rows:
|
||||
self._bc.append((row, self._data.get_i(row)))
|
||||
self._bc.append(self._data.get_i(row))
|
||||
self._bc.sort()
|
||||
|
||||
def undo(self):
|
||||
for row, el in self._bc:
|
||||
self._data.insert(row, el)
|
||||
for el in self._bc:
|
||||
el.set_as_not_deleted()
|
||||
|
||||
def redo(self):
|
||||
self._data.delete_i(self._rows)
|
||||
for el in self._bc:
|
||||
el.set_as_deleted()
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
|
|
|
|||
Loading…
Reference in New Issue