HS: Add to scenarios.

scenarios
Pierre-Antoine Rouby 2024-08-28 16:04:19 +02:00
parent 9ec21d815d
commit 60ee889794
10 changed files with 296 additions and 165 deletions

View File

@ -216,7 +216,9 @@ class AddFile(SQLSubModel):
"additional_files(pamhyr_id, enabled, deleted, " +
"name, path, text, scenario) " +
"VALUES (" +
f"{self._pamhyr_id}, {self._enabled}, {self.is_deleted()}, " +
f"{self._pamhyr_id}, " +
f"{self._db_format(self._enabled)}, " +
f"{self._db_format(self.is_deleted())}, " +
f"'{self._db_format(self._name)}', " +
f"'{self._db_format(self._path)}', " +
f"'{self._db_format(self._text)}', " +

View File

@ -35,13 +35,13 @@ class BasicHS(SQLSubModel):
_sub_classes = [
BHSValue,
]
_id_cnt = 0
def __init__(self, id: int = -1, name: str = "",
status=None):
super(BasicHS, self).__init__(id)
self._status = status
status=None, owner_scenario=-1):
super(BasicHS, self).__init__(
id=id, status=status,
owner_scenario=owner_scenario
)
self._name = name
self._type = ""
@ -53,6 +53,7 @@ class BasicHS(SQLSubModel):
execute(f"""
CREATE TABLE hydraulic_structures_basic{ext} (
{cls.create_db_add_pamhyr_id()},
deleted BOOLEAN NOT NULL DEFAULT FALSE,
name TEXT NOT NULL,
type TEXT NOT NULL,
enabled BOOLEAN NOT NULL,
@ -79,6 +80,13 @@ class BasicHS(SQLSubModel):
else:
cls._db_update_to_0_1_0(execute, data)
if major == "0" and minor == "1":
if release < 2:
execute(
"ALTER TABLE hydraulic_structures_basic " +
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
)
return cls._update_submodel(execute, version, data)
@classmethod
@ -135,28 +143,39 @@ class BasicHS(SQLSubModel):
@classmethod
def _db_load(cls, execute, data=None):
new = []
status = data["status"]
scenario = data["scenario"]
loaded = data['loaded_pid']
if scenario is None:
return []
table = execute(
"SELECT pamhyr_id, name, type, enabled, hs " +
"SELECT pamhyr_id, deleted, name, type, enabled, hs, scenario " +
"FROM hydraulic_structures_basic " +
f"WHERE hs = {data['hs_id']} "
f"WHERE hs = {data['hs_id']} " +
f"AND scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
for row in table:
it = iter(row)
bhs_pid = next(it)
deleted = (next(it) == 1)
name = next(it)
type = next(it)
enabled = (next(it) == 1)
hs_id = next(it)
owner_scenario = next(it)
ctor = cls._get_ctor_from_type(type)
bhs = ctor(
id=bhs_pid,
name=name,
status=data['status']
id=bhs_pid, name=name,
status=status, owner_scenario=owner_scenario
)
if deleted:
bhs.set_as_deleted()
bhs.enabled = enabled
@ -164,31 +183,45 @@ class BasicHS(SQLSubModel):
bhs._data = BHSValue._db_load(
execute, data
)
print(f"{bhs_pid} : {deleted}")
if deleted:
bhs.set_as_deleted()
new.append(bhs)
loaded.add(bhs_pid)
data["scenario"] = scenario.parent
new += cls._db_load(execute, data)
data["scenario"] = scenario
return new
def _db_save(self, execute, data=None):
if not self.must_be_saved():
return True
hs_id = data['hs_id']
sql = (
execute(
"INSERT INTO " +
"hydraulic_structures_basic(pamhyr_id, name, type, enabled, hs) " +
"hydraulic_structures_basic(pamhyr_id, deleted, " +
"name, type, enabled, hs, scenario) " +
"VALUES (" +
f"{self.pamhyr_id}, " +
f"{self._db_format(self.is_deleted())}, " +
f"'{self._db_format(self._name)}', " +
f"'{self._db_format(self._type)}', " +
f"{self._db_format(self.enabled)}, " +
f"{hs_id} " +
f"{hs_id}, " +
f"{self._status.scenario_id}"
")"
)
execute(sql)
data['bhs_id'] = self.pamhyr_id
execute(
"DELETE FROM hydraulic_structures_basic_value " +
f"WHERE bhs = {self.pamhyr_id}"
f"WHERE bhs = {self.pamhyr_id} " +
f"AND scenario = {self._status.scenario_id}"
)
for values in self._data:
@ -209,7 +242,7 @@ class BasicHS(SQLSubModel):
@name.setter
def name(self, name):
self._name = name
self._status.modified()
self.modified()
@property
def type(self):
@ -218,7 +251,7 @@ class BasicHS(SQLSubModel):
@type.setter
def type(self, type):
self._type = type
self._status.modified()
self.modified()
@property
def enabled(self):
@ -227,7 +260,7 @@ class BasicHS(SQLSubModel):
@enabled.setter
def enabled(self, enabled):
self._enabled = enabled
self._status.modified()
self.modified()
@property
def parameters(self):

View File

@ -27,10 +27,11 @@ from Model.HydraulicStructures.Basic.Value import (
class NotDefined(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(NotDefined, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "ND"
@ -39,10 +40,11 @@ class NotDefined(BasicHS):
class DischargeWeir(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(DischargeWeir, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "S1"
@ -55,10 +57,11 @@ class DischargeWeir(BasicHS):
class TrapezoidalWeir(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(TrapezoidalWeir, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "S2"
@ -73,10 +76,11 @@ class TrapezoidalWeir(BasicHS):
class TriangularWeir(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(TriangularWeir, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "S3"
@ -90,10 +94,11 @@ class TriangularWeir(BasicHS):
class RectangularOrifice(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(RectangularOrifice, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "OR"
@ -110,10 +115,11 @@ class RectangularOrifice(BasicHS):
class CircularOrifice(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(CircularOrifice, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "OC"
@ -127,10 +133,11 @@ class CircularOrifice(BasicHS):
class VaultedOrifice(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(VaultedOrifice, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "OV"
@ -145,10 +152,11 @@ class VaultedOrifice(BasicHS):
class RectangularGate(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(RectangularGate, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "V1"
@ -163,10 +171,11 @@ class RectangularGate(BasicHS):
class SimplifiedRectangularGate(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(SimplifiedRectangularGate, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "V2"
@ -181,10 +190,11 @@ class SimplifiedRectangularGate(BasicHS):
class Borda(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(Borda, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "BO"
@ -197,10 +207,11 @@ class Borda(BasicHS):
class CheckValve(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(CheckValve, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "CV"
@ -217,10 +228,11 @@ class CheckValve(BasicHS):
class UserDefined(BasicHS):
def __init__(self, id: int = -1, name: str = "",
status=None):
status=None, owner_scenario=-1):
super(UserDefined, self).__init__(
id=id, name=name,
status=status
status=status,
owner_scenario=owner_scenario
)
self._type = "UD"

View File

@ -26,10 +26,11 @@ class BHSValue(SQLSubModel):
def __init__(self, id: int = -1, name: str = "",
type=float, value=0.0,
status=None):
super(BHSValue, self).__init__(id)
self._status = status
status=None, owner_scenario=-1):
super(BHSValue, self).__init__(
id=id, status=status,
owner_scenario=owner_scenario
)
self._name = name
self._type = type
@ -132,12 +133,20 @@ class BHSValue(SQLSubModel):
@classmethod
def _db_load(cls, execute, data=None):
new = []
status = data["status"]
scenario = data["scenario"]
loaded = data['loaded_pid']
bhs_id = data["bhs_id"]
if scenario is None:
return []
table = execute(
"SELECT pamhyr_id, name, type, value " +
"SELECT pamhyr_id, name, type, value, scenario " +
"FROM hydraulic_structures_basic_value " +
f"WHERE bhs = '{bhs_id}'"
f"WHERE bhs = '{bhs_id}' " +
f"AND scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
for row in table:
@ -147,14 +156,20 @@ class BHSValue(SQLSubModel):
name = next(it)
type = cls._str_to_type(next(it))
value = next(it)
owner_scenario = next(it)
val = cls(
id=pid, name=name,
type=type, value=value,
status=data['status']
status=status, owner_scenario=owner_scenario
)
new.append(val)
loaded.add(pid)
data["scenario"] = scenario.parent
new += cls._db_load(execute, data)
data["scenario"] = scenario
return new
@ -164,13 +179,14 @@ class BHSValue(SQLSubModel):
execute(
"INSERT INTO " +
"hydraulic_structures_basic_value" +
"(pamhyr_id, name, type, value, bhs) " +
"(pamhyr_id, name, type, value, bhs, scenario) " +
"VALUES (" +
f"{self._pamhyr_id}, " +
f"'{self._db_format(self._name)}', " +
f"'{self._db_format(self._type_to_str(self._type))}', " +
f"'{self._db_format(self._value)}', " +
f"{bhs_id}" +
f"{bhs_id}, " +
f"{self._status.scenario_id}"
")"
)
@ -191,4 +207,4 @@ class BHSValue(SQLSubModel):
@value.setter
def value(self, value):
self._value = self._type(value)
self._status.modified()
self.modified()

View File

@ -37,13 +37,13 @@ class HydraulicStructure(SQLSubModel):
_sub_classes = [
BasicHS,
]
_id_cnt = 0
def __init__(self, id: int = -1, name: str = "",
status=None):
super(HydraulicStructure, self).__init__(id)
self._status = status
status=None, owner_scenario=-1):
super(HydraulicStructure, self).__init__(
id=id, status=status,
owner_scenario=owner_scenario
)
self._name = name
self._input_section = None
@ -58,6 +58,7 @@ class HydraulicStructure(SQLSubModel):
execute(f"""
CREATE TABLE hydraulic_structures{ext} (
{cls.create_db_add_pamhyr_id()},
deleted BOOLEAN NOT NULL DEFAULT FALSE,
name TEXT NOT NULL,
enabled BOOLEAN NOT NULL,
input_reach INTEGER,
@ -84,9 +85,9 @@ class HydraulicStructure(SQLSubModel):
@classmethod
def _db_update(cls, execute, version, data=None):
major, minor, release = version.strip().split(".")
if major == minor == "0":
rl = int(release)
rl = int(release)
if major == minor == "0":
if rl < 6:
cls._db_create(execute)
return True
@ -103,9 +104,16 @@ class HydraulicStructure(SQLSubModel):
cls._db_update_to_0_1_0(execute, data)
if major == "0" and minor == "1":
if int(release) < 1:
if rl < 1:
cls._db_update_to_0_1_1(execute, data)
if rl < 2:
execute(
"ALTER TABLE hydraulic_structures " +
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
)
return cls._update_submodel(execute, version, data)
@classmethod
@ -181,70 +189,97 @@ class HydraulicStructure(SQLSubModel):
@classmethod
def _db_load(cls, execute, data=None):
new = []
status = data["status"]
scenario = data["scenario"]
loaded = data['loaded_pid']
if scenario is None:
return []
table = execute(
"SELECT pamhyr_id, name, enabled, " +
"SELECT pamhyr_id, deleted, name, enabled, " +
"input_section, output_section, " +
"input_reach, output_reach " +
"FROM hydraulic_structures"
"input_reach, output_reach, scenario " +
"FROM hydraulic_structures " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
for row in table:
it = iter(row)
new.append(cls._db_load_new(execute, data, row))
hs_id = next(it)
name = next(it)
enabled = (next(it) == 1)
input_section_id = next(it)
input_section_id = (
-1 if input_section_id is None else input_section_id
)
output_section_id = next(it)
output_section_id = (
-1 if output_section_id is None else output_section_id
)
input_reach_id = next(it)
output_reach_id = next(it)
hs = cls(
id=hs_id, name=name, status=data['status']
)
hs.enabled = enabled
hs.input_reach, hs.output_reach = reduce(
lambda acc, n: (
n if n.pamhyr_id == input_reach_id else acc[0],
n if n.pamhyr_id == output_reach_id else acc[1]
),
data["edges"],
[None, None]
)
sections = []
if hs.input_reach is not None:
sections += hs.input_reach.reach.profiles
if hs.output_reach is not None:
sections += hs.output_reach.reach.profiles
hs.input_section, hs.output_section = reduce(
lambda acc, s: (
s if s.pamhyr_id == input_section_id else acc[0],
s if s.pamhyr_id == output_section_id else acc[1]
),
sections,
[None, None]
)
data['hs_id'] = hs_id
hs._data = BasicHS._db_load(execute, data)
new.append(hs)
data["scenario"] = scenario.parent
new += cls._db_load(execute, data)
data["scenario"] = scenario
return new
@classmethod
def _db_load_new(cls, execute, data, row):
it = iter(row)
status = data["status"]
scenario = data["scenario"]
loaded = data['loaded_pid']
hs_id = next(it)
deleted = (next(it) == 1)
name = next(it)
enabled = (next(it) == 1)
input_section_id = next(it)
input_section_id = (
-1 if input_section_id is None else input_section_id
)
output_section_id = next(it)
output_section_id = (
-1 if output_section_id is None else output_section_id
)
input_reach_id = next(it)
output_reach_id = next(it)
owner_scenario = next(it)
hs = cls(
id=hs_id, name=name, status=status,
owner_scenario=owner_scenario
)
if deleted:
new.set_as_deleted()
hs.enabled = enabled
hs.input_reach, hs.output_reach = reduce(
lambda acc, n: (
n if n.pamhyr_id == input_reach_id else acc[0],
n if n.pamhyr_id == output_reach_id else acc[1]
),
data["edges"],
[None, None]
)
sections = []
if hs.input_reach is not None:
sections += hs.input_reach.reach.profiles
if hs.output_reach is not None:
sections += hs.output_reach.reach.profiles
hs.input_section, hs.output_section = reduce(
lambda acc, s: (
s if s.pamhyr_id == input_section_id else acc[0],
s if s.pamhyr_id == output_section_id else acc[1]
),
sections,
[None, None]
)
loaded.add(hs_id)
data['hs_id'] = hs_id
hs._data = BasicHS._db_load(execute, data)
return hs
def _db_save(self, execute, data=None):
execute(
"DELETE FROM hydraulic_structures " +
f"WHERE pamhyr_id = {self.pamhyr_id}"
f"WHERE pamhyr_id = {self.pamhyr_id} " +
f"AND scenario = {self._status.scenario_id}"
)
input_reach_id = -1
@ -266,21 +301,27 @@ class HydraulicStructure(SQLSubModel):
execute(
"INSERT INTO " +
"hydraulic_structures(" +
" pamhyr_id, name, enabled, input_section, output_section, " +
" input_reach, output_reach" +
" pamhyr_id, deleted, name, enabled, " +
" input_section, output_section, " +
" input_reach, output_reach, " +
" scenario" +
") " +
"VALUES (" +
f"{self.pamhyr_id}, '{self._db_format(self._name)}', " +
f"{self.pamhyr_id}, " +
f"{self._db_format(self.is_deleted())}, " +
f"'{self._db_format(self._name)}', " +
f"{self._db_format(self.enabled)}, " +
f"{input_section}, {output_section}, " +
f"{input_reach_id}, {output_reach_id}" +
f"{input_reach_id}, {output_reach_id}, " +
f"{self._status.scenario_id}"
")"
)
data['hs_id'] = self.pamhyr_id
execute(
"DELETE FROM hydraulic_structures_basic " +
f"WHERE hs = {self.pamhyr_id}"
f"WHERE hs = {self.pamhyr_id} " +
f"AND scenario = {self._status.scenario_id}"
)
for basic in self._data:
@ -289,7 +330,16 @@ class HydraulicStructure(SQLSubModel):
return True
def __len__(self):
return len(self._data)
return len(self.lst)
@property
def lst(self):
return list(
filter(
lambda bhs: not bhs.is_deleted(),
self._data,
)
)
@property
def name(self):
@ -301,7 +351,7 @@ class HydraulicStructure(SQLSubModel):
@name.setter
def name(self, name):
self._name = name
self._status.modified()
self.modified()
@property
def input_rk(self):
@ -322,7 +372,7 @@ class HydraulicStructure(SQLSubModel):
@input_section.setter
def input_section(self, input_section):
self._input_section = input_section
self._status.modified()
self.modified()
@property
def output_section(self):
@ -331,7 +381,7 @@ class HydraulicStructure(SQLSubModel):
@output_section.setter
def output_section(self, output_section):
self._output_section = output_section
self._status.modified()
self.modified()
@property
def enabled(self):
@ -340,7 +390,7 @@ class HydraulicStructure(SQLSubModel):
@enabled.setter
def enabled(self, enabled):
self._enabled = enabled
self._status.modified()
self.modified()
@property
def input_reach(self):
@ -349,7 +399,7 @@ class HydraulicStructure(SQLSubModel):
@input_reach.setter
def input_reach(self, input_reach):
self._input_reach = input_reach
self._status.modified()
self.modified()
@property
def output_reach(self):
@ -358,26 +408,31 @@ class HydraulicStructure(SQLSubModel):
@output_reach.setter
def output_reach(self, output_reach):
self._output_reach = output_reach
self._status.modified()
self.modified()
@property
def basic_structures(self):
return self._data.copy()
return self.lst.copy()
def basic_structure(self, index: int):
return self._data[index]
return self.lst[index]
def add(self, index: int):
value = NotDefined(status=self._status)
self._data.insert(index, value)
self._status.modified()
self.modified()
return value
def insert(self, index: int, value: BasicHS):
self._data.insert(index, value)
self._status.modified()
if value in self._data:
value.set_as_not_deleted()
else:
self._data.insert(index, value)
def delete_i(self, indexes):
self.modified()
def hard_delete_i(self, indexes):
self._data = list(
map(
lambda e: e[1],
@ -387,20 +442,30 @@ class HydraulicStructure(SQLSubModel):
)
)
)
self._status.modified()
self.modified()
def delete(self, els):
self._data = list(
filter(
lambda e: e not in els,
self._data
def delete_i(self, indexes):
list(
map(
lambda e: e[1].set_as_deleted(),
filter(
lambda e: e[0] in indexes,
enumerate(self.lst)
)
)
)
self._status.modified()
self.modified()
def delete(self, els):
for el in els:
el.set_as_deleted()
self.modified()
def sort(self, _reverse=False, key=None):
if key is None:
self._data.sort(reverse=_reverse)
else:
self._data.sort(reverse=_reverse, key=key)
self._status.modified()
self.modified()

View File

@ -19,7 +19,7 @@
from copy import copy
from tools import trace, timer
from Model.Tools.PamhyrList import PamhyrModelList
from Model.Tools.PamhyrListExt import PamhyrModelList
from Model.HydraulicStructures.HydraulicStructures import HydraulicStructure
@ -42,10 +42,10 @@ class HydraulicStructureList(PamhyrModelList):
return new
def _db_save(self, execute, data=None):
execute("DELETE FROM hydraulic_structures")
if data is None:
data = {}
execute(
"DELETE FROM hydraulic_structures " +
f"WHERE scenario = {self._status.scenario_id}"
)
for hs in self._lst:
hs._db_save(execute, data=data)
@ -53,9 +53,12 @@ class HydraulicStructureList(PamhyrModelList):
return True
def new(self, lst, index):
n = HydraulicStructure(status=self._status)
n = HydraulicStructure(
status=self._status,
owner_scenario=self._status.scenario_id
)
self._lst.insert(index, n)
self._status.modified()
self.modified()
return n
def __copy__(self):

View File

@ -23,7 +23,6 @@ from Model.Scenario import Scenario
class Stricklers(SQLSubModel):
_id_cnt = 0
_sub_classes = []
def __init__(self, id: int = -1,
@ -33,9 +32,9 @@ class Stricklers(SQLSubModel):
medium: float = 15.0,
status=None, owner_scenario=-1):
super(Stricklers, self).__init__(
id=id, owner_scenario=owner_scenario
id=id, status=status,
owner_scenario=owner_scenario
)
self._status = status
self._name = name
self._comment = comment
@ -111,7 +110,6 @@ class Stricklers(SQLSubModel):
"FROM stricklers " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
)
if table is None:
@ -129,9 +127,7 @@ class Stricklers(SQLSubModel):
owner_scenario = next(it)
new = cls(
id=pid,
name=name,
comment=comment,
id=pid, name=name, comment=comment,
minor=minor, medium=medium,
status=status, owner_scenario=owner_scenario
)
@ -157,7 +153,7 @@ class Stricklers(SQLSubModel):
"name, comment, minor, medium, scenario) " +
"VALUES (" +
f"{self.pamhyr_id}, " +
f"{self.is_deleted()}, " +
f"{self._db_format(self.is_deleted())}, " +
f"'{self._db_format(self.name)}', " +
f"'{self._db_format(self.comment)}', " +
f"{float(self.minor)}, {float(self.medium)}, " +

View File

@ -49,14 +49,14 @@ class SetTypeCommand(QUndoCommand):
self._type = new_type
self._old = self._hs.basic_structure(self._index)
self._new = self._hs.basic_structure(self._index)\
.convert(self._type)
.convert(self._type)
def undo(self):
self._hs.delete_i([self._index])
self._hs.hard_delete_i([self._index])
self._hs.insert(self._index, self._old)
def redo(self):
self._hs.delete_i([self._index])
self._hs.hard_delete_i([self._index])
self._hs.insert(self._index, self._new)

View File

@ -50,20 +50,22 @@ class SetReachCommand(QUndoCommand):
self._h_s_lst = h_s_lst
self._index = index
self._old = self._h_s_lst.get(self._index).input_reach
self._old = self._h_s_lst.get(self._index)\
.input_reach
self._new = reach
self._old_rk = self._h_s_lst.get(self._index).input_rk
self._new_rk = None
self._old_section = self._h_s_lst.get(self._index)\
.input_section
self._new_section = None
def undo(self):
i = self._h_s_lst.get(self._index)
i.input_reach = self._old
i.input_rk = self._old_rk
i.input_section = self._old_section
def redo(self):
i = self._h_s_lst.get(self._index)
i.input_reach = self._new
i.input_rk = self._new_rk
i.input_section = self._new_section
class SetSectionCommand(QUndoCommand):
@ -114,7 +116,7 @@ class AddCommand(QUndoCommand):
if self._new is None:
self._new = self._h_s_lst.new(self._h_s_lst, self._index)
else:
self._h_s_lst.insert(self._index, self._new)
self._h_s_lst.undelete([self._new])
class DelCommand(QUndoCommand):
@ -127,12 +129,11 @@ class DelCommand(QUndoCommand):
self._h_s = []
for row in rows:
self._h_s.append((row, self._h_s_lst.get(row)))
self._h_s.append(self._h_s_lst.get(row))
self._h_s.sort()
def undo(self):
for row, el in self._h_s:
self._h_s_lst.insert(row, el)
self._h_s_lst.undelete(self._h_s)
def redo(self):
self._h_s_lst.delete_i(self._rows)

View File

@ -127,6 +127,9 @@ def display_timers():
)
for func, time, calls in lst:
if time <= 0.000001:
continue
name = (f"{logger_color_blue()}{func.__module__}" +
f"{logger_color_reset()}" +
f".{logger_color_green()}" +