SF.net SVN: fclient: [45] trunk/fclient/fclient_widgets/peer_widget.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2007-11-05 12:42:26
|
Revision: 45 http://fclient.svn.sourceforge.net/fclient/?rev=45&view=rev Author: jUrner Date: 2007-11-05 04:42:27 -0800 (Mon, 05 Nov 2007) Log Message: ----------- added refresh action an some fixes Modified Paths: -------------- trunk/fclient/fclient_widgets/peer_widget.py Modified: trunk/fclient/fclient_widgets/peer_widget.py =================================================================== --- trunk/fclient/fclient_widgets/peer_widget.py 2007-11-04 17:33:33 UTC (rev 44) +++ trunk/fclient/fclient_widgets/peer_widget.py 2007-11-05 12:42:27 UTC (rev 45) @@ -152,16 +152,12 @@ if not observer in event: event += observer - self.clear() - self._peers = {} + ## + self.listPeers() - self._cfg.fcpClientManager.setPriority( - self._fcpClient.connectionName(), - pollPriority=self._cfg.fcpClientManager.priorities['Highest'] - ) - self._fcpClient.listPeers() - + + def handleClientDisconnected(self, event, params): """ """ @@ -175,6 +171,7 @@ identity = params['identity'] item = self._peers.get(identity, None) + # add item if necessary if item is None: itemStrings = [ @@ -191,6 +188,13 @@ item.settext(self.HeaderIndexLastConnected, timeLastConnected) item.setPeerData(params) + # hide item if necessary + flags = self.showPeers() + if params['opennet'] == self._fcpClient.FcpTrue: + item.setHidden(not flags & self.ShowPeersOpennet) + else: + item.setHidden(not flags & self.ShowPeersDarknet) + # get peer notes if possible if params['opennet'] == self._fcpClient.FcpFalse: self._requestsPending += 1 @@ -267,14 +271,26 @@ """ result = '' try: - t = self._cfg.fcpClient.pythonTime(t) - except: pass + t = self._fcpClient.pythonTime(t) + except ValueError: pass else: if t > 0: result = numbers.format_time_delta(t, time.time()) return result + def listPeers(self): + self.clear() + self._peers = {} + + self._cfg.fcpClientManager.setPriority( + self._fcpClient.connectionName(), + pollPriority=self._cfg.fcpClientManager.priorities['Highest'] + ) + self._fcpClient.listPeers() + + + def peers(self): """Returns all currently known peers @return: (dict) identity --> treeItem @@ -290,6 +306,10 @@ actions.append(ShowPeersMenu(menu, self)) + act = RefreshAction('Refresh', self.trUtf8('Refresh'), menu, self) + menu.addAction(act) + actions.append(act) + return actions @@ -308,7 +328,7 @@ self.setUpdatesEnabled(False) for item in self.peers().values(): - if item.peerData()['opennet'] == self._cfg.fcpClient.FcpTrue: + if item.peerData()['opennet'] == self._fcpClient.FcpTrue: item.setHidden(not flags & self.ShowPeersOpennet) else: item.setHidden(not flags & self.ShowPeersDarknet) @@ -434,6 +454,35 @@ +class RefreshAction(QtGui.QAction): + """ + """ + + def __init__(self, name, text, parent, tree): + """ + """ + QtGui.QAction.__init__(self, text, parent) + self.setObjectName(name) + + #self.setShortcuts( + # [QtGui.QKeySequence(self.trUtf8('Ctrl+A'))] + # ) + self.tree = tree + self.connect( + self, + QtCore.SIGNAL('triggered()'), + self.__call__ + ) + + + def __call__(self): + """ + """ + self.tree.listPeers() + + + + '''######################################################## Sample Peer message >> Peer This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |