diff --git a/src/View/BoundaryCondition/Edit/Table.py b/src/View/BoundaryCondition/Edit/Table.py index 287a8fe4..18fce9e6 100644 --- a/src/View/BoundaryCondition/Edit/Table.py +++ b/src/View/BoundaryCondition/Edit/Table.py @@ -99,7 +99,7 @@ class TableModel(PamhyrTableModel): logger.info(e) logger.debug(traceback.format_exc()) - self.dataChanged.emit(index, index) + self.update() return True def add(self, row, parent=QModelIndex()): @@ -112,7 +112,7 @@ class TableModel(PamhyrTableModel): ) self.endInsertRows() - self.layoutChanged.emit() + self.update() def delete(self, rows, parent=QModelIndex()): self.beginRemoveRows(parent, rows[0], rows[-1]) @@ -135,7 +135,7 @@ class TableModel(PamhyrTableModel): ) self.layoutAboutToBeChanged.emit() - self.layoutChanged.emit() + self.update() def move_up(self, row, parent=QModelIndex()): if row <= 0: @@ -152,7 +152,7 @@ class TableModel(PamhyrTableModel): ) self.endMoveRows() - self.layoutChanged.emit() + self.update() def move_down(self, index, parent=QModelIndex()): if row > len(self._data): @@ -169,7 +169,7 @@ class TableModel(PamhyrTableModel): ) self.endMoveRows() - self.layoutChanged.emit() + self.update() def paste(self, row, header, data): if len(data) == 0: @@ -190,4 +190,13 @@ class TableModel(PamhyrTableModel): ) self.layoutAboutToBeChanged.emit() + self.update() + + def auto_sort(self): + self.layoutAboutToBeChanged.emit() + self._data.sort(key=lambda x: x[0]) + self.layoutAboutToBeChanged.emit() + + def update(self): + self.auto_sort() self.layoutChanged.emit() diff --git a/src/View/BoundaryCondition/Edit/Window.py b/src/View/BoundaryCondition/Edit/Window.py index faf41896..94557ddd 100644 --- a/src/View/BoundaryCondition/Edit/Window.py +++ b/src/View/BoundaryCondition/Edit/Window.py @@ -195,6 +195,7 @@ class EditBoundaryConditionWindow(PamhyrWindow): self.find(QAction, "action_sort").triggered.connect(self.sort) self._table.dataChanged.connect(self.update) + self._table.layoutChanged.connect(self.update) if self._is_solid: self._d50sigma.d50Changed.connect(self.d50_changed) diff --git a/src/View/LateralContribution/Edit/Table.py b/src/View/LateralContribution/Edit/Table.py index c0ab3b44..3e726cc5 100644 --- a/src/View/LateralContribution/Edit/Table.py +++ b/src/View/LateralContribution/Edit/Table.py @@ -99,7 +99,7 @@ class TableModel(PamhyrTableModel): logger.info(e) logger.debug(traceback.format_exc()) - self.dataChanged.emit(index, index) + self.update() return True def add(self, row, parent=QModelIndex()): @@ -112,7 +112,7 @@ class TableModel(PamhyrTableModel): ) self.endInsertRows() - self.layoutChanged.emit() + self.update() def delete(self, rows, parent=QModelIndex()): self.beginRemoveRows(parent, rows[0], rows[-1]) @@ -135,7 +135,7 @@ class TableModel(PamhyrTableModel): ) self.layoutAboutToBeChanged.emit() - self.layoutChanged.emit() + self.update() def move_up(self, row, parent=QModelIndex()): if row <= 0: @@ -152,7 +152,7 @@ class TableModel(PamhyrTableModel): ) self.endMoveRows() - self.layoutChanged.emit() + self.update() def move_down(self, index, parent=QModelIndex()): if row > len(self._data): @@ -169,7 +169,7 @@ class TableModel(PamhyrTableModel): ) self.endMoveRows() - self.layoutChanged.emit() + self.update() def paste(self, row, header, data): if len(data) == 0: @@ -190,4 +190,13 @@ class TableModel(PamhyrTableModel): ) self.layoutAboutToBeChanged.emit() + self.update() + + def auto_sort(self): + self.layoutAboutToBeChanged.emit() + self._data.sort(key=lambda x: x[0]) + self.layoutAboutToBeChanged.emit() + + def update(self): + self.auto_sort() self.layoutChanged.emit() diff --git a/src/View/LateralContribution/Edit/Window.py b/src/View/LateralContribution/Edit/Window.py index 53c774cb..1b5beec7 100644 --- a/src/View/LateralContribution/Edit/Window.py +++ b/src/View/LateralContribution/Edit/Window.py @@ -137,6 +137,7 @@ class EditLateralContributionWindow(PamhyrWindow): self.find(QAction, "action_sort").triggered.connect(self.sort) self._table.dataChanged.connect(self.update) + self._table.layoutChanged.connect(self.update) def update(self): self.plot.update()