Use the new view plugin structure to offer a flat list person view
svn: r14195
This commit is contained in:
@@ -18,6 +18,7 @@ pkgdata_PYTHON = \
|
||||
libmapservice.py\
|
||||
libmixin.py\
|
||||
libodfbackend.py\
|
||||
libpersonview.py\
|
||||
libplugins.gpr.py\
|
||||
libtranslate.py
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2008 Gary Burton
|
||||
# Copyright (C) 2009 Nick Hall
|
||||
# Copyright (C) 2010 Benny Malengier
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -16,13 +17,13 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 021111307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Provide the person view.
|
||||
Provide the base for a list person view.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -46,8 +47,7 @@ _LOG = logging.getLogger(".gui.personview")
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gui.views.listview import ListView, LISTTREE
|
||||
from gui.views.treemodels import PeopleModel
|
||||
from gui.views.listview import ListView
|
||||
import Utils
|
||||
from gen.display.name import displayer as name_displayer
|
||||
from QuestionDialog import ErrorDialog, QuestionDialog
|
||||
@@ -71,9 +71,9 @@ from gen.ggettext import sgettext as _
|
||||
# PersonView
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class PersonView(ListView):
|
||||
class BasePersonView(ListView):
|
||||
"""
|
||||
PersonView class, derived from the ListView, a treeview
|
||||
Base view for PersonView listviews ListView, a treeview
|
||||
"""
|
||||
COL_NAME = 0
|
||||
COL_ID = 1
|
||||
@@ -109,7 +109,7 @@ class PersonView(ListView):
|
||||
FILTER_TYPE = "Person"
|
||||
QR_CATEGORY = CATEGORY_QR_PERSON
|
||||
|
||||
def __init__(self, dbstate, uistate, nav_group=0):
|
||||
def __init__(self, dbstate, uistate, title, model, nav_group=0):
|
||||
"""
|
||||
Create the Person View
|
||||
"""
|
||||
@@ -119,12 +119,11 @@ class PersonView(ListView):
|
||||
'person-delete' : self.row_delete,
|
||||
'person-rebuild' : self.object_build,
|
||||
}
|
||||
|
||||
|
||||
ListView.__init__(
|
||||
self, _('People'), dbstate, uistate,
|
||||
PersonView.COLUMN_NAMES, len(PersonView.COLUMN_NAMES),
|
||||
PeopleModel,
|
||||
signal_map, dbstate.db.get_bookmarks(),
|
||||
self, title, dbstate, uistate,
|
||||
BasePersonView.COLUMN_NAMES, len(BasePersonView.COLUMN_NAMES),
|
||||
model, signal_map, dbstate.db.get_bookmarks(),
|
||||
Bookmarks.PersonBookmarks, nav_group,
|
||||
multiple=True,
|
||||
filter_class=PersonSidebarFilter,
|
||||
@@ -137,12 +136,6 @@ class PersonView(ListView):
|
||||
|
||||
config.connect("interface.filter", self.filter_toggle)
|
||||
|
||||
def type_list(self):
|
||||
"""
|
||||
set the listtype, this governs eg keybinding
|
||||
"""
|
||||
return LISTTREE
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Person'
|
||||
|
||||
@@ -168,18 +161,13 @@ class PersonView(ListView):
|
||||
"""
|
||||
Returns a tuple indicating columns requiring an exact search
|
||||
"""
|
||||
return (PersonView.COL_GEN,) # Gender ('female' contains the string 'male')
|
||||
return (BasePersonView.COL_GEN,) # Gender ('female' contains the string 'male')
|
||||
|
||||
def get_stock(self):
|
||||
"""
|
||||
Use the gramps-person stock icon
|
||||
Use the grampsperson stock icon
|
||||
"""
|
||||
return 'gramps-person'
|
||||
|
||||
def get_viewtype_stock(self):
|
||||
"""Type of view in category
|
||||
"""
|
||||
return 'gramps-tree-group'
|
||||
|
||||
def ui_definition(self):
|
||||
"""
|
||||
@@ -223,7 +211,7 @@ class PersonView(ListView):
|
||||
</menubar>
|
||||
<toolbar name="ToolBar">
|
||||
<placeholder name="CommonNavigation">
|
||||
<toolitem action="Back"/>
|
||||
<toolitem action="Back"/>
|
||||
<toolitem action="Forward"/>
|
||||
<toolitem action="HomePerson"/>
|
||||
</placeholder>
|
||||
@@ -238,9 +226,6 @@ class PersonView(ListView):
|
||||
<menuitem action="Forward"/>
|
||||
<menuitem action="HomePerson"/>
|
||||
<separator/>
|
||||
<menuitem action="OpenAllNodes"/>
|
||||
<menuitem action="CloseAllNodes"/>
|
||||
<separator/>
|
||||
<menuitem action="Add"/>
|
||||
<menuitem action="Edit"/>
|
||||
<menuitem action="Remove"/>
|
||||
@@ -261,23 +246,11 @@ class PersonView(ListView):
|
||||
def add(self, obj):
|
||||
person = gen.lib.Person()
|
||||
|
||||
# attempt to get the current surname
|
||||
(model, pathlist) = self.selection.get_selected_rows()
|
||||
name = u""
|
||||
if len(pathlist) == 1:
|
||||
path = pathlist[0]
|
||||
if len(path) == 1:
|
||||
name = model.on_get_iter(path).name
|
||||
else:
|
||||
node = model.on_get_iter(path)
|
||||
name = model.on_iter_parent(node).name
|
||||
|
||||
try:
|
||||
person.get_primary_name().set_surname(name)
|
||||
EditPerson(self.dbstate, self.uistate, [], person)
|
||||
EditPerson(self.dbstate, self.uistate, [], gen.lib.Person())
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
|
||||
|
||||
def edit(self, obj):
|
||||
for handle in self.selected_handles():
|
||||
person = self.dbstate.db.get_person_from_handle(handle)
|
||||
@@ -336,7 +309,7 @@ class PersonView(ListView):
|
||||
path = self.model.on_get_path(node)
|
||||
(col, row) = path
|
||||
if row > 0:
|
||||
self.selection.select_path((col, row-1))
|
||||
self.selection.select_path((col, row1))
|
||||
elif row == 0 and self.model.on_get_iter(path):
|
||||
self.selection.select_path(path)
|
||||
|
||||
@@ -369,16 +342,13 @@ class PersonView(ListView):
|
||||
self.all_action.add_actions([
|
||||
('FilterEdit', None, _('Person Filter Editor'), None, None,
|
||||
self.filter_editor),
|
||||
('OpenAllNodes', None, _("Expand all Nodes"), None, None,
|
||||
self.open_all_nodes),
|
||||
('Edit', gtk.STOCK_EDIT, _("action|_Edit..."), "<control>Return",
|
||||
_("Edit the selected person"), self.edit),
|
||||
('CloseAllNodes', None, _("Collapse all Nodes"), None, None,
|
||||
self.close_all_nodes),
|
||||
('QuickReport', None, _("Quick View"), None, None, None),
|
||||
('Dummy', None, ' ', None, None, self.dummy_report),
|
||||
])
|
||||
|
||||
|
||||
self.edit_action.add_actions(
|
||||
[
|
||||
('Add', gtk.STOCK_ADD, _("_Add..."), "<control>Insert",
|
@@ -238,3 +238,19 @@ fname = 'libtranslate.py',
|
||||
authors = ["Brian Matherly"],
|
||||
authors_email = ["brian@gramps-project.org"],
|
||||
)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# libpersonview
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
register(GENERAL,
|
||||
id = 'libpersonview',
|
||||
name = "lib for the person list views",
|
||||
description = _("Provides the Base needed for the List People views.") ,
|
||||
version = '1.0',
|
||||
status = STABLE,
|
||||
fname = 'libpersonview.py',
|
||||
authors = ["The Gramps project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
)
|
||||
|
@@ -45,7 +45,8 @@ import gtk
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.display.name import displayer as name_displayer
|
||||
import ManagedWindow
|
||||
from gui.views.treemodels import PeopleModel
|
||||
from gui.views.treemodels import PeopleBaseModel, PersonTreeModel
|
||||
from libpersonview import BasePersonView
|
||||
import Relationship
|
||||
|
||||
from QuestionDialog import ErrorDialog
|
||||
@@ -58,18 +59,7 @@ from glade import Glade
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
column_names = [
|
||||
_('Name'),
|
||||
_('ID') ,
|
||||
_('Gender'),
|
||||
_('Birth Date'),
|
||||
_('Birth Place'),
|
||||
_('Death Date'),
|
||||
_('Death Place'),
|
||||
_('Spouse'),
|
||||
_('Last Change'),
|
||||
_('Cause of Death'),
|
||||
]
|
||||
column_names = BasePersonView.COLUMN_NAMES
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -86,6 +76,21 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
Tool.Tool.__init__(self, dbstate, options_class, name)
|
||||
ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__)
|
||||
|
||||
#set the columns to see
|
||||
for data in BasePersonView.CONFIGSETTINGS:
|
||||
if data[0] == 'columns.order':
|
||||
colord = data[1]
|
||||
elif data[0] == 'columns.visible':
|
||||
colvis = data[1]
|
||||
elif data[0] == 'columns.sizecol':
|
||||
colsize = data[1]
|
||||
self.colord = []
|
||||
for col, size in zip(colord, colsize):
|
||||
if col in colvis:
|
||||
self.colord.append((1, col, size))
|
||||
else:
|
||||
self.colord.append((0, col, size))
|
||||
|
||||
self.dbstate = dbstate
|
||||
self.relationship = Relationship.get_relationship_calculator()
|
||||
self.relationship.connect_db_signals(dbstate)
|
||||
@@ -110,23 +115,16 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
self.textbuffer = gtk.TextBuffer()
|
||||
self.text.set_buffer(self.textbuffer)
|
||||
|
||||
self.model = PeopleModel(self.db)
|
||||
self.model = PersonTreeModel(self.db)
|
||||
self.tree.set_model(self.model)
|
||||
|
||||
self.tree.connect('key-press-event', self._key_press)
|
||||
self.selection = self.tree.get_selection()
|
||||
self.selection.set_mode(gtk.SELECTION_SINGLE)
|
||||
|
||||
column = gtk.TreeViewColumn(_('Name'), gtk.CellRendererText(),text=0)
|
||||
column.set_resizable(True)
|
||||
column.set_min_width(225)
|
||||
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
||||
self.tree.append_column(column)
|
||||
#keep reference of column so garbage collection works
|
||||
self.columns = [column]
|
||||
|
||||
index = 1
|
||||
for pair in self.db.get_person_column_order():
|
||||
self.columns = []
|
||||
for pair in self.colord:
|
||||
if not pair[0]:
|
||||
continue
|
||||
name = column_names[pair[1]]
|
||||
@@ -138,7 +136,6 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
self.tree.append_column(column)
|
||||
#keep reference of column so garbage collection works
|
||||
self.columns.append(column)
|
||||
index += 1
|
||||
|
||||
self.sel = self.tree.get_selection()
|
||||
self.changedkey = self.sel.connect('changed',self.on_apply_clicked)
|
||||
@@ -171,7 +168,7 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow):
|
||||
if not node:
|
||||
return
|
||||
|
||||
handle = model.get_value(node, PeopleModel.COLUMN_INT_ID)
|
||||
handle = model.get_value(node, PeopleBaseModel.COLUMN_INT_ID)
|
||||
other_person = self.db.get_person_from_handle(handle)
|
||||
if other_person is None :
|
||||
self.textbuffer.set_text("")
|
||||
|
@@ -17,7 +17,8 @@ pkgdata_PYTHON = \
|
||||
pedigreeview.py \
|
||||
pedigreeviewext.py \
|
||||
pedigreeviewext.gpr.py \
|
||||
personview.py \
|
||||
personlistview.py \
|
||||
persontreeview.py \
|
||||
placetreeview.gpr.py \
|
||||
placetreeview.py \
|
||||
placeview.py \
|
||||
|
@@ -131,15 +131,29 @@ name = _("Person View"),
|
||||
description = _("The view showing all people in the family tree"),
|
||||
version = '1.0',
|
||||
status = STABLE,
|
||||
fname = 'personview.py',
|
||||
fname = 'persontreeview.py',
|
||||
authors = [u"The Gramps project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = ("People", _("People")),
|
||||
viewclass = 'PersonView',
|
||||
viewclass = 'PersonTreeView',
|
||||
order = START,
|
||||
)
|
||||
|
||||
register(VIEW,
|
||||
id = 'personlistview',
|
||||
name = _("Person List View"),
|
||||
description = _("The view showing all people in the family tree"
|
||||
" in a flat list"),
|
||||
version = '1.0',
|
||||
status = STABLE,
|
||||
fname = 'personlistview.py',
|
||||
authors = [u"The Gramps project"],
|
||||
authors_email = ["http://gramps-project.org"],
|
||||
category = ("People", _("People")),
|
||||
viewclass = 'PersonListView',
|
||||
order = END,
|
||||
)
|
||||
register(VIEW,
|
||||
id = 'placeview',
|
||||
name = _("Place View"),
|
||||
description = _("The view showing all the places of the family tree"),
|
||||
|
Reference in New Issue
Block a user