summaryrefslogtreecommitdiff
path: root/plugins/Library.py
blob: 4f82c2e64a1d6a0a3556711ca9391e9c6b5507a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from PyQt4 import QtGui
from clMonty import monty
from clPlugin import *
from misc import *
from wgPlaylist import Playlist
from wgSongList import clrRowSel

class pluginLibrary(Plugin):
	o=None
	def __init__(self, winMain):
		Plugin.__init__(self, winMain, 'Library')
		self.o=Playlist(winMain, self, ['song'], 'The Library'
				, self.onDoubleClick, self.onKeyPress)
		self.o.showColumn(0,False)
		self.o.setMode('library', 'artist/album')
	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()