* src/DataViews/_MediaView.py: pylint

* src/DataViews/_RepositoryView.py: pylint
	* src/DataViews/_SourceView.py: pylint
	* src/DataViews/_EventView.py: pylint
	* src/DataViews/_FamilyList.py: pylint
	* src/DataViews/_PlaceView.py: pylint
	* src/DataViews/__init__.py: pylint
	* src/DataViews/_PersonView.py: pylint
	* src/DataViews/Makefile.am: pylint
	* src/DataViews/_RelationView.py: pylint
	* src/RelLib/_CalSdn.py: pylint
	* src/RelLib/_Person.py: pylint
	* src/RelLib/_Family.py: pylint
	* src/RelLib/_EventType.py: pylint
	* src/RelLib/_GrampsType.py: pylint
	* src/RelLib/_Event.py: pylint
	* src/RelLib/_LdsOrd.py: pylint
	* src/PageView.py: pylint


svn: r7885
This commit is contained in:
Don Allingham
2007-01-09 04:32:07 +00:00
parent 2d5349b7b8
commit 39368e4eb6
19 changed files with 579 additions and 429 deletions

View File

@@ -1,4 +1,23 @@
2007-01-08 Don Allingham <don@gramps-project.org>
* src/DataViews/_MediaView.py: pylint
* src/DataViews/_RepositoryView.py: pylint
* src/DataViews/_SourceView.py: pylint
* src/DataViews/_EventView.py: pylint
* src/DataViews/_FamilyList.py: pylint
* src/DataViews/_PlaceView.py: pylint
* src/DataViews/__init__.py: pylint
* src/DataViews/_PersonView.py: pylint
* src/DataViews/Makefile.am: pylint
* src/DataViews/_RelationView.py: pylint
* src/RelLib/_CalSdn.py: pylint
* src/RelLib/_Person.py: pylint
* src/RelLib/_Family.py: pylint
* src/RelLib/_EventType.py: pylint
* src/RelLib/_GrampsType.py: pylint
* src/RelLib/_Event.py: pylint
* src/RelLib/_LdsOrd.py: pylint
* src/PageView.py: pylint
* src/Filters/Rules/Place/__init__.py: add HasPlace to editor_rule_list
* src/RelLib/_Name.py: default utf8 strings
* src/RelLib/_MarkerType.py: default utf8 strings

View File

@@ -15,9 +15,10 @@ pkgdata_PYTHON = \
_SourceView.py\
_PlaceView.py\
_MediaView.py\
_MapView.py\
_RepositoryView.py
# _MapView.py
pkgpyexecdir = @pkgpyexecdir@/DataViews
pkgpythondir = @pkgpythondir@/DataViews
@@ -29,3 +30,6 @@ GRAMPS_PY_MODPATH = "../"
pycheck:
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
pychecker $(pkgdata_PYTHON));
pylint:
PYTHONPATH=$(GRAMPS_PY_MODPATH) pylint $(pkgdata_PYTHON) > pylint.out

View File

@@ -19,6 +19,13 @@
# $Id$
"""
Provides the event view
"""
__author__ = "Don Allingham"
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# gramps modules
@@ -59,12 +66,19 @@ column_names = [
#
#-------------------------------------------------------------------------
class EventView(PageView.ListView):
"""
EventView class, derived from the ListView
"""
ADD_MSG = _("Add a new event")
EDIT_MSG = _("Edit the selected event")
DEL_MSG = _("Delete the selected event")
FILTER_TYPE = "Event"
def __init__(self, dbstate, uistate):
"""
Create the Event View
"""
signal_map = {
'event-add' : self.row_add,
@@ -83,18 +97,33 @@ class EventView(PageView.ListView):
self.filter_toggle)
def get_bookmarks(self):
"""
Returns the bookmark object
"""
return self.dbstate.db.get_event_bookmarks()
def drag_info(self):
"""
Indicates that the drag type is an EVENT
"""
return DdTargets.EVENT
def column_order(self):
"""
returns a tuple indicating the column order
"""
return self.dbstate.db.get_event_column_order()
def get_stock(self):
"""
Use the gramps-event stock icon
"""
return 'gramps-event'
def ui_definition(self):
"""
Defines the UI string for UIManager
"""
return '''<ui>
<menubar name="MenuBar">
<menu action="BookMenu">
@@ -132,25 +161,6 @@ class EventView(PageView.ListView):
self.add_action('FilterEdit', None, _('Event Filter Editor'),
callback=self.filter_editor,)
def filter_toggle(self, client, cnxn_id, etnry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
def filter_editor(self,obj):
from FilterEditor import FilterEditor
try:
FilterEditor('Event',const.custom_filters,
self.dbstate,self.uistate)
except Errors.WindowActiveError:
pass
def column_editor(self, obj):
import ColumnOrder
@@ -161,8 +171,8 @@ class EventView(PageView.ListView):
column_names,
self.set_column_order)
def set_column_order(self,list):
self.dbstate.db.set_event_column_order(list)
def set_column_order(self, clist):
self.dbstate.db.set_event_column_order(clist)
self.build_columns()
def on_double_click(self, obj, event):
@@ -180,19 +190,22 @@ class EventView(PageView.ListView):
pass
def remove(self, obj):
for event_handle in self.selected_handles():
for ehandle in self.selected_handles():
db = self.dbstate.db
person_list = [ handle for handle in
person_list = [
h for h in
db.get_person_handles(False)
if db.get_person_from_handle(handle).has_handle_reference('Event',event_handle) ]
family_list = [ handle for handle in
if db.get_person_from_handle(h).has_handle_reference('Event',
ehandle) ]
family_list = [
h for h in
db.get_family_handles()
if db.get_family_from_handle(handle).has_handle_reference('Event',event_handle) ]
if db.get_family_from_handle(h).has_handle_reference('Event',
ehandle) ]
event = db.get_event_from_handle(event_handle)
event = db.get_event_from_handle(ehandle)
ans = DelEventQuery(event,db,
person_list,family_list)
ans = DelEventQuery(event, db, person_list, family_list)
if len(person_list) + len(family_list) > 0:
msg = _('This event is currently being used. Deleting it '

View File

@@ -19,6 +19,13 @@
# $Id$
"""
FamilyList View
"""
__author__ = "Don Allingham"
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# gramps modules
@@ -59,6 +66,7 @@ class FamilyListView(PageView.ListView):
ADD_MSG = _("Add a new family")
EDIT_MSG = _("Edit the selected family")
DEL_MSG = _("Delete the selected family")
FILTER_TYPE = "Family"
def __init__(self, dbstate, uistate):
@@ -81,7 +89,9 @@ class FamilyListView(PageView.ListView):
self.filter_toggle)
def define_actions(self):
# add the Forward action group to handle the Forward button
"""
add the Forward action group to handle the Forward button
"""
PageView.ListView.define_actions(self)
self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES,
@@ -90,25 +100,6 @@ class FamilyListView(PageView.ListView):
self.add_action('FilterEdit', None, _('Family Filter Editor'),
callback=self.filter_editor,)
def filter_toggle(self, client, cnxn_id, etnry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
def filter_editor(self,obj):
from FilterEditor import FilterEditor
try:
FilterEditor('Family',const.custom_filters,
self.dbstate,self.uistate)
except Errors.WindowActiveError:
pass
def add_bookmark(self, obj):
mlist = []
self.selection.selected_foreach(self.blist, mlist)
@@ -138,8 +129,8 @@ class FamilyListView(PageView.ListView):
column_names,
self.set_column_order)
def set_column_order(self,list):
self.dbstate.db.set_family_list_column_order(list)
def set_column_order(self, clist):
self.dbstate.db.set_family_list_column_order(clist)
self.build_columns()
def get_stock(self):

View File

@@ -19,6 +19,13 @@
# $Id$
"""
Media View
"""
__author__ = "Don Allingham"
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# Python modules
@@ -76,6 +83,7 @@ class MediaView(PageView.ListView):
ADD_MSG = _("Add a new media object")
EDIT_MSG = _("Edit the selected media object")
DEL_MSG = _("Delete the selected media object")
FILTER_TYPE = 'MediaObject'
_DND_TYPE = DdTargets.URI_LIST
@@ -194,25 +202,6 @@ class MediaView(PageView.ListView):
if app:
Utils.launch(app[0], ref_obj.get_path())
def filter_toggle(self, client, cnxn_id, etnry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
def filter_editor(self,obj):
from FilterEditor import FilterEditor
try:
FilterEditor('MediaObject',const.custom_filters,
self.dbstate,self.uistate)
except Errors.WindowActiveError:
pass
def column_editor(self, obj):
import ColumnOrder
@@ -223,8 +212,8 @@ class MediaView(PageView.ListView):
column_names,
self.set_column_order)
def set_column_order(self,list):
self.dbstate.db.set_media_column_order(list)
def set_column_order(self, clist):
self.dbstate.db.set_media_column_order(clist)
self.build_columns()
def column_order(self):

View File

@@ -20,6 +20,13 @@
# $Id$
"""
PersonView interface
"""
__author__ = "Don Allingham"
__revision__ = "$Revision$"
#------------------------------------------------------------------------
#
# standard python modules
@@ -31,7 +38,7 @@ import cPickle as pickle
try:
set()
except:
except NameError:
from sets import Set as set
#-------------------------------------------------------------------------
@@ -77,8 +84,14 @@ column_names = [
]
class PersonView(PageView.PersonNavView):
"""
PersonView interface
"""
def __init__(self, dbstate, uistate):
"""
Creates the new PersonView interface, with the current dbstate and uistate
"""
PageView.PersonNavView.__init__(self, _('People'), dbstate, uistate)
self.inactive = False
@@ -132,18 +145,27 @@ class PersonView(PageView.PersonNavView):
self.edit_action = gtk.ActionGroup(self.title + "/PersonEdit")
self.all_action.add_actions([
('OpenAllNodes', None, _("Expand all nodes"), None, None, self.open_all_nodes),
('Edit', gtk.STOCK_EDIT, _("_Edit"), None, _("Edit the selected person"), self.edit),
('CloseAllNodes', None, _("Collapse all nodes"), None, None, self.close_all_nodes),
('OpenAllNodes', None, _("Expand all nodes"), None, None,
self.open_all_nodes),
('Edit', gtk.STOCK_EDIT, _("_Edit"), None,
_("Edit the selected person"), self.edit),
('CloseAllNodes', None, _("Collapse all nodes"), None, None,
self.close_all_nodes),
('Jump', None, _("_Jump"),"<control>j", None, self.jumpto),
])
self.edit_action.add_actions([
('Add', gtk.STOCK_ADD, _("_Add"), None, _("Add a new person"), self.add),
('Remove', gtk.STOCK_REMOVE, _("_Remove"), None, _("Remove the selected person"), self.remove),
('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'), None, None, self.column_editor),
('CmpMerge', None, _('_Compare and merge'), None, None, self.cmp_merge),
('FastMerge', None, _('_Fast merge'), None, None, self.fast_merge),
self.edit_action.add_actions(
[
('Add', gtk.STOCK_ADD, _("_Add"), None, _("Add a new person"),
self.add),
('Remove', gtk.STOCK_REMOVE, _("_Remove"), None,
_("Remove the selected person"), self.remove),
('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'), None,
None, self.column_editor),
('CmpMerge', None, _('_Compare and merge'), None, None,
self.cmp_merge),
('FastMerge', None, _('_Fast merge'), None, None,
self.fast_merge),
])
self.add_action_group(self.edit_action)
@@ -172,11 +194,11 @@ class PersonView(PageView.PersonNavView):
"control key while clicking on the desired person."))
else:
import Merge
p1 = self.db.get_person_from_handle(mlist[0])
p2 = self.db.get_person_from_handle(mlist[1])
if p1 and p2:
Merge.PersonCompare(self.dbstate, self.uistate, p1, p2,
self.build_tree)
person1 = self.db.get_person_from_handle(mlist[0])
person2 = self.db.get_person_from_handle(mlist[1])
if person1 and person2:
Merge.PersonCompare(self.dbstate, self.uistate, person1,
person2, self.build_tree)
else:
QuestionDialog.ErrorDialog(
_("Cannot merge people"),
@@ -197,11 +219,11 @@ class PersonView(PageView.PersonNavView):
else:
import Merge
p1 = self.db.get_person_from_handle(mlist[0])
p2 = self.db.get_person_from_handle(mlist[1])
if p1 and p2:
Merge.MergePeopleUI(self.dbstate, self.uistate, p1, p2,
self.build_tree)
person1 = self.db.get_person_from_handle(mlist[0])
person2 = self.db.get_person_from_handle(mlist[1])
if person1 and person2:
Merge.MergePeopleUI(self.dbstate, self.uistate, person1,
person2, self.build_tree)
else:
QuestionDialog.ErrorDialog(
_("Cannot merge people"),
@@ -299,6 +321,17 @@ class PersonView(PageView.PersonNavView):
self.generic_filter = self.filter_sidebar.get_filter()
self.build_tree()
def filter_toggle(self, client, cnxn_id, entry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
self.build_tree()
def drag_begin(self, widget, *data):
widget.drag_source_set_icon_stock(self.get_stock())
@@ -422,21 +455,23 @@ class PersonView(PageView.PersonNavView):
self.handle_history(self.dbstate.active.handle)
def _goto(self):
"""
select the active person in the person view
"""
# select the active person in the person view
p = self.dbstate.active
person = self.dbstate.active
try:
if self.model and p:
path = self.model.on_get_path(p.get_handle())
if self.model and person:
path = self.model.on_get_path(person.get_handle())
group_name = p.get_primary_name().get_group_name()
group_name = person.get_primary_name().get_group_name()
top_name = self.dbstate.db.get_name_group_mapping(group_name)
top_path = self.model.on_get_path(top_name)
self.tree.expand_row(top_path, 0)
current = self.model.on_get_iter(path)
selected = self.selection.path_is_selected(path)
if current != p.get_handle() or not selected:
if current != person.get_handle() or not selected:
self.selection.unselect_all()
self.selection.select_path(path)
self.tree.scroll_to_cell(path, None, 1, 0.5, 0)
@@ -444,7 +479,7 @@ class PersonView(PageView.PersonNavView):
self.selection.unselect_all()
self.uistate.push_message(self.dbstate,
_("Active person not visible"))
self.dbstate.active = p
self.dbstate.active = person
def setup_filter(self):
"""
@@ -491,17 +526,6 @@ class PersonView(PageView.PersonNavView):
else:
self.dirty = True
def filter_toggle(self, client, cnxn_id, etnry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
self.build_tree()
def add(self, obj):
person = RelLib.Person()
@@ -517,9 +541,10 @@ class PersonView(PageView.PersonNavView):
name = self.model.on_get_iter(path)
else:
node = self.model.on_get_iter(path)
handle = self.model.on_get_value(node, PeopleModel.COLUMN_INT_ID)
p = self.dbstate.db.get_person_from_handle(handle)
name = p.get_primary_name().get_surname()
handle = self.model.on_get_value(node,
PeopleModel.COLUMN_INT_ID)
newp = self.dbstate.db.get_person_from_handle(handle)
name = newp.get_primary_name().get_surname()
try:
person.get_primary_name().set_surname(name)
EditPerson(self.dbstate, self.uistate, [], person)
@@ -547,14 +572,15 @@ class PersonView(PageView.PersonNavView):
return
for sel in mlist:
p = self.dbstate.db.get_person_from_handle(sel)
self.active_person = p
name = NameDisplay.displayer.display(p)
person = self.dbstate.db.get_person_from_handle(sel)
self.active_person = person
name = NameDisplay.displayer.display(person)
msg = _('Deleting the person will remove the person '
'from the database.')
msg = "%s %s" % (msg, Utils.data_recover_msg)
QuestionDialog.QuestionDialog(_('Delete %s?') % name,msg,
QuestionDialog.QuestionDialog(_('Delete %s?') % name,
msg,
_('_Delete Person'),
self.delete_person_response)
@@ -562,7 +588,7 @@ class PersonView(PageView.PersonNavView):
#self.disable_interface()
trans = self.dbstate.db.transaction_begin()
n = NameDisplay.displayer.display(self.active_person)
active_name = NameDisplay.displayer.display(self.active_person)
if self.dbstate.db.get_default_person() == self.active_person:
self.dbstate.db.set_default_person_handle(None)
@@ -599,8 +625,10 @@ class PersonView(PageView.PersonNavView):
handle = self.active_person.get_handle()
person_list = [ phandle for phandle in self.dbstate.db.get_person_handles(False)
if self.dbstate.db.get_person_from_handle(phandle).has_handle_reference('Person',handle) ]
person_list = [
phdl for phdl in self.dbstate.db.get_person_handles(False)
if self.dbstate.db.get_person_from_handle(phdl).has_handle_reference('Person',
handle) ]
for phandle in person_list:
person = self.dbstate.db.get_person_from_handle(phandle)
person.remove_handle_references('Person', handle)
@@ -611,7 +639,8 @@ class PersonView(PageView.PersonNavView):
self.dbstate.db.remove_person(handle, trans)
self.uistate.phistory.back()
self.dbstate.db.transaction_commit(trans,_("Delete Person (%s)") % n)
self.dbstate.db.transaction_commit(
trans, _("Delete Person (%s)") % active_name)
def build_columns(self):
for column in self.columns:
@@ -619,7 +648,8 @@ class PersonView(PageView.PersonNavView):
try:
column = gtk.TreeViewColumn(
_('Name'),
self.renderer,text=0,
self.renderer,
text=0,
foreground=self.model.marker_color_column)
except AttributeError:
@@ -681,8 +711,8 @@ class PersonView(PageView.PersonNavView):
selected_ids = self.get_selected_objects()
nonempty_ids = [h for h in selected_ids if h]
if nonempty_ids:
data = (DdTargets.PERSON_LINK.drag_type, id(self),
nonempty_ids[0], 0)
data = (DdTargets.PERSON_LINK.drag_type,
id(self), nonempty_ids[0], 0)
sel_data.set(sel_data.target, 8, pickle.dumps(data))
def person_added(self, handle_list):
@@ -692,8 +722,8 @@ class PersonView(PageView.PersonNavView):
self.dirty = False
for node in handle_list:
person = self.dbstate.db.get_person_from_handle(node)
pn = person.get_primary_name()
top = NameDisplay.displayer.name_grouping_name(self.db, pn)
pname = person.get_primary_name()
top = NameDisplay.displayer.name_grouping_name(self.db, pname)
self.model.rebuild_data()
if not self.model.is_visable(node):

View File

@@ -19,6 +19,13 @@
# $Id$
"""
Place View
"""
__author__ = "Don Allingham"
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
@@ -76,6 +83,7 @@ class PlaceView(PageView.ListView):
ADD_MSG = _("Add a new place")
EDIT_MSG = _("Edit the selected place")
DEL_MSG = _("Delete the selected place")
FILTER_TYPE = "Place"
def __init__(self, dbstate, uistate):
@@ -115,25 +123,6 @@ class PlaceView(PageView.ListView):
def drag_info(self):
return DdTargets.PLACE_LINK
def filter_toggle(self, client, cnxn_id, etnry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
def filter_editor(self,obj):
from FilterEditor import FilterEditor
try:
FilterEditor('Place',const.custom_filters,
self.dbstate,self.uistate)
except Errors.WindowActiveError:
pass
def google(self, obj):
import GrampsDisplay
from PlaceUtils import conv_lat_lon
@@ -168,8 +157,8 @@ class PlaceView(PageView.ListView):
column_names,
self.set_column_order)
def set_column_order(self,list):
self.dbstate.db.set_place_column_order(list)
def set_column_order(self, clist):
self.dbstate.db.set_place_column_order(clist)
self.build_columns()
def column_order(self):
@@ -234,12 +223,12 @@ class PlaceView(PageView.ListView):
def remove(self, obj):
for place_handle in self.selected_handles():
db = self.dbstate.db
person_list = [ handle for handle in
person_list = [ h for h in
db.get_person_handles(False)
if db.get_person_from_handle(handle).has_handle_reference('Place',place_handle) ]
family_list = [ handle for handle in
if db.get_person_from_handle(h).has_handle_reference('Place', place_handle) ]
family_list = [ h for h in
db.get_family_handles()
if db.get_family_from_handle(handle).has_handle_reference('Place',place_handle) ]
if db.get_family_from_handle(h).has_handle_reference('Place', place_handle) ]
place = db.get_place_from_handle(place_handle)

View File

@@ -19,6 +19,13 @@
# $Id$
"""
Relationship View
"""
__author__ = "Don Allingham"
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# Python modules
@@ -29,7 +36,7 @@ import cgi
try:
set()
except:
except NameError:
from sets import Set as set
#-------------------------------------------------------------------------
@@ -358,10 +365,10 @@ class RelationshipView(PageView.PersonNavView):
def get_name(self, handle, use_gender=False):
if handle:
p = self.dbstate.db.get_person_from_handle(handle)
name = NameDisplay.displayer.display(p)
person = self.dbstate.db.get_person_from_handle(handle)
name = NameDisplay.displayer.display(person)
if use_gender:
gender = _GenderCode[p.gender]
gender = _GenderCode[person.gender]
else:
gender = ""
return (name, gender)

View File

@@ -19,6 +19,13 @@
# $Id$
"""
Repository View
"""
__author__ = "Don Allingham"
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
@@ -77,6 +84,7 @@ class RepositoryView(PageView.ListView):
ADD_MSG = _("Add a new repository")
EDIT_MSG = _("Edit the selected repository")
DEL_MSG = _("Delete the selected repository")
FILTER_TYPE = "Repository"
def __init__(self, dbstate, uistate):
@@ -110,25 +118,6 @@ class RepositoryView(PageView.ListView):
self.add_action('FilterEdit', None, _('Repository Filter Editor'),
callback=self.filter_editor,)
def filter_toggle(self, client, cnxn_id, etnry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
def filter_editor(self,obj):
from FilterEditor import FilterEditor
try:
FilterEditor('Repository',const.custom_filters,
self.dbstate,self.uistate)
except Errors.WindowActiveError:
pass
def column_editor(self, obj):
import ColumnOrder
@@ -139,8 +128,8 @@ class RepositoryView(PageView.ListView):
column_names,
self.set_column_order)
def set_column_order(self,list):
self.dbstate.db.set_repository_column_order(list)
def set_column_order(self, clist):
self.dbstate.db.set_repository_column_order(clist)
self.build_columns()
def column_order(self):

View File

@@ -19,6 +19,13 @@
# $Id$
"""
Source View
"""
__author__ = "Don Allingham"
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
@@ -70,6 +77,7 @@ class SourceView(PageView.ListView):
ADD_MSG = _("Add a new source")
EDIT_MSG = _("Edit the selected source")
DEL_MSG = _("Delete the selected source")
FILTER_TYPE = "Source"
def __init__(self, dbstate, uistate):
@@ -105,25 +113,6 @@ class SourceView(PageView.ListView):
self.add_action('FilterEdit', None, _('Source Filter Editor'),
callback=self.filter_editor,)
def filter_toggle(self, client, cnxn_id, etnry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
def filter_editor(self,obj):
from FilterEditor import FilterEditor
try:
FilterEditor('Source',const.custom_filters,
self.dbstate,self.uistate)
except Errors.WindowActiveError:
pass
def column_editor(self, obj):
import ColumnOrder
@@ -134,8 +123,8 @@ class SourceView(PageView.ListView):
column_names,
self.set_column_order)
def set_column_order(self,list):
self.dbstate.db.set_source_column_order(list)
def set_column_order(self, clist):
self.dbstate.db.set_source_column_order(clist)
self.build_columns()
def column_order(self):

View File

@@ -19,6 +19,13 @@
# $Id: __init__.py 6067 2006-03-04 05:24:16Z dallingham $
"""
Package init for the DataView package
"""
__author__ = "Don Allingham"
__revision__ = "$Revision: $"
from _PersonView import PersonView
from _RelationView import RelationshipView
from _FamilyList import FamilyListView
@@ -31,6 +38,9 @@ from _MediaView import MediaView
from _RepositoryView import RepositoryView
def get_views():
"""
Returns a list of PageView instances
"""
return [
PersonView,
RelationshipView,

View File

@@ -478,6 +478,16 @@ class ListView(BookMarkView):
self.filter_toggle(None, None, None, None)
return hpaned
def filter_toggle(self, client, cnxn_id, entry, data):
if Config.get(Config.FILTER):
self.search_bar.hide()
self.filter_pane.show()
active = True
else:
self.search_bar.show()
self.filter_pane.hide()
active = False
def post(self):
if self.filter_class:
if Config.get(Config.FILTER):
@@ -698,6 +708,15 @@ class ListView(BookMarkView):
Config.set(Config.FILTER, active)
self.build_tree()
def filter_editor(self,obj):
from FilterEditor import FilterEditor
try:
FilterEditor(self.FILTER_TYPE ,const.custom_filters,
self.dbstate, self.uistate)
except Errors.WindowActiveError:
pass
def change_db(self,db):
for sig in self.signal_map:
db.connect(sig, self.signal_map[sig])

View File

@@ -20,6 +20,10 @@
# $Id$
"""
Provides calendar to sdn (serial date number) conversion.
"""
__revision__ = "$Revision$"
#-------------------------------------------------------------------------
@@ -100,11 +104,12 @@ def _tishri1(metonic_year, molad_day, molad_halakim):
return tishri1
def _tishri_molad(input_day):
# Estimate the metonic cycle number. Note that this may be an under
# estimate because there are 6939.6896 days in a metonic cycle not
# 6940, but it will never be an over estimate. The loop below will
# correct for any error in this estimate. */
"""
Estimate the metonic cycle number. Note that this may be an under
estimate because there are 6939.6896 days in a metonic cycle not
6940, but it will never be an over estimate. The loop below will
correct for any error in this estimate.
"""
metonic_cycle = (input_day + 310) / 6940
@@ -134,12 +139,13 @@ def _tishri_molad(input_day):
molad_day = molad_day + (molad_halakim / _HBR_HALAKIM_PER_DAY)
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
else:
metonic_year = metonic_year + 1
metonic_year += 1
return (metonic_cycle, metonic_year, molad_day, molad_halakim)
def _molad_of_metonic_cycle(metonic_cycle):
# Start with the time of the first molad after creation.
"""
Start with the time of the first molad after creation.
"""
r1 = _HBR_NEW_MOON_OF_CREATION
@@ -167,7 +173,9 @@ def _molad_of_metonic_cycle(metonic_cycle):
return (molad_day, molad_halakim)
def _start_of_year(year):
"""
calculate the start of the year.
"""
metonic_cycle = (year - 1) / 19;
metonic_year = (year - 1) % 19;
(molad_day, molad_halakim) = _molad_of_metonic_cycle(metonic_cycle)
@@ -473,6 +481,7 @@ def french_ymd(sdn):
return (year, month, day)
def persian_sdn(year, month, day):
"""Converts an Persian date to an SDN number"""
if year >= 0:
epbase = year - 474
else:
@@ -491,6 +500,7 @@ def persian_sdn(year, month, day):
return int(math.ceil(v1 + v2 + v3 + v4 + _PRS_EPOCH - 1))
def persian_ymd(sdn):
"""Converts an SDN number to a Persian calendar date"""
sdn = math.floor(sdn) + 0.5
depoch = sdn - 2121446
@@ -516,6 +526,7 @@ def persian_ymd(sdn):
return (int(year), int(month), int(day))
def islamic_sdn(year, month, day):
"""Converts an Islamic date to an SDN number"""
v1 = math.ceil(29.5 * (month - 1))
v2 = (year - 1) * 354
v3 = math.floor((3 + (11 *year)) / 30)
@@ -523,6 +534,7 @@ def islamic_sdn(year, month, day):
return int(math.ceil((day + v1 + v2 + v3 + _ISM_EPOCH) - 1))
def islamic_ymd(sdn):
"""Converts an SDN number to an Islamic calendar date"""
sdn = math.floor(sdn) + 0.5
year = int(math.floor(((30*(sdn-_ISM_EPOCH))+10646)/10631))
month = int(min(12, math.ceil((sdn-(29+islamic_sdn(year, 1, 1)))/29.5) + 1))

View File

@@ -126,15 +126,44 @@ class Event(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
NoteBase.unserialize(self, note)
def _has_handle_reference(self, classname, handle):
"""
Returns True if the object has reference to a given handle
of given primary object type.
@param classname: The name of the primary object class.
@type classname: str
@param handle: The handle to be checked.
@type handle: str
@return: Returns whether the object has reference to this handle of this object type.
@rtype: bool
"""
if classname == 'Place':
return self.place == handle
return False
def _remove_handle_references(self, classname, handle_list):
"""
Removes all references in this object to object handles in the list.
@param classname: The name of the primary object class.
@type classname: str
@param handle_list: The list of handles to be removed.
@type handle_list: str
"""
if classname == 'Place' and self.place in handle_list:
self.place = ""
def _replace_handle_reference(self, classname, old_handle, new_handle):
"""
Replaces all references to old handle with those to the new handle.
@param classname: The name of the primary object class.
@type classname: str
@param old_handle: The handle to be replaced.
@type old_handle: str
@param new_handle: The handle to replace the old one with.
@type new_handle: str
"""
if classname == 'Place' and self.place == old_handle:
self.place = new_handle

View File

@@ -30,7 +30,9 @@ from _GrampsType import GrampsType, init_map
from gettext import gettext as _
class EventType(GrampsType):
"""
Event types
"""
UNKNOWN = -1
CUSTOM = 0
MARRIAGE = 1

View File

@@ -146,6 +146,17 @@ class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
LdsOrdBase.unserialize(self, lds_seal_list)
def _has_handle_reference(self, classname, handle):
"""
Returns True if the object has reference to a given handle
of given primary object type.
@param classname: The name of the primary object class.
@type classname: str
@param handle: The handle to be checked.
@type handle: str
@return: Returns whether the object has reference to this handle of this object type.
@rtype: bool
"""
if classname == 'Event':
return handle in [ref.ref for ref in self.event_ref_list]
elif classname == 'Person':
@@ -156,6 +167,14 @@ class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
return False
def _remove_handle_references(self, classname, handle_list):
"""
Removes all references in this object to object handles in the list.
@param classname: The name of the primary object class.
@type classname: str
@param handle_list: The list of handles to be removed.
@type handle_list: str
"""
if classname == 'Event':
new_list = [ ref for ref in self.event_ref_list \
if ref.ref not in handle_list ]
@@ -174,6 +193,16 @@ class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase,
x.place = None
def _replace_handle_reference(self, classname, old_handle, new_handle):
"""
Replaces all references to old handle with those to the new handle.
@param classname: The name of the primary object class.
@type classname: str
@param old_handle: The handle to be replaced.
@type old_handle: str
@param new_handle: The handle to replace the old one with.
@type new_handle: str
"""
if classname == 'Event':
handle_list = [ref.ref for ref in self.event_ref_list]
while old_handle in handle_list:

View File

@@ -29,6 +29,9 @@ __revision__ = "$Revision$"
from gettext import gettext as _
def init_map(data, key_col, data_col):
"""
Initializes the map, building a new map from the specified columns.
"""
new_data = {}
for item in data:
new_data[item[key_col]] = item[data_col]
@@ -47,6 +50,9 @@ class GrampsType:
_E2IMAP = init_map(_DATAMAP, 2, 0)
def __init__(self, value=None):
"""
Creates a new type, initialize the value from one of several possible states.
"""
self.value = None
self.string = None
self.set(value)

View File

@@ -199,9 +199,21 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
return self.source_list
def get_type(self):
"""
Returns the type of the Event.
@return: Type of the Event
@rtype: tuple
"""
return self.type
def set_type(self, ord_type):
"""
Sets the type of the LdsOrd to the passed (int,str) tuple.
@param ord_type: Type to assign to the LdsOrd
@type ord_type: tuple
"""
self.type = ord_type
def set_family_handle(self, family):

View File

@@ -199,6 +199,17 @@ class Person(PrimaryObject, SourceBase, NoteBase, MediaBase,
NoteBase.unserialize(self, note)
def _has_handle_reference(self, classname, handle):
"""
Returns True if the object has reference to a given handle
of given primary object type.
@param classname: The name of the primary object class.
@type classname: str
@param handle: The handle to be checked.
@type handle: str
@return: Returns whether the object has reference to this handle of this object type.
@rtype: bool
"""
if classname == 'Event':
return handle in [ref.ref for ref in self.event_ref_list]
elif classname == 'Person':