Mercurial > fife-parpg
comparison clients/editor/plugins/objectselector.py @ 231:c62ed457e954
Case-insensitive multi-word search
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 21 Mar 2009 23:26:09 +0000 |
parents | 664d7c2530e4 |
children | 45c63a621366 |
comparison
equal
deleted
inserted
replaced
230:664d7c2530e4 | 231:c62ed457e954 |
---|---|
201 | 201 |
202 def _search(self): | 202 def _search(self): |
203 self.search(self._searchfield.text) | 203 self.search(self._searchfield.text) |
204 | 204 |
205 def search(self, str): | 205 def search(self, str): |
206 namespaces = self.engine.getModel().getNamespaces() | 206 results = [] |
207 results = [] | 207 |
208 for namesp in namespaces: | 208 # Format search terms |
209 objects = self.engine.getModel().getObjects(namesp) | 209 terms = [term.lower() for term in str.split()] |
210 for obj in objects: | 210 |
211 if obj.getId().find(str) > -1: | 211 # Search |
212 results.append(obj) | 212 if len(terms) > 0: |
213 namespaces = self.engine.getModel().getNamespaces() | |
214 for namesp in namespaces: | |
215 objects = self.engine.getModel().getObjects(namesp) | |
216 for obj in objects: | |
217 doAppend = True | |
218 for term in terms: | |
219 if obj.getId().lower().find(term) < 0: | |
220 doAppend = False | |
221 break | |
222 if doAppend: | |
223 results.append(obj) | |
224 else: | |
225 results = None | |
213 | 226 |
214 if self.mode == 'list': | 227 if self.mode == 'list': |
215 self.fillTextList(results) | 228 self.fillTextList(results) |
216 elif self.mode == 'preview': | 229 elif self.mode == 'preview': |
217 self.fillPreviewList(results) | 230 self.fillPreviewList(results) |