mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
7 Commits
befe1a550d
...
c58620fdc2
| Author | SHA1 | Date |
|---|---|---|
|
|
c58620fdc2 | |
|
|
a6341dedd2 | |
|
|
ba7171326c | |
|
|
78b4269a69 | |
|
|
a30bf8e364 | |
|
|
bd1edbaf30 | |
|
|
bdf9264963 |
|
|
@ -239,10 +239,10 @@ class Profile(object):
|
|||
# Move
|
||||
|
||||
def move_up_point(self, index: int):
|
||||
if index < len(self.points):
|
||||
if index < len(self._points):
|
||||
next = index - 1
|
||||
|
||||
p = self.points
|
||||
p = self._points
|
||||
p[index], p[next] = p[next], p[index]
|
||||
self.modified()
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ class Profile(object):
|
|||
if index >= 0:
|
||||
prev = index + 1
|
||||
|
||||
p = self.points
|
||||
p = self._points
|
||||
p[index], p[prev] = p[prev], p[index]
|
||||
self.modified()
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ class Profile(object):
|
|||
def predicate(p): return p.z
|
||||
|
||||
self._points = sorted(
|
||||
self.points,
|
||||
self._points,
|
||||
key=predicate,
|
||||
reverse=is_reversed
|
||||
)
|
||||
|
|
@ -273,14 +273,14 @@ class Profile(object):
|
|||
|
||||
@timer
|
||||
def sort_with_indexes(self, indexes: list):
|
||||
if len(self.points) != len(indexes):
|
||||
if len(self._points) != len(indexes):
|
||||
logger.critical("Indexes list do not correspond to point list")
|
||||
|
||||
self._points = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
sorted(
|
||||
enumerate(self.points),
|
||||
enumerate(self._points),
|
||||
key=lambda x: indexes[x[0]]
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ class Reach(SQLSubModel):
|
|||
self.modified()
|
||||
|
||||
def move_up_profile(self, index: int):
|
||||
if index < len(self.profiles):
|
||||
if index < len(self._profiles):
|
||||
next = index - 1
|
||||
|
||||
p = self._profiles
|
||||
|
|
@ -534,7 +534,7 @@ class Reach(SQLSubModel):
|
|||
|
||||
@timer
|
||||
def sort_with_indexes(self, indexes: list):
|
||||
if len(self.profiles) != len(indexes):
|
||||
if len(self._profiles) != len(indexes):
|
||||
logger.critical("Indexes list do not correspond to profile list")
|
||||
|
||||
self._profiles = list(
|
||||
|
|
|
|||
|
|
@ -319,7 +319,10 @@ class Pollutants(SQLSubModel):
|
|||
)
|
||||
""")
|
||||
|
||||
return True
|
||||
if ext != "":
|
||||
return True
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
|
||||
@classmethod
|
||||
def _db_update(cls, execute, version, data=None):
|
||||
|
|
|
|||
|
|
@ -45,6 +45,19 @@ _translate = QCoreApplication.translate
|
|||
|
||||
|
||||
class GeometryProfileTableModel(PamhyrTableModel):
|
||||
def get_true_data_row(self, row):
|
||||
profile = self._data.point(row)
|
||||
|
||||
return next(
|
||||
map(
|
||||
lambda e: e[0],
|
||||
filter(
|
||||
lambda e: e[1] == profile,
|
||||
enumerate(self._data._points)
|
||||
)
|
||||
), 0
|
||||
)
|
||||
|
||||
def data(self, index, role=Qt.DisplayRole):
|
||||
if index.isValid():
|
||||
if role == Qt.DisplayRole:
|
||||
|
|
@ -162,6 +175,8 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||
def insert_row(self, row, parent=QModelIndex()):
|
||||
self.beginInsertRows(parent, row, row - 1)
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
|
||||
self._undo.push(
|
||||
AddCommand(
|
||||
self._data, row
|
||||
|
|
@ -176,7 +191,12 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||
|
||||
self._undo.push(
|
||||
DelCommand(
|
||||
self._data, rows
|
||||
self._data, list(
|
||||
map(
|
||||
lambda r: self.get_true_data_row(r),
|
||||
rows
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -200,10 +220,10 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||
if row <= 0:
|
||||
return
|
||||
|
||||
target = row + 2
|
||||
|
||||
target = row + 1
|
||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
self._undo.push(
|
||||
MoveCommand(
|
||||
self._data, "up", row
|
||||
|
|
@ -218,9 +238,9 @@ class GeometryProfileTableModel(PamhyrTableModel):
|
|||
return
|
||||
|
||||
target = row
|
||||
|
||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
self._undo.push(
|
||||
MoveCommand(
|
||||
self._data, "down", row
|
||||
|
|
|
|||
|
|
@ -144,9 +144,9 @@ class SortCommand(QUndoCommand):
|
|||
self._column = column
|
||||
self._reverse = _reverse
|
||||
|
||||
old = self._profile.points
|
||||
old = self._profile._points
|
||||
self._profile.sort(self._column, self._reverse)
|
||||
new = self._profile.points
|
||||
new = self._profile._points
|
||||
|
||||
self._indexes = list(
|
||||
map(
|
||||
|
|
|
|||
|
|
@ -132,8 +132,8 @@ class ProfileWindow(PamhyrWindow):
|
|||
actions = {}
|
||||
else:
|
||||
actions = {
|
||||
"action_sort_asc": self.sort_X_ascending,
|
||||
"action_sort_des": self.sort_X_descending,
|
||||
"action_sort_asc": self.sort_Y_ascending,
|
||||
"action_sort_des": self.sort_Y_descending,
|
||||
"action_up": self.move_up,
|
||||
"action_down": self.move_down,
|
||||
"action_add": self.add,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,19 @@ _translate = QCoreApplication.translate
|
|||
|
||||
|
||||
class GeometryReachTableModel(PamhyrTableModel):
|
||||
def get_true_data_row(self, row):
|
||||
profile = self._data.profile(row)
|
||||
|
||||
return next(
|
||||
map(
|
||||
lambda e: e[0],
|
||||
filter(
|
||||
lambda e: e[1] == profile,
|
||||
enumerate(self._data._profiles)
|
||||
)
|
||||
), 0
|
||||
)
|
||||
|
||||
def data(self, index, role=Qt.DisplayRole):
|
||||
if not index.isValid():
|
||||
return QVariant()
|
||||
|
|
@ -155,10 +168,10 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
if row <= 0:
|
||||
return
|
||||
|
||||
target = row + 2
|
||||
|
||||
target = row + 1
|
||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
self._undo.push(
|
||||
MoveCommand(
|
||||
self._data, "up", row
|
||||
|
|
@ -176,6 +189,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
|
||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
self._undo.push(
|
||||
MoveCommand(
|
||||
self._data, "down", row
|
||||
|
|
@ -212,7 +226,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
self.layoutChanged.emit()
|
||||
|
||||
def paste(self, row, header, data):
|
||||
if row > self._data.number_profiles:
|
||||
if row > len(self._data._profiles):
|
||||
return
|
||||
|
||||
if len(data) == 0:
|
||||
|
|
@ -220,9 +234,10 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
true_row = self.get_true_data_row(row)
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, row,
|
||||
self._data, true_row,
|
||||
list(
|
||||
map(
|
||||
lambda d: ProfileXYZ.from_data(header, d),
|
||||
|
|
|
|||
|
|
@ -111,9 +111,9 @@ class SortCommand(QUndoCommand):
|
|||
self._reach = reach
|
||||
self._reverse = _reverse
|
||||
|
||||
old = self._reach.profiles
|
||||
old = self._reach._profiles
|
||||
self._reach.sort(self._reverse)
|
||||
new = self._reach.profiles
|
||||
new = self._reach._profiles
|
||||
|
||||
self._indexes = list(
|
||||
map(
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ try:
|
|||
from View.Doc.Window import DocWindow
|
||||
_doc = "internal"
|
||||
except Exception as e:
|
||||
print("Handle exception: {e}")
|
||||
print(f"Handle exception: {e}")
|
||||
_doc = "external"
|
||||
|
||||
from Model.Study import Study
|
||||
|
|
|
|||
Loading…
Reference in New Issue