SF.net SVN: fclient: [568] trunk/fclient/src/fclient
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-08 18:01:38
|
Revision: 568
http://fclient.svn.sourceforge.net/fclient/?rev=568&view=rev
Author: jUrner
Date: 2008-07-08 11:00:50 -0700 (Tue, 08 Jul 2008)
Log Message:
-----------
plugin views into the gui seems to work as expected
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_View.py
trunk/fclient/src/fclient/Ui_ViewConnection.py
trunk/fclient/src/fclient/Ui_ViewLogger.py
Modified: trunk/fclient/src/fclient/Ui_View.py
===================================================================
--- trunk/fclient/src/fclient/Ui_View.py 2008-07-08 16:52:34 UTC (rev 567)
+++ trunk/fclient/src/fclient/Ui_View.py 2008-07-08 18:00:50 UTC (rev 568)
@@ -52,14 +52,14 @@
return getattr(self, idControl)
- def addViews(top=True, *views):
- tab = self.controlById(self.IdTabTop) if top else self.controlById(self.IdTabBottom)
+ def addViews(self, toTop, *views):
+ tab = self.controlById(self.IdTabTop) if toTop else self.controlById(self.IdTabBottom)
for view in views:
- uuid = view.uuid()
- if uuid in self.views:
- raise ValueError('view is already present: %s' % uuid)
- i = tab.addTab(view.widget(tab), view.displayName(), view.icon())
- self.views[uuid] = (i, tab, view)
+ ido = str(view.objectName())
+ if ido in self.views:
+ raise ValueError('view is already present: %s' % ido)
+ i = tab.addTab(view.widget(tab), view.icon(), view.displayName())
+ self.views[ido] = (i, tab, view)
def viewFromUuid(self, uuid):
@@ -72,27 +72,39 @@
#**********************************************************************************
#
#**********************************************************************************
+#NOTE: to self. no need to register views to config.ObjectRegistry. they are just
+# opaque objects private to ViewWidget
class View(object):
- """base class for views"""
+ """base class for views handled by L{ViewWidget}"""
- UUID = ''
-
def __init__(self):
- pass
+ raise NotImplemetedError()
-
def displayName(self):
- return 'tab'
+ """should return the user visible name of the view
+ @return: (QString)
+ """
+ raise NotImplemetedError()
def icon(self):
- pass
-
- def uuid(self):
- return self.UUID
-
+ """should return the icon associated to the view
+ @return: (QIcon)
+ """
+ raise NotImplemetedError()
+
+ def objectName(self):
+ """should return the internally used id of the view
+ @return: (str) id
+ """
+ raise NotImplemetedError()
+
def widget(self, parent):
- pass
-
+ """should return the widget contained in the view
+ @param parent: (QWidget) parent
+ @return: (QWidget)
+ note: if the widget is not already created _now_ is the right time to create it
+ """
+ raise NotImplemetedError()
#**********************************************************************************
#
Modified: trunk/fclient/src/fclient/Ui_ViewConnection.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-08 16:52:34 UTC (rev 567)
+++ trunk/fclient/src/fclient/Ui_ViewConnection.py 2008-07-08 18:00:50 UTC (rev 568)
@@ -7,10 +7,12 @@
from . import config
+from . import Ui_View
+
from .lib import fcp2
from .lib.qt4ex import settingsbase
+
from .tpls.Ui_ViewConnectionWidgetTpl import Ui_ViewConnectionWidget
-
#**********************************************************************************
#
#**********************************************************************************
@@ -75,9 +77,7 @@
self.controlById(self.IdBtConnect).setChecked(True)
self.onBtConnectClicked(True)
-
-
-
+
def controlById(self, idControl):
return getattr(self, idControl)
@@ -88,7 +88,17 @@
if bt.isChecked():
bt.setText()
+ #########################################
+ ## view methods
+ #########################################
+ def displayName(self):
+ return QtGui.QApplication.translate("ViewConnectionWidget", "Connection", None, QtGui.QApplication.UnicodeUTF8)
+
+ def icon(self):
+ return QtGui.QIcon()
+
+
#########################################
##
#########################################
@@ -103,11 +113,41 @@
#**********************************************************************************
#
#**********************************************************************************
+class ViewConnection(Ui_View.View):
+
+ def __init__(self):
+ self._widget = None
+
+ def displayName(self):
+ return QtGui.QApplication.translate("ViewConnectionWidget", "Connection", None, QtGui.QApplication.UnicodeUTF8)
+
+ def icon(self):
+ return QtGui.QIcon()
+
+ def objectName(self):
+ return 'ViewConnection'
+
+
+ def widget(self, parent):
+ if self._widget is None:
+ self._widget = ViewConnectionWidget(parent)
+ return self._widget
+
+
+#**********************************************************************************
+#
+#**********************************************************************************
if __name__ == '__main__':
import sys
+ app = QtGui.QApplication(sys.argv)
- app = QtGui.QApplication(sys.argv)
- w = ViewConnectionWidget(None)
+
+ from . import Ui_ViewLogger
+
+ w = Ui_View.ViewWidget(None)
+ w.addViews(True, ViewConnection())
+ w.addViews(False, Ui_ViewLogger.ViewLogger())
+
w.show()
res = app.exec_()
sys.exit(res)
Modified: trunk/fclient/src/fclient/Ui_ViewLogger.py
===================================================================
--- trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-08 16:52:34 UTC (rev 567)
+++ trunk/fclient/src/fclient/Ui_ViewLogger.py 2008-07-08 18:00:50 UTC (rev 568)
@@ -8,6 +8,8 @@
from . import config
+from . import Ui_View
+
from .tpls.Ui_ViewLoggerWidgetTpl import Ui_ViewLoggerWidget
#**********************************************************************************
#
@@ -30,6 +32,30 @@
#**********************************************************************************
#
#**********************************************************************************
+class ViewLogger(Ui_View.View):
+
+ def __init__(self):
+ self._widget = None
+
+ def displayName(self):
+ return QtGui.QApplication.translate("ViewLogger", "Logger", None, QtGui.QApplication.UnicodeUTF8)
+
+ def icon(self):
+ return QtGui.QIcon()
+
+ def objectName(self):
+ return 'ViewLogger'
+
+
+ def widget(self, parent):
+ if self._widget is None:
+ self._widget = ViewLoggerWidget(parent)
+ return self._widget
+
+
+#**********************************************************************************
+#
+#**********************************************************************************
if __name__ == '__main__':
import sys
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|