from PyQt4 import QtGui from clMonty import monty from clPlugin import * from misc import * from wgPlaylist import Playlist from wgSongList import clrRowSel LIBRARY_MODES_DEFAULT='$artist\n'\ '$artist/$date - $album\n'\ '$artist - $album\n'\ '$album ($artist)\n'\ '$genre\n'\ '$genre/$artist\n'\ '$genre/$artist - $album\n' class pluginLibrary(Plugin): o=None def __init__(self, winMain): Plugin.__init__(self, winMain, 'Library') def _load(self): self.o=Playlist(self.winMain, self, ['song'], 'Library' , self.onDoubleClick, self.onKeyPress, self.getSetting('modes').split('\n')) def _unload(self): self.o=None def getInfo(self): return "List showing all the songs allowing filtering and grouping." def getList(self): return self.o def _getDockWidget(self): return self._createDock(self.o) def onDoubleClick(self): self.addLibrarySelToPlaylist() def onKeyPress(self, event): # Add selection, or entire library to playlist using ENTER-key. if event.key()==QtCore.Qt.Key_Enter or event.key()==QtCore.Qt.Key_Return: self.addLibrarySelToPlaylist() return QtGui.QWidget.keyPressEvent(self.o, event) def addLibrarySelToPlaylist(self): """Add the library selection to the playlist.""" songs=self.o.selectedSongs() self.setStatus('Adding '+str(len(songs))+' songs to library ...') doEvents() # add filepaths of selected songs to path paths=map(lambda song: unicode(song.getFilepath()), songs) # add in chunks of 1000 CHUNK_SIZE=1000 start=0 while start