diff options
author | Anton Khirnov <wyskas@gmail.com> | 2009-02-20 18:38:10 +0100 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2009-02-20 18:38:10 +0100 |
commit | 9ae39fd276e65d346778dd637632fa073e3643bd (patch) | |
tree | c5e2788c7d0b5a34845b59eea6a75ac2d0c1d10f /nephilim | |
parent | f731bb7e274ba764d7f86b9084002c2d1a5ec4b5 (diff) |
Filebrowser: add lineedit for path.
Diffstat (limited to 'nephilim')
-rw-r--r-- | nephilim/plugins/Filebrowser.py | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/nephilim/plugins/Filebrowser.py b/nephilim/plugins/Filebrowser.py index cb85a28..3f96236 100644 --- a/nephilim/plugins/Filebrowser.py +++ b/nephilim/plugins/Filebrowser.py @@ -6,13 +6,32 @@ from ..clPlugin import Plugin from ..misc import ORGNAME, APPNAME class Filebrowser(Plugin): - view = None - model = None - + o = None def __init__(self, winMain): Plugin.__init__(self, winMain, 'Filebrowser') def _load(self): + self.o = wgFilebrowser(self) + + def _unload(self): + self.o = None + + def getInfo(self): + return 'A file browser that allows adding files not in collection.' + + def _getDockWidget(self): + return self._createDock(self.o) + +class wgFilebrowser(QtGui.QWidget): + view = None + model = None + path = None + plugin = None + + def __init__(self, plugin): + QtGui.QWidget.__init__(self) + self.plugin = plugin + self.model = QtGui.QDirModel() self.model.setFilter(QtCore.QDir.AllDirs|QtCore.QDir.AllEntries) self.model.setSorting(QtCore.QDir.DirsFirst) @@ -21,27 +40,30 @@ class Filebrowser(Plugin): self.view.setModel(self.model) self.view.setRootIndex(self.model.index(os.path.expanduser('~'))) self.view.setSelectionMode(QtGui.QTreeWidget.ExtendedSelection) - self.view.connect(self.view, QtCore.SIGNAL('activated(const QModelIndex&)'), self.item_activated) - - def _unload(self): - self.view = None - self.model = None + self.connect(self.view, QtCore.SIGNAL('activated(const QModelIndex&)'), self.item_activated) - def getInfo(self): - return 'A file browser that allows adding files not in collection.' + self.path = QtGui.QLineEdit(self.model.filePath(self.view.rootIndex())) + self.connect(self.path, QtCore.SIGNAL('returnPressed()'), self.path_changed) - def _getDockWidget(self): - return self._createDock(self.view) + self.setLayout(QtGui.QVBoxLayout()) + self.layout().setSpacing(0) + self.layout().setMargin(0) + self.layout().addWidget(self.path) + self.layout().addWidget(self.view) def item_activated(self, index): if self.model.hasChildren(index): self.view.setRootIndex(index) + self.path.setText(self.model.filePath(index)) else: - if not 'file://' in self.mpclient.urlhandlers(): + if not 'file://' in self.plugin.mpclient.urlhandlers(): self.setStatus('file:// handler not available. Connect via unix domain sockets.') return paths = [] for index in self.view.selectedIndexes(): paths.append(u'file://' + self.model.filePath(index)) - self.mpclient.addToPlaylist(paths) + self.plugin.mpclient.addToPlaylist(paths) + def path_changed(self): + if os.path.isdir(self.path.text()): + self.view.setRootIndex(self.model.index(self.path.text())) |