SF.net SVN: fclient: [584] trunk/fclient/src/fclient/Ui_ViewConnection.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-12 11:07:25
|
Revision: 584
http://fclient.svn.sourceforge.net/fclient/?rev=584&view=rev
Author: jUrner
Date: 2008-07-12 04:07:35 -0700 (Sat, 12 Jul 2008)
Log Message:
-----------
continued working on widget
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-12 11:06:56 UTC (rev 583)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-12 11:07:35 UTC (rev 584)
@@ -5,11 +5,9 @@
from PyQt4 import QtCore, QtGui
-
from . import config
-from . import Ui_View
-
from .lib import fcp2
+from . import Ui_View
from .tpls.Ui_ViewConnectionWidgetTpl import Ui_ViewConnectionWidget
#**********************************************************************************
#
@@ -17,126 +15,126 @@
class Settings(config.SettingsBase):
_key_ = config.IdViewConnectionWidget
_settings_ = (
- ('AutoConnect', 'Bool', False),
- ('ConnectionHost', 'String', fcp2.Client.DefaultFcpHost),
- ('ConnectionName', 'String', ''), #TODO: we need a python ansi string
- ('ConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort),
+ ('ConnectionTimerTimeout', 'UInt', 100, config.SettingScopeExpert),
+
+ ('AutoConnect', 'Bool', False, config.SettingScopeUser),
+ ('ConnectionName', 'String', '', config.SettingScopeUser), #TODO: we need a python ansi string
+ ('ConnectionHost', 'String', fcp2.Client.DefaultFcpHost, config.SettingScopeUser),
+ ('ConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort, config.SettingScopeUser),
)
+#**********************************************************************************
+#
+#**********************************************************************************
+class ConnectionTimer(QtCore.QTimer):
+
+ def __init__(self,parent):
+ QtCore.QTimer.__init__(self, parent)
+ self.iterConnect = None
+ self.nodeHello = None
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
+
+ def start(self, settings):
+ self.iterConnect = config.fcpClient.iterConnect() #TODO: ...more args
+ QtCore.QTimer.start(self, settings.value('ConnectionTimerTimeout'))
+
+ def handleNext(self):
+ try:
+ result = self.iterConnect.next()
+ except StopIteration:
+ self.stop()
+ else:
+ if result is not None:
+ self.stop()
+ self.nodeHello = result
+
#***********************************************************************
#
#***********************************************************************
class ViewConnectionWidget(QtGui.QWidget, Ui_ViewConnectionWidget):
IdBtConnect = 'btConnect'
- IdEdConnectionHost = 'edConnectionHost'
+ IdEdConnectionHost = 'edConnectionHost' #TODO: combobox? validate input.
IdSpinConnectionPort = 'spinConnectionPort'
-
def __init__(self, parent, cfg=None):
QtGui.QWidget.__init__(self, parent)
self._isCreated = False
- self.settings = Settings()
+ self._connectionTimer = ConnectionTimer(self)
+ self.settings = Settings()
self.setupUi(self)
-
- self.settings.restore()
config.ObjectRegistry.register(self)
-
+ #########################################
+ ##
+ #########################################
def controlById(self, idControl):
return getattr(self, idControl)
-
- def retranslateUi(self, w):
- Ui_ViewConnectionWidget.retranslateUi(self, w)
- bt = self.controlById(self.IdBtConnect)
- if bt.isChecked():
- bt.setText()
-
#########################################
- ## events
+ ## overwritten events
#########################################
def showEvent(self, event):
QtGui.QWidget.showEvent(self, event)
- if self._isCreated:
+ if self._isCreated:
return
-
self._isCreated = True
+
self.connect(
self.controlById(self.IdBtConnect),
QtCore.SIGNAL('clicked(bool)'),
- self.onBtConnectClicked
+ self.handleBtConnectClicked
)
+ self.settings.restore()
+
# setup host / port boxes
edHost = self.controlById(self.IdEdConnectionHost)
edHost.setText(self.settings.value('ConnectionHost'))
spinPort = self.controlById(self.IdSpinConnectionPort)
- #TODO: no idea if port range (0, 0xFFFF) this is reasonable
- spinPort.setRange(0, 0xFFFF)
+ spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
spinPort.setValue(self.settings.value('ConnectionPort'))
-
# autoconnect if desired
- self.settings.restore()
if self.settings.value('AutoConnect'):
self.controlById(self.IdBtConnect).setChecked(True)
self.onBtConnectClicked(True)
- #XXX
- self.settings.setValues(ConnectionName='abc')
-
-
+
#########################################
- ##
+ ## overwritten methods
#########################################
- def onBtConnectClicked(self, checked):
+ def retranslateUi(self, w):
+ Ui_ViewConnectionWidget.retranslateUi(self, w)
bt = self.controlById(self.IdBtConnect)
+ if bt.isChecked():
+ bt.setText()
+
+ #########################################
+ ## event handlers
+ #########################################
+ def handleBtConnectClicked(self, checked):
+ bt = self.controlById(self.IdBtConnect)
if checked:
- bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
+ bt.setText(QtGui.QApplication.translate(config.IdViewConnectionWidget, "Disconnect", None, QtGui.QApplication.UnicodeUTF8))
if config.fcpClient.isConnected():
config.fcpClient.close()
- t = self.ConnectTimer(self)
+ self._connectionTimer.start(self.settings)
else:
- bt.setText(QtGui.QApplication.translate("ViewConnectionWidget", "Connect", None, QtGui.QApplication.UnicodeUTF8))
+ bt.setText(QtGui.QApplication.translate(config.IdViewConnectionWidget, "Connect", None, QtGui.QApplication.UnicodeUTF8))
config.fcpClient.close()
-
- #TODO: under construction!
- class ConnectTimer(QtCore.QTimer):
-
- def __init__(self,parent):
- QtCore.QTimer.__init__(self, parent)
- #self.setInterval(10)
- self.connect(self, QtCore.SIGNAL('timeout()'), self.handleNext)
+ self._connectionTimer.stop()
- self.iterConnect = config.fcpClient.iterConnect() # ...more args
- self.start(10)
-
- def handleNext(self):
- try:
- result = self.iterConnect.next()
- except StopIteration:
- self.stop()
- else:
- if result is not None:
- self.stop()
-
-
-
-
-
-
-
-
- def handleFoo(self):
+ #########################################
+ ## fcp event handlers
+ #########################################
+ def handleFcpClientDisconected(self, event):
pass
-
-
-
+
#**********************************************************************************
#
#**********************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|