1 from PyQt4
import QtGui
2 from clMonty
import monty
5 from wgPlaylist
import Playlist
7 LIBRARY_MODES_DEFAULT
='$artist\n'\
8 '$artist/$date - $album\n'\
13 '$genre/$artist - $album\n'
14 class pluginLibrary(Plugin
):
16 def __init__(self
, winMain
):
17 Plugin
.__init
__(self
, winMain
, 'Library')
19 self
.o
=Playlist(self
.winMain
, self
, ['song'], 'Library'
20 , self
.onDoubleClick
, self
.onKeyPress
, self
.getSetting('modes').split('\n'))
24 return "List showing all the songs allowing filtering and grouping."
29 def _getDockWidget(self
):
30 return self
._createDock
(self
.o
)
32 def onDoubleClick(self
):
33 self
.addLibrarySelToPlaylist()
35 def onKeyPress(self
, event
):
36 # Add selection, or entire library to playlist using ENTER-key.
37 if event
.key()==QtCore
.Qt
.Key_Enter
or event
.key()==QtCore
.Qt
.Key_Return
:
38 self
.addLibrarySelToPlaylist()
39 return QtGui
.QWidget
.keyPressEvent(self
.o
, event
)
41 def addLibrarySelToPlaylist(self
):
42 """Add the library selection to the playlist."""
43 songs
=self
.o
.selectedSongs()
44 self
.setStatus('Adding '+str(len(songs
))+' songs to library ...')
47 # add filepaths of selected songs to path
48 paths
=map(lambda song
: unicode(song
.getFilepath()), songs
)
49 # add in chunks of 1000
52 while start
<len(paths
):
53 if start
+CHUNK_SIZE
<len(paths
):
57 self
.setStatus('Adding '+str(len(songs
))+' songs to library: %i%%'%(int(100*start
/len(paths
))))
59 monty
.addToPlaylist(paths
[start
:end
])
64 self
.getWinMain().fillPlaylist()
66 def _getSettings(self
):
67 modes
=QtGui
.QTextEdit()
68 modes
.insertPlainText(self
.getSetting('modes'))
70 ['modes', 'Modes', 'Sets the available modes.', modes
],
72 def afterSaveSettings(self
):
73 self
.o
.setModes(self
.getSetting('modes').split('\n'))