mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Section: Fix move up and down.
parent
78b4269a69
commit
ba7171326c
|
|
@ -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,6 +168,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
if row <= 0:
|
||||
return
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
target = row + 2
|
||||
|
||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||
|
|
@ -172,6 +186,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
if row >= self._data.number_profiles-1:
|
||||
return
|
||||
|
||||
row = self.get_true_data_row(row)
|
||||
target = row
|
||||
|
||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||
|
|
@ -218,19 +233,9 @@ class GeometryReachTableModel(PamhyrTableModel):
|
|||
if len(data) == 0:
|
||||
return
|
||||
|
||||
profile = self._data.profile(row)
|
||||
true_row = next(
|
||||
map(
|
||||
lambda e: e[0],
|
||||
filter(
|
||||
lambda e: e[1] == profile,
|
||||
enumerate(self._data._profiles)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
|
||||
true_row = self.get_true_data_row(row)
|
||||
self._undo.push(
|
||||
PasteCommand(
|
||||
self._data, true_row,
|
||||
|
|
|
|||
Loading…
Reference in New Issue