[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9338 - in trunk/gnue-forms/src: . GFObjects
From: |
reinhard |
Subject: |
[gnue] r9338 - in trunk/gnue-forms/src: . GFObjects |
Date: |
Fri, 26 Jan 2007 17:11:59 -0600 (CST) |
Author: reinhard
Date: 2007-01-26 17:11:58 -0600 (Fri, 26 Jan 2007)
New Revision: 9338
Modified:
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/GFObjects/GFBlock.py
Log:
Added some methods to trigger namespace necessary to dynamically enable/disable
actions.
issue79 in-progress
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2007-01-26 22:00:32 UTC (rev 9337)
+++ trunk/gnue-forms/src/GFForm.py 2007-01-26 23:11:58 UTC (rev 9338)
@@ -106,6 +106,9 @@
self._currentBlock = None
self._currentEntry = None
+ # Is the form in query mode?
+ self.__in_query_mode = False
+
# Set to true while focus is moving so a record change in
# focusin/focusout triggers doesn't run endEditing and beginEditing
self.__editing_blocked = False
@@ -188,6 +191,7 @@
'previous_block': {'function': self.previous_block},
'next_page': {'function': self.next_page},
'previous_page': {'function': self.previous_page},
+ 'get_focus_block': {'function': self.__trigger_get_focus_block},
# Record navigation
'first_record': {'function': self.first_record},
@@ -206,10 +210,12 @@
'copy_query': {'function': self.copy_query},
'cancel_query': {'function': self.cancel_query},
'execute_query': {'function': self.execute_query},
+ 'in_query_mode': {'function': self.in_query_mode},
# Transactions
'commit': {'function': self.commit, 'global': True},
'rollback': {'function': self.rollback, 'global': True},
+ 'is_saved': {'function': self.is_saved},
# Other stuff
'toggle_insert_mode': {'function': self.toggle_insert_mode},
@@ -1055,13 +1061,12 @@
Returns the editing mode of the current record
@return: 'query', 'new' or 'edit'
"""
- if self._currentBlock is not None:
- if self._currentBlock.mode == 'query':
- return 'query'
- elif self._currentBlock.get_record_status() in [None, 'empty']:
- return 'new'
- else:
- return 'edit'
+ if self.__in_query_mode:
+ return 'query'
+ elif self._currentBlock is not None \
+ and self._currentBlock.get_record_status() \
+ not in [None, 'empty', 'new']:
+ return 'edit'
else:
return 'new'
@@ -1196,6 +1201,14 @@
# -------------------------------------------------------------------------
+ def __trigger_get_focus_block(self):
+ if self._currentBlock is not None:
+ return self._currentBlock.get_namespace_object()
+ else:
+ return None
+
+ # -------------------------------------------------------------------------
+
def get_focus_object(self):
"""
Return the block that currently has the focus.
@@ -1351,6 +1364,8 @@
for block in self._logic._blockList:
block.init_query()
+ self.__in_query_mode = True
+
self.status_message(u_('Enter your query criteria.'))
finally:
self.beginEditing()
@@ -1375,6 +1390,8 @@
for block in self._logic._blockList:
block.copy_query()
+ self.__in_query_mode = True
+
self.status_message(u_('Enter your query criteria.'))
finally:
self.beginEditing()
@@ -1389,6 +1406,8 @@
self.endEditing()
try:
+ self.__in_query_mode = False
+
for block in self._logic._blockList:
block.cancel_query()
@@ -1417,6 +1436,8 @@
self.__rollback_all_connections()
try:
+ self.__in_query_mode = False
+
self._currentBlock.execute_query()
except DBError:
@@ -1434,7 +1455,15 @@
# self.beginEditing() # happens via _focus_in()
+ # -------------------------------------------------------------------------
+ def in_query_mode(self):
+ """
+ Return True if the form is in query mode.
+ """
+ return self.__in_query_mode
+
+
# -------------------------------------------------------------------------
# Commit all pending changes
# -------------------------------------------------------------------------
@@ -1586,7 +1615,7 @@
# Check all blocks in the form whether they are saved (committed) or not.
# -------------------------------------------------------------------------
- def isSaved(self):
+ def is_saved(self):
"""
Checks all block in the form whether they are saved (committed) or not.
@return: boolean, True if all the blocks are committed.
@@ -1739,12 +1768,11 @@
else:
dispatchEvent('cannot' + event)
- if self._currentBlock is not None \
- and self._currentBlock.mode == 'query':
+ if self.in_query_mode():
dispatchEvent('cannotCOMMIT')
dispatchEvent('cannotROLLBACK')
else:
- if not self.isSaved():
+ if not self.is_saved():
dispatchEvent('canCOMMIT')
else:
dispatchEvent('cannotCOMMIT')
@@ -1886,7 +1914,7 @@
def _must_save(self):
- if self.isSaved():
+ if self.is_saved():
return True
answer = self.show_message(message=u_("Save changes?"),
Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py 2007-01-26 22:00:32 UTC (rev
9337)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2007-01-26 23:11:58 UTC (rev
9338)
@@ -170,6 +170,8 @@
# Record status
'get_record_status': {'function': self.get_record_status},
'is_pending': {'function': self.is_pending},
+ 'get_possible_operations':
+ {'function': self.get_possible_operations},
# Record navigation
'first_record': {'function': self.first_record},
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9338 - in trunk/gnue-forms/src: . GFObjects,
reinhard <=