mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
SL: Model add basic command for SL and fix DB save artifact.
This commit is contained in:
1 parent
17c0035a0a
commit
7898ab86c6
2 files changed
+54
-1
No files matched your search
@@ -180,7 +180,56 @@ class SedimentLayer(SQLSubModel):
|
|||||||
for l in self._layers:
|
for l in self._layers:
|
||||||
data["ind"] = ind
|
data["ind"] = ind
|
||||||
l._sql_save(execute, data)
|
l._sql_save(execute, data)
|
||||||
|
|
||||||
ind += 1
|
ind += 1
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def get(self, index):
|
||||||
|
return self._layers[index]
|
||||||
|
|
||||||
|
def set(self, index, new):
|
||||||
|
self._layers[index] = new
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
def insert(self, index, new):
|
||||||
|
self._layers.insert(index, new)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
def new(self, index):
|
||||||
|
n = Layer(status = self._status)
|
||||||
|
self.insert(index, n)
|
||||||
|
self._status.modified()
|
||||||
|
return n
|
||||||
|
|
||||||
|
def delete(self, els):
|
||||||
|
for el in els:
|
||||||
|
self._layers.remove(el)
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
def delete_i(self, indexes):
|
||||||
|
els = list(
|
||||||
|
map(
|
||||||
|
lambda x: x[1],
|
||||||
|
filter(
|
||||||
|
lambda x: x[0] in indexes,
|
||||||
|
enumerate(self._layers)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.delete(els)
|
||||||
|
|
||||||
|
def move_up(self, index):
|
||||||
|
if index < len(self._layers):
|
||||||
|
next = index - 1
|
||||||
|
|
||||||
|
l = self._layers
|
||||||
|
l[index], l[next] = l[next], l[index]
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
def move_down(self, index):
|
||||||
|
if index >= 0:
|
||||||
|
prev = index + 1
|
||||||
|
|
||||||
|
l = self._layers
|
||||||
|
l[index], l[prev] = l[prev], l[index]
|
||||||
|
self._status.modified()
|
||||||
@@ -37,6 +37,10 @@ class SedimentLayerList(SQLSubModel):
|
|||||||
def _sql_save(self, execute, data = None):
|
def _sql_save(self, execute, data = None):
|
||||||
ok = True
|
ok = True
|
||||||
|
|
||||||
|
# Delete previous data
|
||||||
|
execute("DELETE FROM sedimentary_layer")
|
||||||
|
execute("DELETE FROM sedimentary_layer_layer")
|
||||||
|
|
||||||
for sl in self._sl:
|
for sl in self._sl:
|
||||||
ok &= sl._sql_save(execute, data)
|
ok &= sl._sql_save(execute, data)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user