inverted searches
svn: r6611
This commit is contained in:
parent
4f2b19a733
commit
374f689b8c
@ -1,3 +1,11 @@
|
||||
2006-05-10 Don Allingham <don@gramps-project.org>
|
||||
* src/DataViews/_PersonView.py: support for inverted searchs
|
||||
* src/PeopleModel.py: support for inverted searchs
|
||||
* src/DisplayModel.py: support for inverted searchs
|
||||
* src/PageView.py: support for inverted searchs, correct col index
|
||||
* src/Filters/_SearchBar.py: support for inverted searchs
|
||||
* src/Filters/_SearchFilter.py: support for inverted searchs
|
||||
|
||||
2006-05-10 Alex Roitman <shura@gramps-project.org>
|
||||
* src/GrampsDb/_ReadGedcom.py (func_person_attr): Typos.
|
||||
|
||||
@ -7,7 +15,7 @@
|
||||
* src/DisplayModels.py: handle search filter
|
||||
* src/PageView.py: search bar support
|
||||
* src/Filters/_SearchBar.py: remove SearchFilter to separate file,
|
||||
fix status bar message
|
||||
fix status bar message, improved buttons.
|
||||
* src/Filters/_SearchFilter.py: added
|
||||
* src/Filters/__init__.py: added SearchBar
|
||||
|
||||
|
@ -333,7 +333,6 @@ class PersonView(PageView.PersonNavView):
|
||||
db.connect('person-delete', self.person_removed)
|
||||
db.connect('person-rebuild', self.build_tree)
|
||||
self.build_tree()
|
||||
#self.search_bar.apply_filter()
|
||||
self.goto_active_person()
|
||||
self.bookmarks.update_bookmarks(db.get_bookmarks())
|
||||
if self.active:
|
||||
@ -399,11 +398,11 @@ class PersonView(PageView.PersonNavView):
|
||||
"""
|
||||
|
||||
cols = []
|
||||
cols.append(_("Name"))
|
||||
cols.append((_("Name"),0))
|
||||
for pair in self.dbstate.db.get_person_column_order():
|
||||
if not pair[0]:
|
||||
continue
|
||||
cols.append(column_names[pair[1]])
|
||||
cols.append((column_names[pair[1]],pair[1]))
|
||||
|
||||
self.search_bar.setup_filter(cols)
|
||||
|
||||
@ -415,7 +414,7 @@ class PersonView(PageView.PersonNavView):
|
||||
if self.active:
|
||||
|
||||
if Config.get(Config.FILTER):
|
||||
search = (0, '')
|
||||
search = (0, '', False)
|
||||
else:
|
||||
search = self.search_bar.get_value()
|
||||
|
||||
|
@ -81,8 +81,9 @@ class BaseModel(gtk.GenericTreeModel):
|
||||
if search:
|
||||
col = search[0]
|
||||
text = search[1]
|
||||
func = lambda x: self.on_get_value(x, col)
|
||||
self.search = SearchFilter(func, text)
|
||||
inv = search[2]
|
||||
func = lambda x: self.on_get_value(x, col) or u""
|
||||
self.search = SearchFilter(func, text, inv)
|
||||
else:
|
||||
self.search = None
|
||||
|
||||
|
@ -49,6 +49,7 @@ class SearchBar:
|
||||
self.filterbar = gtk.HBox()
|
||||
self.filterbar.set_spacing(4)
|
||||
self.filter_list = gtk.ComboBox()
|
||||
self.filter_list.connect('changed', self.filter_changed)
|
||||
|
||||
self.filter_text = gtk.Entry()
|
||||
self.filter_text.connect('key-press-event',self.key_press)
|
||||
@ -69,20 +70,34 @@ class SearchBar:
|
||||
|
||||
return self.filterbar
|
||||
|
||||
def setup_filter( self, column_names ):
|
||||
def setup_filter( self, column_data ):
|
||||
old_value = self.filter_list.get_active()
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
self.filter_list.clear()
|
||||
self.filter_list.pack_start(cell,True)
|
||||
self.filter_list.add_attribute(cell,'text',0)
|
||||
|
||||
self.filter_model = gtk.ListStore(str)
|
||||
|
||||
for col in column_names:
|
||||
rule = _("Search %s") % col
|
||||
self.filter_model.append(row=[rule])
|
||||
self.filter_model = gtk.ListStore(str, int, bool)
|
||||
|
||||
maxval = 0
|
||||
for col,index in column_data:
|
||||
rule = _("%s contains") % col
|
||||
self.filter_model.append(row=[rule,index,False])
|
||||
maxval += 1
|
||||
rule = _("%s does not contain") % col
|
||||
self.filter_model.append(row=[rule,index,True])
|
||||
maxval += 1
|
||||
|
||||
self.filter_list.set_model(self.filter_model)
|
||||
self.filter_list.set_active(0)
|
||||
if old_value == -1 or old_value >= maxval:
|
||||
self.filter_list.set_active(0)
|
||||
else:
|
||||
self.filter_list.set_active(old_value)
|
||||
|
||||
def filter_changed(self, obj):
|
||||
self.filter_button.set_sensitive(True)
|
||||
self.clear_button.set_sensitive(True)
|
||||
|
||||
def text_changed(self, obj):
|
||||
text = obj.get_text()
|
||||
@ -112,8 +127,10 @@ class SearchBar:
|
||||
|
||||
def get_value(self):
|
||||
text = self.filter_text.get_text().strip()
|
||||
index = self.filter_list.get_active()
|
||||
return (index, text)
|
||||
node = self.filter_list.get_active_iter()
|
||||
index = self.filter_model.get_value(node,1)
|
||||
inv = self.filter_model.get_value(node,2)
|
||||
return (index, text, inv)
|
||||
|
||||
def apply_filter(self,current_model=None):
|
||||
self.apply_text = self.filter_text.get_text()
|
||||
|
@ -25,10 +25,11 @@ Package providing filtering framework for GRAMPS.
|
||||
"""
|
||||
|
||||
class SearchFilter:
|
||||
def __init__(self, func, text):
|
||||
def __init__(self, func, text, invert):
|
||||
self.func = func
|
||||
self.text = text.upper()
|
||||
self.invert = invert
|
||||
|
||||
def match(self, handle):
|
||||
return self.func(handle).upper().find(self.text) != -1
|
||||
return self.invert ^ (self.func(handle).upper().find(self.text) != -1)
|
||||
|
||||
|
@ -534,7 +534,7 @@ class ListView(BookMarkView):
|
||||
"""
|
||||
cols = []
|
||||
for pair in [pair for pair in self.column_order() if pair[0]]:
|
||||
cols.append(self.colinfo[pair[1]])
|
||||
cols.append((self.colinfo[pair[1]],pair[1]))
|
||||
self.search_bar.setup_filter(cols)
|
||||
|
||||
def goto_handle(self, handle):
|
||||
@ -570,7 +570,7 @@ class ListView(BookMarkView):
|
||||
handle = self.first_selected()
|
||||
|
||||
if Config.get(Config.FILTER):
|
||||
search = (0, '')
|
||||
search = (0, '', False)
|
||||
else:
|
||||
search = self.search_bar.get_value()
|
||||
|
||||
|
@ -151,8 +151,9 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
if search:
|
||||
col = search[0]
|
||||
text = search[1]
|
||||
func = lambda x: self.on_get_value(x, col)
|
||||
data_filter = SearchFilter(func, text)
|
||||
inv = search[2]
|
||||
func = lambda x: self.on_get_value(x, col) or u""
|
||||
data_filter = SearchFilter(func, text, inv)
|
||||
self.rebuild_data(data_filter, skip)
|
||||
|
||||
def rebuild_data(self, data_filter=None, skip=[]):
|
||||
|
Loading…
Reference in New Issue
Block a user