SF.net SVN: fclient:[917] trunk/fclient/fclient
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-08-16 08:19:16
|
Revision: 917 http://fclient.svn.sourceforge.net/fclient/?rev=917&view=rev Author: jUrner Date: 2008-08-16 08:19:24 +0000 (Sat, 16 Aug 2008) Log Message: ----------- isolated uploads view Modified Paths: -------------- trunk/fclient/fclient/fclient.py Added Paths: ----------- trunk/fclient/fclient/impl/ViewUploads/ trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py trunk/fclient/fclient/impl/ViewUploads/__init__.py trunk/fclient/fclient/impl/ViewUploads/_fix_mexec.py Removed Paths: ------------- trunk/fclient/fclient/impl/ViewUploads.py Modified: trunk/fclient/fclient/fclient.py =================================================================== --- trunk/fclient/fclient/fclient.py 2008-08-16 08:13:58 UTC (rev 916) +++ trunk/fclient/fclient/fclient.py 2008-08-16 08:19:24 UTC (rev 917) @@ -18,7 +18,7 @@ from .impl.ViewConnection import ViewConnection from .impl.ViewDownloads import ViewDownloads from .impl.ViewLogger import ViewLogger -from .impl.ViewUploads import ViewUploadsWidget +from .impl.ViewUploads import ViewUploads from .impl.DlgSingleAppError import DlgSingleAppError #************************************************************* @@ -79,7 +79,7 @@ ViewConnection.ViewConnectionWidget(mainWindow), ViewBrowser.ViewBrowserWidget(mainWindow), ViewDownloads.ViewDownloadsWidget(mainWindow), - ViewUploadsWidget(mainWindow), + ViewUploads.ViewUploadsWidget(mainWindow), ) viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(mainWindow)) Added: trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py =================================================================== --- trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py (rev 0) +++ trunk/fclient/fclient/impl/ViewUploads/ViewUploads.py 2008-08-16 08:19:24 UTC (rev 917) @@ -0,0 +1,181 @@ + +"""""" + +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + + +from PyQt4 import QtCore, QtGui + +from .. import config +from ..BaseRequestsWidget import BaseRequestsWidget +#************************************************************************************ +# +#************************************************************************************ +class UploadsWidgetGlobalFeedback(config.GlobalFeedbackBase): + """wrapper for global statusbar widgets, menus""" + + def __init__(self, parent, idGlobalFeedback): + config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback) + + # menus + self.menus = [] + if self.menuBar is not None and hasattr(parent, 'fcViewObject'): + menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar) + parent.populateMenu(menu) + self.menus.append(menu) + self.menuBar.addViewMenu(menu) + + # status bar widgets + self.labelStatus = None + self.progress = None + self.labelFeedbackWrap = None + #if self.statusBar is not None: + # self.labelStatus = QtGui.QLabel(QtCore.QString(), self.statusBar) + # self.statusBar.addWidget(self.labelStatus) + # + # self.progress = QtGui.QProgressBar(self.statusBar) + # self.progress.setRange(0, Browser.MaxProgress) + # self.progress.setValue(0) + # self.statusBar.addWidget(self.progress) + # + # label = QtGui.QLabel(self.statusBar) + # label.setFrameStyle(QtGui.QLabel.Sunken | QtGui.QLabel.Box) + # self.labelFeedbackWrap = pathlabelwrap.PathLabelWrap( + # label, + # path_module=config.CompactPathFcpKeyModule, + # ) + # self.statusBar.addWidget(self.labelFeedbackWrap.label, 1) + + + def setVisible(self, flag): + if self.menuBar is not None: + for menu in self.menus: + menu.children()[0].setEnabled(flag) + #if self.statusBar is not None: + # self.progress.setVisible(flag) + # self.labelStatus.setVisible(flag) + # self.labelFeedbackWrap.label.setVisible(flag) + + #def setProgress(self, n): + # if self.progress is not None: + # self.progress.setValue(n) + + #def setStatusMessage(self, qString): + # if self.labelStatus is not None: + # self.labelStatus.setText(qString) + + #def setFeedback(self, qString): + # if self.labelFeedbackWrap is not None: + # self.labelFeedbackWrap.setPath(unicode(qString)) + + + +class DownloadsViewObject(config.ViewObject): + + def __init__(self, parent): + config.ViewObject. __init__(self, parent) + + self.name=parent.objectName() + self.displayName=self.trUtf8('Uploads') + self.icon=QtGui.QIcon() + + +class UploadsWidgetSettings(config.SettingsBase): + + + _key_ = config.IdViewUploadsWidget + _settings_ = ( + ) + + +class ViewUploadsWidget(BaseRequestsWidget.RequestsWidget): + + def __init__(self, parent, idGlobalFeedback=config.IdMainWindow): + + self.menuRemoveGroup = None + + BaseRequestsWidget.RequestsWidget.__init__(self, parent) + + self.setObjectName(config.IdViewUploadsWidget) + config.ObjectRegistry.register(self) + self.fcSettings = UploadsWidgetSettings(self).restore() + self.fcViewObject = DownloadsViewObject(self) + self.fcGlobalFeedback = UploadsWidgetGlobalFeedback(self, idGlobalFeedback) + + # setup menus + self.menuRemoveGroup = QtGui.QMenu(self) + self.menuRemoveGroup.setTitle(self.trUtf8('Remove group')) + for action in self.fcActions['GroupRemoveGroup'].actions(): + self.menuRemoveGroup.addAction(action) + + + ################################### + ## overwritten methods + ################################### + def hideEvent(self, event): + self.fcGlobalFeedback.setVisible(False) + BaseRequestsWidget.RequestsWidget.hideEvent(self, event) + + def showEvent(self, event): + self.fcGlobalFeedback.setVisible(True) + BaseRequestsWidget.RequestsWidget.showEvent(self, event) + + def retranslateUi(self, parent): + BaseRequestsWidget.RequestsWidget.retranslateUi(self, parent) + if self.menuRemoveGroup is not None: + self.menuRemoveGroup.setTitle(self.trUtf8('Remove group')) + + ################################### + ## methods + ################################### + + ################################### + ## event handlers + ################################### + def onTreeCustomContextMenuRequested(self, pt): + tree = self.controlById(self.IdTree) + pt = tree.viewport().mapToGlobal(pt) + + menu = QtGui.QMenu(self) + menu.addMenu(self.menuRemoveGroup) + menu.exec_(pt) + + def onTreeItemSelectionChanged(self): + tree = self.controlById(self.IdTree) + hasSelectedItems = tree.selectionModel().hasSelection() + +#********************************************************************************** +# +#********************************************************************************** +if __name__ == '__main__': + import sys + from .. import View + from ..ViewConnection import ViewConnection + from ..ViewLogger import ViewLogger + from ..MainWindow import MainWindow + + app = QtGui.QApplication(sys.argv) + + mainWindow = MainWindow.MainWindow() + viewWidget = View.ViewWidget(mainWindow) + mainWindow.setCentralWidget(viewWidget) + + viewWidget.addTopViews( + ViewConnection.ViewConnectionWidget(None), + ViewUploadsWidget(None), + ) + viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(None)) + + mainWindow.show() + res = app.exec_() + sys.exit(res) \ No newline at end of file Added: trunk/fclient/fclient/impl/ViewUploads/__init__.py =================================================================== --- trunk/fclient/fclient/impl/ViewUploads/__init__.py (rev 0) +++ trunk/fclient/fclient/impl/ViewUploads/__init__.py 2008-08-16 08:19:24 UTC (rev 917) @@ -0,0 +1 @@ + Added: trunk/fclient/fclient/impl/ViewUploads/_fix_mexec.py =================================================================== --- trunk/fclient/fclient/impl/ViewUploads/_fix_mexec.py (rev 0) +++ trunk/fclient/fclient/impl/ViewUploads/_fix_mexec.py 2008-08-16 08:19:24 UTC (rev 917) @@ -0,0 +1,93 @@ +'''python 2.5 relative impports are srsly broken ..fix this to make relative imports work +when executing a module as main (-m), including relative imports up to the root package + +see: [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] + +@note: root package is the highest available package in the package hirarchy. +don't look at __name__ too closely. it gets adjusted for a module to just "do the right +thing" in __name__ == '__main__' comparisons. + +usage:: + + # place this at the top a module, before doing any relative imports + from fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + + from ...foo import bar + + + +##<-- copy and paste code, assuming _fix_mexec resides in the current dir.. + +# some fixes for relative imports +# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below) +# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a +# ...package containing relative imports +from __future__ import absolute_import +if __name__ == '__main__': + import os + __path__ = [os.path.dirname(__file__)] + from ._fix_mexec import fix_mexec + fix_mexec(__name__, __file__) + del fix_mexec + + +##--> copy and paste code +''' + +import imp, os, sys +#******************************************************************************** +# +#******************************************************************************** +class MainName(str): + def __eq__(self, other): + if other == '__main__': return True + return str.__eq__(self, other) + def __ne__(self, other): + if other == '__main__': return False + return str.__ne__(self, other) + + +def fix_mexec(_name_, _file_): + """bugfix for relative imports not working + @param _name_: __name__ of the module + @param _file_: __file__ of the module + + @note: not complete: relies on __init__.py, .pyo (...) is ignored currently + """ + if _name_ == '__main__': + out = [] + # find allparent packages + p = os.path.dirname(os.path.abspath(_file_)) + prev = p + while True: + pkg = os.path.join(p, '__init__.py') + if os.path.isfile(pkg): + out.append([pkg, os.path.basename(p)]) + else: + break + prev = p + p = os.path.dirname(p) + if p == prev: + break + out.reverse() + + # adjust sub package names an import parent modules + name = None + for n, (fpath, name) in enumerate(out): + if n > 0: + name = out[n][1] = out[n -1][1] + '.' + out[n][1] + m = imp.load_source(name, fpath) + m.__path__ = [os.path.dirname(fpath)] + + # adjust name of the __main__ module + if name is not None: + m = sys.modules.pop('__main__') + # 'foo.bar..__main__' does not work for some reason. 'foo.bar' seems to work as expected + ##m.__name__ = _Name_(name + '.' + '__main__') + m.__name__ = MainName(name) + sys.modules[m.__name__] = m + + + Deleted: trunk/fclient/fclient/impl/ViewUploads.py =================================================================== --- trunk/fclient/fclient/impl/ViewUploads.py 2008-08-16 08:13:58 UTC (rev 916) +++ trunk/fclient/fclient/impl/ViewUploads.py 2008-08-16 08:19:24 UTC (rev 917) @@ -1,173 +0,0 @@ - -"""""" - -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__)] - - -from PyQt4 import QtCore, QtGui - -from . import config -from .BaseRequestsWidget import RequestsWidget -#************************************************************************************ -# -#************************************************************************************ -class UploadsWidgetGlobalFeedback(config.GlobalFeedbackBase): - """wrapper for global statusbar widgets, menus""" - - def __init__(self, parent, idGlobalFeedback): - config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback) - - # menus - self.menus = [] - if self.menuBar is not None and hasattr(parent, 'fcViewObject'): - menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar) - parent.populateMenu(menu) - self.menus.append(menu) - self.menuBar.addViewMenu(menu) - - # status bar widgets - self.labelStatus = None - self.progress = None - self.labelFeedbackWrap = None - #if self.statusBar is not None: - # self.labelStatus = QtGui.QLabel(QtCore.QString(), self.statusBar) - # self.statusBar.addWidget(self.labelStatus) - # - # self.progress = QtGui.QProgressBar(self.statusBar) - # self.progress.setRange(0, Browser.MaxProgress) - # self.progress.setValue(0) - # self.statusBar.addWidget(self.progress) - # - # label = QtGui.QLabel(self.statusBar) - # label.setFrameStyle(QtGui.QLabel.Sunken | QtGui.QLabel.Box) - # self.labelFeedbackWrap = pathlabelwrap.PathLabelWrap( - # label, - # path_module=config.CompactPathFcpKeyModule, - # ) - # self.statusBar.addWidget(self.labelFeedbackWrap.label, 1) - - - def setVisible(self, flag): - if self.menuBar is not None: - for menu in self.menus: - menu.children()[0].setEnabled(flag) - #if self.statusBar is not None: - # self.progress.setVisible(flag) - # self.labelStatus.setVisible(flag) - # self.labelFeedbackWrap.label.setVisible(flag) - - #def setProgress(self, n): - # if self.progress is not None: - # self.progress.setValue(n) - - #def setStatusMessage(self, qString): - # if self.labelStatus is not None: - # self.labelStatus.setText(qString) - - #def setFeedback(self, qString): - # if self.labelFeedbackWrap is not None: - # self.labelFeedbackWrap.setPath(unicode(qString)) - - - -class DownloadsViewObject(config.ViewObject): - - def __init__(self, parent): - config.ViewObject. __init__(self, parent) - - self.name=parent.objectName() - self.displayName=self.trUtf8('Uploads') - self.icon=QtGui.QIcon() - - -class UploadsWidgetSettings(config.SettingsBase): - - - _key_ = config.IdViewUploadsWidget - _settings_ = ( - ) - - -class ViewUploadsWidget(RequestsWidget): - - def __init__(self, parent, idGlobalFeedback=config.IdMainWindow): - - self.menuRemoveGroup = None - - RequestsWidget.__init__(self, parent) - - self.setObjectName(config.IdViewUploadsWidget) - config.ObjectRegistry.register(self) - self.fcSettings = UploadsWidgetSettings(self).restore() - self.fcViewObject = DownloadsViewObject(self) - self.fcGlobalFeedback = UploadsWidgetGlobalFeedback(self, idGlobalFeedback) - - # setup menus - self.menuRemoveGroup = QtGui.QMenu(self) - self.menuRemoveGroup.setTitle(self.trUtf8('Remove group')) - for action in self.fcActions['GroupRemoveGroup'].actions(): - self.menuRemoveGroup.addAction(action) - - - ################################### - ## overwritten methods - ################################### - def hideEvent(self, event): - self.fcGlobalFeedback.setVisible(False) - RequestsWidget.hideEvent(self, event) - - def showEvent(self, event): - self.fcGlobalFeedback.setVisible(True) - RequestsWidget.showEvent(self, event) - - def retranslateUi(self, parent): - RequestsWidget.retranslateUi(self, parent) - if self.menuRemoveGroup is not None: - self.menuRemoveGroup.setTitle(self.trUtf8('Remove group')) - - ################################### - ## methods - ################################### - - ################################### - ## event handlers - ################################### - def onTreeCustomContextMenuRequested(self, pt): - tree = self.controlById(self.IdTree) - pt = tree.viewport().mapToGlobal(pt) - - menu = QtGui.QMenu(self) - menu.addMenu(self.menuRemoveGroup) - menu.exec_(pt) - - def onTreeItemSelectionChanged(self): - tree = self.controlById(self.IdTree) - hasSelectedItems = tree.selectionModel().hasSelection() - -#********************************************************************************** -# -#********************************************************************************** -if __name__ == '__main__': - import sys - from . import View - from . import ViewConnection - from . import ViewLogger - from . import MainWindow - - app = QtGui.QApplication(sys.argv) - - mainWindow = MainWindow.MainWindow() - viewWidget = View.ViewWidget(mainWindow) - mainWindow.setCentralWidget(viewWidget) - - viewWidget.addTopViews( - ViewConnection.ViewConnectionWidget(None), - ViewUploadsWidget(None), - ) - viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(None)) - - mainWindow.show() - res = app.exec_() - sys.exit(res) \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |