SF.net SVN: fclient:[899] trunk/fclient/fclient/impl
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-08-11 17:56:46
|
Revision: 899
http://fclient.svn.sourceforge.net/fclient/?rev=899&view=rev
Author: jUrner
Date: 2008-08-11 17:56:50 +0000 (Mon, 11 Aug 2008)
Log Message:
-----------
started rewriting downloadsWidget to a more gemeral purpose requests widget
Modified Paths:
--------------
trunk/fclient/fclient/impl/ViewDownloads.py
Added Paths:
-----------
trunk/fclient/fclient/impl/tpls/Ui_ViewRequestsWidgetTpl.py
trunk/fclient/fclient/impl/tpls/ViewRequestsWidgetTpl.ui
Modified: trunk/fclient/fclient/impl/ViewDownloads.py
===================================================================
--- trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-11 10:42:48 UTC (rev 898)
+++ trunk/fclient/fclient/impl/ViewDownloads.py 2008-08-11 17:56:50 UTC (rev 899)
@@ -56,7 +56,7 @@
from . import DlgDownloadKeyToDisk
-from .tpls.Ui_ViewDownloadsWidgetTpl import Ui_ViewDownloadsWidget
+from .tpls.Ui_ViewRequestsWidgetTpl import Ui_ViewRequestsWidget
#**********************************************************************************
#
#**********************************************************************************
@@ -65,126 +65,6 @@
#**********************************************************************************
#
#**********************************************************************************
-class DownloadsViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Downloads')
- self.icon=QtGui.QIcon()
-
-#**********************************************************************************
-#
-#**********************************************************************************
-class DownloadsWidgetGlobalFeedback(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 DownloadsWidgetActions(config.ActionsBase):
-
- def __init__(self, parent):
- config.ActionsBase.__init__(self, parent)
-
- self.action(
- name='ActionDownloadKeyToDisk',
- text=self.trUtf8('Download &key...'),
- trigger=parent.onDlgDownloadKey,
- )
- self.action(
- name='ActionRemoveSelectedDownloads',
- text=self.trUtf8('Remove download'),
- trigger=parent.onRemoveSelectedDownloads,
- isEnabled=False,
- )
- self.action(
- name='ActionRestartSelectedDownloads',
- text=self.trUtf8('Restart download'),
- trigger=parent.onRestartSelectedDownloads,
- isEnabled=False,
- )
-
- #TODO: enable/disable if items of that type are available?
- group = self.group(
- name='GroupRemoveGroup',
- trigger=parent.onRemoveGroup,
- )
- self.action(
- name='ActionRemoveFailed',
- group=group,
- text=self.trUtf8('Failed'),
- isEnabled=False,
- )
- self.action(
- name='ActionRemoveCompleted',
- group=group,
- text=self.trUtf8('Completed'),
- isEnabled=False,
- )
-
-class DownloadsWidgetSettings(config.SettingsBase):
-
-
- _key_ = config.IdViewDownloadsWidget
- _settings_ = (
- ('MaxSimultaneousDownloads', 'UInt', 3),
- )
-#**********************************************************************************
-#
-#**********************************************************************************
class PersistentRequestData(pmstruct.PMStruct):
_fields_ = (
('ClientName', pmstruct.STRING),
@@ -239,10 +119,52 @@
return self.item.status()
status= QtCore.pyqtProperty("QString", _get_status)
+
+class RequestsWidgetActions(config.ActionsBase):
+
+ def __init__(self, parent):
+ config.ActionsBase.__init__(self, parent)
+
+ self.action(
+ name='ActionDownloadKeyToDisk',
+ text=self.trUtf8('Download &key...'),
+ trigger=parent.onDlgDownloadKey,
+ )
+ self.action(
+ name='ActionRemoveSelectedDownloads',
+ text=self.trUtf8('Remove download'),
+ trigger=parent.onRemoveSelectedDownloads,
+ isEnabled=False,
+ )
+ self.action(
+ name='ActionRestartSelectedDownloads',
+ text=self.trUtf8('Restart download'),
+ trigger=parent.onRestartSelectedDownloads,
+ isEnabled=False,
+ )
+
+ #TODO: enable/disable if items of that type are available?
+ group = self.group(
+ name='GroupRemoveGroup',
+ trigger=parent.onRemoveGroup,
+ )
+ self.action(
+ name='ActionRemoveFailed',
+ group=group,
+ text=self.trUtf8('Failed'),
+ isEnabled=False,
+ )
+ self.action(
+ name='ActionRemoveCompleted',
+ group=group,
+ text=self.trUtf8('Completed'),
+ isEnabled=False,
+ )
+
#**********************************************************************************
#
#**********************************************************************************
-class ViewDownloadsWidget(QtGui.QWidget, Ui_ViewDownloadsWidget):
+class RequestsWidget(QtGui.QWidget, Ui_ViewRequestsWidget):
IdTree = 'tree'
@@ -250,17 +172,12 @@
QtGui.QWidget.__init__(self, parent)
self._isCreated = False
self.fcHeaderLabels = {} # fcpIdentifier --> treeItem
+ self.fcActions = RequestsWidgetActions(self)
self.fcpRequests = {}
self.fcRequestStatusNames = {}
self.menuRemoveGroup = QtGui.QMenu(self)
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)
self.fcpClientEvents = (
(config.fcpClient.events.ClientConnected, self.onFcpClientConnected),
(config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconnected),
@@ -274,9 +191,6 @@
)
config.fcpClient.events += self.fcpClientEvents
- # setup menus
- for action in self.fcActions['GroupRemoveGroup'].actions():
- self.menuRemoveGroup.addAction(action)
############################
## private methods
@@ -357,7 +271,7 @@
##
############################
def retranslateUi(self, parent):
- Ui_ViewDownloadsWidget.retranslateUi(self, parent)
+ Ui_ViewRequestsWidget.retranslateUi(self, parent)
tree = self.controlById(self.IdTree)
root = tree.invisibleRootItem()
@@ -515,21 +429,14 @@
parent = root
parent.removeChild(item)
+
+ # overwrite
def onTreeCustomContextMenuRequested(self, pt):
- tree = self.controlById(self.IdTree)
- pt = tree.viewport().mapToGlobal(pt)
+ pass
- menu = QtGui.QMenu(self)
- menu.addAction(self.fcActions['ActionRemoveSelectedDownloads'])
- menu.addAction(self.fcActions['ActionRestartSelectedDownloads'])
- menu.addMenu(self.menuRemoveGroup)
- menu.exec_(pt)
-
+ # overwrite
def onTreeItemSelectionChanged(self):
- tree = self.controlById(self.IdTree)
- hasSelectedItems = tree.selectionModel().hasSelection()
- self.fcActions['ActionRemoveSelectedDownloads'].setEnabled(hasSelectedItems)
- self.fcActions['ActionRestartSelectedDownloads'].setEnabled(hasSelectedItems)
+ pass
#########################################
## fcp event handlers
@@ -611,9 +518,142 @@
if item is not None:
self._adjustItemStatus(item)
+
#**********************************************************************************
#
#**********************************************************************************
+class DownloadsWidgetGlobalFeedback(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('Downloads')
+ self.icon=QtGui.QIcon()
+
+
+class DownloadsWidgetSettings(config.SettingsBase):
+
+
+ _key_ = config.IdViewDownloadsWidget
+ _settings_ = (
+ ('MaxSimultaneousDownloads', 'UInt', 3),
+ )
+
+
+class ViewDownloadsWidget(RequestsWidget):
+
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
+
+ self.menuRemoveGroup = None
+
+ RequestsWidget.__init__(self, parent)
+
+ self.setObjectName(config.IdViewDownloadsWidget)
+ config.ObjectRegistry.register(self)
+ self.fcSettings = DownloadsWidgetSettings(self).restore()
+ self.fcViewObject = DownloadsViewObject(self)
+ self.fcGlobalFeedback = DownloadsWidgetGlobalFeedback(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)
+
+
+ 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'))
+
+ def onTreeCustomContextMenuRequested(self, pt):
+ tree = self.controlById(self.IdTree)
+ pt = tree.viewport().mapToGlobal(pt)
+
+ menu = QtGui.QMenu(self)
+ menu.addAction(self.fcActions['ActionRemoveSelectedDownloads'])
+ menu.addAction(self.fcActions['ActionRestartSelectedDownloads'])
+ menu.addMenu(self.menuRemoveGroup)
+ menu.exec_(pt)
+
+ def onTreeItemSelectionChanged(self):
+ tree = self.controlById(self.IdTree)
+ hasSelectedItems = tree.selectionModel().hasSelection()
+ self.fcActions['ActionRemoveSelectedDownloads'].setEnabled(hasSelectedItems)
+ self.fcActions['ActionRestartSelectedDownloads'].setEnabled(hasSelectedItems)
+
+
+#**********************************************************************************
+#
+#**********************************************************************************
if __name__ == '__main__':
import sys
from . import View
Added: trunk/fclient/fclient/impl/tpls/Ui_ViewRequestsWidgetTpl.py
===================================================================
--- trunk/fclient/fclient/impl/tpls/Ui_ViewRequestsWidgetTpl.py (rev 0)
+++ trunk/fclient/fclient/impl/tpls/Ui_ViewRequestsWidgetTpl.py 2008-08-11 17:56:50 UTC (rev 899)
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/tpls/ViewRequestsWidgetTpl.ui'
+#
+# Created: Mon Aug 11 19:50:32 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_ViewRequestsWidget(object):
+ def setupUi(self, ViewRequestsWidget):
+ ViewRequestsWidget.setObjectName("ViewRequestsWidget")
+ ViewRequestsWidget.resize(400, 300)
+ self.gridLayout = QtGui.QGridLayout(ViewRequestsWidget)
+ self.gridLayout.setMargin(0)
+ self.gridLayout.setSpacing(0)
+ self.gridLayout.setObjectName("gridLayout")
+ self.tree = QtGui.QTreeWidget(ViewRequestsWidget)
+ self.tree.setObjectName("tree")
+ self.gridLayout.addWidget(self.tree, 0, 0, 1, 1)
+
+ self.retranslateUi(ViewRequestsWidget)
+ QtCore.QMetaObject.connectSlotsByName(ViewRequestsWidget)
+
+ def retranslateUi(self, ViewRequestsWidget):
+ ViewRequestsWidget.setWindowTitle(QtGui.QApplication.translate("ViewRequestsWidget", "Form", None, QtGui.QApplication.UnicodeUTF8))
+ self.tree.headerItem().setText(0, QtGui.QApplication.translate("ViewRequestsWidget", "1", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ ViewRequestsWidget = QtGui.QWidget()
+ ui = Ui_ViewRequestsWidget()
+ ui.setupUi(ViewRequestsWidget)
+ ViewRequestsWidget.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/fclient/impl/tpls/ViewRequestsWidgetTpl.ui
===================================================================
--- trunk/fclient/fclient/impl/tpls/ViewRequestsWidgetTpl.ui (rev 0)
+++ trunk/fclient/fclient/impl/tpls/ViewRequestsWidgetTpl.ui 2008-08-11 17:56:50 UTC (rev 899)
@@ -0,0 +1,35 @@
+<ui version="4.0" >
+ <class>ViewRequestsWidget</class>
+ <widget class="QWidget" name="ViewRequestsWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </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="QTreeWidget" name="tree" >
+ <column>
+ <property name="text" >
+ <string>1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|