# HG changeset patch # User cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1237677969 0 # Node ID c62ed457e954bd8245343386f15399dee9305a52 # Parent 664d7c2530e4bb1a293839475723a20409e239be Case-insensitive multi-word search diff -r 664d7c2530e4 -r c62ed457e954 clients/editor/plugins/objectselector.py --- 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)