SF.net SVN: fclient:[910] trunk/fclient/fclient
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-08-16 07:43:10
|
Revision: 910 http://fclient.svn.sourceforge.net/fclient/?rev=910&view=rev Author: jUrner Date: 2008-08-16 07:43:18 +0000 (Sat, 16 Aug 2008) Log Message: ----------- isolated browser view Modified Paths: -------------- trunk/fclient/fclient/fclient.py trunk/fclient/fclient/impl/Prefs.py Added Paths: ----------- trunk/fclient/fclient/impl/ViewBrowser/ trunk/fclient/fclient/impl/ViewBrowser/Actions.py trunk/fclient/fclient/impl/ViewBrowser/Browser.py trunk/fclient/fclient/impl/ViewBrowser/BrowserWidget.ui trunk/fclient/fclient/impl/ViewBrowser/GlobalFeedback.py trunk/fclient/fclient/impl/ViewBrowser/NetworkAccessManager.py trunk/fclient/fclient/impl/ViewBrowser/Page.py trunk/fclient/fclient/impl/ViewBrowser/Settings.py trunk/fclient/fclient/impl/ViewBrowser/SideBar.py trunk/fclient/fclient/impl/ViewBrowser/SideBars/ trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetails.py trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetailsTpl.ui trunk/fclient/fclient/impl/ViewBrowser/SideBars/Ui_SideBarLoadDetailsTpl.py trunk/fclient/fclient/impl/ViewBrowser/SideBars/__init__.py trunk/fclient/fclient/impl/ViewBrowser/SideBars/_fix_mexec.py trunk/fclient/fclient/impl/ViewBrowser/TabBar.py trunk/fclient/fclient/impl/ViewBrowser/Ui_BrowserWidget.py trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py trunk/fclient/fclient/impl/ViewBrowser/__init__.py trunk/fclient/fclient/impl/ViewBrowser/_fix_mexec.py trunk/fclient/fclient/impl/ViewBrowser/dlgs/ trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgPropsBrowserObject.py trunk/fclient/fclient/impl/ViewBrowser/dlgs/DlgPropsBrowserObjectTpl.ui trunk/fclient/fclient/impl/ViewBrowser/dlgs/Ui_DlgPropsBrowserObjectTpl.py trunk/fclient/fclient/impl/ViewBrowser/dlgs/__init__.py trunk/fclient/fclient/impl/ViewBrowser/dlgs/_fix_mexec.py trunk/fclient/fclient/impl/ViewBrowser/prefs/ trunk/fclient/fclient/impl/ViewBrowser/prefs/PrefsBrowserWidget.py trunk/fclient/fclient/impl/ViewBrowser/prefs/PrefsBrowserWidgetTpl.ui trunk/fclient/fclient/impl/ViewBrowser/prefs/Ui_PrefsBrowserWidgetTpl.py trunk/fclient/fclient/impl/ViewBrowser/prefs/__init__.py trunk/fclient/fclient/impl/ViewBrowser/prefs/_fix_mexec.py Removed Paths: ------------- trunk/fclient/fclient/impl/DlgPropsBrowserObject.py trunk/fclient/fclient/impl/PrefsBrowserWidget.py trunk/fclient/fclient/impl/tpls/DlgPropsBrowserObjectTpl.ui trunk/fclient/fclient/impl/tpls/PrefsBrowserWidgetTpl.ui trunk/fclient/fclient/impl/tpls/Ui_DlgPropsBrowserObjectTpl.py trunk/fclient/fclient/impl/tpls/Ui_PrefsBrowserWidgetTpl.py trunk/fclient/fclient/impl/tpls/Ui_ViewBrowserWidgetTpl.py trunk/fclient/fclient/impl/tpls/ViewBrowserWidgetTpl.ui Modified: trunk/fclient/fclient/fclient.py =================================================================== --- trunk/fclient/fclient/fclient.py 2008-08-16 06:51:24 UTC (rev 909) +++ trunk/fclient/fclient/fclient.py 2008-08-16 07:43:18 UTC (rev 910) @@ -14,7 +14,7 @@ from .impl.MainWindow import MainWindow from .impl.View import ViewWidget -from .impl.ViewBrowser import ViewBrowserWidget +from .impl.ViewBrowser import ViewBrowser from .impl.ViewConnection import ViewConnectionWidget from .impl.ViewDownloads import ViewDownloadsWidget from .impl.ViewLogger import ViewLoggerWidget @@ -77,7 +77,7 @@ mainWindow.setCentralWidget(viewWidget) viewWidget.addTopViews( ViewConnectionWidget(mainWindow), - ViewBrowserWidget(mainWindow), + ViewBrowser.ViewBrowserWidget(mainWindow), ViewDownloadsWidget(mainWindow), ViewUploadsWidget(mainWindow), ) Deleted: trunk/fclient/fclient/impl/DlgPropsBrowserObject.py =================================================================== --- trunk/fclient/fclient/impl/DlgPropsBrowserObject.py 2008-08-16 06:51:24 UTC (rev 909) +++ trunk/fclient/fclient/impl/DlgPropsBrowserObject.py 2008-08-16 07:43:18 UTC (rev 910) @@ -1,69 +0,0 @@ -#********************************************************************* -#TODO: -# just a sketch so far -# -# x. link and image url are not selectable -# -# -#********************************************************************** -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 posixpath -from PyQt4 import QtGui - -from . import config -from .lib.compactpath.qt4 import pathlabelwrap -from .lib.qt4ex.lib import tools as qtools - -from .tpls.Ui_DlgPropsBrowserObjectTpl import Ui_DlgPropsBrowserObject -#********************************************************************************** -# -#********************************************************************************** -class DlgPropsBrowserObject(QtGui.QDialog, Ui_DlgPropsBrowserObject): - - IdLabelType = 'labelType' - IdLabelTitle = 'labelTitle' - IdLabelName = 'labelName' - IdLabelLinkUrl = 'labelLinkUrl' - IdLabelImageUrl = 'labelImageUrl' - - MaxText = 80 - - def __init__(self, parent, browser=None, hitTestResult=None): - QtGui.QDialog.__init__(self, parent) - - self.setupUi(self) - self.setWindowTitle(config.FcAppName + self.trUtf8(' - Properties')) - - if hitTestResult is not None: - - if not hitTestResult.linkUrl().isEmpty(): - labelLinkUrl = self.controlById(self.IdLabelLinkUrl) - self.wrapLinkUrl = pathlabelwrap.PathLabelWrap(labelLinkUrl, path_module=config.CompactPathFcpKeyModule) - self.wrapLinkUrl.setPath(unicode(hitTestResult.linkUrl().toString())) - if not hitTestResult.imageUrl().isEmpty(): - labelImageUrl = self.controlById(self.IdLabelImageUrl) - self.wrapImageUrl = pathlabelwrap.PathLabelWrap(labelImageUrl, path_module=config.CompactPathFcpKeyModule) - self.wrapImageUrl.setPath(unicode(hitTestResult.imageUrl().toString())) - - ellipsis = self.trUtf8('..') - self.labelTitle.setText(qtools.truncateString(self.MaxText, hitTestResult.linkTitle().toString(), ellipsis)) - self.labelTitle.setText(qtools.truncateString(self.MaxText, hitTestResult.linkText(), ellipsis)) - - def controlById(self, idControl): - return getattr(self, idControl) - -#********************************************************************************** -# -#********************************************************************************** -if __name__ == '__main__': - import sys - - app = QtGui.QApplication(sys.argv) - w = PropsBrowserObjectDlg(None) - w.show() - res = app.exec_() - sys.exit(res) - Modified: trunk/fclient/fclient/impl/Prefs.py =================================================================== --- trunk/fclient/fclient/impl/Prefs.py 2008-08-16 06:51:24 UTC (rev 909) +++ trunk/fclient/fclient/impl/Prefs.py 2008-08-16 07:43:18 UTC (rev 910) @@ -8,7 +8,7 @@ from . import config from .lib.qt4ex import dlgpreferences from .PrefsGlobal import PrefsPageGlobal -from .PrefsBrowserWidget import PrefsPageBrowser +from .ViewBrowser.prefs import PrefsBrowserWidget from .PrefsConnectionWidget import PrefsPageConnectionExpertSettings from .PrefsSingleApp import PrefsPageSingleApp #********************************************************************************** @@ -59,7 +59,7 @@ ( PrefsPageSingleApp(), ), - PrefsPageBrowser(), + PrefsBrowserWidget.PrefsPageBrowser(), ) dlgpreferences.DlgPreferencesFlatTree.__init__(self, parent, Deleted: trunk/fclient/fclient/impl/PrefsBrowserWidget.py =================================================================== --- trunk/fclient/fclient/impl/PrefsBrowserWidget.py 2008-08-16 06:51:24 UTC (rev 909) +++ trunk/fclient/fclient/impl/PrefsBrowserWidget.py 2008-08-16 07:43:18 UTC (rev 910) @@ -1,131 +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 .lib.qt4ex import dlgpreferences -from .lib.qt4ex.lib import settings - - -from .tpls.Ui_PrefsBrowserWidgetTpl import Ui_PrefsBrowserWidget -#********************************************************************************** -# -#********************************************************************************** -class PrefsBrowserWidget(QtGui.QWidget, Ui_PrefsBrowserWidget): - - IdEdHomePage = 'edHomePage' - IdCkOpenAddressBarInNewTab = 'ckOpenAddressBarInNewTab' - IdCkOpenBookmarksInNewTab = 'ckOpenBookmarksInNewTab' - IdCkOpenLinksInNewTab = 'ckOpenLinksInNewTab' - IdCkOpenHomePageOnNewTabCreated = 'ckOpenHomePageOnNewTabCreated' - IdCkBackIsClose = 'ckBackIsClose' - IdCkAutoLoadImages = 'ckAutoLoadImages' - - def __init__(self, parent=None, page=None): - QtGui.QWidget.__init__(self, parent) - - self.setupUi(self) - - browserWidget = config.ObjectRegistry.get(config.IdViewBrowserWidget, None) - if browserWidget is None: - self.setEnabled(False) - else: - self.fcSettingsControler = settings.SettingsControler(browserWidget.fcSettings, parent=self) - if page is not None: - page.connect(self.fcSettingsControler, QtCore.SIGNAL('isDirty(bool)'), page.setDirty) - - self.fcSettingsControler.addLineEdit( - self.controlById(self.IdEdHomePage), - 'HomePage', - ) - self.fcSettingsControler.addCheckBox( - self.controlById(self.IdCkOpenAddressBarInNewTab), - 'OpenAddressBarInNewTab', - ) - self.fcSettingsControler.addCheckBox( - self.controlById(self.IdCkOpenBookmarksInNewTab), - 'OpenBookmarksInNewTab', - ) - self.fcSettingsControler.addCheckBox( - self.controlById(self.IdCkOpenLinksInNewTab), - 'OpenLinksInNewTab', - ) - self.fcSettingsControler.addCheckBox( - self.controlById(self.IdCkOpenHomePageOnNewTabCreated), - 'OpenHomePageOnNewTabCreated', - ) - self.fcSettingsControler.addCheckBox( - self.controlById(self.IdCkBackIsClose), - 'BackIsClose', - ) - self.fcSettingsControler.addCheckBox( - self.controlById(self.IdCkAutoLoadImages), - 'AutoLoadImages', - ) - - def controlById(self, idControl): - return getattr(self, idControl) - - def doApply(self): - if self.fcSettingsControler is not None: - return self.fcSettingsControler.apply() - return False - - def doRestoreDefaults(self): - if self.fcSettingsControler is not None: - return self.fcSettingsControler.restoreDefaults() - return False - -#*********************************************************************** -# -#*********************************************************************** -class PrefsPageBrowser(dlgpreferences.Page): - - UUID = '{c85e63a8-6806-435a-81ce-f4b46872246f}' - - def __init__(self): - dlgpreferences.Page.__init__(self, self.UUID) - self._widget = None - - def displayName(self): - return self.trUtf8('Browser') - - def canApply(self): return True - def canHelp(self): return False - def canRestoreDefaults(self): return True - - def setVisible(self, parent, flag): - createdNew = False - if flag and self._widget is None: - createdNew = True - self._widget = PrefsBrowserWidget(parent=parent, page=self) - self._widget.setVisible(flag) - return (createdNew, self._widget) - - - def doApply(self): - self._widget.doApply() - return True - - def doRestoreDefaults(self): - self._widget.doRestoreDefaults() - return True - - -#*********************************************************************** -# -#*********************************************************************** -if __name__ == '__main__': - from PyQt4 import QtGui - import sys - - app = QtGui.QApplication(sys.argv) - w = PrefsBrowserWidget(None) - w.show() - res = app.exec_() - sys.exit(res) - Added: trunk/fclient/fclient/impl/ViewBrowser/Actions.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/Actions.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,220 @@ +# 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, QtWebKit + +from .. import config + +from PyQt4 import QtCore, QtGui +#********************************************************************************** +# +#********************************************************************************** +class Actions(config.ActionsBase): + + def __init__(self, parent): + config.ActionsBase.__init__(self, parent) + + iconSize = config.fcSettings.value('IconSize') + iconTheme = config.fcSettings.value('IconTheme') + + #TODO: shortcut + self.action( + name='ActionCloseCurrentTab', + text=self.trUtf8('Close ¤t tab'), + trigger=parent.onCloseCurrentTab, + ) + #TODO: shortcut + self.action( # context menu only + name='ActionCloseBrowserUnderMouse', + text=self.trUtf8('&Close tab'), + trigger=None, + ) + self.action( + name='ActionCloseAllTabs', + text=self.trUtf8('Close &all tabs'), + trigger=parent.onCloseAllTabs, + ) + #TODO: shortcut + self.action( + name='ActionCreateNewTab', + text=self.trUtf8('Create &new tab'), + trigger=parent.onCreateNewTab, + ) + #TODO: shortcut + self.action( + name='ActionDuplicateTab', + text=self.trUtf8('&Duplicate tab'), + trigger=parent.onDuplicateTab, + ) + + #TODO: shortcut + self.action( + name='ActionGoToFProxy', + text=self.trUtf8('Go to f&Proxy homepage'), + trigger=parent.onGoToFProxy, + ) + self.action( + name='ActionGoToHomePage', + text=self.trUtf8('Go to &homepage'), + shortcut=QtGui.QKeySequence(self.trUtf8('Alt+Home')), + trigger=parent.onGoToHomePage, + ) + #TODO: shortcut + self.action( + name='ActionObjectProperties', + text=self.trUtf8('Properties..'), + trigger=None, + ) + self.action( + name='ActionZoomIn', + text=self.trUtf8('Zoom in'), + shortcut=QtGui.QKeySequence(QtGui.QKeySequence.ZoomIn), + trigger=parent.onZoomIn, + ) + self.action( + name='ActionZoomOut', + text=self.trUtf8('Zoom out'), + shortcut=QtGui.QKeySequence(QtGui.QKeySequence.ZoomOut), + trigger=parent.onZoomOut, + ) + + # default browser actions + self.action( + name='ActionBack', + text=self.trUtf8('Back'), + trigger=None, + isEnabled=False, + shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Back), + icon=config.fcResources.getIcon('back', iconSize, iconTheme=iconTheme), + userData=(None, None), + ) + self.action( + name='ActionForward', + text=self.trUtf8('Forward'), + trigger=None, + isEnabled=False, + shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Forward), + icon=config.fcResources.getIcon('forward', iconSize, iconTheme=iconTheme), + userData=(None, None), + ) + self.action( + name='ActionReload', + text=self.trUtf8('Reload'), + #EXPERIMENTAL: we handle it, cos page.url() is empty if fproxy did not respond. + # for some reason QWebView has "Reload" enabled in this case. we keep track of + # the last known url and reload it manually. hope we don't get into trouble with + # this. NOTE: we may have to do this for other actions aswell + trigger=parent.onBrowserReloadTriggered, + isEnabled=False, + #TODO: how to assign QKeySequence.Refresh and* F5 ? + shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Refresh), + icon=config.fcResources.getIcon('reload_page', iconSize, iconTheme=iconTheme), + userData=(None, None), + ) + self.action( + name='ActionStop', + text=self.trUtf8('Stop'), + trigger=None, + isEnabled=False, + shortcut=QtGui.QKeySequence(self.trUtf8('Esc')), + icon=config.fcResources.getIcon('stop', iconSize, iconTheme=iconTheme), + userData=(None, None), + ) + self.action( + name='ActionBackIsClose', + text=self.trUtf8('Back is close'), + icon=config.fcResources.getIcon('button_cancel', iconSize, iconTheme=iconTheme), + trigger=None, + ) + + # find actions + self.action( + name='ActionFind', + text=self.trUtf8('Find'), + shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Find), + trigger=parent.onFind, + ) + self.action( + name='ActionFindNext', + text=self.trUtf8('Find next'), + isEnabled=False, + shortcut=QtGui.QKeySequence(QtGui.QKeySequence.FindNext), + trigger=parent.onFindNext, + ) + self.action( + name='ActionFindPrevious', + text=self.trUtf8('Find previous'), + isEnabled=False, + shortcut=QtGui.QKeySequence(QtGui.QKeySequence.FindPrevious), + trigger=parent.onFindPrevious, + ) + self.action( + name='ActionSavePage', + text=self.trUtf8('Save page..'), + isEnabled=True, + ##shortcut=QtGui.QKeySequence(QtGui.QKeySequence.FindPrevious), + trigger=parent.onSavePage, + ) + + # sideBars + group = self.group( + name='GroupSideBars', + isExclusive=True, + trigger=parent.onShowSidebar, + ) + self.action( + name='ActionShowSideBarLoadDetails', + group=group, + text=self.trUtf8('Load details'), + isEnabled=True, + isCheckable=True, + ) + + self.action( + name='ActionCloseCurrentSideBar', + text=self.trUtf8('Close sidebar'), + isEnabled=True, + trigger=parent.onCloseCurrentSideBar, + ) + + + def intertwineBrowserActions(self, browser=None): + """intertwines Browser actions with BrowserWidget actions + @note: call everytime the current browser changes + """ + actions = ( + ('ActionBack', QtWebKit.QWebPage.Back), + ('ActionForward', QtWebKit.QWebPage.Forward), + ('ActionReload', QtWebKit.QWebPage.Reload), + ('ActionStop', QtWebKit.QWebPage.Stop), + ) + for actionName, pageAction in actions: + myPageAction = self[actionName] + newPageAction = None if browser is None else browser.pageAction(pageAction) + oldPageAction, cb = myPageAction.userData() + + if oldPageAction is not None: + myPageAction.disconnect(oldPageAction, QtCore.SIGNAL('changed()'), cb) + oldPageAction.disconnect(myPageAction, QtCore.SIGNAL('triggered()'), oldPageAction.trigger) + + if newPageAction is None: + myPageAction.setUserData((None, None)) + myPageAction.setEnabled(False) + else: + def onActionChanged(browser=browser, myPageAction=myPageAction, browserPageAction=newPageAction): + myPageAction.setEnabled(browserPageAction.isEnabled()) + + myPageAction.setEnabled(newPageAction.isEnabled()) + myPageAction.setUserData((newPageAction, onActionChanged)) + myPageAction.connect(newPageAction, QtCore.SIGNAL('changed()'), onActionChanged) + newPageAction.connect(myPageAction, QtCore.SIGNAL('triggered()'), newPageAction.trigger) Added: trunk/fclient/fclient/impl/ViewBrowser/Browser.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/Browser.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/Browser.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,216 @@ +# 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 . import Page + +from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork + +#***************************************************************************************** +# +#***************************************************************************************** +class NetworkReplyData(QtCore.QObject): + def __init__(self, parent, url): + QtCore.QObject.__init__(self, parent) + self.url = url + self.bytesReceived = 0 + self.bytesTotal = 0 + self.finished = False + self.errorCode = None + +#***************************************************************************************** +# +#***************************************************************************************** +#TODO: impl functionality in browser +class LastBrowserState(object): + """records the last known state browser""" + + StateNone = 0x0 + StateLoading = 0x1 + StateComplete = 0x2 + StateError = 0x4 + StateHideProgressBar = 0x100 + + + __slots__ = ('clearProgressBarTimers', 'icon', 'progress', 'state', 'statusMessage', 'title', 'url') + + def __init__(self, icon=None, progress=0, statusMessage=None, state=StateNone, title=None, url=None): + self.clearProgressBarTimers = [] # timers scheduled for hiding progressBar + self.progress = 0 + self.icon = tCore.QIcon() if icon is None else icon + self.state = state + self.statusMessage = QtCore.QString() if statusMessage is None else statusMessage + self.title = QtCore.QString() if title is None else title + #NOTE: opening a browser in a new tab may take a while to load. + # self.url() will return '' untill the page is found, so we handle + # it ourself and keep track of the last known url in self._lastUrl + # to give feedback to the user on the navbar. downside is we have + # to reimplement contextMenuEvent() :-( + self.url = QtCore.QUrl() if url is None else url + +#***************************************************************************************** +# +#***************************************************************************************** +class Browser(QtWebKit.QWebView): + """ browser customized for freenet + """ + + MaxProgress = 100 + + def __init__(self, parent=None, userData=None): + QtWebKit.QWebView.__init__(self, parent) + + page = Page.Page(self) + self.setPage(page) + + #NOTE: we store last progress made to set busy cursor accordingly + self._lastProgress = 0 + self._userData = userData + self._networkGetReplies = [[], []] # (QNetworkReplies, urls) + self._networkReplySignals = ( + ('downloadProgress(qint64, qint64)', self.onNetworkReplyDownloadProgress), + ('error(QNetworkReply::NetworkError)', self.onNetworkReplyError), + ('finished()', self.onNetworkReplyFinished), + ) + + # connect actions + self.connect(self, QtCore.SIGNAL('loadStarted()'), self.onLoadStarted) + self.connect(self, QtCore.SIGNAL('loadProgress(int)'), self.onLoadProgress) + self.connect(self, QtCore.SIGNAL('loadFinished(bool)'), self.onLoadFinished) + self.connect(self.pageAction(QtWebKit.QWebPage.Stop), QtCore.SIGNAL('triggered()'), self.onActionStopTriggered) + + ################################ + ## methods + ################################ + #TODO: impl in BrowserWidget + def lastProgress(self): + """returns the last progress made by the browser + @return: (int) last progress + """ + return self._lastProgress + + def networkGetReplies(self): + return self._networkGetReplies[1] + + def networkGetReply(self, indexReply): + return self._networkGetReplies[1][indexReply] + + def setUserData(self, userData): + self._userData = userData + + def userData(self): + return self._userData + + ################################ + ## overwritten methods + ################################ + #def createWindow(self, typeWindow): + # pass + + def load(self, url): + self._lastProgress = 0 + return QtWebKit.QWebView.load(self, url) + + def setUrl(self, url): + return self.load(url) + + def setContents(self, *args): + """sets the contents of the browser without changing its url""" + self._lastProgress = 0 + return QtWebKit.QWebView.setContents(self, *args) + + def setHtml(self, *args): + """sets the contents of the browser without changing its url""" + self._lastProgress = 0 + return QtWebKit.QWebView.setHtm(self, *args) + + def setPage(self, page): + """""" + self._lastProgress = 0 + self.connect( + page.networkAccessManager(), + QtCore.SIGNAL('networkRequestCreated(QNetworkReply*)'), + self.onNetworkRequestCreated + ) + + self.emit(QtCore.SIGNAL('pageSet(QWebPage*)'), page) + return QtWebKit.QWebView.setPage(self, page) + + def mouseMoveEvent(self, event): + QtWebKit.QWebView.mouseMoveEvent(self, event) + if self._lastProgress < self.MaxProgress: + self.setCursor(QtCore.Qt.BusyCursor) + + ############################### + ## event handlers + ############################### + def onActionStopTriggered(self): + # check wich cursor to set cos we may have busy cursor set + pt = self.mapFromGlobal(self.cursor().pos()) #TODO: self.mapFromGlobal(self.viewPort().cursor().pos()) ?? + frame = self.page().currentFrame() + hitTest = frame.hitTestContent(pt) + #if not hitTest.isNull(): #TODO: looks like hitTest.isNull() alwas returns True + if hitTest.linkUrl().isValid(): + self.setCursor(QtCore.Qt.PointingHandCursor) + else: + self.setCursor(QtCore.Qt.ArrowCursor) + + def onLoadStarted(self): + self._lastProgress = 0 + self._networkGetReplies = [[], []] + + def onLoadProgress(self, n): + self._lastProgress = n + + def onLoadFinished(self, ok): + if ok: + self._lastProgress = self.MaxProgress + self.onActionStopTriggered() + + def onPageDownloadRequested(self, networkRequest): + self.emit(QtCore.SIGNAL('downloadRequested(const QNetworkRequest &)'), networkRequest) + + def onNetworkRequestCreated(self, reply): + if reply.operation() == QtNetwork.QNetworkAccessManager.GetOperation: + self._networkGetReplies[0].append(reply) + url = QtCore.QUrl(reply.url()) # copy url, qt nules it on return + networkReplyData = NetworkReplyData(self, url) + self._networkGetReplies[1].append(networkReplyData) + for signal, handler in self._networkReplySignals: + self.connect(reply, QtCore.SIGNAL(signal), handler) + self.emit(QtCore.SIGNAL('networkGetRequestCreated(int, QObject*)'), self._networkGetReplies[0].index(reply), networkReplyData) + + def onNetworkReplyDownloadProgress(self, bytesReceived, bytesTotal): + reply = self.sender() + i = self._networkGetReplies[0].index(reply) + networkReplyData = self._networkGetReplies[1][i] + networkReplyData.bytesReceived = bytesReceived + networkReplyData.bytesTotal = bytesTotal + self.emit(QtCore.SIGNAL('networkReplyProgress(int, QObject*)'), i, networkReplyData) + + def onNetworkReplyError(self, errorCode): + reply = self.sender() + i = self._networkGetReplies[0].index(reply) + networkReplyData = self._networkGetReplies[1][i] + networkReplyData.finished = True + networkReplyData.errorCode = errorCode + self.emit(QtCore.SIGNAL('networkReplyError(int, QObject*)'), i, networkReplyData) + #for signal, handler in self._networkReplySignals: + # self.disconnect(reply, QtCore.SIGNAL(signal), handler) + + def onNetworkReplyFinished(self): + reply = self.sender() + i = self._networkGetReplies[0].index(reply) + networkReplyData = self._networkGetReplies[1][i] + networkReplyData.finished = True + for signal, handler in self._networkReplySignals: + self.disconnect(reply, QtCore.SIGNAL(signal), handler) + self.emit(QtCore.SIGNAL('networkReplyFinished(int, QObject*)'), i, networkReplyData) \ No newline at end of file Added: trunk/fclient/fclient/impl/ViewBrowser/BrowserWidget.ui =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/BrowserWidget.ui (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/BrowserWidget.ui 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,267 @@ +<ui version="4.0" > + <class>ViewBrowserWidget</class> + <widget class="QWidget" name="ViewBrowserWidget" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>710</width> + <height>794</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout_4" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>0</number> + </property> + <item row="0" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout" > + <property name="spacing" > + <number>0</number> + </property> + <item> + <layout class="QHBoxLayout" > + <item> + <widget class="QFrame" name="frameTools" > + <property name="frameShape" > + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <layout class="QGridLayout" name="gridLayout_2" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>0</number> + </property> + <item row="0" column="0" > + <widget class="QToolButton" name="btBack" > + <property name="text" > + <string>Back</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QToolButton" name="btForward" > + <property name="text" > + <string>Forward</string> + </property> + </widget> + </item> + <item row="0" column="3" > + <widget class="QToolButton" name="btReload" > + <property name="text" > + <string>Reload</string> + </property> + </widget> + </item> + <item row="0" column="4" > + <widget class="QToolButton" name="btStop" > + <property name="text" > + <string>Stop</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QFrame" name="frameAddressBar" > + <property name="minimumSize" > + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="frameShape" > + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Plain</enum> + </property> + <property name="lineWidth" > + <number>0</number> + </property> + <layout class="QGridLayout" name="gridLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>0</number> + </property> + <item row="0" column="0" > + <widget class="QLineEdit" name="edAddressBar" > + <property name="dragEnabled" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </item> + <item row="1" column="0" > + <widget class="QSplitter" name="splitter" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Expanding" hsizetype="Expanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <widget class="QTabWidget" name="tabSideBar" > + <widget class="QWidget" name="tab_2" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>137</width> + <height>736</height> + </rect> + </property> + <attribute name="title" > + <string>Tab 1</string> + </attribute> + </widget> + <widget class="QWidget" name="tab_3" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>150</width> + <height>712</height> + </rect> + </property> + <attribute name="title" > + <string>Tab 2</string> + </attribute> + </widget> + </widget> + <widget class="QWidget" name="layoutWidget" > + <layout class="QVBoxLayout" name="verticalLayout" > + <property name="spacing" > + <number>0</number> + </property> + <property name="margin" > + <number>0</number> + </property> + <item> + <widget class="QTabWidget" name="tabBrowsers" > + <property name="currentIndex" > + <number>0</number> + </property> + <widget class="QWidget" name="tab" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>557</width> + <height>700</height> + </rect> + </property> + <attribute name="title" > + <string>Tab 1</string> + </attribute> + </widget> + </widget> + </item> + <item> + <widget class="QFrame" name="frameFind" > + <property name="frameShape" > + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <layout class="QGridLayout" name="gridLayout_3" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>0</number> + </property> + <item row="0" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout_2" > + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="label" > + <property name="text" > + <string>Find:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="edFind" > + <property name="dragEnabled" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btFindNext" > + <property name="text" > + <string>Next</string> + </property> + <property name="flat" > + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="btFindPrevious" > + <property name="text" > + <string>Previous</string> + </property> + <property name="flat" > + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="ckFindCaseSensitive" > + <property name="text" > + <string>Case sensitive</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>48</width> + <height>25</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> Added: trunk/fclient/fclient/impl/ViewBrowser/GlobalFeedback.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/GlobalFeedback.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/GlobalFeedback.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,58 @@ +# 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 .. import config +from ..lib.compactpath.qt4 import pathlabelwrap + + + +from PyQt4 import QtCore, QtGui +#********************************************************************************** +# +#********************************************************************************** +class GlobalFeedback(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: + 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, 10) + + 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.labelFeedbackWrap.label.setVisible(flag) + + def setFeedback(self, qString): + if self.labelFeedbackWrap is not None: + self.labelFeedbackWrap.setPath(unicode(qString)) \ No newline at end of file Added: trunk/fclient/fclient/impl/ViewBrowser/NetworkAccessManager.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/NetworkAccessManager.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/NetworkAccessManager.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,19 @@ + +from PyQt4 import QtCore, QtNetwork +#***************************************************************************************** +# +#***************************************************************************************** +class NetworkAccessManager(QtNetwork.QNetworkAccessManager): + + def __init__(self, parent): + QtNetwork.QNetworkAccessManager.__init__(self, parent) + + def createRequest(self, operation, request, outgoingData): + reply = QtNetwork.QNetworkAccessManager.createRequest(self, operation, request, outgoingData) + self.emit(QtCore.SIGNAL('networkRequestCreated(QNetworkReply*)'), reply) + #print 'createRequest', reply.url() + #self.connect(reply, QtCore.SIGNAL('downloadProgress(qint64, qint64)'), self.foo) + return reply + + def foo(self, *args): + print args Added: trunk/fclient/fclient/impl/ViewBrowser/Page.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/Page.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/Page.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,25 @@ +# 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, QtWebKit + +from . import NetworkAccessManager +#***************************************************************************************** +# +#***************************************************************************************** +class Page(QtWebKit.QWebPage): + def __init__(self, parent): + QtWebKit.QWebPage.__init__(self, parent) + + self.setNetworkAccessManager(NetworkAccessManager.NetworkAccessManager(self)) + #def acceptNavigationRequest(self, frame, request, typeRequest): + # return True Added: trunk/fclient/fclient/impl/ViewBrowser/Settings.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/Settings.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/Settings.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,63 @@ +# 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 .. import config + +from PyQt4 import QtCore, QtGui +#********************************************************************************** +# +#********************************************************************************** +class Settings(config.SettingsBase): + _key_ = config.IdViewBrowserWidget + _settings_ = ( + ('OpenLinksInNewTab', 'Bool', False), + ('OpenAddressBarInNewTab', 'Bool', False), + ('OpenBookmarksInNewTab', 'Bool', False), + ('OpenHomePageOnNewTabCreated', 'Bool', False), + ('BackIsClose', 'Bool', False), #TODO: not implemented + ('HomePage', 'String', QtCore.QString()), + ('AutoLoadImages', 'Bool', True), #TODO: not yet implemented + ('MaxTabText', 'UInt', 15), #NOTE: make shure Max >= Min and Max and Min > 0 + ('MinTabText', 'UInt', 15), + + ('TabProgressBarColor', 'QColor', QtGui.QColor('blue')), + ('TabProgressBarAlpha', 'UInt', 55), + + ('SplitterPos', 'ByteArray', QtCore.QByteArray()), + ('LastSideBarAction', 'String', QtCore.QString('')), + + ) + + def setValues(self, **kws): + config.SettingsBase.setValues(self, **kws) + if not self.parent().isCreated: + return + + autoLoadImages = kws.get('AutoLoadImages', None) + if autoLoadImages is not None: + browserWidget = self.parent() + tabWidget = browserWidget.controlById(browserWidget.IdTabBrowsers) + for i in xrange(tabWidget.count()): + browser = tabWidget.widget(i) + if hasattr(browser, 'settings'): # QTabWidget may return a Null QWidget + settings = browser.settings() + settings.setAttribute(settings.AutoLoadImages, autoLoadImages) + + if kws.get('TabProgressBarColor', None) is not None or kws.get('TabProgressBarAlpha', None) is not None: + tabWidget = browserWidget.controlById(browserWidget.IdTabBrowsers) + tabWidget.tabBar().repaint() + + + #backIsClose = kws.get('BackIsClose', None) + #if backIsClose is not None: + # self.parent()._adjustBackIsClose() + \ No newline at end of file Added: trunk/fclient/fclient/impl/ViewBrowser/SideBar.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/SideBar.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/SideBar.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1 @@ + Added: trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetails.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetails.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetails.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,278 @@ +"""sideBar for the browser to show detailed information on page load""" +#******************************************************************************** +#TODO: +# +# x. how to adjust item colors via stylesheet? +# x. limit number of requests we keep track off (performance)? +# x. context menu actions for items like ...load in browser ..download key (...) +# x. save column widths +# +#******************************************************************************** +# 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 + +import posixpath +from PyQt4 import QtCore, QtGui + +from ... import config +from .Ui_SideBarLoadDetailsTpl import Ui_SideBarLoadDetails +#********************************************************************************** +# +#********************************************************************************** +class SideBarLoadDetailsSettings(config.SettingsBase): + _key_ = config.IdSideBarLoadDetails + _settings_ = ( + ('ColorFgItem', 'QColor', QtGui.QColor('black')), + ('ColorBgItem', 'QColor', QtGui.QColor('white')), + ('ColorFgItemError', 'QColor', QtGui.QColor('red')), + ('ColorBgItemError', 'QColor', QtGui.QColor('white')), + ('ColorFgItemComplete', 'QColor', QtGui.QColor('green')), + ('ColorBgItemComplete', 'QColor', QtGui.QColor('white')), + ) + + +class TreeItem(QtGui.QTreeWidgetItem): + + StatusNone = 0 + StatusLoading = 1 + StatusComplete = 2 + StatusError = 3 + def __init__(self, *args): + QtGui.QTreeWidgetItem.__init__(self, *args) + self.status = self.StatusNone + self.url = None + + + +class SideBarLoadDetails(QtGui.QWidget, Ui_SideBarLoadDetails): + + IdTree = 'tree' + IdBtClose = 'btClose' + + IndexProgress = 0 + IndexStatus = 1 + IndexName = 2 + + + def __init__(self, parent=None, closeAction=None): + QtGui.QWidget.__init__(self, parent) + self.statusNames = {} # TreeItem.Status* --> displayName + + self.setupUi(self) + + config.ObjectRegistry.register(self) + self.fcSettings = SideBarLoadDetailsSettings(self).restore() + self.baseKey = None # base key of the page + + # setup tree + tree = self.controlById(self.IdTree) + tree.setUniformRowHeights(True) + tree.setRootIsDecorated(False) + + # setup close button + if closeAction is not None: + bt = self.controlById(self.IdBtClose) + bt.setDefaultAction(closeAction) + + ############################## + ## private methods + ############################## + def _splitBaseKey(self, url): + baseKey = '' + fileName = tmp_fileName = unicode(url.path()) + if tmp_fileName: + tmp_fileName = tmp_fileName.lstrip('/') + if tmp_fileName: + # prep fileName to extract freenetKey + T = tmp_fileName.split('/', 1) + if len(T) == 2: + tmp_baseKey, tmp_fileName = T + else: + tmp_baseKey, tmp_fileName = T[0], '' + # check if baseKey is a freenet key + if config.qStringToFcpKey(tmp_baseKey) is not None: + baseKey = tmp_baseKey + fileName = tmp_fileName + else: + fileName = fileName.lstrip('/') + return baseKey, fileName + + ############################## + ## methods + ############################## + def addNetworkReply(self, indexReply, networkReplyData): + #TODO: better extraction of filename part + tree = self.controlById(self.IdTree) + n = tree.topLevelItemCount() + if indexReply < n: + return + + if indexReply == 0: + self.baseKey, fileName = self._splitBaseKey(networkReplyData.url) + else: + #problem: index page may point somewhere deep into a container + # ..so we can not assume all following requests of are lokated deeper + # ..in the age hirarchy. anyways. links to external resources are + # ..always displayed as absolute urls + baseKey, fileName = self._splitBaseKey(networkReplyData.url) + if baseKey != self.baseKey: + fileName = unicode(networkReplyData.url.toString()) + if not fileName: + fileName = '/' + + item = TreeItem(tree) + item.url = networkReplyData.url + # set progress + if networkReplyData.bytesTotal < 1: + progress = '0%' + else: + progress = str(int((float(networkReplyData.bytesReceived) / networkReplyData.bytesTotal * 100))) + '%' + item.setData( + self.IndexProgress, + QtCore.Qt.DisplayRole, + QtCore.QVariant(progress), + ) + # set status + if networkReplyData.bytesReceived: + item.status = TreeItem.StatusLoading + if networkReplyData.errorCode is not None: + item.status = TreeItem.StatusError + if networkReplyData.finished: + item.status = TreeItem.StatusComplete + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) + # set fileName + item.setData( + self.IndexName, + QtCore.Qt.DisplayRole, + QtCore.QVariant(fileName), + ) + # set vcolors + item.setForeground(self.IndexStatus, self.fcSettings.value('ColorFgItem')) + item.setBackground(self.IndexStatus, self.fcSettings.value('ColorBgItem')) + + + def controlById(self, idControl): + return getattr(self, idControl) + + def setCurrent(self, browserWidget, flag): + if flag: + self.setBrowser(browserWidget.currentBrowser()) + else: + tree = self.controlById(self.IdTree) + tree.clear() + self.baseUrl = None + + def setBrowser(self, browser): + tree = self.controlById(self.IdTree) + tree.clear() + self.baseUrl = None + # setup browser + if browser is not None: + self.connect(browser, QtCore.SIGNAL('networkGetRequestCreated(int, QObject*)'), self.addNetworkReply) + self.connect(browser, QtCore.SIGNAL('networkReplyProgress(int, QObject*)'), self.onBrowserNetworkReplyProgress) + self.connect(browser, QtCore.SIGNAL('networkReplyError(int, QObject*)'), self.onBrowserNetworkReplyError) + self.connect(browser, QtCore.SIGNAL('networkReplyFinished(int, QObject*)'), self.onBrowserNetworkReplyFinished) + self.connect(browser, QtCore.SIGNAL('loadStarted()'), self.onBrowserLoadStarted) + for indexReply, networkReplyData in enumerate(browser.networkGetReplies()): + self.addNetworkReply(indexReply, networkReplyData) + + ########################### + ## overwritten methods + ########################### + def retranslateUi(self, this): + Ui_SideBarLoadDetails.retranslateUi(self, this) + tree = self.controlById(self.IdTree) + headerLabels = [ + (self.IndexProgress, self.trUtf8('Progress')), + (self.IndexStatus, self.trUtf8('Status')), + (self.IndexName, self.trUtf8('Name')), + ] + headerLabels.sort() + tree.setHeaderLabels([i[1] for i in headerLabels]) + self.statusNames = { + TreeItem.StatusNone: self.trUtf8('waiting'), + TreeItem.StatusLoading: self.trUtf8('loading'), + TreeItem.StatusComplete: self.trUtf8('complete'), + TreeItem.StatusError: self.trUtf8('error'), + } + root = tree.invisibleRootItem() + for i in xrange(root.childCount()): + item = root.child(i) + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) + ############################## + ## event handlers + ############################## + def onBrowserLoadStarted(self): + tree = self.controlById(self.IdTree) + tree.clear() + + def onBrowserNetworkReplyProgress(self, indexReply, networkReplyData): + tree = self.controlById(self.IdTree) + item = tree.invisibleRootItem().child(indexReply) + if item is None: + return + if item.status != TreeItem.StatusError: + item.status = item.StatusLoading + if networkReplyData.bytesTotal < 1: + progress = '0%' + else: + progress = str(int((float(networkReplyData.bytesReceived) / networkReplyData.bytesTotal * 100))) + '%' + + item.setData( + self.IndexProgress, + QtCore.Qt.DisplayRole, + QtCore.QVariant(progress), + ) + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) + + def onBrowserNetworkReplyError(self, indexReply, networkReplyData): + tree = self.controlById(self.IdTree) + item = tree.invisibleRootItem().child(indexReply) + if item is None: + return + item.setForeground(self.IndexStatus, self.fcSettings.value('ColorFgItemError')) + item.setBackground(self.IndexStatus, self.fcSettings.value('ColorBgItemError')) + item.status = item.StatusError + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) + + def onBrowserNetworkReplyFinished(self, indexReply, networkReplyData): + tree = self.controlById(self.IdTree) + item = tree.invisibleRootItem().child(indexReply) + if item is None: + return + if item.status != TreeItem.StatusError: + item.status = item.StatusComplete + item.setData( + self.IndexStatus, + QtCore.Qt.DisplayRole, + QtCore.QVariant(self.statusNames[item.status]), + ) + item.setForeground(self.IndexStatus, self.fcSettings.value('ColorFgItemComplete')) + item.setBackground(self.IndexStatus, self.fcSettings.value('ColorBgItemComplete')) + + Added: trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetailsTpl.ui =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetailsTpl.ui (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetailsTpl.ui 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,47 @@ +<ui version="4.0" > + <class>SideBarLoadDetails</class> + <widget class="QWidget" name="SideBarLoadDetails" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>497</width> + <height>488</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QLabel" name="header" > + <property name="text" > + <string>Load details</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="btClose" > + <property name="text" > + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0" > + <widget class="QTreeWidget" name="tree" > + <column> + <property name="text" > + <string>1</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> Added: trunk/fclient/fclient/impl/ViewBrowser/SideBars/Ui_SideBarLoadDetailsTpl.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/SideBars/Ui_SideBarLoadDetailsTpl.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/SideBars/Ui_SideBarLoadDetailsTpl.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/ViewBrowser/SideBars/SideBarLoadDetailsTpl.ui' +# +# Created: Sat Aug 16 09:12:46 2008 +# by: PyQt4 UI code generator 4.4.3-snapshot-20080705 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_SideBarLoadDetails(object): + def setupUi(self, SideBarLoadDetails): + SideBarLoadDetails.setObjectName("SideBarLoadDetails") + SideBarLoadDetails.resize(497, 488) + self.gridLayout = QtGui.QGridLayout(SideBarLoadDetails) + self.gridLayout.setObjectName("gridLayout") + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.header = QtGui.QLabel(SideBarLoadDetails) + self.header.setObjectName("header") + self.horizontalLayout.addWidget(self.header) + self.btClose = QtGui.QToolButton(SideBarLoadDetails) + self.btClose.setObjectName("btClose") + self.horizontalLayout.addWidget(self.btClose) + self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) + self.tree = QtGui.QTreeWidget(SideBarLoadDetails) + self.tree.setObjectName("tree") + self.gridLayout.addWidget(self.tree, 1, 0, 1, 1) + + self.retranslateUi(SideBarLoadDetails) + QtCore.QMetaObject.connectSlotsByName(SideBarLoadDetails) + + def retranslateUi(self, SideBarLoadDetails): + SideBarLoadDetails.setWindowTitle(QtGui.QApplication.translate("SideBarLoadDetails", "Form", None, QtGui.QApplication.UnicodeUTF8)) + self.header.setText(QtGui.QApplication.translate("SideBarLoadDetails", "Load details", None, QtGui.QApplication.UnicodeUTF8)) + self.btClose.setText(QtGui.QApplication.translate("SideBarLoadDetails", "...", None, QtGui.QApplication.UnicodeUTF8)) + self.tree.headerItem().setText(0, QtGui.QApplication.translate("SideBarLoadDetails", "1", None, QtGui.QApplication.UnicodeUTF8)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + SideBarLoadDetails = QtGui.QWidget() + ui = Ui_SideBarLoadDetails() + ui.setupUi(SideBarLoadDetails) + SideBarLoadDetails.show() + sys.exit(app.exec_()) + Added: trunk/fclient/fclient/impl/ViewBrowser/SideBars/__init__.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/SideBars/__init__.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/SideBars/__init__.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,14 @@ + +class BrowserSideBar: + """template for sidebars""" + + def __init__(self, parent=None, closeAction=None): + """ + @param parent: parent widget + @param closeAction: (QAction) that should be triggered to close the sideBar + """ + def setCurrent(self, browserWidget, flag): + """ + @param browserWidget: browser widget the sideBar is attatched to + @param flag: (bool) True if the sideBar is the current sidebar now, False otherwise + """ \ No newline at end of file Added: trunk/fclient/fclient/impl/ViewBrowser/SideBars/_fix_mexec.py =================================================================== --- trunk/fclient/fclient/impl/ViewBrowser/SideBars/_fix_mexec.py (rev 0) +++ trunk/fclient/fclient/impl/ViewBrowser/SideBars/_fix_mexec.py 2008-08-16 07:43:18 UTC (rev 910) @@ -0,0 +1,99 @@ +'''in 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 +@note: this patch does not work if relative imports are done in __init__.py. no idea why +and to be honest, I don't wanna* know.. +@note: this is more or less a hack. so it may have unwanted side effects for example +when importing parent packages. use at your own risk. could improve this module +by adding a __main__.py to stop at this level or by fixing the __init__.py bug, but +I don't think its worth it. see what python2.6 or 3k brings.. + +usage:: + + # place this at the top a module, before doing any relative imports + from fix_mexec import fix_mexec + fi... [truncated message content] |