SF.net SVN: fclient: [647] trunk/fclient/src/fclient/Ui_ViewConnection.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-15 23:57:33
|
Revision: 647
http://fclient.svn.sourceforge.net/fclient/?rev=647&view=rev
Author: jUrner
Date: 2008-07-15 16:57:40 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
what a diff
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_ViewConnection.py
Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-15 23:57:01 UTC (rev 646)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-15 23:57:40 UTC (rev 647)
@@ -17,6 +17,7 @@
_settings_ = (
('ConnectionTimerTimeout', 'UInt', 800, config.SettingScopeExpert),
('ConnectionTimerMaxDuration', 'UInt', 20, config.SettingScopeExpert),
+ ('PollTimerTimeout', 'UInt', 200, config.SettingScopeExpert),
('AutoConnect', 'Bool', False, config.SettingScopeUser),
('ConnectionName', 'String', '', config.SettingScopeUser), #TODO: we need a python ansi string
@@ -31,27 +32,46 @@
def __init__(self,parent):
QtCore.QTimer.__init__(self, parent)
- self.iterConnect = None
- self.nodeHello = None
+ self.fcpIterConnect = None
self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
def start(self, settings):
- self.iterConnect = config.fcpClient.iterConnect(
+ self.fcpIterConnect = config.fcpClient.iterConnect(
duration=settings.value('ConnectionTimerMaxDuration'),
timeout=0
)
- QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout'))
+ if not self.handleNext():
+ QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout'))
def handleNext(self):
try:
- result = self.iterConnect.next()
+ result = self.fcpIterConnect.next()
except StopIteration:
self.stop()
else:
if result is not None:
self.stop()
- self.nodeHello = result
+ # 1st thing todo after connect is to query the config from the node so all
+ # listeners right away so not everyone has to query it so. needs more details
+ # or joins the gui later.. feel free to query again
+ config.fcpClient.getConfig()
+ return True
+ return False
+
+
+class PollTimer(QtCore.QTimer):
+
+ def __init__(self,parent):
+ QtCore.QTimer.__init__(self, parent)
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
+ def start(self, settings):
+ QtCore.QTimer.start(self, settings.value('PollTimerTimeout'))
+
+ def handleNext(self):
+ if config.fcpClient.isConnected():
+ result = config.fcpClient.next()
+
#***********************************************************************
#
#***********************************************************************
@@ -65,24 +85,25 @@
def __init__(self, parent, cfg=None):
QtGui.QWidget.__init__(self, parent)
- self._acts = []
self._isCreated = False
self._connectionTimer = ConnectionTimer(self)
- self._eventHandlers = (
+ self._pollTimer = PollTimer(self)
+ self._fcpEventHandlers = (
+ (config.fcpClient.events.ClientConnected, self.handleFcpClientConected),
(config.fcpClient.events.ClientDisconnected, self.handleFcpClientDisconected),
)
+ config.fcpClient.events += self._fcpEventHandlers
self._mainWindowMenus = ()
self.settings = Settings()
self.setupUi(self)
config.ObjectRegistry.register(self)
-
+
# atatch menus to main window if present. have to do it in __init__ to reserve order
menuBarWrap = config.ObjectRegistry.get(config.IdMainWindowMenuBarWrap, None)
if menuBarWrap is not None:
menu = QtGui.QMenu(self.viewDisplayName(), menuBarWrap.menuBar())
- for act in self.acts():
- menu.addAction(act)
+ self.populateMenu(menu)
self._mainWindowMenus = (
menuBarWrap.addViewMenu(menu),
)
@@ -90,26 +111,18 @@
#########################################
## methods
#########################################
- def close(self):
- config.fcpClient.events -= self._eventHandlers
-
def controlById(self, idControl):
return getattr(self, idControl)
+
- def displayName(self):
- return self.trUft8('Connection')
+ def populateMenu(self, menu):
+ return menu
- def acts(self):
- if not self._acts:
- self._acts = (
- )
- return self._acts
-
#########################################
## view methods
#########################################
def viewClose(self):
- self.close()
+ config.fcpClient.events -= self._fcpEventHandlers
def viewDisplayName(self):
return self.trUtf8('Connection')
@@ -128,7 +141,7 @@
## overwritten events
#########################################
def closeEvent(self, event):
- self.close()
+ self.viewClose()
def showEvent(self, event):
if self._isCreated:
@@ -137,8 +150,7 @@
self.settings.restore()
- config.fcpClient.events += self._eventHandlers
-
+
# setup host / port boxes
edHost = self.controlById(self.IdEdConnectionHost)
edHost.setText(self.settings.value('ConnectionHost'))
@@ -157,10 +169,7 @@
self.connect(bt, QtCore.SIGNAL('clicked(bool)'), self.handleBtConnectClicked)
if doAutoConnect:
self.controlById(self.IdBtConnect).click()
-
-
-
-
+
########################################
## overwritten methods
#########################################
@@ -183,6 +192,7 @@
else:
self._connectionTimer.stop()
if config.fcpClient.isConnected():
+ self._pollTimer.stop()
config.fcpClient.close()
@@ -197,6 +207,9 @@
if bt.isChecked():
bt.click()
+ def handleFcpClientConected(self, event, msg):
+ self._pollTimer.start(self.settings)
+
#**********************************************************************************
#
#**********************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|