Author: reinhard Date: 2010-10-20 13:56:02 -0500 (Wed, 20 Oct 2010) New Revision: 10213
Modified: trunk/gnue-forms/ trunk/gnue-forms/src/GFObjects/GFBlock.py trunk/gnue-forms/src/GFObjects/GFField.py trunk/gnue-forms/src/GFParser.py Log: Added autosearch support. Property changes on: trunk/gnue-forms ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2010-10-20 18:54:11.900000095 +0200 committer: Reinhard Müller <[email protected]> properties: branch-nick: forms + timestamp: 2010-10-20 20:55:29.381999969 +0200 committer: Reinhard Müller <[email protected]> properties: branch-nick: forms Name: bzr:file-ids - src/input/displayHandlers/Image.py 7...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2Finput%2FdisplayHandlers%2FImage.py src/uidrivers/qt3/widgets/image.py 8...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2Fuidrivers%2Fqt3%2Fwidgets%2Fimage.py src/uidrivers/qt4/widgets/image.py 9...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2Fuidrivers%2Fqt4%2Fwidgets%2Fimage.py src/uidrivers/wx/widgets/image.py 10...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2Fuidrivers%2Fwx%2Fwidgets%2Fimage.py + src/GFObjects/GFBlock.py 1...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2FGFObjects%2FGFBlock.py src/GFObjects/GFField.py 1...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2FGFObjects%2FGFField.py src/GFParser.py 1...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2FGFParser.py Name: bzr:revision-id:v4 - 3116 [email protected] 3117 [email protected] 3118 [email protected] 3119 [email protected] 3120 [email protected] 3121 [email protected] 3122 [email protected] 3123 [email protected] 3124 [email protected] 3125 [email protected] 3126 [email protected] 3127 [email protected] 3128 [email protected] 3129 [email protected] 3130 [email protected] 3131 [email protected] 3132 [email protected] 3133 [email protected] 3134 [email protected] + 3116 [email protected] 3117 [email protected] 3118 [email protected] 3119 [email protected] 3120 [email protected] 3121 [email protected] 3122 [email protected] 3123 [email protected] 3124 [email protected] 3125 [email protected] 3126 [email protected] 3127 [email protected] 3128 [email protected] 3129 [email protected] 3130 [email protected] 3131 [email protected] 3132 [email protected] 3133 [email protected] 3134 [email protected] 3135 [email protected] Name: bzr:text-parents - src/input/displayHandlers/Image.py svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:9956 src/uidrivers/qt3/widgets/image.py svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:10117 src/uidrivers/qt4/widgets/image.py svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:10117 src/uidrivers/wx/widgets/image.py [email protected] + src/GFObjects/GFBlock.py [email protected] src/GFObjects/GFField.py [email protected] src/GFParser.py [email protected] Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py =================================================================== --- trunk/gnue-forms/src/GFObjects/GFBlock.py 2010-10-20 18:55:58 UTC (rev 10212) +++ trunk/gnue-forms/src/GFObjects/GFBlock.py 2010-10-20 18:56:02 UTC (rev 10213) @@ -884,13 +884,13 @@ """ if self._dataSourceLink.type == 'unbound': - return + return True if self.mode == 'query': return False if self.__resultset is None: - return + return False # First, convert the fieldname/value pairs to column/value pairs. cond = {} Modified: trunk/gnue-forms/src/GFObjects/GFField.py =================================================================== --- trunk/gnue-forms/src/GFObjects/GFField.py 2010-10-20 18:55:58 UTC (rev 10212) +++ trunk/gnue-forms/src/GFObjects/GFField.py 2010-10-20 18:56:02 UTC (rev 10213) @@ -76,9 +76,10 @@ self.__lookup_dict_reverse = {} # {user_value: db_value} self.lookup_ignorecase = True - # Autoquery support + # Autoquery/autosearch support self.__autoquery_value = None - self.__in_autoquery = False + self.__autosearch_value = None + self.__in_validate = False # These are only here because "rows" and "gap" is passed from GFBlock # through GFField to GFEntry. @@ -512,13 +513,19 @@ # If this is an autoquery field, don't pass the value to the block, but # save it for later. - if (self.autoquery == 'Y') \ - or (self.autoquery == 'new' \ - and self._block.get_record_status() == 'empty'): - if not self.__in_autoquery: - self.__autoquery_value = value - return + if self._block.mode == 'normal': + if (self.autoquery == 'Y') \ + or (self.autoquery == 'new' \ + and self._block.get_record_status() == 'empty'): + if not self.__in_validate: + self.__autoquery_value = value + return + if self.autosearch: + if not self.__in_validate: + self.__autosearch_value = value + return + self._block.set_value(self, value) @@ -586,14 +593,19 @@ will be prevented. """ + # When autoquery/autoserach do the set_filter/search_record, then the + # field is changed and validate is called recursively. + if self.__in_validate: + return + if self._block.mode == 'normal': self.processTrigger('PRE-FOCUSOUT', ignoreAbort=False) - if self.__autoquery_value is not None and not self.__in_autoquery: + if self.__autoquery_value is not None and not self.__in_validate: if (self.autoquery == 'Y') \ or (self.autoquery == 'new' \ and self._block.get_record_status() == 'empty'): - self.__in_autoquery = True + self.__in_validate = True try: self._block.set_filter({self.field: self.__autoquery_value}) if self._block.get_record_status() == 'empty': @@ -601,8 +613,18 @@ self.__set_value(self.__autoquery_value) self.__autoquery_value = None finally: - self.__in_autoquery = False + self.__in_validate = False + if self.autosearch and self.__autosearch_value is not None: + self.__in_validate = True + try: + if not self._block.search_record( + **{self.field: self.__autosearch_value}): + self._block.new_record() + self.__set_value(self.__autosearch_value) + finally: + self.__in_validate = False + # ------------------------------------------------------------------------- def focus_out(self): Modified: trunk/gnue-forms/src/GFParser.py =================================================================== --- trunk/gnue-forms/src/GFParser.py 2010-10-20 18:55:58 UTC (rev 10212) +++ trunk/gnue-forms/src/GFParser.py 2010-10-20 18:56:02 UTC (rev 10213) @@ -682,6 +682,15 @@ 'new': {'Label': _('Empty forms only')} }, 'Typecast': GTypecast.text, 'Default': 'N' }, + 'autosearch': { + 'Description': 'If {Y} then any changes in this field will ' + 'cause the form to automatically jump to the ' + 'first matching record within the current ' + 'result set, or create a new record if no ' + 'record matches.', + 'Label': _('Automatic Search'), + 'Typecast': GTypecast.boolean, + 'Default': False}, 'ltrim': { 'Label': _('Trim left spaces'), 'Description': 'Trim extraneous space at ' _______________________________________________ commit-gnue mailing list [email protected] http://lists.gnu.org/mailman/listinfo/commit-gnue
