from PyQt4 import QtGui from clMonty import monty from clPlugin import * from misc import * from wgPlaylist import Playlist from wgSongList import clrRowSel from clSettings import settings 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) 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: song.getFilepath(), songs) monty.addToPlaylist(paths) self.setStatus('') doEvents() self.getWinMain().fillPlaylist()