2009-11-17 05:43:03 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2010-03-28 04:30:41 +05:30
|
|
|
# Copyright (C) 2009-2010 Nick Hall
|
2009-11-17 05:43:03 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
"""
|
|
|
|
Place Tree View
|
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-01-09 21:46:52 +05:30
|
|
|
from gui.views.listview import LISTTREE
|
2010-02-04 02:14:00 +05:30
|
|
|
from libplaceview import PlaceBaseView
|
2010-02-05 02:35:15 +05:30
|
|
|
from gui.views.treemodels.placemodel import PlaceTreeModel, COUNTRYLEVELS
|
2009-11-17 05:43:03 +05:30
|
|
|
import gen.lib
|
|
|
|
import Errors
|
2009-12-15 11:26:12 +05:30
|
|
|
from gui.editors import EditPlace
|
2009-11-17 05:43:03 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2009-11-17 05:43:03 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# PlaceTreeView
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class PlaceTreeView(PlaceBaseView):
|
|
|
|
"""
|
|
|
|
A hierarchical view of the top three levels of places.
|
|
|
|
"""
|
2010-03-28 04:30:41 +05:30
|
|
|
COL_PLACE = 0
|
|
|
|
COL_ID = 1
|
2010-10-27 23:43:53 +05:30
|
|
|
COL_STREET = 2
|
|
|
|
COL_LOCALITY = 3
|
2010-03-28 04:30:41 +05:30
|
|
|
COL_CITY = 4
|
|
|
|
COL_COUNTY = 5
|
|
|
|
COL_STATE = 6
|
|
|
|
COL_COUNTRY = 7
|
2010-10-27 23:43:53 +05:30
|
|
|
COL_ZIP = 8
|
|
|
|
COL_PARISH = 9
|
|
|
|
COL_LAT = 10
|
|
|
|
COL_LON = 11
|
|
|
|
COL_CHAN = 12
|
|
|
|
COL_NAME = 13
|
2010-03-28 04:30:41 +05:30
|
|
|
# name of the columns
|
|
|
|
COLUMN_NAMES = [
|
|
|
|
_('Place'),
|
|
|
|
_('ID'),
|
2010-10-27 23:43:53 +05:30
|
|
|
_('Street'),
|
|
|
|
_('Locality'),
|
2010-03-28 04:30:41 +05:30
|
|
|
_('City'),
|
|
|
|
_('County'),
|
|
|
|
_('State'),
|
|
|
|
_('Country'),
|
2010-10-27 23:43:53 +05:30
|
|
|
_('ZIP/Postal Code'),
|
|
|
|
_('Church Parish'),
|
2010-03-28 04:30:41 +05:30
|
|
|
_('Latitude'),
|
|
|
|
_('Longitude'),
|
|
|
|
_('Last Changed'),
|
|
|
|
_('Place Name'),
|
|
|
|
]
|
|
|
|
# default setting with visible columns, order of the col, and their size
|
|
|
|
CONFIGSETTINGS = (
|
2010-10-27 23:43:53 +05:30
|
|
|
('columns.visible', [COL_PLACE, COL_ID, COL_STREET, COL_LOCALITY,
|
|
|
|
COL_CITY, COL_COUNTY, COL_STATE]),
|
|
|
|
('columns.rank', [COL_PLACE, COL_ID, COL_STREET, COL_LOCALITY, COL_CITY,
|
|
|
|
COL_COUNTY, COL_STATE, COL_COUNTRY, COL_ZIP,
|
|
|
|
COL_PARISH, COL_LAT, COL_LON, COL_CHAN, COL_NAME]),
|
|
|
|
('columns.size', [250, 75, 150, 150, 150, 150, 100, 100, 100,
|
|
|
|
100, 150, 150, 100, 150])
|
|
|
|
)
|
2009-11-17 05:43:03 +05:30
|
|
|
|
2010-12-28 22:34:41 +05:30
|
|
|
def __init__(self, pdata, dbstate, uistate):
|
|
|
|
PlaceBaseView.__init__(self, pdata, dbstate, uistate,
|
2010-02-07 01:40:25 +05:30
|
|
|
_('Place Tree View'), PlaceTreeModel,
|
2010-02-12 04:00:16 +05:30
|
|
|
nav_group=0, markup=PlaceBaseView.MARKUP_COLS)
|
2009-11-17 05:43:03 +05:30
|
|
|
|
2010-01-09 21:46:52 +05:30
|
|
|
def type_list(self):
|
|
|
|
"""
|
|
|
|
set the listtype, this governs eg keybinding
|
|
|
|
"""
|
|
|
|
return LISTTREE
|
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
def get_viewtype_stock(self):
|
|
|
|
"""
|
|
|
|
Override the default icon. Set for hierarchical view.
|
|
|
|
"""
|
|
|
|
return 'gramps-tree-group'
|
|
|
|
|
|
|
|
def define_actions(self):
|
|
|
|
"""
|
|
|
|
Define actions for the popup menu specific to the tree view.
|
|
|
|
"""
|
|
|
|
PlaceBaseView.define_actions(self)
|
|
|
|
|
2010-01-09 21:46:52 +05:30
|
|
|
self._add_action('OpenBranch', None, _("Expand this Entire Group"),
|
2009-11-17 05:43:03 +05:30
|
|
|
callback=self.open_branch)
|
2010-01-09 21:46:52 +05:30
|
|
|
self._add_action('CloseBranch', None, _("Collapse this Entire Group"),
|
2009-11-17 05:43:03 +05:30
|
|
|
callback=self.close_branch)
|
|
|
|
self._add_action('OpenAllNodes', None, _("Expand all Nodes"),
|
|
|
|
callback=self.open_all_nodes)
|
|
|
|
self._add_action('CloseAllNodes', None, _("Collapse all Nodes"),
|
|
|
|
callback=self.close_all_nodes)
|
|
|
|
|
2010-12-28 22:34:41 +05:30
|
|
|
def additional_ui(self):
|
2009-11-17 05:43:03 +05:30
|
|
|
"""
|
|
|
|
A user interface definition including tree specific actions.
|
|
|
|
"""
|
|
|
|
return '''<ui>
|
|
|
|
<menubar name="MenuBar">
|
|
|
|
<menu action="FileMenu">
|
|
|
|
<placeholder name="LocalExport">
|
|
|
|
<menuitem action="ExportTab"/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
|
|
|
<menu action="BookMenu">
|
|
|
|
<placeholder name="AddEditBook">
|
|
|
|
<menuitem action="AddBook"/>
|
|
|
|
<menuitem action="EditBook"/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
2010-03-09 23:11:37 +05:30
|
|
|
<menu action="GoMenu">
|
|
|
|
<placeholder name="CommonGo">
|
|
|
|
<menuitem action="Back"/>
|
|
|
|
<menuitem action="Forward"/>
|
|
|
|
<separator/>
|
|
|
|
</placeholder>
|
|
|
|
</menu>
|
2009-11-17 05:43:03 +05:30
|
|
|
<menu action="EditMenu">
|
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
2010-07-30 23:43:06 +05:30
|
|
|
<menuitem action="Merge"/>
|
2009-11-17 05:43:03 +05:30
|
|
|
</placeholder>
|
|
|
|
<menuitem action="FilterEdit"/>
|
|
|
|
</menu>
|
|
|
|
</menubar>
|
|
|
|
<toolbar name="ToolBar">
|
2010-03-09 23:11:37 +05:30
|
|
|
<placeholder name="CommonNavigation">
|
|
|
|
<toolitem action="Back"/>
|
|
|
|
<toolitem action="Forward"/>
|
|
|
|
</placeholder>
|
2009-11-17 05:43:03 +05:30
|
|
|
<placeholder name="CommonEdit">
|
|
|
|
<toolitem action="Add"/>
|
|
|
|
<toolitem action="Edit"/>
|
|
|
|
<toolitem action="Remove"/>
|
2010-07-30 23:43:06 +05:30
|
|
|
<toolitem action="Merge"/>
|
2009-11-17 05:43:03 +05:30
|
|
|
<separator/>
|
|
|
|
<toolitem action="MapsList"/>
|
|
|
|
</placeholder>
|
|
|
|
</toolbar>
|
|
|
|
<popup name="Popup">
|
|
|
|
<menuitem action="OpenBranch"/>
|
|
|
|
<menuitem action="CloseBranch"/>
|
|
|
|
<menuitem action="OpenAllNodes"/>
|
|
|
|
<menuitem action="CloseAllNodes"/>
|
|
|
|
<separator/>
|
|
|
|
<menuitem action="Add"/>
|
|
|
|
<menuitem action="Edit"/>
|
|
|
|
<menuitem action="Remove"/>
|
2010-07-30 23:43:06 +05:30
|
|
|
<menuitem action="Merge"/>
|
2009-11-17 05:43:03 +05:30
|
|
|
<separator/>
|
2010-01-02 00:29:58 +05:30
|
|
|
<menu name="QuickReport" action="QuickReport">
|
|
|
|
<menuitem action="Dummy"/>
|
|
|
|
</menu>
|
|
|
|
<separator/>
|
2009-11-17 05:43:03 +05:30
|
|
|
<menuitem action="GotoMap"/>
|
|
|
|
</popup>
|
|
|
|
</ui>'''
|
|
|
|
|
|
|
|
def add(self, obj):
|
|
|
|
"""
|
|
|
|
Add a new place. Attempt to get the top three levels of hierarchy from
|
|
|
|
the currently selected row.
|
|
|
|
"""
|
|
|
|
place = gen.lib.Place()
|
|
|
|
|
|
|
|
model, pathlist = self.selection.get_selected_rows()
|
2010-01-13 03:20:37 +05:30
|
|
|
level = [u"", u"", u""]
|
2009-11-17 05:43:03 +05:30
|
|
|
level1 = level2 = level3 = u""
|
|
|
|
if len(pathlist) == 1:
|
|
|
|
path = pathlist[0]
|
2009-12-27 01:12:22 +05:30
|
|
|
node = model.on_get_iter(path)
|
|
|
|
value = model.on_get_value(node, 0)
|
2010-01-13 03:20:37 +05:30
|
|
|
|
2009-11-17 05:43:03 +05:30
|
|
|
if len(path) == 1:
|
2010-01-13 03:20:37 +05:30
|
|
|
level[0] = node.name
|
2009-11-17 05:43:03 +05:30
|
|
|
elif len(path) == 2:
|
2010-01-13 03:20:37 +05:30
|
|
|
level[1] = node.name
|
|
|
|
parent = model.on_iter_parent(node)
|
|
|
|
level[0] = parent.name
|
2009-11-17 05:43:03 +05:30
|
|
|
elif len(path) == 3:
|
2010-01-13 03:20:37 +05:30
|
|
|
level[2] = node.name
|
|
|
|
parent = model.on_iter_parent(node)
|
|
|
|
level[1] = parent.name
|
|
|
|
parent = model.on_iter_parent(parent)
|
|
|
|
level[0] = parent.name
|
2009-11-17 05:43:03 +05:30
|
|
|
else:
|
2010-01-13 03:20:37 +05:30
|
|
|
parent = model.on_iter_parent(node)
|
|
|
|
level[2] = parent.name
|
|
|
|
parent = model.on_iter_parent(parent)
|
|
|
|
level[1] = parent.name
|
|
|
|
parent = model.on_iter_parent(parent)
|
|
|
|
level[0] = parent.name
|
2009-11-17 05:43:03 +05:30
|
|
|
|
2010-01-13 03:20:37 +05:30
|
|
|
for ind in [0, 1, 2]:
|
|
|
|
if level[ind] and level[ind] == COUNTRYLEVELS['default'][ind+1]:
|
|
|
|
level[ind] = u""
|
|
|
|
place.get_main_location().set_country(level[0])
|
|
|
|
place.get_main_location().set_state(level[1])
|
|
|
|
place.get_main_location().set_county(level[2])
|
2009-11-17 05:43:03 +05:30
|
|
|
try:
|
|
|
|
EditPlace(self.dbstate, self.uistate, [], place)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|