示例#1
0
 def undo(self):
     path = self.slot_path or self.path.rsplit("/", 1)[0]  # slot or parent
     widget = common.root.find_widget_from_path(path)
     if widget.IS_ROOT:  # or widget.IS_CONTAINER:
         widget.clipboard_paste(self.xml_data, self.index)
     elif self.IS_SLOT:
         widget.insert_item(None, self.index)  # placeholder
         if self.slot_tab is not None:
             tabs_p = widget.properties["tabs"]
             tabs_p.value.insert(self.index, [self.slot_tab])
             tabs_p.reset()
         if widget.IS_SIZER:
             from edit_sizers import SizerSlot as Slot
         else:
             from edit_base import Slot
         slot = Slot(widget, index=self.index)
         if widget.widget:
             slot.create_widget()
             widget.child_widget_created(slot, 0)
         # update structure
         misc.rebuild_tree(widget, focus=False)
         # update following slots
         for c in widget.children[self.index + 1:]:
             if c.IS_SLOT: common.app_tree.refresh(c)
         misc.set_focused_widget(slot)
     else:
         widget.clipboard_paste(self.xml_data)
示例#2
0
    def undo(self):
        # identical to HistoryAddedItem.redo, except for the slot_tab part
        path = self.slot_path or self.path.rsplit("/", 1)[0]  # slot or parent
        widget = common.root.find_widget_from_path(path)
        if widget is None:
            # something was pasted/added to e.g. a panel which had a slot as child
            parent_path, leaf = path.rsplit("/", 1)
            assert leaf.startswith('SLOT ')
            widget = common.root.find_widget_from_path(parent_path)

        if widget.IS_ROOT:  # or widget.IS_CONTAINER:
            widget.clipboard_paste(self.xml_data, self.index)
        elif self.IS_SLOT:
            widget.insert_item(None, self.index)  # placeholder
            if self.slot_tab is not None:
                tabs_p = widget.properties["tabs"]
                tabs_p.value.insert(self.index, [self.slot_tab])
                tabs_p.reset()
            if widget.IS_SIZER:
                from edit_sizers import SizerSlot as Slot
            else:
                from edit_base import Slot
            slot = Slot(widget, index=self.index)
            if widget.widget:
                slot.create_widget()
                widget.child_widget_created(slot, 0)
            # update structure
            misc.rebuild_tree(widget, focus=False)
            # update following slots
            for c in widget.children[self.index + 1:]:
                if c.IS_SLOT: common.app_tree.refresh(c)
            misc.set_focused_widget(slot)
        else:
            widget.clipboard_paste(self.xml_data)