mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Geometry: Section: Fix move up and down.
This commit is contained in:
1 parent
78b4269a69
commit
ba7171326c
1 file changed
+16
-11
+16
-11
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user