SF.net SVN: fclient:[825] trunk/fclient/src/fclient/impl/ViewDownloads.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-07-30 22:18:26
|
Revision: 825 http://fclient.svn.sourceforge.net/fclient/?rev=825&view=rev Author: jUrner Date: 2008-07-30 22:18:33 +0000 (Wed, 30 Jul 2008) Log Message: ----------- icons for mimetypes ++ this and that Modified Paths: -------------- trunk/fclient/src/fclient/impl/ViewDownloads.py Modified: trunk/fclient/src/fclient/impl/ViewDownloads.py =================================================================== --- trunk/fclient/src/fclient/impl/ViewDownloads.py 2008-07-30 22:17:39 UTC (rev 824) +++ trunk/fclient/src/fclient/impl/ViewDownloads.py 2008-07-30 22:18:33 UTC (rev 825) @@ -24,18 +24,27 @@ # warnings # x. it may take a while untill the final DataFound message arrives when a request is % completed. feedback would be nice # x. DataFound for a request the file has been removed by the user. no idea what happens. have to test this -#************************************************************************************************************** +# x. when the node is about to start up, looks like persistents may arrive or not. check + # x. how to get early information about mimetype/size? maybe use FcpClient.getFileInfo() + # x. show/hide header izems + # x. sort by header + # x. indicate over all time / dl speed + # x. indicate status / remove items by status + # x. ...whatevs + #************************************************************************************************************** from __future__ import absolute_import if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below import os; __path__ = [os.path.dirname(__file__)] - + +import mimetypes import os from PyQt4 import QtCore, QtGui from . import config from .lib import fcp2 from .lib.fcp2.lib import pmstruct -from .lib.qt4ex import treewidgetwrap +from .lib.qt4ex import treewidgetwrap, progressbarwrap + from . import DlgDownloadKeyToDisk from .tpls.Ui_ViewDownloadsWidgetTpl import Ui_ViewDownloadsWidget @@ -51,8 +60,6 @@ self.displayName=self.trUtf8('Downloads') self.icon=QtGui.QIcon() - - #********************************************************************************** # #********************************************************************************** @@ -129,7 +136,13 @@ trigger=parent.onRemoveSelectedRequests, isEnabled=False, ) + +class DownloadsWidgetSettings(config.SettingsBase): + + _key_ = config.IdViewCDownloadsWidget + _settings_ = ( + ) #********************************************************************************** # #********************************************************************************** @@ -189,6 +202,19 @@ self.fcpIdentifier = fcpIdentifier +# can be used to expose properties for stylesheets for example +class ProgressBar(QtGui.QProgressBar): + + def __init__(self, parent): + QtGui.QProgressBar.__init__(self, parent) + # self.__foo = True + + #def foo(self): + # return self.__foo + #def setFoo(self, value): + # self.__foo = value + #foo = QtCore.pyqtProperty("bool",foo, setFoo) + #********************************************************************************** # #********************************************************************************** @@ -198,8 +224,10 @@ HeaderIndexName = 0 - HeaderIndexFoo = 1 - HeaderIndexProgress = 2 + HeaderIndexSize = 1 + HeaderIndexMimeType = 2 + HeaderIndexStatus = 3 + HeaderIndexProgress = 4 def __init__(self, parent, idGlobalFeedback=config.IdMainWindow): QtGui.QWidget.__init__(self, parent) @@ -207,6 +235,7 @@ self.setupUi(self) config.ObjectRegistry.register(self) + self.fcSettings = DownloadsWidgetSettings(self).restore() self.fcActions = DownloadsWidgetActions(self) self.fcViewObject = DownloadsViewObject(self) self.fcGlobalFeedback = DownloadsWidgetGlobalFeedback(self, idGlobalFeedback) @@ -222,19 +251,28 @@ config.fcpClient.events += self.fcpEvents self.fcHeadeLabels = {} self.fcpRequests = {} + + self.foo = True ############################ ## private methods ############################ def _createItemFromFcpRequest(self, fcpRequest): item= TreeItem(fcpRequest['Identifier'], self.tree) + fileName = fcpRequest['Filename'] + mimeType = mimetypes.guess_type(fileName)[0] + icon = config.fcResources.getIcon( + config.mimeTypeIconName(mimeType), + config.fcSettings.value('IconSize'), + config.fcSettings.value('IconTheme'), + ) + item.setIcon(0, icon) item.setData( self.HeaderIndexName, QtCore.Qt.DisplayRole, QtCore.QVariant(os.path.basename(fcpRequest['Filename'])) ) - - progressBar = QtGui.QProgressBar(self) + progressBar = ProgressBar(self) progressBar.setRange(0, 0) self.tree.setItemWidget(item, self.HeaderIndexProgress, progressBar) self.fcpRequests[fcpRequest['Identifier']] = item @@ -248,7 +286,9 @@ tree = self.controlById(self.IdTree) self.fcHeadeLabels = { self.HeaderIndexName: self.trUtf8('Name'), - self.HeaderIndexFoo: self.trUtf8('Foo'), + self.HeaderIndexSize: self.trUtf8('Size'), + self.HeaderIndexMimeType: self.trUtf8('Type'), + self.HeaderIndexStatus: self.trUtf8('Status'), self.HeaderIndexProgress: self.trUtf8('Progress'), } tree.setHeaderLabels([i[1] for i in sorted(self.fcHeadeLabels.items())]) @@ -267,6 +307,7 @@ # setup tree tree = self.controlById(self.IdTree) tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + tree.setRootIsDecorated(False) tree.setSelectionMode(tree.ExtendedSelection) tree.setUniformRowHeights(True) self.connect(tree, QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'), self.onTreeCustomContextMenuRequested) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |