* src/DataViews/_PersonView.py: exact search for gender (bug #633)

* src/DisplayModels/_PeopleModel.py: exact search for gender (bug #633)
	* src/Filters/_SearchFilter.py: exact search for gender (bug #633)
	* src/Filters/__init__.py: export ExactSearchFilter


svn: r7817
This commit is contained in:
Don Allingham 2006-12-19 04:47:07 +00:00
parent 3c73746665
commit 6183354ba4
5 changed files with 28 additions and 5 deletions

View File

@ -1,4 +1,8 @@
2006-12-18 Don Allingham <don@gramps-project.org> 2006-12-18 Don Allingham <don@gramps-project.org>
* src/DataViews/_PersonView.py: exact search for gender (bug #633)
* src/DisplayModels/_PeopleModel.py: exact search for gender (bug #633)
* src/Filters/_SearchFilter.py: exact search for gender (bug #633)
* src/Filters/__init__.py: export ExactSearchFilter
* src/DataViews/_EventView.py: disable items with readonly db (bug #771) * src/DataViews/_EventView.py: disable items with readonly db (bug #771)
* src/DataViews/_PersonView.py: disable items with readonly db (bug #771) * src/DataViews/_PersonView.py: disable items with readonly db (bug #771)
* src/DataViews/_RelationView.py: disable items with readonly db (bug #771) * src/DataViews/_RelationView.py: disable items with readonly db (bug #771)

View File

@ -721,7 +721,12 @@ class PersonView(PageView.PersonNavView):
else: else:
col,text,inv = self.search_bar.get_value() col,text,inv = self.search_bar.get_value()
func = lambda x: self.model.on_get_value(x, col) or u"" func = lambda x: self.model.on_get_value(x, col) or u""
data_filter = SearchFilter(func, text, inv) print col, PeopleModel.PeopleModel._GENDER_COL
if col == PeopleModel.PeopleModel._GENDER_COL:
data_filter = ExactSearchFilter(func, text, inv)
else:
data_filter = SearchFilter(func, text, inv)
print data_filter
self.model.clear_cache() self.model.clear_cache()
for node in handle_list: for node in handle_list:

View File

@ -65,7 +65,7 @@ import DateHandler
import ToolTips import ToolTips
import GrampsLocale import GrampsLocale
import Config import Config
from Filters import SearchFilter from Filters import SearchFilter, ExactSearchFilter
from Lru import LRU from Lru import LRU
_CACHE_SIZE = 250 _CACHE_SIZE = 250
@ -169,7 +169,12 @@ class PeopleModel(gtk.GenericTreeModel):
text = filter_info[1][1] text = filter_info[1][1]
inv = filter_info[1][2] inv = filter_info[1][2]
func = lambda x: self.on_get_value(x, col) or u"" func = lambda x: self.on_get_value(x, col) or u""
data_filter = SearchFilter(func, text, inv)
if col == self._GENDER_COL:
data_filter = ExactSearchFilter(func, text, inv)
else:
data_filter = SearchFilter(func, text, inv)
self._build_data = self._build_search_sub self._build_data = self._build_search_sub
else: else:
data_filter = filter_info[1] data_filter = filter_info[1]

View File

@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id:$ # $Id$
""" """
Package providing filtering framework for GRAMPS. Package providing filtering framework for GRAMPS.
@ -32,4 +32,13 @@ class SearchFilter:
def match(self, handle): def match(self, handle):
return self.invert ^ (self.func(handle).upper().find(self.text) != -1) return self.invert ^ (self.func(handle).upper().find(self.text) != -1)
class ExactSearchFilter(SearchFilter):
def __init__(self, func, text, invert):
self.func = func
self.text = text.upper()
self.invert = invert
def match(self, handle):
return self.invert ^ (self.func(handle).upper() == self.text.strip())

View File

@ -54,4 +54,4 @@ from _FilterComboBox import FilterComboBox
from _FilterMenu import build_filter_menu, build_filter_model from _FilterMenu import build_filter_menu, build_filter_model
from _FilterStore import FilterStore from _FilterStore import FilterStore
from _SearchBar import SearchBar from _SearchBar import SearchBar
from _SearchFilter import SearchFilter from _SearchFilter import SearchFilter, ExactSearchFilter