Example #1
0
 def dropEvent(self, event):
     if self.collection.__class__.__name__ != "Repository":
         return
     location = event.mimeData().text().replace("file://", "").replace("%20", " ").strip()
     if os.path.isdir(location):
         for fileName in dirtools.search(location, libmgr.SUPPORTED_FILE_TYPES, relative = False):
             song = libmgr.getSongByLocation(fileName)
             if song:
                 self.collection.addSong(fileName, song, keepOriginal = True)
     if os.path.isfile(location):
         song = libmgr.getSongByLocation(location)
         if song:
             self.collection.addSong(location, song, keepOriginal = True)
Example #2
0
 def importDirectory(self, repository=None):
     if not repository:
         repository = self.viewPane.getCurrentRepository()
     if not repository:
         return
     dirName = QtGui.QFileDialog.getExistingDirectory(
         self, "Import Song Directory", QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.MusicLocation)
     )
     if not dirName:
         return
     for fileName in dirtools.search(dirName, libmgr.SUPPORTED_FILE_TYPES, relative=False):
         song = libmgr.getSongByLocation(fileName)
         repository.addSong(fileName, song, keepOriginal=True)