Exemplo n.º 1
0
    def dropEvent(self, event):
        source = event.source()
        pos = event.pos()

        if source == self:
            offset = None
            if event.mimeData().hasFormat('application/x-dnditemdata'):
                itemData = event.mimeData().data('application/x-dnditemdata')
                dataStream = QtCore.QDataStream(itemData, QtCore.QIODevice.ReadOnly)

                pixmap = QtGui.QPixmap()
                offset = QtCore.QPoint()
                dataStream >> offset

            self.selected.taskData['pos'] = pos
            draw_task(self, self.selected.taskData, offset=offset)

            event.setDropAction(QtCore.Qt.MoveAction)
            event.accept()
            return

        if source == None:
            urls = event.mimeData().urls()
            if urls:
                sources = [i.path()[1:] for i in urls]

                child = self.childAt(pos)
                if child:
                    child_sources = child.taskData.get('sources', [])
                    child_sources.update(sources)
                    redraw(child)
                else:
                    task = init_task(self, sources, pos)
                    draw_task(self, task, middle=1)

                event.accept()
            else:
                event.ignore()
            return
Exemplo n.º 2
0
 def loadScheme(self):
     tasks = self.s.get('tasks', [])
     for task in tasks:
         draw_task(self.ui.gragWidget, task)