Esempio n. 1
0
    def dropMimeData(self, mimeData, action, row, column, parentIndex):
        # In the test I have made, the row and column args always seem to be -1/-1 except when
        # parentIndex is invalid (which means that the drop destination is the root node).
        def find_path(path):
            if path[0] == DESIGN_BOARD_NAME:
                return self.app.board.find_path(path[1:])
            elif path[0] == IGNORE_BOX_NAME:
                return self.app.board.ignore_box.find_path(path[1:])

        if not mimeData.hasFormat(MIME_PATHS):
            return False
        if parentIndex.isValid():
            destNode = parentIndex.internalPointer()
        else:
            destNode = self
        paths = str(mimeData.data(MIME_PATHS), 'utf-8').split('\n')
        sourceItems = set(find_path(Path(path)) for path in paths)
        sourceItems = set(item for item in sourceItems
                          if item.parent not in sourceItems
                          | set([destNode.ref]))
        if not sourceItems:
            return False
        smart_move(sourceItems, destNode.ref, allow_merge=True)
        destNode.invalidate()
        # InsertRow calls have to be made at correct indexes or else the subsequent removeRows call
        # will be made at incorrect indexes. To do so, we just go through every subitem of destNode.ref
        # and if it's in sourceItems, we call insertRow.
        # destNode.subnodes
        for index, node in enumerate(destNode.subnodes):
            if node.ref in sourceItems:
                self.insertRow(index, parentIndex)
        return True
Esempio n. 2
0
 def dropMimeData(self, mimeData, action, row, column, parentIndex):
     # In the test I have made, the row and column args always seem to be -1/-1 except when
     # parentIndex is invalid (which means that the drop destination is the root node).
     def find_path(path):
         if path[0] == DESIGN_BOARD_NAME:
             return self.app.board.find_path(path[1:])
         elif path[0] == IGNORE_BOX_NAME:
             return self.app.board.ignore_box.find_path(path[1:])
     
     if not mimeData.hasFormat(MIME_PATHS):
         return False
     if parentIndex.isValid():
         destNode = parentIndex.internalPointer()
     else:
         destNode = self
     paths = str(mimeData.data(MIME_PATHS), 'utf-8').split('\n')
     sourceItems = set(find_path(Path(path)) for path in paths)
     sourceItems = set(item for item in sourceItems if item.parent not in sourceItems | set([destNode.ref]))
     if not sourceItems:
         return False
     smart_move(sourceItems, destNode.ref, allow_merge=True)
     destNode.invalidate()
     # InsertRow calls have to be made at correct indexes or else the subsequent removeRows call
     # will be made at incorrect indexes. To do so, we just go through every subitem of destNode.ref
     # and if it's in sourceItems, we call insertRow. 
     # destNode.subnodes
     for index, node in enumerate(destNode.subnodes):
         if node.ref in sourceItems:
             self.insertRow(index, parentIndex)
     return True
Esempio n. 3
0
 def moveSelectedToIgnoreBox(self):
     smart_move(self.selectedBoardItems,
                self.board.ignore_box,
                allow_merge=True)
     self.emit(SIGNAL('boardChanged()'))
     self.emit(SIGNAL('ignoreBoxChanged()'))
Esempio n. 4
0
 def moveSelectedToIgnoreBox(self):
     smart_move(self.selectedBoardItems, self.board.ignore_box, allow_merge=True)
     self.emit(SIGNAL('boardChanged()'))
     self.emit(SIGNAL('ignoreBoxChanged()'))