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):
|
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):
|
def data(self, index, role=Qt.DisplayRole):
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
@ -155,6 +168,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
row = self.get_true_data_row(row)
|
||||||
target = row + 2
|
target = row + 2
|
||||||
|
|
||||||
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
self.beginMoveRows(parent, row - 1, row - 1, parent, target)
|
||||||
|
|
@ -172,6 +186,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
if row >= self._data.number_profiles-1:
|
if row >= self._data.number_profiles-1:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
row = self.get_true_data_row(row)
|
||||||
target = row
|
target = row
|
||||||
|
|
||||||
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
self.beginMoveRows(parent, row + 1, row + 1, parent, target)
|
||||||
|
|
@ -218,19 +233,9 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
return
|
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()
|
self.layoutAboutToBeChanged.emit()
|
||||||
|
|
||||||
|
true_row = self.get_true_data_row(row)
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
PasteCommand(
|
PasteCommand(
|
||||||
self._data, true_row,
|
self._data, true_row,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue