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)
|
self._data.index(bc)
|
||||||
|
|
||||||
def get_i(self, index):
|
def get_i(self, index):
|
||||||
if len(self.data) == 0:
|
if len(self._data) == 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.data[index]
|
return self._data[index]
|
||||||
|
|
||||||
def get_range(self, _range):
|
def get_range(self, _range):
|
||||||
lst = []
|
lst = []
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,10 @@ class Results(SQLSubModel):
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
return True
|
if ext != "":
|
||||||
|
return True
|
||||||
|
|
||||||
|
return cls._create_submodel(execute)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_update(cls, execute, version, data=None):
|
def _db_update(cls, execute, version, data=None):
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ logger = logging.getLogger()
|
||||||
|
|
||||||
class TableModel(PamhyrTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def get_true_data_row(self, row):
|
def get_true_data_row(self, row):
|
||||||
bc = self._data.get_i(row)
|
bc = self._data.data[row]
|
||||||
|
|
||||||
return next(
|
return next(
|
||||||
map(
|
map(
|
||||||
|
|
@ -83,6 +83,7 @@ class TableModel(PamhyrTableModel):
|
||||||
value = QVariant()
|
value = QVariant()
|
||||||
|
|
||||||
if 0 <= column < 2:
|
if 0 <= column < 2:
|
||||||
|
row = self.get_true_data_row(row)
|
||||||
v = self._data.get_i(row)[column]
|
v = self._data.get_i(row)[column]
|
||||||
if self._data.get_type_column(column) == float:
|
if self._data.get_type_column(column) == float:
|
||||||
if type(v) is str:
|
if type(v) is str:
|
||||||
|
|
@ -106,13 +107,16 @@ class TableModel(PamhyrTableModel):
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
row = self.get_true_data_row(row)
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetDataCommand(
|
SetDataCommand(
|
||||||
self._data, row, column, value
|
self._data, row,
|
||||||
|
column, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.info(e)
|
logger.warning(e)
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
|
||||||
|
|
@ -83,13 +83,13 @@ class AddCommand(QUndoCommand):
|
||||||
self._new = None
|
self._new = None
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._data.delete_i([self._index])
|
self._new.set_as_deleted()
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self._new is None:
|
if self._new is None:
|
||||||
self._new = self._data.add(self._index)
|
self._new = self._data.add(self._index)
|
||||||
else:
|
else:
|
||||||
self._data.insert(self._index, self._new)
|
self._new.set_as_not_deleted()
|
||||||
|
|
||||||
|
|
||||||
class DelCommand(QUndoCommand):
|
class DelCommand(QUndoCommand):
|
||||||
|
|
@ -101,15 +101,16 @@ class DelCommand(QUndoCommand):
|
||||||
|
|
||||||
self._bc = []
|
self._bc = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self._bc.append((row, self._data.get_i(row)))
|
self._bc.append(self._data.get_i(row))
|
||||||
self._bc.sort()
|
self._bc.sort()
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
for row, el in self._bc:
|
for el in self._bc:
|
||||||
self._data.insert(row, el)
|
el.set_as_not_deleted()
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._data.delete_i(self._rows)
|
for el in self._bc:
|
||||||
|
el.set_as_deleted()
|
||||||
|
|
||||||
|
|
||||||
class SortCommand(QUndoCommand):
|
class SortCommand(QUndoCommand):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue