hytos / HYTOS / HYTOS / Commands / CreateCommand.py @ f93e6d5e
이력 | 보기 | 이력해설 | 다운로드 (813 Bytes)
1 |
# coding: utf-8
|
---|---|
2 |
""" This is create command module """
|
3 |
import copy |
4 |
from PyQt5.QtCore import * |
5 |
from PyQt5.QtGui import * |
6 |
from PyQt5.QtWidgets import * |
7 |
|
8 |
|
9 |
class CreateCommand(QUndoCommand): |
10 |
def __init__(self, scene, items, parent=None): |
11 |
super(CreateCommand, self).__init__(parent) |
12 |
self._scene = scene
|
13 |
self._items = items
|
14 |
self._created = True |
15 |
|
16 |
def undo(self): |
17 |
"""undo"""
|
18 |
for item in self._items: |
19 |
if hasattr(item, 'transfer'): |
20 |
item.transfer.onRemoved.emit(item) |
21 |
else:
|
22 |
self._scene.removeItem(item)
|
23 |
self._created = False |
24 |
|
25 |
def redo(self): |
26 |
"""redo"""
|
27 |
|
28 |
if not self._created: |
29 |
for item in self._items: |
30 |
self._scene.addItem(item)
|
31 |
self._created = True |
32 |
|