MCPcopy Create free account
hub / github.com/Syncplay/syncplay / dropEvent

Method dropEvent

syncplay/ui/gui.py:306–331  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

304 window.setPlaylistInsertPosition(None)
305
306 def dropEvent(self, event):
307 window = self.parent().parent().parent().parent().parent()
308 if not window.playlist.isEnabled():
309 return
310 window.setPlaylistInsertPosition(None)
311 if QtGui.QDropEvent.proposedAction(event) == Qt.MoveAction:
312 QtGui.QDropEvent.setDropAction(event, Qt.CopyAction) # Avoids file being deleted
313 data = event.mimeData()
314 urls = data.urls()
315
316 if urls and urls[0].scheme() == 'file':
317 indexRow = window.playlist.count() if window.clearedPlaylistNote else 0
318
319 for url in urls[::-1]:
320 if isMacOS() and IsPySide:
321 macURL = NSString.alloc().initWithString_(str(url.toString()))
322 pathString = macURL.stringByAddingPercentEscapesUsingEncoding_(NSUTF8StringEncoding)
323 dropfilepath = os.path.abspath(NSURL.URLWithString_(pathString).filePathURL().path())
324 else:
325 dropfilepath = os.path.abspath(str(url.toLocalFile()))
326 if os.path.isfile(dropfilepath):
327 window.addFileToPlaylist(dropfilepath, indexRow)
328 elif os.path.isdir(dropfilepath):
329 window.addFolderToPlaylist(dropfilepath)
330 else:
331 super(MainWindow.PlaylistWidget, self).dropEvent(event)
332
333 class PlaylistWidget(QtWidgets.QListWidget):
334 selfWindow = None

Callers

nothing calls this directly

Calls 5

isMacOSFunction · 0.90
addFolderToPlaylistMethod · 0.80
addFileToPlaylistMethod · 0.45
dropEventMethod · 0.45

Tested by

no test coverage detected