diff --git a/mal_gui/model_scene.py b/mal_gui/model_scene.py index d4724c7..a6482aa 100644 --- a/mal_gui/model_scene.py +++ b/mal_gui/model_scene.py @@ -463,6 +463,7 @@ def add_attacker(self, position, name = None): ) new_item.attackerAttachment = new_attacker_attachment self._attacker_id_to_item[new_attacker_attachment.id] = new_item + return new_item def create_item(self, itemType, position, name): """Create item""" @@ -599,7 +600,7 @@ def serialize_graphics_items(self, items: list[AssetBase], cut_intended): # - This is causing issue with Serialization asset_name = str(item.asset_name) prop_keys_to_ignore = ['id','type'] - + print(asset_name, item.asset_type) item_details = { 'asset_type': item.asset_type, 'asset_name': asset_name, @@ -613,12 +614,16 @@ def serialize_graphics_items(self, items: list[AssetBase], cut_intended): if conn.start_item.asset_sequence_id in selected_sequence_ids and conn.end_item.asset_sequence_id in selected_sequence_ids ], - 'asset_properties': [ + 'asset_properties': [] + } + + if item.asset_type != "Attacker": + item_details['asset_properties'] = [ (str(key),str(value)) - for key,value in item.asset._properties.items() - if key not in prop_keys_to_ignore + for key, value in item.asset._properties.items() + if key not in prop_keys_to_ignore ] - } + objdetails.append(item_details) serialized_data = pickle.dumps(objdetails) diff --git a/mal_gui/undo_redo_commands/paste_command.py b/mal_gui/undo_redo_commands/paste_command.py index f266b88..318d8a8 100644 --- a/mal_gui/undo_redo_commands/paste_command.py +++ b/mal_gui/undo_redo_commands/paste_command.py @@ -5,6 +5,8 @@ from PySide6.QtGui import QUndoCommand from PySide6.QtCore import QPointF +from maltoolbox.model import AttackerAttachment + from ..connection_item import AssociationConnectionItem if TYPE_CHECKING: @@ -49,14 +51,7 @@ def redo(self): # AddAsset Equivalent - Start - To Be Discussed if asset_type == "Attacker": - # newAttackerAttachment = AttackerAttachment() - # self.scene.model.add_attacker(newAttackerAttachment) - - new_item = self.scene.asset_factory.get_asset(asset_type) - # new_item.asset_name = "Attacker" - # new_item.type_text_item.setPlainText(str("Attacker")) - new_item.setPos(position) - # self.scene._attacker_id_to_item[newAttackerAttachment.id] = new_item + new_item = self.scene.add_attacker(position) else: new_item = self.scene.add_asset(asset_type, position) # we can assign the properties to new asset