diff options
author | Colin Noga <Tempus@Spectrum-Song.local> | 2011-11-17 06:44:17 -0600 |
---|---|---|
committer | Colin Noga <Tempus@Spectrum-Song.local> | 2011-11-17 06:44:17 -0600 |
commit | 68e66b16255ea2603bd323083e3b5b43280caff1 (patch) | |
tree | 412b5b48a9910526d70b0b4c70326c937bf20663 /src/editorui | |
parent | f14806abe907d6e04a12c5e2990c1e10a34ed103 (diff) | |
download | koopatlas-68e66b16255ea2603bd323083e3b5b43280caff1.tar.gz koopatlas-68e66b16255ea2603bd323083e3b5b43280caff1.zip |
Deleting Editor Items and their associated shitpiles of underlying abstractions is now implemented.
Diffstat (limited to '')
-rw-r--r-- | src/editorui.py | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/src/editorui.py b/src/editorui.py index 3b9b74e..6b0815c 100644 --- a/src/editorui.py +++ b/src/editorui.py @@ -237,6 +237,18 @@ class KPEditorObject(KPEditorItem): self._layerRef().updateCache() + def remove(self): + + obj = self._objRef() + layer = self._layerRef() + + index = layer.objects.index(obj) + layer.objects.pop(index) + layer.updateCache() + del obj + + + class KPEditorDoodad(QtGui.QGraphicsPixmapItem): def __init__(self, doodad, layer): QtGui.QGraphicsPixmapItem.__init__(self) @@ -400,8 +412,8 @@ class KPEditorDoodad(QtGui.QGraphicsPixmapItem): origX = originalPos.x() origY = originalPos.y() - dy = origY - objY - dx = origX - objX + dy = origY - objY + dx = origX - objX rads = math.atan2(dy, dx) origAngle = math.degrees(rads) @@ -409,8 +421,8 @@ class KPEditorDoodad(QtGui.QGraphicsPixmapItem): - dy = mouseY - objY - dx = mouseX - objX + dy = mouseY - objY + dx = mouseX - objX rads = math.atan2(dy, dx) angle = math.degrees(rads) @@ -431,7 +443,7 @@ class KPEditorDoodad(QtGui.QGraphicsPixmapItem): # Fucking Transform can't do independent transforms with doing matrix math directly. # And before anyone asks, using QTransform.scale() is no good. - + if self.resizing: obj = self._doodadRef() scenePos = event.scenePos() @@ -474,6 +486,17 @@ class KPEditorDoodad(QtGui.QGraphicsPixmapItem): KPEditorItem.mouseReleaseEvent(self, event) + def remove(self): + + doodad = self._doodadRef() + layer = self._layerRef() + + index = layer.objects.index(doodad) + layer.objects.pop(index) + del doodad + + + class KPMapScene(QtGui.QGraphicsScene): def __init__(self): @@ -753,3 +776,23 @@ class KPEditorWidget(QtGui.QGraphicsView): QtGui.QGraphicsView.mouseMoveEvent(self, event) + def keyPressEvent(self, event): + if event.key() == QtCore.Qt.Key_Delete or event.key() == QtCore.Qt.Key_Backspace: + scene = self.scene() + + selection = scene.selectedItems() + if len(selection) > 0: + for obj in selection: + obj.remove() + obj.setSelected(False) + scene.removeItem(obj) + scene.update() + self.update() + return + + else: + QtGui.QGraphicsView.keyPressEvent(self, event) + + + + |