SF.net SVN: fclient:[796] trunk/fclient/src/fclient/impl/lib/qt4ex/ dlgpreferences.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-28 12:18:13
|
Revision: 796
http://fclient.svn.sourceforge.net/fclient/?rev=796&view=rev
Author: jUrner
Date: 2008-07-28 12:18:20 +0000 (Mon, 28 Jul 2008)
Log Message:
-----------
some fixes. dlg still needs rework
Modified Paths:
--------------
trunk/fclient/src/fclient/impl/lib/qt4ex/dlgpreferences.py
Modified: trunk/fclient/src/fclient/impl/lib/qt4ex/dlgpreferences.py
===================================================================
--- trunk/fclient/src/fclient/impl/lib/qt4ex/dlgpreferences.py 2008-07-28 12:17:35 UTC (rev 795)
+++ trunk/fclient/src/fclient/impl/lib/qt4ex/dlgpreferences.py 2008-07-28 12:18:20 UTC (rev 796)
@@ -1,8 +1,4 @@
-"""Preferences dialog"""
-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__)]
-
+#****************************************************************************
# TODO:
#
# x. how to set some reasonable initial size? Mabe split the page population
@@ -13,8 +9,20 @@
# page.initialize()
# page.setVisible(flag)
#
+# x. apply and resoreDefaults behaviour is not well designed
+# apply: aply changes on all pages. isDirty is for all pages
+# restoreDfaults: restore defaults of the current page
+# x. should restoreDefaults be disabled when already restored?
+# x. docs are outdated
+# x. UUID is probably not a good idea. use objectName() instead
+#
+#*******************************************************************************
+"""Preferences dialog"""
+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__)]
import sys, os
import cPickle
@@ -74,7 +82,6 @@
'children': [],
'isDirty': False,
'lastSelectedChildPage': None,
- 'parent': None,
'userData': None,
'uuid': uuid,
}
@@ -84,7 +91,7 @@
children = self._pageData['children']
for i in others:
children.append(i)
- i._pageData['parent'] = self
+ i.setParent(self)
return self
def canApply(self):
@@ -121,12 +128,6 @@
"""
return True
- def doOk(self):
- """Should apply changes
- @return: True on success, False otherwise
- """
- return True
-
def doRestoreDefaults(self):
"""Should restore defaults
@return: True on success, False otherwise
@@ -143,6 +144,11 @@
"""Should return a flag indicating if the page has unsaved changes"""
return self._pageData['isDirty']
+ #TODO: looks shitty
+ def isRoot(self):
+ """"""
+ return not isinstance(self.parent(), self.__class__)
+
def lastSelectedChildPage(self):
"""Returns the uuid of the most recently selected child page of the current page"""
return self._pageData['lastSelectedChildPage']
@@ -154,10 +160,6 @@
if page.uuid() == uuid:
return page
- def parent(self):
- """Returns the parent page of the page"""
- return self._pageData['parent']
-
def setDirty(self, flag):
"""Sets or clears the dirty flag"""
self._pageData['isDirty'] = bool(flag)
@@ -231,7 +233,7 @@
MethodNameApply = 'doApply'
- def __init__(self, ui, cb, pageContainer, buttonBox, maxPageDepth=None, pages=None):
+ def __init__(self, parent, cb, pageContainer, buttonBox, maxPageDepth=None, pages=None):
"""
@param ui: (QDialog) parent
@param cb: callback
@@ -260,7 +262,7 @@
return = will be passed in the next call of PageAdd to all emidiate child pages
"""
- QtCore.QObject.__init__(self, ui)
+ QtCore.QObject.__init__(self, parent)
self.buttonBox = buttonBox
self.cb = cb
@@ -268,8 +270,7 @@
self.lastSelectedPage = None
self.pageContainer = pageContainer
self.pages = pages
- self.ui = ui
-
+
# buttons handld by the controler
self.buttonBoxButtons = {
QtGui.QDialogButtonBox.Apply: 'Apply',
@@ -288,10 +289,11 @@
# dump sections and pages to tree
if pages is not None:
-
+
# drop root item
enum = iter(pages.walk(report=True))
flag, root = enum.next()
+ root.setParent(self)
# dump items
parent = self.cb(self.PageQueryParent, None, None)
@@ -316,9 +318,7 @@
self.onStandardButtonClicked
)
self.adjustStandardButtons(None)
-
-
-
+
################################################
## slots
################################################
@@ -332,14 +332,16 @@
if self.lastSelectedPage is None:
return
- page = self.lastSelectedPage[0]
+ page = self.currentPage()
standardButton = self.buttonBox.standardButton(button)
standardButtonName = self.buttonBoxButtons.get(standardButton, None)
+ if standardButtonName == 'Ok': # handled on DlgPreferences.accept()
+ return
if standardButtonName is not None:
methodName = self.PrefixCapabilityApply + standardButtonName
method = getattr(page, methodName, None)
if method is None:
- raise valueError('Pages must prvide a "%s" method' % methodName)
+ raise valueError('Pages must provide a "%s" method' % methodName)
if method():
if standardButton == QtGui.QDialogButtonBox.Apply:
page.setDirty(False)
@@ -389,7 +391,6 @@
method()
-
def currentPage(self):
"""Returns the currently displayed page or None"""
if self.lastSelectedPage is not None:
@@ -433,7 +434,7 @@
)
# inform parent about changes
- if page.parent() is not None:
+ if not page.isRoot():
page.parent().setLastSelectedChildPage(page.uuid())
# enshure enough space is available for the widget
@@ -713,6 +714,8 @@
while True:
out.prepend(page.displayName() + '/')
#out.append(page.displayName())
+ if page.isRoot():
+ break
page = page.parent()
if page.parent() is None:
break
@@ -777,8 +780,7 @@
def __init__(self, *args):
Page.__init__(self, *args)
self._widget = None
- self.setDirty(True)
-
+
def displayName(self): return self.uuid()
def canApply(self): return True
def canHelp(self): return True
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|