SF.net SVN: fclient:[768] trunk/fclient/src/fclient
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-27 11:31:12
|
Revision: 768
http://fclient.svn.sourceforge.net/fclient/?rev=768&view=rev
Author: jUrner
Date: 2008-07-27 11:31:20 +0000 (Sun, 27 Jul 2008)
Log Message:
-----------
naming
Modified Paths:
--------------
trunk/fclient/src/fclient/fclient.py
trunk/fclient/src/fclient/impl/MainWindow.py
trunk/fclient/src/fclient/impl/Ui_ViewBrowser.py
trunk/fclient/src/fclient/impl/Ui_ViewConnection.py
trunk/fclient/src/fclient/impl/Ui_ViewDownloads.py
Added Paths:
-----------
trunk/fclient/src/fclient/impl/View.py
Removed Paths:
-------------
trunk/fclient/src/fclient/impl/Ui_View.py
Modified: trunk/fclient/src/fclient/fclient.py
===================================================================
--- trunk/fclient/src/fclient/fclient.py 2008-07-27 11:29:02 UTC (rev 767)
+++ trunk/fclient/src/fclient/fclient.py 2008-07-27 11:31:20 UTC (rev 768)
@@ -7,7 +7,7 @@
from PyQt4 import QtGui
from .impl.MainWindow import MainWindow
-from .impl.Ui_View import ViewWidget
+from .impl.View import ViewWidget
from .impl.Ui_ViewBrowser import ViewBrowserWidget
from .impl.Ui_ViewConnection import ViewConnectionWidget
from .impl.Ui_ViewDownloads import ViewDownloadsWidget
Modified: trunk/fclient/src/fclient/impl/MainWindow.py
===================================================================
--- trunk/fclient/src/fclient/impl/MainWindow.py 2008-07-27 11:29:02 UTC (rev 767)
+++ trunk/fclient/src/fclient/impl/MainWindow.py 2008-07-27 11:31:20 UTC (rev 768)
@@ -10,7 +10,6 @@
from . import config
from . import Ui_Prefs
-from . import Ui_View
from .lib.qt4ex import dlgabout
from .tpls.Ui_MainWindowTpl import Ui_MainWindow
Deleted: trunk/fclient/src/fclient/impl/Ui_View.py
===================================================================
--- trunk/fclient/src/fclient/impl/Ui_View.py 2008-07-27 11:29:02 UTC (rev 767)
+++ trunk/fclient/src/fclient/impl/Ui_View.py 2008-07-27 11:31:20 UTC (rev 768)
@@ -1,277 +0,0 @@
-#FIXES
-#***************************************************************************
-# [0001]
-#
-# QTabWidget.closeEvent() does not seem to propagate close events
-# to child widgets
-#
-#
-#***************************************************************************
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-
-from PyQt4 import QtCore, QtGui
-
-
-from . import config
-from .lib import fcp2
-from .tpls.Ui_ViewWidgetTpl import Ui_ViewWidget
-#**********************************************************************************
-#
-#**********************************************************************************
-class Actions(config.ActionsBase):
-
- def __init__(self, parent):
- config.ActionsBase.__init__(self, parent)
-
- self.action(
- name='ActionShowTopTabBar',
- text=self.trUtf8('Show top &tabs'),
- trigger=parent.onActionShowTabsTop,
- isCheckable=True,
- isChecked=True,
- )
-
-
-class GlobalFeedback(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)
-
- def setVisible(self, flag):
- for menu in self.menus:
- menu.children()[0].setVisible(flag)
-
-
-
-class Settings(config.SettingsBase):
- _key_ = config.IdViewWidget
- _settings_ = (
- ('LastViewTop', 'String', '', config.SettingScopePrivate),
- ('LastViewBottom', 'String', '', config.SettingScopePrivate),
- ('SplitterPos', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate),
- ('ShowTopTabBar', 'Bool', True, config.SettingScopePrivate),
-
- )
-
-
-class ViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('View')
- self.icon=QtGui.QIcon()
-
-#***********************************************************************
-#
-#***********************************************************************
-class ViewWidget(QtGui.QWidget, Ui_ViewWidget):
-
- IdSplitter = 'Splitter'
- IdTabTop = 'tabTop'
- IdTabBottom = 'tabBottom'
-
-
- def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
- QtGui.QWidget.__init__(self, parent)
-
- self._isCreated = False
-
- self.views = {}
-
- self.setupUi(self)
- config.ObjectRegistry.register(self)
- self.fcActions = Actions(self)
- self.fcSettings = Settings().restore()
- self.fcViewObject = ViewObject(self)
- self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
-
- # setup tab widgets
- tabWidgetTop = self.controlById(self.IdTabTop)
- tabWidgetTop.removeTab(0)
- tabWidgetBottom = self.controlById(self.IdTabBottom)
- tabWidgetBottom.removeTab(0)
-
- # setup splitter
- splitter = self.controlById(self.IdSplitter)
- splitter.restoreState(self.fcSettings.value('SplitterPos'))
- self.connect(splitter, QtCore.SIGNAL('splitterMoved(int, int)'), self.onSplitterMoved)
-
- # setup actions
- showTopTabBar = self.fcSettings.value('ShowTopTabBar')
- self.fcActions['ActionShowTopTabBar'].setChecked(showTopTabBar)
- tabWidgetTop.tabBar().setVisible(showTopTabBar)
-
-
-
- def controlById(self, idControl):
- return getattr(self, idControl)
-
-
- def _addViews(self, toTop, *views):
- tabWidget = self.controlById(self.IdTabTop) if toTop else self.controlById(self.IdTabBottom)
- for view in views:
- name = view.fcViewObject.name
- if not name:
- raise ValueError('view must have a name')
- if name in self.views:
- raise ValueError('view with that name is already present: %s' % name)
- view.setParent(tabWidget)
- i = tabWidget.addTab(view, view.fcViewObject.icon, view.fcViewObject.displayName)
- self.views[name] = (tabWidget, view)
-
- #tab.tabBar().setVisible(tab.count() > 1)
-
-
- def addBottomViews(self, *views):
- return self._addViews(False, *views)
-
-
- def addTopViews(self, *views):
- return self._addViews(True, *views)
-
-
- def populateMenu(self, menu):
- menu.addAction(self.fcActions['ActionShowTopTabBar'])
- return menu
-
-
-
- def setCurrentView(self, name):
- result = self.views.get(name, None)
- if result is not None:
- tab, view = result
- tab.setCurrentWidget(view)
- return True
- return False
-
-
- def viewFromName(self, name):
- result = self.views.get(name, None)
- if result is not None:
- return result[1]
- return None
-
- #########################################################
- ##
- #########################################################
- def hideEvent(self, event):
- self.fcGlobalFeedback.setVisible(False)
-
-
- def showEvent(self, event):
- self.fcGlobalFeedback.setVisible(True)
-
-
- #########################################################
- ##
- #########################################################
- def closeEvent(self, event):
- for tab, view in self.views.values():
- view.viewClose()
-
-
- def showEvent(self, event):
- if self._isCreated:
- return
- self._isCreated = True
-
- # restore current views
- tabWidgetTop = self.controlById(self.IdTabTop)
- lastName = self.fcSettings.value('LastViewTop')
- self.setCurrentView(lastName)
-
- tabWidgetBottom = self.controlById(self.IdTabBottom)
- lastName = self.fcSettings.value('LastViewBottom')
- self.setCurrentView(lastName)
-
- # finally connect... not to overwrite settings
- self.connect(tabWidgetTop, QtCore.SIGNAL('currentChanged(int)'), self.onTabTopCurrentChanged)
- self.connect(tabWidgetBottom, QtCore.SIGNAL('currentChanged(int)'), self.onTabBottomCurrentChanged)
-
- #########################################################
- ##
- #########################################################
- def onActionShowTabsTop(self, action):
- tabWidgetTop = self.controlById(self.IdTabTop)
- tabWidgetTop.tabBar().setVisible(action.isChecked())
- self.fcSettings.setValues(ShowTopTabBar=action.isChecked())
-
-
- def onSplitterMoved(self, pos, index):
- splitter = self.controlById(self.IdSplitter)
- self.fcSettings.setValues(SplitterPos=splitter.saveState())
-
-
- def onTabTopCurrentChanged(self, index):
- tabWidget = self.controlById(self.IdTabTop)
- view = tabWidget.currentWidget()
- self.fcSettings.setValues(LastViewTop=view.fcViewObject.name)
-
-
- def onTabBottomCurrentChanged(self, index):
- tab = self.controlById(self.IdTabBottom)
- view = tab.currentWidget()
- self.fcSettings.setValues(LastViewBottom=view.fcViewObject.name)
-
-#**********************************************************************************
-#
-#**********************************************************************************
-#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 ond by L{ViewWidget}"""
-
- def __init__(self):
- raise NotImplemetedError()
-
- def viewClose(self):
- """called when the view is about to be closed"""
-
- def viewDisplayName(self):
- """should return the user visible name of the view
- @return: (QString)
- """
- raise NotImplemetedError()
-
-
- def viewIcon(self):
- """should return the icon associated to the view
- @return: (QIcon)
- """
- raise NotImplemetedError()
-
- def viewName(self):
- """should return the internally used id of the view
- @return: (str) id
- """
- raise NotImplemetedError()
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = ViewWidget(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
-
-
-
-
Modified: trunk/fclient/src/fclient/impl/Ui_ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/impl/Ui_ViewBrowser.py 2008-07-27 11:29:02 UTC (rev 767)
+++ trunk/fclient/src/fclient/impl/Ui_ViewBrowser.py 2008-07-27 11:31:20 UTC (rev 768)
@@ -976,7 +976,7 @@
import sys
from .Ui_ViewLogger import ViewLoggerWidget
from .MainWindow import MainWindow
- from .Ui_View import ViewWidget
+ from .View import ViewWidget
from .Ui_ViewConnection import ViewConnectionWidget
from .Ui_ViewDownloads import ViewDownloadsWidget
Modified: trunk/fclient/src/fclient/impl/Ui_ViewConnection.py
===================================================================
--- trunk/fclient/src/fclient/impl/Ui_ViewConnection.py 2008-07-27 11:29:02 UTC (rev 767)
+++ trunk/fclient/src/fclient/impl/Ui_ViewConnection.py 2008-07-27 11:31:20 UTC (rev 768)
@@ -295,7 +295,7 @@
#**********************************************************************************
if __name__ == '__main__':
import sys
- from . import Ui_View, Ui_ViewLogger
+ from . import View, Ui_ViewLogger
app = QtGui.QApplication(sys.argv)
w = Ui_View.ViewWidget(None)
Modified: trunk/fclient/src/fclient/impl/Ui_ViewDownloads.py
===================================================================
--- trunk/fclient/src/fclient/impl/Ui_ViewDownloads.py 2008-07-27 11:29:02 UTC (rev 767)
+++ trunk/fclient/src/fclient/impl/Ui_ViewDownloads.py 2008-07-27 11:31:20 UTC (rev 768)
@@ -253,7 +253,7 @@
#**********************************************************************************
if __name__ == '__main__':
import sys
- from . import Ui_View
+ from . import View
from . import Ui_ViewConnection
from . import Ui_ViewLogger
from . import MainWindow
Added: trunk/fclient/src/fclient/impl/View.py
===================================================================
--- trunk/fclient/src/fclient/impl/View.py (rev 0)
+++ trunk/fclient/src/fclient/impl/View.py 2008-07-27 11:31:20 UTC (rev 768)
@@ -0,0 +1,277 @@
+#FIXES
+#***************************************************************************
+# [0001]
+#
+# QTabWidget.closeEvent() does not seem to propagate close events
+# to child widgets
+#
+#
+#***************************************************************************
+from __future__ import absolute_import
+if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
+ import os; __path__ = [os.path.dirname(__file__)]
+
+
+from PyQt4 import QtCore, QtGui
+
+
+from . import config
+from .lib import fcp2
+from .tpls.Ui_ViewWidgetTpl import Ui_ViewWidget
+#**********************************************************************************
+#
+#**********************************************************************************
+class Actions(config.ActionsBase):
+
+ def __init__(self, parent):
+ config.ActionsBase.__init__(self, parent)
+
+ self.action(
+ name='ActionShowTopTabBar',
+ text=self.trUtf8('Show top &tabs'),
+ trigger=parent.onActionShowTabsTop,
+ isCheckable=True,
+ isChecked=True,
+ )
+
+
+class GlobalFeedback(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)
+
+ def setVisible(self, flag):
+ for menu in self.menus:
+ menu.children()[0].setVisible(flag)
+
+
+
+class Settings(config.SettingsBase):
+ _key_ = config.IdViewWidget
+ _settings_ = (
+ ('LastViewTop', 'String', '', config.SettingScopePrivate),
+ ('LastViewBottom', 'String', '', config.SettingScopePrivate),
+ ('SplitterPos', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate),
+ ('ShowTopTabBar', 'Bool', True, config.SettingScopePrivate),
+
+ )
+
+
+class ViewObject(config.ViewObject):
+
+ def __init__(self, parent):
+ config.ViewObject. __init__(self, parent)
+
+ self.name=parent.objectName()
+ self.displayName=self.trUtf8('View')
+ self.icon=QtGui.QIcon()
+
+#***********************************************************************
+#
+#***********************************************************************
+class ViewWidget(QtGui.QWidget, Ui_ViewWidget):
+
+ IdSplitter = 'Splitter'
+ IdTabTop = 'tabTop'
+ IdTabBottom = 'tabBottom'
+
+
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
+ QtGui.QWidget.__init__(self, parent)
+
+ self._isCreated = False
+
+ self.views = {}
+
+ self.setupUi(self)
+ config.ObjectRegistry.register(self)
+ self.fcActions = Actions(self)
+ self.fcSettings = Settings().restore()
+ self.fcViewObject = ViewObject(self)
+ self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
+
+ # setup tab widgets
+ tabWidgetTop = self.controlById(self.IdTabTop)
+ tabWidgetTop.removeTab(0)
+ tabWidgetBottom = self.controlById(self.IdTabBottom)
+ tabWidgetBottom.removeTab(0)
+
+ # setup splitter
+ splitter = self.controlById(self.IdSplitter)
+ splitter.restoreState(self.fcSettings.value('SplitterPos'))
+ self.connect(splitter, QtCore.SIGNAL('splitterMoved(int, int)'), self.onSplitterMoved)
+
+ # setup actions
+ showTopTabBar = self.fcSettings.value('ShowTopTabBar')
+ self.fcActions['ActionShowTopTabBar'].setChecked(showTopTabBar)
+ tabWidgetTop.tabBar().setVisible(showTopTabBar)
+
+
+
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+
+ def _addViews(self, toTop, *views):
+ tabWidget = self.controlById(self.IdTabTop) if toTop else self.controlById(self.IdTabBottom)
+ for view in views:
+ name = view.fcViewObject.name
+ if not name:
+ raise ValueError('view must have a name')
+ if name in self.views:
+ raise ValueError('view with that name is already present: %s' % name)
+ view.setParent(tabWidget)
+ i = tabWidget.addTab(view, view.fcViewObject.icon, view.fcViewObject.displayName)
+ self.views[name] = (tabWidget, view)
+
+ #tab.tabBar().setVisible(tab.count() > 1)
+
+
+ def addBottomViews(self, *views):
+ return self._addViews(False, *views)
+
+
+ def addTopViews(self, *views):
+ return self._addViews(True, *views)
+
+
+ def populateMenu(self, menu):
+ menu.addAction(self.fcActions['ActionShowTopTabBar'])
+ return menu
+
+
+
+ def setCurrentView(self, name):
+ result = self.views.get(name, None)
+ if result is not None:
+ tab, view = result
+ tab.setCurrentWidget(view)
+ return True
+ return False
+
+
+ def viewFromName(self, name):
+ result = self.views.get(name, None)
+ if result is not None:
+ return result[1]
+ return None
+
+ #########################################################
+ ##
+ #########################################################
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
+
+
+ def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
+
+
+ #########################################################
+ ##
+ #########################################################
+ def closeEvent(self, event):
+ for tab, view in self.views.values():
+ view.viewClose()
+
+
+ def showEvent(self, event):
+ if self._isCreated:
+ return
+ self._isCreated = True
+
+ # restore current views
+ tabWidgetTop = self.controlById(self.IdTabTop)
+ lastName = self.fcSettings.value('LastViewTop')
+ self.setCurrentView(lastName)
+
+ tabWidgetBottom = self.controlById(self.IdTabBottom)
+ lastName = self.fcSettings.value('LastViewBottom')
+ self.setCurrentView(lastName)
+
+ # finally connect... not to overwrite settings
+ self.connect(tabWidgetTop, QtCore.SIGNAL('currentChanged(int)'), self.onTabTopCurrentChanged)
+ self.connect(tabWidgetBottom, QtCore.SIGNAL('currentChanged(int)'), self.onTabBottomCurrentChanged)
+
+ #########################################################
+ ##
+ #########################################################
+ def onActionShowTabsTop(self, action):
+ tabWidgetTop = self.controlById(self.IdTabTop)
+ tabWidgetTop.tabBar().setVisible(action.isChecked())
+ self.fcSettings.setValues(ShowTopTabBar=action.isChecked())
+
+
+ def onSplitterMoved(self, pos, index):
+ splitter = self.controlById(self.IdSplitter)
+ self.fcSettings.setValues(SplitterPos=splitter.saveState())
+
+
+ def onTabTopCurrentChanged(self, index):
+ tabWidget = self.controlById(self.IdTabTop)
+ view = tabWidget.currentWidget()
+ self.fcSettings.setValues(LastViewTop=view.fcViewObject.name)
+
+
+ def onTabBottomCurrentChanged(self, index):
+ tab = self.controlById(self.IdTabBottom)
+ view = tab.currentWidget()
+ self.fcSettings.setValues(LastViewBottom=view.fcViewObject.name)
+
+#**********************************************************************************
+#
+#**********************************************************************************
+#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 ond by L{ViewWidget}"""
+
+ def __init__(self):
+ raise NotImplemetedError()
+
+ def viewClose(self):
+ """called when the view is about to be closed"""
+
+ def viewDisplayName(self):
+ """should return the user visible name of the view
+ @return: (QString)
+ """
+ raise NotImplemetedError()
+
+
+ def viewIcon(self):
+ """should return the icon associated to the view
+ @return: (QIcon)
+ """
+ raise NotImplemetedError()
+
+ def viewName(self):
+ """should return the internally used id of the view
+ @return: (str) id
+ """
+ raise NotImplemetedError()
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+
+ app = QtGui.QApplication(sys.argv)
+ w = ViewWidget(None)
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
+
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|