Example #1
0
    def _playlistDragDropHandle(self, event, isDropped):
        from txplayagui.client import moveTrack, libraryInsert

        mimeData = event.mimeData()

        # get row
        rowPosition = event.pos().y() - self.playlistTable.rowHeight(0)
        rowTarget = self.playlistTable.rowAt(rowPosition)

        if rowTarget == -1:
            # new row
            rowTarget = self.playlistModel.rowCount()

        if mimeData.hasUrls():
            urls = mimeData.urls()
            if len(urls) > 0:
                url = urls[0]
                if url.isLocalFile():
                    if not isDropped:
                        event.acceptProposedAction()
                        return

                    # file dropped
                    filepath = url.toLocalFile()

                    from txplayagui.client import insert
                    _ = insert(filepath, rowTarget)
                    return

        # no urls or not local file
        if not mimeData.hasText():
            return

        try:
            data = unwrapMime(mimeData)
        except ValueError:
            # invalid data passed
            return

        # check for proper flag
        source = data.get('source')
        if source not in ('playlist', 'library'):
            return

        if not isDropped:
            # drag entered
            event.acceptProposedAction()
            return

        if source == 'playlist':
            rowSource = data['row']
            moveTrack(rowSource, rowTarget)

        elif source == 'library':
            hashes = [item['hash'] for item in data['items']]
            libraryInsert(hashes, position=rowTarget)
Example #2
0
 def onLibraryItemActivated(self, hashes):
     from txplayagui.client import libraryInsert
     _ = libraryInsert(hashes)
Example #3
0
 def onLibraryItemActivated(self, hashes):
     from txplayagui.client import libraryInsert
     _ = libraryInsert(hashes)