* src/FilterEditor/_FilterEditor.py (__init__): Remove unneeded
argument, namespace is enough to get the filter class via factory; (add_new_filter): Use factory; (get_all_handles): Get handles for any object type. * src/FilterEditor/_ShowResults.py (get_name_id): Add method to return name and id for different object types; (sort_val_from_handle): Support different object types. (__init__): Accept namespace as an argument. * src/Filters/__init__.py: Do not expose GenericFamilyFilter; expose GenericFilterFactory instead. * src/Filters/_FamilySidebarFilter.py (GenericFamilyFilter): Use factory. svn: r7122
This commit is contained in:
parent
b7ddf09cba
commit
d265fadc1f
12
ChangeLog
12
ChangeLog
@ -1,4 +1,16 @@
|
|||||||
2006-08-04 Alex Roitman <shura@gramps-project.org>
|
2006-08-04 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* src/FilterEditor/_FilterEditor.py (__init__): Remove unneeded
|
||||||
|
argument, namespace is enough to get the filter class via factory;
|
||||||
|
(add_new_filter): Use factory; (get_all_handles): Get handles for
|
||||||
|
any object type.
|
||||||
|
* src/FilterEditor/_ShowResults.py (get_name_id): Add method to
|
||||||
|
return name and id for different object types;
|
||||||
|
(sort_val_from_handle): Support different object types.
|
||||||
|
(__init__): Accept namespace as an argument.
|
||||||
|
* src/Filters/__init__.py: Do not expose GenericFamilyFilter;
|
||||||
|
expose GenericFilterFactory instead.
|
||||||
|
* src/Filters/_FamilySidebarFilter.py (GenericFamilyFilter): Use
|
||||||
|
factory.
|
||||||
* src/FilterEditor/_EditRule.py (MyID.name_from_gramps_id): Remove
|
* src/FilterEditor/_EditRule.py (MyID.name_from_gramps_id): Remove
|
||||||
debugginb output.
|
debugginb output.
|
||||||
* src/DataViews/_MediaView.py (row_change): Work around older pygtk.
|
* src/DataViews/_MediaView.py (row_change): Work around older pygtk.
|
||||||
|
@ -54,7 +54,7 @@ import GrampsDisplay
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import const
|
import const
|
||||||
from Filters import GenericFilter, FilterList, \
|
from Filters import GenericFilterFactory, FilterList, \
|
||||||
reload_custom_filters, reload_system_filters
|
reload_custom_filters, reload_system_filters
|
||||||
import ListModel
|
import ListModel
|
||||||
import ManagedWindow
|
import ManagedWindow
|
||||||
@ -65,11 +65,10 @@ import ManagedWindow
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class FilterEditor(ManagedWindow.ManagedWindow):
|
class FilterEditor(ManagedWindow.ManagedWindow):
|
||||||
def __init__(self, space, filterdb, dbstate, uistate, ftype=GenericFilter):
|
def __init__(self, space, filterdb, dbstate, uistate):
|
||||||
|
|
||||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [],
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [],
|
||||||
FilterEditor)
|
FilterEditor)
|
||||||
self.ftype = ftype
|
|
||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.db = dbstate.db
|
self.db = dbstate.db
|
||||||
self.filterdb = FilterList(filterdb)
|
self.filterdb = FilterList(filterdb)
|
||||||
@ -138,7 +137,7 @@ class FilterEditor(ManagedWindow.ManagedWindow):
|
|||||||
def add_new_filter(self,obj):
|
def add_new_filter(self,obj):
|
||||||
from _EditFilter import EditFilter
|
from _EditFilter import EditFilter
|
||||||
|
|
||||||
the_filter = self.ftype()
|
the_filter = GenericFilterFactory(self.space)()
|
||||||
EditFilter(self.space, self.dbstate, self.uistate, self.track,
|
EditFilter(self.space, self.dbstate, self.uistate, self.track,
|
||||||
the_filter, self.filterdb, self.draw_filters)
|
the_filter, self.filterdb, self.draw_filters)
|
||||||
|
|
||||||
@ -157,10 +156,9 @@ class FilterEditor(ManagedWindow.ManagedWindow):
|
|||||||
from _ShowResults import ShowResults
|
from _ShowResults import ShowResults
|
||||||
|
|
||||||
filt = self.clist.get_object(node)
|
filt = self.clist.get_object(node)
|
||||||
handle_list = filt.apply(
|
handle_list = filt.apply(self.db,self.get_all_handles())
|
||||||
self.db, self.db.get_person_handles(sort_handles=False))
|
|
||||||
ShowResults(self.db, self.uistate, self.track, handle_list,
|
ShowResults(self.db, self.uistate, self.track, handle_list,
|
||||||
filt.get_name())
|
filt.get_name(),self.space)
|
||||||
|
|
||||||
def delete_filter(self,obj):
|
def delete_filter(self,obj):
|
||||||
store,node = self.clist.get_selected()
|
store,node = self.clist.get_selected()
|
||||||
@ -169,3 +167,8 @@ class FilterEditor(ManagedWindow.ManagedWindow):
|
|||||||
self.filterdb.get_filters(self.space).remove(gfilter)
|
self.filterdb.get_filters(self.space).remove(gfilter)
|
||||||
self.draw_filters()
|
self.draw_filters()
|
||||||
|
|
||||||
|
def get_all_handles(self):
|
||||||
|
if self.space == 'Person':
|
||||||
|
return self.db.get_person_handles(sort_handles=False)
|
||||||
|
elif self.space == 'Family':
|
||||||
|
return self.db.get_family_handles()
|
||||||
|
@ -56,7 +56,8 @@ import gtk
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import const
|
import const
|
||||||
import ManagedWindow
|
import ManagedWindow
|
||||||
import NameDisplay
|
from NameDisplay import displayer as _nd
|
||||||
|
import Utils
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -64,18 +65,19 @@ import NameDisplay
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class ShowResults(ManagedWindow.ManagedWindow):
|
class ShowResults(ManagedWindow.ManagedWindow):
|
||||||
def __init__(self, db, uistate, track, handle_list, filtname):
|
def __init__(self, db, uistate, track, handle_list, filtname, space):
|
||||||
|
|
||||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
||||||
|
|
||||||
|
self.db = db
|
||||||
self.filtname = filtname
|
self.filtname = filtname
|
||||||
|
self.space = space
|
||||||
self.define_glade('test', const.rule_glade,)
|
self.define_glade('test', const.rule_glade,)
|
||||||
self.set_window(
|
self.set_window(
|
||||||
self.get_widget('test'),
|
self.get_widget('test'),
|
||||||
self.get_widget('title'),
|
self.get_widget('title'),
|
||||||
_('Filter Test'))
|
_('Filter Test'))
|
||||||
|
|
||||||
nd = NameDisplay.displayer
|
|
||||||
render = gtk.CellRendererText()
|
render = gtk.CellRendererText()
|
||||||
|
|
||||||
tree = self.get_widget('list')
|
tree = self.get_widget('list')
|
||||||
@ -88,25 +90,35 @@ class ShowResults(ManagedWindow.ManagedWindow):
|
|||||||
column_n = gtk.TreeViewColumn(_('ID'), render, text=1)
|
column_n = gtk.TreeViewColumn(_('ID'), render, text=1)
|
||||||
tree.append_column(column_n)
|
tree.append_column(column_n)
|
||||||
|
|
||||||
self.get_widget('close').connect('clicked',self.close_window)
|
self.get_widget('close').connect('clicked',self.close)
|
||||||
|
|
||||||
new_list = [self.sort_val_from_handle(db, h) for h in handle_list]
|
new_list = [self.sort_val_from_handle(h) for h in handle_list]
|
||||||
new_list.sort()
|
new_list.sort()
|
||||||
handle_list = [ h[1] for h in new_list ]
|
handle_list = [ h[1] for h in new_list ]
|
||||||
|
|
||||||
for p_handle in handle_list:
|
for handle in handle_list:
|
||||||
person = db.get_person_from_handle(p_handle)
|
name,gid = self.get_name_id(handle)
|
||||||
name = nd.sorted(person)
|
|
||||||
gid = person.get_gramps_id()
|
|
||||||
|
|
||||||
model.append(row=[name, gid])
|
model.append(row=[name, gid])
|
||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def sort_val_from_handle(self, db, h):
|
def get_name_id(self,handle):
|
||||||
n = db.get_person_from_handle(h).get_primary_name()
|
if self.space == 'Person':
|
||||||
return (locale.strxfrm(NameDisplay.displayer.sort_string(n)),h)
|
person = self.db.get_person_from_handle(handle)
|
||||||
|
name = _nd.sorted(person)
|
||||||
def close_window(self,obj):
|
gid = person.get_gramps_id()
|
||||||
self.close()
|
elif self.space == 'Family':
|
||||||
|
family = self.db.get_family_from_handle(handle)
|
||||||
|
name = Utils.family_name(family,self.db)
|
||||||
|
gid = family.get_gramps_id()
|
||||||
|
return (name,gid)
|
||||||
|
|
||||||
|
def sort_val_from_handle(self, handle):
|
||||||
|
if self.space == 'Person':
|
||||||
|
name = self.db.get_person_from_handle(handle).get_primary_name()
|
||||||
|
sortname = locale.strxfrm(_nd.sort_string(name))
|
||||||
|
elif self.space == 'Family':
|
||||||
|
name = Utils.family_name(
|
||||||
|
self.db.get_family_from_handle(handle),self.db)
|
||||||
|
sortname = locale.strxfrm(name)
|
||||||
|
return (sortname,handle)
|
||||||
|
@ -43,9 +43,10 @@ import GrampsWidgets
|
|||||||
import RelLib
|
import RelLib
|
||||||
|
|
||||||
from _SidebarFilter import SidebarFilter
|
from _SidebarFilter import SidebarFilter
|
||||||
from Filters import GenericFamilyFilter, build_filter_model, Rules
|
from Filters import GenericFilterFactory, build_filter_model, Rules
|
||||||
from Filters.Rules.Family import *
|
from Filters.Rules.Family import *
|
||||||
|
|
||||||
|
GenericFamilyFilter = GenericFilterFactory('Family')
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# PersonSidebarFilter class
|
# PersonSidebarFilter class
|
||||||
|
@ -31,7 +31,7 @@ CustomFilters = None
|
|||||||
|
|
||||||
from const import system_filters, custom_filters
|
from const import system_filters, custom_filters
|
||||||
from _FilterList import FilterList
|
from _FilterList import FilterList
|
||||||
from _GenericFilter import GenericFilter, GenericFamilyFilter
|
from _GenericFilter import GenericFilter, GenericFilterFactory
|
||||||
from _ParamFilter import ParamFilter
|
from _ParamFilter import ParamFilter
|
||||||
|
|
||||||
def reload_system_filters():
|
def reload_system_filters():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user