diff options
| author | tassaron | 2017-08-16 22:17:12 -0400 |
|---|---|---|
| committer | tassaron | 2017-08-16 22:17:12 -0400 |
| commit | f66ec40ba6e9c4062d1e41894e0a88f713add96d (patch) | |
| tree | 907ba966411efe859a0e7dceaf2a4b4aa4aa0666 /src/gui/mainwindow.py | |
| parent | ddb04f3a2fe6454a9c98bba39d07a12bd6a91b45 (diff) | |
undoable component movement
Diffstat (limited to 'src/gui/mainwindow.py')
| -rw-r--r-- | src/gui/mainwindow.py | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/gui/mainwindow.py b/src/gui/mainwindow.py index 47111a0..26464a9 100644 --- a/src/gui/mainwindow.py +++ b/src/gui/mainwindow.py @@ -716,27 +716,19 @@ class MainWindow(QtWidgets.QMainWindow): def moveComponent(self, change): '''Moves a component relatively from its current position''' componentList = self.window.listWidget_componentList + tag = change if change == 'top': change = -componentList.currentRow() elif change == 'bottom': change = len(componentList)-componentList.currentRow()-1 - stackedWidget = self.window.stackedWidget + else: + tag = 'down' if change == 1 else 'up' row = componentList.currentRow() newRow = row + change if newRow > -1 and newRow < componentList.count(): - self.core.moveComponent(row, newRow) - - # update widgets - page = self.pages.pop(row) - self.pages.insert(newRow, page) - item = componentList.takeItem(row) - newItem = componentList.insertItem(newRow, item) - widget = stackedWidget.removeWidget(page) - stackedWidget.insertWidget(newRow, page) - componentList.setCurrentRow(newRow) - stackedWidget.setCurrentIndex(newRow) - self.drawPreview(True) + action = MoveComponent(self, row, newRow, tag) + self.undoStack.push(action) def getComponentListMousePos(self, position): ''' |
