1 from PyQt4
import QtGui
, QtCore
2 from PyQt4
.QtCore
import QVariant
5 from clPlugin
import Plugin
6 from misc
import ORGNAME
, APPNAME
8 class pluginFilebrowser(Plugin
):
12 def __init__(self
, winMain
):
13 Plugin
.__init
__(self
, winMain
, 'Filebrowser')
16 self
.model
= QtGui
.QDirModel()
17 self
.model
.setFilter(QtCore
.QDir
.AllDirs|QtCore
.QDir
.AllEntries
)
18 self
.model
.setSorting(QtCore
.QDir
.DirsFirst
)
20 self
.view
= QtGui
.QListView()
21 self
.view
.setModel(self
.model
)
22 self
.view
.setRootIndex(self
.model
.index(os
.path
.expanduser('~')))
23 self
.view
.setSelectionMode(QtGui
.QTreeWidget
.ExtendedSelection
)
24 self
.view
.connect(self
.view
, QtCore
.SIGNAL('activated(const QModelIndex&)'), self
.item_activated
)
31 return 'A file browser that allows adding files not in collection.'
33 def _getDockWidget(self
):
34 return self
._createDock
(self
.view
)
36 def item_activated(self
, index
):
37 if self
.model
.hasChildren(index
):
38 self
.view
.setRootIndex(index
)
40 if not 'file://' in self
.monty
.urlhandlers():
41 self
.setStatus('file:// handler not available. Connect via unix domain sockets.')
44 for index
in self
.view
.selectedIndexes():
45 paths
.append(u
'file://' + self
.model
.filePath(index
))
46 self
.monty
.addToPlaylist(paths
)