Mercurial > fife-parpg
changeset 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 | f10a35efebc0 |
files | clients/editor/plugins/objectselector.py |
diffstat | 1 files changed, 20 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/clients/editor/plugins/objectselector.py Sat Mar 21 22:27:01 2009 +0000 +++ b/clients/editor/plugins/objectselector.py Sat Mar 21 23:26:09 2009 +0000 @@ -203,13 +203,26 @@ self.search(self._searchfield.text) def search(self, str): - namespaces = self.engine.getModel().getNamespaces() - results = [] - for namesp in namespaces: - objects = self.engine.getModel().getObjects(namesp) - for obj in objects: - if obj.getId().find(str) > -1: - results.append(obj) + results = [] + + # Format search terms + terms = [term.lower() for term in str.split()] + + # Search + if len(terms) > 0: + namespaces = self.engine.getModel().getNamespaces() + for namesp in namespaces: + objects = self.engine.getModel().getObjects(namesp) + for obj in objects: + doAppend = True + for term in terms: + if obj.getId().lower().find(term) < 0: + doAppend = False + break + if doAppend: + results.append(obj) + else: + results = None if self.mode == 'list': self.fillTextList(results)