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 <reinhard.muel...@bytewise.at>
properties: 
        branch-nick: forms

   + timestamp: 2010-10-20 20:55:29.381999969 +0200
committer: Reinhard Müller <reinhard.muel...@bytewise.at>
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 reinhard.muel...@bytewise.at-20100426083500-vtmq0qvd7htz02zx
3117 reinhard.muel...@bytewise.at-20100512151744-2jx8tmtop30kl5n0
3118 reinhard.muel...@bytewise.at-20100705094014-ks9yv7b8gs6ychrb
3119 reinhard.muel...@bytewise.at-20100706085143-hyxadj30ayg28jpx
3120 reinhard.muel...@bytewise.at-20100706140804-sn3npws1ykm81ubx
3121 reinhard.muel...@bytewise.at-20100909134008-5p7jq048nkutldse
3122 reinhard.muel...@bytewise.at-20100923144753-e8hthxho7n5mwg9z
3123 reinhard.muel...@bytewise.at-20100929193018-7r3injoy8g28fwm6
3124 reinhard.muel...@bytewise.at-20100930073631-ilf6smgjt6mfvkpz
3125 reinhard.muel...@bytewise.at-20101011191957-yaj9rkqbervc91ac
3126 reinhard.muel...@bytewise.at-20101020084039-jmfxjbctt6vc2usd
3127 reinhard.muel...@bytewise.at-20101020124425-0dpprxsmanmaenty
3128 reinhard.muel...@bytewise.at-20101020124541-zppkmzww1lnsk8x4
3129 reinhard.muel...@bytewise.at-20101020141905-vjg7r3wihnm7mxam
3130 reinhard.muel...@bytewise.at-20101020143045-pf9ywx1s3hdqbsh7
3131 reinhard.muel...@bytewise.at-20101020143328-ctfmr3fpp5quq1eo
3132 reinhard.muel...@bytewise.at-20101020152139-rlllh9m2qn45atcz
3133 reinhard.muel...@bytewise.at-20101020163022-tgnjcv18nzrc5sfw
3134 reinhard.muel...@bytewise.at-20101020165411-krluvclyw61ef9zp

   + 3116 reinhard.muel...@bytewise.at-20100426083500-vtmq0qvd7htz02zx
3117 reinhard.muel...@bytewise.at-20100512151744-2jx8tmtop30kl5n0
3118 reinhard.muel...@bytewise.at-20100705094014-ks9yv7b8gs6ychrb
3119 reinhard.muel...@bytewise.at-20100706085143-hyxadj30ayg28jpx
3120 reinhard.muel...@bytewise.at-20100706140804-sn3npws1ykm81ubx
3121 reinhard.muel...@bytewise.at-20100909134008-5p7jq048nkutldse
3122 reinhard.muel...@bytewise.at-20100923144753-e8hthxho7n5mwg9z
3123 reinhard.muel...@bytewise.at-20100929193018-7r3injoy8g28fwm6
3124 reinhard.muel...@bytewise.at-20100930073631-ilf6smgjt6mfvkpz
3125 reinhard.muel...@bytewise.at-20101011191957-yaj9rkqbervc91ac
3126 reinhard.muel...@bytewise.at-20101020084039-jmfxjbctt6vc2usd
3127 reinhard.muel...@bytewise.at-20101020124425-0dpprxsmanmaenty
3128 reinhard.muel...@bytewise.at-20101020124541-zppkmzww1lnsk8x4
3129 reinhard.muel...@bytewise.at-20101020141905-vjg7r3wihnm7mxam
3130 reinhard.muel...@bytewise.at-20101020143045-pf9ywx1s3hdqbsh7
3131 reinhard.muel...@bytewise.at-20101020143328-ctfmr3fpp5quq1eo
3132 reinhard.muel...@bytewise.at-20101020152139-rlllh9m2qn45atcz
3133 reinhard.muel...@bytewise.at-20101020163022-tgnjcv18nzrc5sfw
3134 reinhard.muel...@bytewise.at-20101020165411-krluvclyw61ef9zp
3135 reinhard.muel...@bytewise.at-20101020185529-pmdkwkm59c1h630f

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       
reinhard.muel...@bytewise.at-20101020143045-pf9ywx1s3hdqbsh7

   + src/GFObjects/GFBlock.py   
reinhard.muel...@bytewise.at-20101020163022-tgnjcv18nzrc5sfw
src/GFObjects/GFField.py        
reinhard.muel...@bytewise.at-20100705094014-ks9yv7b8gs6ychrb
src/GFParser.py reinhard.muel...@bytewise.at-20101020143328-ctfmr3fpp5quq1eo


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
commit-gnue@gnu.org
http://lists.gnu.org/mailman/listinfo/commit-gnue

Reply via email to